7 #ifndef KAIM_TAG_VOLUME_SLICER_H
8 #define KAIM_TAG_VOLUME_SLICER_H
19 #include "../containers/bitfield.h"
29 class ScopedDisplayList;
31 enum TagVolumeSlicerResult
33 TAG_VOLUME_SLICE_RESULT_SKIPPED,
34 TAG_VOLUME_SLICE_RESULT_SUCCESS,
35 TAG_VOLUME_SLICE_RESULT_FAILURE
39 class ContourLineEdgePiece
43 ContourLineEdgePiece() : m_parentEdge(
KY_NULL), m_swap(false), m_canceled(false), m_inPolygon(false), m_currentPolygonIdx(0) {}
45 EdgePoints m_edgePiece;
46 const ContourLineEdge* m_parentEdge;
58 TagVolumeEdgeExtremity = 0,
59 LevelLineEdgeExtremity = 1,
60 DiagonalEdgeExtremity = 2,
61 IntersectionWithLevelLineDiagonal = 3,
62 IntersectionWithFloorLink = 4,
63 IntersectionWithBorder = 5,
68 TypedIndexedPos() : m_index(
KyUInt32MAXVAL), m_pointType(InvalidPointType) {}
69 TypedIndexedPos(
const Vec2i& pos,
KyUInt32 index, PointType pointType) :
70 m_pos(pos), m_index(index), m_pointType(pointType) {}
75 PointType m_pointType;
78 class TypedIndexedPosSorter
81 bool operator() (
const TypedIndexedPos& hotPoint1,
const TypedIndexedPos& hotPoint2)
const
83 return hotPoint1.m_pos < hotPoint2.m_pos;
91 UniqueHotPoint(
const Vec2i& pos) : m_pos(pos) {}
101 TagVolumeSlicer(Database* db, NavFloor* navFloor, WorkingMemory* workingMemory) :
102 m_database(db), m_navFloor(navFloor), m_workingMemory(workingMemory), m_slicedTagVolumes(
KY_NULL) {}
105 TagVolumeSlicerResult SliceTagVolumeAccordingToAltitudes(
const TagVolume* tagVolume, KyArray<KyArrayPOD<Vec2i> >& slicedTagVolumes, ScopedDisplayList* displayList);
112 Stop_KeepTagVolumeContour,
117 KyResult ComputeTagVolumeContour(
const TagVolume& tagVolume);
119 KyResult ComputeNavFloorData(WorkingMemArray<PixelBox>& trianglePixelBoxArray, WorkingMemArray<Vec3f>& staticFloatVertices,
120 WorkingMemBitField& triangleVsTagVolumeBoxIntersection);
122 KyResult ExtractLevelLines(
const WorkingMemBitField& triangleVsTagVolumeBoxIntersection,
const WorkingMemArray<Vec3f>& staticFloatVertices);
124 void ComputeTriangleIndexAndVertexStatusOfTagVolumeVertices(
const WorkingMemArray<PixelBox>& trianglePixelBoxArray,
const WorkingMemArray<Vec3f>& staticFloatVertices);
126 InternalResult IntersectContourLineWithTagVolume();
128 KyResult BuildPolygons(KyArray<KyArrayPOD<Vec2i> >& result);
129 KyResult BuildPolygonFromTagVolume(KyArray<KyArray<Vec2i> >& result);
131 KyResult MarkAsTreatedPairedLevelLineEdges(BitField& levelLinesIsPaired,
KyUInt32& firstNonTVEdge);
132 KyFloat32 GetAltitudeOfPointInTriangle(
const Vec2i& tVpixelPos,
const WorkingMemArray<Vec3f>& staticFloatVertices,
NavTriangleIdx triangleIdx);
133 bool ProjectTagVolumePixelPosInStaticFloor(
const WorkingMemArray<PixelBox>& trianglePixelBoxArray,
const Vec2i& tVpixelPos,
136 void AddTagVolumeEdgesToContourLines();
137 KyResult ComputeAllContourEdgeBBox(WorkingMemArray<Box2i>& edgeBoundingBoxes);
138 void AddAllEdgeExtremitiesToHotPoints(WorkingMemArray<TypedIndexedPos>& hotPoints);
139 KyResult ComputeIntersections(
const WorkingMemArray<Box2i>& edgeBoundingBoxes, KyArray<KyArrayPOD<KyUInt32> >& cuts,
140 WorkingMemArray<TypedIndexedPos>& hotPoints);
142 TypedIndexedPos::PointType GetIntersectionPointType(ContourLineEdgeType nonTvEdgeType);
144 KyResult RemoveDuplicatedHotPoints(WorkingMemArray<TypedIndexedPos>& hotPoints, WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
145 void BreakEdgesOnHotPoints(
const WorkingMemArray<Box2i>& edgeBoundingBoxes, WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
146 void SortCuts(
const WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
147 void BuildFinalTagVolumeBrokenContour(
const WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
148 void BuildContourEdgePiece(
const WorkingMemArray<UniqueHotPoint>& uniqueHotPoints, KyArray<KyArrayPOD<KyUInt32> >& cuts);
150 KyResult BuildPolygonsStartingFromTagVolumeEdges(
KyUInt32 firstNonTVEdge, KyArray<KyArrayPOD<Vec2i> >& result, BitField& treatedEdges);
151 KyResult BuildOtherPolygons(
KyUInt32 firstNonTVEdge, KyArray<KyArrayPOD<Vec2i> >& result, BitField& treatedEdges);
153 void RenderLevelLines(ScopedDisplayList* displayList);
154 void RenderBrokenEdges(ScopedDisplayList* displayList);
155 void RenderSlicedTagVolumes(
const KyArray<KyArrayPOD<Vec2i> >& result, ScopedDisplayList* displayList);
157 void PrintTagVolumeForDebug(
const TagVolume* tagVolume);
159 Database* m_database;
160 NavFloor* m_navFloor;
161 WorkingMemory* m_workingMemory;
165 PixelBox m_tagVolumePixelBox;
166 PixelBox m_tagVolumePixelBoxEnlargeOf1;
168 KyArrayPOD<Vec2i> m_tagVolumePixelPos;
176 KyArrayPOD<TvAltStatus> m_verticesAltStatus;
178 KyArrayPOD<Vec2i> m_brokenTagVolumePixelPos;
179 KyArray<ContourLineEdge> m_contourLineEdges;
180 KyArray<ContourLineEdgePiece> m_contourLineEdgePiece;
181 KyArray<KyArrayPOD<Vec2i> >* m_slicedTagVolumes;
187 #endif //KAIM_CONTOUR_LINE_EXTRACTOR_H
KyUInt32 NavTriangleIdx
An index that uniquely identifies a single triangle within the set of triangles owned by a NavFloor...
Definition: navmeshtypes.h:100
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
#define KY_NULL
Null value.
Definition: types.h:247
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
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43