10 #ifndef Navigation_DatabaseVisRepGrid_H
11 #define Navigation_DatabaseVisRepGrid_H
20 class DatabaseGeometryBuildingManager
22 class DatabaseVisualTile
25 DatabaseVisualTile() : m_needToBeRebuild(false) {}
26 ~DatabaseVisualTile() {}
28 Ptr<IVisualGeometry> m_visualGeometry;
30 bool m_needToBeRebuild;
34 DatabaseGeometryBuildingManager();
35 ~DatabaseGeometryBuildingManager();
40 void BuildGeometry(
bool forceRebuildAll =
false);
50 void SetVisualGeometry(Ptr<IVisualGeometry> geometry);
51 IVisualGeometry* GetVisualGeometry()
const;
54 void SetVisualGeometryFactory(Ptr<IVisualGeometryFactory> factory);
55 IVisualGeometryFactory* GetVisualGeometryFactory()
const;
59 void SetTileSize(
KyInt32 tileSize);
62 void OnEnlarge(
const CellBox& cellBox);
63 void OnChangeAtPos(
const CellPos& cellPos);
64 void OnChangeInGraph();
67 Vec2i ComputeTilePosFromCellPos(
const CellPos& cellPos)
const;
68 Box2i ComputeTileBoxFromCellBox(
const CellBox& cellBox)
const;
69 CellBox ComputeCellBoxForTilePos(
const Vec2i& tilePos)
const;
72 friend class Database;
73 void OnEnlarge_FactoryProvided(
const CellBox& newCellBox);
74 void OnChangeAtPos_FactoryProvided(
const CellPos& cellPos);
75 void OnChangeInGraph_FactoryProvided();
77 void AskNewGeometryForTileIfNeeded(DatabaseVisualTile& tile);
82 VisualGeometryBuildConfig m_buildConfig;
92 DatabaseVisualTile* m_bufferOfTile;
95 DatabaseVisualTile m_tileForGraphs;
97 Ptr<IVisualGeometryFactory> m_geometryFactory;
101 Ptr<IVisualGeometry> m_visualGeometry;
104 KY_INLINE IVisualGeometryFactory* DatabaseGeometryBuildingManager::GetVisualGeometryFactory()
const {
return m_geometryFactory; }
105 KY_INLINE IVisualGeometry* DatabaseGeometryBuildingManager::GetVisualGeometry()
const {
return m_visualGeometry; }
106 KY_INLINE
VisualGeometryDetailLevel DatabaseGeometryBuildingManager::GetDetailLevel()
const {
return m_buildConfig.m_detailLevel; }
108 KY_INLINE
void DatabaseGeometryBuildingManager::SetAltOffSet(
KyFloat32 altOffset) { m_buildConfig.m_altitudeOffset = altOffset; }
109 KY_INLINE
void DatabaseGeometryBuildingManager::SetDetailLevel(
VisualGeometryDetailLevel detailLevel) { m_buildConfig.m_detailLevel = detailLevel; }
111 KY_INLINE
KyInt32 DatabaseGeometryBuildingManager::ComputeTileCoordFromCellCoord(
KyInt32 coord)
const
113 return coord >= 0 ? coord / m_tileSize : ((coord + 1) / m_tileSize) - 1;
116 KY_INLINE Vec2i DatabaseGeometryBuildingManager::ComputeTilePosFromCellPos(
const CellPos& cellPos)
const
118 return Vec2i(ComputeTileCoordFromCellCoord(cellPos.x), ComputeTileCoordFromCellCoord(cellPos.y));
121 KY_INLINE Box2i DatabaseGeometryBuildingManager::ComputeTileBoxFromCellBox(
const CellBox& cellBox)
const
123 return Box2i(ComputeTilePosFromCellPos(cellBox.Min()), ComputeTilePosFromCellPos(cellBox.Max()));
126 KY_INLINE
CellBox DatabaseGeometryBuildingManager::ComputeCellBoxForTilePos(
const Vec2i& tilePos)
const
128 const CellPos minCellPos(tilePos.x * m_tileSize, tilePos.y * m_tileSize);
129 return CellBox(minCellPos, minCellPos +
CellPos(m_tileSize - 1, m_tileSize - 1));
132 KY_INLINE
void DatabaseGeometryBuildingManager::OnEnlarge(
const CellBox& cellBox)
134 if (m_geometryFactory !=
KY_NULL)
135 OnEnlarge_FactoryProvided(cellBox);
137 KY_INLINE
void DatabaseGeometryBuildingManager::OnChangeAtPos(
const CellPos& cellPos)
139 if (m_geometryFactory !=
KY_NULL)
140 OnChangeAtPos_FactoryProvided(cellPos);
142 KY_INLINE
void DatabaseGeometryBuildingManager::OnChangeInGraph()
144 if (m_geometryFactory !=
KY_NULL)
145 AskNewGeometryForTileIfNeeded(m_tileForGraphs);
148 KY_INLINE
void DatabaseGeometryBuildingManager::AskNewGeometryForTileIfNeeded(DatabaseVisualTile& tile)
150 tile.m_needToBeRebuild =
true;
151 if (tile.m_visualGeometry ==
KY_NULL)
153 tile.m_visualGeometry = m_geometryFactory->CreateIVisualGeometryForDatabase(m_databaseIdx);
154 KY_LOG_ERROR_IF(tile.m_visualGeometry ==
KY_NULL,
155 (
"Failed to create an IVisualGeometry from the IVisualGeometryFactory. A portion of the Database won't be displayed."));
161 #endif // Navigation_DatabaseVisRepGrid_H
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#define KY_NULL
Null value.
Definition: types.h:247
VisualGeometryDetailLevel
Enumerates the possible levels of detail that can be set for a VisualRepresentation.
Definition: ivisualgeometrybuilder.h:35
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43