Skip to content

Commit 441a356

Browse files
committed
Revert "add isometric grids (start)"
This reverts commit d91c3f3.
1 parent d91c3f3 commit 441a356

File tree

11 files changed

+13
-1208
lines changed

11 files changed

+13
-1208
lines changed

examples/29_grid.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ int main() {
6060

6161
NamedGrid grids[] = {
6262
{ "Orthogonal"s, gf::Grid::createOrthogonal(GridSize, CellSize) },
63-
{ "Isometric"s, gf::Grid::createIsometric(GridSize, CellSize) },
6463
{ "Staggered X Odd"s, gf::Grid::createStaggered(GridSize, StaggeredCellSize, gf::CellAxis::X, gf::CellIndex::Odd) },
6564
{ "Staggered X Even"s, gf::Grid::createStaggered(GridSize, StaggeredCellSize, gf::CellAxis::X, gf::CellIndex::Even) },
6665
{ "Staggered Y Odd"s, gf::Grid::createStaggered(GridSize, StaggeredCellSize, gf::CellAxis::Y, gf::CellIndex::Odd) },
@@ -119,14 +118,6 @@ int main() {
119118
grids[current].grid.hover(renderer.mapPixelToCoords(event.mouseCursor.coords));
120119
break;
121120

122-
case gf::EventType::MouseButtonPressed:
123-
{
124-
auto coords = renderer.mapPixelToCoords(event.mouseButton.coords);
125-
auto localCoords = gf::transform(grids[current].grid.getInverseTransform(), coords);
126-
auto position = grids[current].grid.getCells().computeCoordinates(localCoords);
127-
std::cout << "Position: " << position.x << ',' << position.y << '\n';
128-
}
129-
130121
default:
131122
break;
132123
}

include/gf/Cells.h

Lines changed: 0 additions & 265 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ inline namespace v1 {
4747
Diagonal = 0x02, ///< The neighbors may be in diagonal
4848
};
4949

50-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
51-
}
52-
#endif
53-
54-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
55-
namespace v1 {
56-
#endif
5750

5851
/**
5952
* @ingroup core_cells
@@ -265,264 +258,6 @@ namespace v1 {
265258

266259
#ifndef DOXYGEN_SHOULD_SKIP_THIS
267260
}
268-
#endif
269-
270-
#ifndef DOXYGEN_SHOULD_SKIP_THIS
271-
inline namespace v2 {
272-
273-
/**
274-
* @ingroup core_cells
275-
* @brief The properties of cells
276-
*
277-
* These properties depend on the orientation of the cells in the map:
278-
*
279-
* - gf::OrthogonalCells
280-
* - gf::IsometricCells
281-
* - gf::StaggeredCells
282-
* - gf::HexagonalCells
283-
*
284-
* @sa gf::CellOrientation, gf::Grid, gf::TileLayer
285-
*/
286-
class GF_CORE_API Cells {
287-
public:
288-
/**
289-
* @brief Virtual destructor
290-
*/
291-
virtual ~Cells();
292-
293-
/**
294-
* @brief Compute the local bounds of the cells
295-
*
296-
* @returns The bounds of the cells
297-
*/
298-
virtual RectF computeBounds() const noexcept = 0;
299-
300-
/**
301-
* @brief Compute the visible area in terms of coordinates
302-
*
303-
* @param local The visible area
304-
* @returns The visible coordinates
305-
*/
306-
virtual RectI computeVisibleArea(const RectF& local) const noexcept = 0;
307-
308-
/**
309-
* @brief Compute the cell bounds
310-
*
311-
* @param coords The coordinates of the cell
312-
* @returns The rectangular bounding box of the cell
313-
*/
314-
virtual RectF computeCellBounds(Vector2i coords) const noexcept = 0;
315-
316-
/**
317-
* @brief Compute the coordinates of a cell
318-
*
319-
* @param position The local position
320-
* @returns The coordinates of the cell
321-
*/
322-
virtual Vector2i computeCoordinates(Vector2f position) const noexcept = 0;
323-
324-
/**
325-
* @brief Compute the polyline representing a cell
326-
*
327-
* @param coords The coordinates of the cell
328-
* @returns A polyline (loop) that represents the cell
329-
*/
330-
virtual Polyline computePolyline(Vector2i coords) const = 0;
331-
332-
/**
333-
* @brief Compute the neighbors of a cell
334-
*
335-
* @param coords The coordinates of the cell
336-
* @param flags The parameters of the query
337-
* @returns An array of coordinates of the neighbors
338-
*/
339-
virtual std::vector<Vector2i> computeNeighbors(Vector2i coords, Flags<CellNeighborQuery> flags = gf::None) const = 0;
340-
};
341-
342-
/**
343-
* @ingroup core_cells
344-
* @brief Orthogonal cells
345-
*/
346-
class GF_CORE_API OrthogonalCells final : public Cells {
347-
public:
348-
/**
349-
* @brief Make orthogonal cells of the specified size
350-
*
351-
* @param layerSize The size of the layer
352-
* @param tileSize The size of a cell
353-
*/
354-
OrthogonalCells(Vector2i layerSize, Vector2f tileSize)
355-
: m_layerSize(layerSize)
356-
, m_tileSize(tileSize)
357-
{
358-
}
359-
360-
RectF computeBounds() const noexcept override;
361-
362-
RectI computeVisibleArea(const RectF& local) const noexcept override;
363-
364-
RectF computeCellBounds(Vector2i coords) const noexcept override;
365-
366-
Vector2i computeCoordinates(Vector2f position) const noexcept override;
367-
368-
Polyline computePolyline(Vector2i coords) const override;
369-
370-
std::vector<Vector2i> computeNeighbors(Vector2i coords, Flags<CellNeighborQuery> flags = gf::None) const override;
371-
372-
private:
373-
Vector2i m_layerSize;
374-
Vector2f m_tileSize;
375-
};
376-
377-
/**
378-
* @ingroup core_cells
379-
* @brief Isometric cells
380-
*/
381-
class GF_CORE_API IsometricCells final : public Cells {
382-
public:
383-
/**
384-
* @brief Make orthogonal cells of the specified size
385-
*
386-
* @param layerSize The size of the layer
387-
* @param tileSize The size of a cell
388-
*/
389-
IsometricCells(Vector2i layerSize, Vector2f tileSize)
390-
: m_layerSize(layerSize)
391-
, m_tileSize(tileSize)
392-
{
393-
}
394-
395-
RectF computeBounds() const noexcept override;
396-
397-
RectI computeVisibleArea(const RectF& local) const noexcept override;
398-
399-
RectF computeCellBounds(Vector2i coords) const noexcept override;
400-
401-
Vector2i computeCoordinates(Vector2f position) const noexcept override;
402-
403-
Polyline computePolyline(Vector2i coords) const override;
404-
405-
std::vector<Vector2i> computeNeighbors(Vector2i coords, Flags<CellNeighborQuery> flags = gf::None) const override;
406-
407-
private:
408-
Vector2i m_layerSize;
409-
Vector2f m_tileSize;
410-
};
411-
412-
/**
413-
* @ingroup core_cells
414-
* @brief Staggered cells
415-
*/
416-
class GF_CORE_API StaggeredCells final : public Cells {
417-
public:
418-
/**
419-
* @brief Make staggered cells of the specified size
420-
*
421-
* @param layerSize The size of the layer
422-
* @param tileSize The size of a cell
423-
* @param axis The cells axis
424-
* @param index The cells index
425-
*/
426-
StaggeredCells(Vector2i layerSize, Vector2f tileSize, CellAxis axis, CellIndex index)
427-
: m_layerSize(layerSize)
428-
, m_tileSize(tileSize)
429-
, m_axis(axis)
430-
, m_index(index)
431-
{
432-
}
433-
434-
RectF computeBounds() const noexcept override;
435-
436-
RectI computeVisibleArea(const RectF& local) const noexcept override;
437-
438-
RectF computeCellBounds(Vector2i coords) const noexcept override;
439-
440-
Vector2i computeCoordinates(Vector2f position) const noexcept override;
441-
442-
Polyline computePolyline(Vector2i coords) const override;
443-
444-
std::vector<Vector2i> computeNeighbors(Vector2i coords, Flags<CellNeighborQuery> flags = gf::None) const override;
445-
446-
private:
447-
Vector2i m_layerSize;
448-
Vector2f m_tileSize;
449-
CellAxis m_axis;
450-
CellIndex m_index;
451-
};
452-
453-
454-
/**
455-
* @ingroup core_cells
456-
* @brief Hexagonal cells
457-
*/
458-
class GF_CORE_API HexagonalCells final : public Cells {
459-
public:
460-
/**
461-
* @brief Make hexagonal cells of the specified size
462-
*
463-
* @param layerSize The size of the layer
464-
* @param tileSize The size of a cell
465-
* @param sideLength The length of the side
466-
* @param axis The cells axis
467-
* @param index The cells index
468-
*/
469-
HexagonalCells(Vector2i layerSize, Vector2f tileSize, float sideLength, CellAxis axis, CellIndex index)
470-
: m_layerSize(layerSize)
471-
, m_tileSize(tileSize)
472-
, m_sideLength(sideLength)
473-
, m_axis(axis)
474-
, m_index(index)
475-
{
476-
}
477-
478-
/**
479-
* @brief Make hexagonal cells of the specified size
480-
*
481-
* @param layerSize The size of the layer
482-
* @param radius The radius of the regular hexagon
483-
* @param axis The cells axis
484-
* @param index The cells index
485-
*/
486-
HexagonalCells(Vector2i layerSize, float radius, CellAxis axis, CellIndex index)
487-
: m_layerSize(layerSize)
488-
, m_tileSize(computeRegularSize(axis, radius))
489-
, m_sideLength(radius)
490-
, m_axis(axis)
491-
, m_index(index)
492-
{
493-
}
494-
495-
RectF computeBounds() const noexcept override;
496-
497-
RectI computeVisibleArea(const RectF& local) const noexcept override;
498-
499-
RectF computeCellBounds(Vector2i coords) const noexcept override;
500-
501-
Vector2i computeCoordinates(Vector2f position) const noexcept override;
502-
503-
Polyline computePolyline(Vector2i coords) const override;
504-
505-
std::vector<Vector2i> computeNeighbors(Vector2i coords, Flags<CellNeighborQuery> flags = gf::None) const override;
506-
507-
/**
508-
* @brief Get the size of a regular hexagon
509-
*
510-
* @param axis The hexagon axis
511-
* @param radius Radius of hexagon
512-
*
513-
* @returns The size of the bounding box of the hexagon
514-
*/
515-
static Vector2f computeRegularSize(CellAxis axis, float radius);
516-
517-
private:
518-
Vector2i m_layerSize;
519-
Vector2f m_tileSize;
520-
float m_sideLength;
521-
CellAxis m_axis;
522-
CellIndex m_index;
523-
};
524-
525-
}
526261

527262
template<>
528263
struct EnableBitmaskOperators<CellNeighborQuery> {

include/gf/Grid.h

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
* misrepresented as being the original software.
1919
* 3. This notice may not be removed or altered from any source distribution.
2020
*/
21-
#ifndef GF_GRID_V2_H
22-
#define GF_GRID_V2_H
21+
#ifndef GF_GRID_H
22+
#define GF_GRID_H
2323

2424
#include <memory>
2525

@@ -32,7 +32,7 @@
3232

3333
namespace gf {
3434
#ifndef DOXYGEN_SHOULD_SKIP_THIS
35-
inline namespace v2 {
35+
inline namespace v1 {
3636
#endif
3737

3838
/**
@@ -61,14 +61,6 @@ inline namespace v2 {
6161
*/
6262
static Grid createOrthogonal(Vector2i gridSize, Vector2f cellSize);
6363

64-
/**
65-
* @brief Create an isometric grid
66-
*
67-
* @param gridSize The size of the grid
68-
* @param cellSize The size of a cell
69-
*/
70-
static Grid createIsometric(Vector2i gridSize, Vector2f cellSize);
71-
7264
/**
7365
* @brief Create a staggered grid
7466
*
@@ -101,11 +93,11 @@ inline namespace v2 {
10193
static Grid createHexagonal(Vector2i gridSize, float radius, CellAxis axis, CellIndex index);
10294

10395
/**
104-
* @brief Get the underlying cells
96+
* @brief Set the grid size
97+
*
98+
* @param gridSize The new grid size
10599
*/
106-
const Cells& getCells() const {
107-
return *m_properties;
108-
}
100+
void setGridSize(Vector2i gridSize);
109101

110102
/**
111103
* @brief Get the grid size
@@ -227,4 +219,4 @@ inline namespace v2 {
227219
#endif
228220
}
229221

230-
#endif // GF_GRID_V2_H
222+
#endif // GF_GRID_H

0 commit comments

Comments
 (0)