8 #ifndef Navigation_NavCellStitcher_H
9 #define Navigation_NavCellStitcher_H
24 class NavHalfEdgeRawPtr;
25 class Stitch1To1EdgeLink;
39 class NavFloorStitcherData
42 NavFloorStitcherData();
44 void Init(NavCell& navCell,
NavFloorIdx floorIdx,
bool getFutureActiveFloorBlob =
false);
45 void Init(
const Stitch1To1EdgeLink& stitch1To1EdgeLink,
bool getFutureActiveFloorBlob =
false);
50 const NavFloorBlob* m_navFloorBlob;
51 const NavHalfEdge* m_halfEdges;
52 const NavVertex* m_navVertexBuffer;
54 NavHalfEdgeRawPtr* m_links;
55 const KyUInt16* m_stitch1To1EdgeIdxToFirstIdxBuffer;
56 const KyUInt16* m_stitch1To1EdgeIdxToCountBuffer;
57 const CompactNavHalfEdgeIdx* m_navHalfEdgeIdxBuffer;
58 const Stitch1To1EdgeLink* m_stitch1To1EdgeLinkBuffer;
61 class NavFloorStitcher
65 NavFloorStitcher(Database* database) : m_altitudeTolerance(0.5f), m_database(database) {}
69 void UnStitchAll1To1EdgeInNavCell(NavCell& navCell);
70 void StitchAllNew1To1EdgeAndTagPotentialRunTimeStitchNeed(
const CellPos& cellPos, NavCellPosInfo* navCellPosInfo);
73 void RetrieveNeighborCellCandidates(
const CellPos& cellPos);
74 void StitchAll1To1EdgeInNavCell(NavCell& navCell);
75 void TryToLinkCellBoundaryStitch1To1EdgeWithCandidates(NavCell* navCell,
KyUInt32 floorIdx,
KyUInt32 stitch1To1EdgeIdx,
76 const EdgeVertices& edgeVertices, KyArrayPOD<NavCell*, MemStat_NavData>& neihgborCellCandidates,
CardinalDir cardinalDirInNeighbor);
77 void TryToLinkFloorBoundaryStitch1To1EdgeWithCandidates(NavCell* navCell,
KyUInt32 floorIdx,
KyUInt32 stitch1To1EdgeIdx,
const EdgeVertices& edgeVertices);
78 bool DoesFloorCauseRuntimeStitchInNeighbor(NavCell* navCell,
KyUInt32 floorIdx);
80 void StitchAllNavFloorsOfNavCell(NavCell& navCell);
81 void StitchAllNavFloorLink(NavCell& navCell,
NavFloorIdx floorIdx);
82 bool CanEdgesStitch(EdgeVertices& currentEdgeVertices, EdgeVertices& candidateEdgeVertices,
NavHalfEdgeType edgeType);
84 void UnStitchAllNavFloorsOfNavCell(NavCell& navCell);
93 KyArrayPOD<NavCell*, MemStat_NavData> m_neihgborCellCandidates[4];
97 KY_INLINE
bool NavFloorStitcher::AreVerticesEqualInAltitude(
KyFloat32 edge1_startAlt,
KyFloat32 edge1_endAlt,
100 const KyFloat32 altitudeDiff1 = fabsf(edge1_startAlt - edge2_endAlt);
101 const KyFloat32 altitudeDiff2 = fabsf(edge1_endAlt - edge2_startAlt);
102 const KyFloat32 operand1 =
Fsel(altitudeDiff1 - altitudeTolerance, 0.f, 1.f);
103 const KyFloat32 operand2 =
Fsel(altitudeDiff2 - altitudeTolerance, 0.f, 1.f);
104 return operand1 * operand2 > 0;
107 template <
class VertexComparator>
111 static bool CanEdgesStitch(
const EdgeVertices& edge1,
const EdgeVertices& edge2,
KyFloat32 altitudeTolerance)
114 VertexComparator::AreVerticesEqual(edge1.m_startVertex, edge2.m_endVertex) &&
115 VertexComparator::AreVerticesEqual(edge1.m_endVertex, edge2.m_startVertex) &&
116 NavFloorStitcher::AreVerticesEqualInAltitude(edge1.m_startAltitude, edge1.m_endAltitude, edge2.m_startAltitude, edge2.m_endAltitude, altitudeTolerance);
120 class Comparator_InFloor
123 static bool AreVerticesEqual(
const Vec2i& vertex1,
const Vec2i& vertex2) {
return vertex1 == vertex2; }
126 class Comparator_OnCellBoundEASTorWEST
129 static bool AreVerticesEqual(
const Vec2i& vertex1,
const Vec2i& vertex2) {
return vertex1.y == vertex2.y; }
132 class Comparator_OnCellBoundNORTHorSOUTH
135 static bool AreVerticesEqual(
const Vec2i& vertex1,
const Vec2i& vertex2) {
return vertex1.x == vertex2.x; }
140 #endif //Navigation_NavCellStitcher_H
Vec2i CellPos
A type that represents the position of a cell within a 2D grid.
Definition: navmeshtypes.h:33
KyUInt32 CardinalDir
Defines a type that refers to one of the cardinal points on the compass:
Definition: cardinaldir.h:23
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:115
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
NavHalfEdgeType
Enumerates the possible types of boundary that can be represented by a NavHalfEdge.
Definition: navmeshtypes.h:52
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
KyFloat32 Fsel(KyFloat32 cmp, KyFloat32 v1, KyFloat32 v2)
Ifcmp is greater than 0, returnsv1. Otherwise, returnsv2.
Definition: fastmath.h:58