16 #include "../containers/bitfield.h"
28 enum TagVolumeSlicerResult
30 TAG_VOLUME_SLICE_RESULT_SKIPPED,
31 TAG_VOLUME_SLICE_RESULT_SUCCESS,
32 TAG_VOLUME_SLICE_RESULT_FAILURE
36 class ContourLineEdgePiece
40 ContourLineEdgePiece() : m_parentEdge(
nullptr), m_swap(false), m_canceled(false), m_inPolygon(false), m_currentPolygonIdx(0) {}
42 EdgePoints m_edgePiece;
43 const ContourLineEdge* m_parentEdge;
55 TagVolumeEdgeExtremity = 0,
56 LevelLineEdgeExtremity = 1,
57 DiagonalEdgeExtremity = 2,
58 IntersectionWithLevelLineDiagonal = 3,
59 IntersectionWithFloorLink = 4,
60 IntersectionWithBorder = 5,
65 TypedIndexedPos() : m_index(
KyUInt32MAXVAL), m_pointType(InvalidPointType) {}
66 TypedIndexedPos(
const Vec2i& pos,
KyUInt32 index, PointType pointType) :
67 m_pos(pos), m_index(index), m_pointType(pointType) {}
72 PointType m_pointType;
75 class TypedIndexedPosSorter
78 bool operator() (
const TypedIndexedPos& hotPoint1,
const TypedIndexedPos& hotPoint2)
const
80 return hotPoint1.m_pos < hotPoint2.m_pos;
88 UniqueHotPoint(
const Vec2i& pos) : m_pos(pos) {}
98 TagVolumeSlicer(Database* db, NavFloor* navFloor, WorkingMemory* workingMemory) :
99 m_database(db), m_navFloor(navFloor), m_workingMemory(workingMemory), m_slicedTagVolumes(
nullptr) {}
102 TagVolumeSlicerResult SliceTagVolumeAccordingToAltitudes(
const TagVolume* tagVolume, KyArray<KyArrayPOD<Vec2i> >& slicedTagVolumes, DisplayList* displayList);
109 Stop_KeepTagVolumeContour,
114 KyResult ComputeTagVolumeContour(
const TagVolume& tagVolume);
116 KyResult ComputeNavFloorData(WorkingMemArray<PixelBox>& trianglePixelBoxArray, WorkingMemArray<Vec3f>& staticFloatVertices,
117 WorkingMemBitField& triangleVsTagVolumeBoxIntersection);
119 KyResult ExtractLevelLines(
const WorkingMemBitField& triangleVsTagVolumeBoxIntersection,
const WorkingMemArray<Vec3f>& staticFloatVertices);
121 void ComputeTriangleIndexAndVertexStatusOfTagVolumeVertices(
const WorkingMemArray<PixelBox>& trianglePixelBoxArray,
const WorkingMemArray<Vec3f>& staticFloatVertices);
123 InternalResult IntersectContourLineWithTagVolume();
125 KyResult BuildPolygons(KyArray<KyArrayPOD<Vec2i> >& result);
126 KyResult BuildPolygonFromTagVolume(KyArray<KyArray<Vec2i> >& result);
128 KyResult MarkAsTreatedPairedLevelLineEdges(BitField& levelLinesIsPaired,
KyUInt32& firstNonTVEdge);
129 KyFloat32 GetAltitudeOfPointInTriangle(
const Vec2i& tVpixelPos,
const WorkingMemArray<Vec3f>& staticFloatVertices,
NavTriangleIdx triangleIdx);
130 bool ProjectTagVolumePixelPosInStaticFloor(
const WorkingMemArray<PixelBox>& trianglePixelBoxArray,
const Vec2i& tVpixelPos,
133 void AddTagVolumeEdgesToContourLines();
134 KyResult ComputeAllContourEdgeBBox(WorkingMemArray<Box2i>& edgeBoundingBoxes);
135 void AddAllEdgeExtremitiesToHotPoints(WorkingMemArray<TypedIndexedPos>& hotPoints);
136 KyResult ComputeIntersections(
const WorkingMemArray<Box2i>& edgeBoundingBoxes, KyArray<KyArrayPOD<KyUInt32> >& cuts,
137 WorkingMemArray<TypedIndexedPos>& hotPoints);
139 TypedIndexedPos::PointType GetIntersectionPointType(ContourLineEdgeType nonTvEdgeType);
141 KyResult RemoveDuplicatedHotPoints(WorkingMemArray<TypedIndexedPos>& hotPoints, WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
142 void BreakEdgesOnHotPoints(
const WorkingMemArray<Box2i>& edgeBoundingBoxes, WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
143 void SortCuts(
const WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
144 void BuildFinalTagVolumeBrokenContour(
const WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
145 void BuildContourEdgePiece(
const WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
147 KyResult BuildPolygonsStartingFromTagVolumeEdges(
KyUInt32 firstNonTVEdge, KyArray<KyArrayPOD<Vec2i> >& result, BitField& treatedEdges);
148 KyResult BuildOtherPolygons(
KyUInt32 firstNonTVEdge, KyArray<KyArrayPOD<Vec2i> >& result, BitField& treatedEdges);
150 void RenderLevelLines(DisplayList* displayList);
151 void RenderBrokenEdges(DisplayList* displayList);
152 void RenderSlicedTagVolumes(
const KyArray<KyArrayPOD<Vec2i> >& result, DisplayList* displayList);
154 void PrintTagVolumeForDebug(
const TagVolume* tagVolume);
156 Database* m_database;
157 NavFloor* m_navFloor;
158 WorkingMemory* m_workingMemory;
162 PixelBox m_tagVolumePixelBox;
163 PixelBox m_tagVolumePixelBoxEnlargeOf1;
165 KyArrayPOD<Vec2i> m_tagVolumePixelPos;
173 KyArrayPOD<TvAltStatus> m_verticesAltStatus;
175 KyArrayPOD<Vec2i> m_brokenTagVolumePixelPos;
176 KyArray<ContourLineEdge> m_contourLineEdges;
177 KyArray<ContourLineEdgePiece> m_contourLineEdgePiece;
178 KyArray<KyArrayPOD<Vec2i> >* m_slicedTagVolumes;
KyUInt32 NavTriangleIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:97
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
float KyFloat32
float
Definition: types.h:32