Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
Rasterize.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_HELPER_RASTERIZE
19#define INCLUDED_HELPER_RASTERIZE
20
21/**
22 * @file
23 * Helper functions related to rasterizing geometric shapes to grids.
24 */
25
28
29#include <vector>
30
31namespace SimRasterize
32{
33
34/**
35 * Represents the set of cells (i,j) where i0 <= i < i1
36 */
37struct Span
38{
39 std::int16_t i0;
40 std::int16_t i1;
41 std::int16_t j;
42};
43
44typedef std::vector<Span> Spans;
45
46/**
47 * Converts an ObstructionSquare @p shape (a rotated rectangle),
48 * expanded by the given @p clearance,
49 * into a list of spans of cells that are strictly inside the shape.
50 */
53 entity_pos_t clearance, entity_pos_t cellSize);
54
55}
56
57#endif // INCLUDED_HELPER_RASTERIZE
Entity coordinate types.
A simple fixed-point number class.
Definition: Fixed.h:129
Definition: Rasterize.h:32
void RasterizeRectWithClearance(Spans &spans, const ICmpObstructionManager::ObstructionSquare &shape, entity_pos_t clearance, entity_pos_t cellSize)
Converts an ObstructionSquare shape (a rotated rectangle), expanded by the given clearance,...
Definition: Rasterize.cpp:29
std::vector< Span > Spans
Definition: Rasterize.h:44
Standard representation for all types of shapes, for use with geometry processing code.
Definition: ICmpObstructionManager.h:70
Represents the set of cells (i,j) where i0 <= i < i1.
Definition: Rasterize.h:38
std::int16_t i0
Definition: Rasterize.h:39
std::int16_t i1
Definition: Rasterize.h:40
std::int16_t j
Definition: Rasterize.h:41