gwnavgeneration/raster/rastercelltagvolume.h Source File

rastercelltagvolume.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: LASI - secondary contact: NOBODY
9 
10 // This class is meant to speed-up the evaluation of IsInside() for each pixel in a raster
11 // by pre-computing some early exit conditions. The benefits of this class regarding performance are
12 // critical as IsPixelPos() is called once for each pixel of the raster (~10 000 times / cell) and for
13 // each coloration volume
14 // Call to TagVolume::IsInside() can be very costly (especially when the contour has many vertices)
15 // and therefore need to be avoided as much as possible, hence this class.
16 
17 #ifndef GwNavGen_RasterCellTagVolume_H
18 #define GwNavGen_RasterCellTagVolume_H
19 
24 
25 namespace Kaim
26 {
27 
28 class DynamicRasterCell;
29 class GeneratorSystem;
30 
31 class RasterCellTagVolume
32 {
33  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
34 
35 public:
36  RasterCellTagVolume();
37 
38  void Initialize(const TagVolumeBlob& volumeBlob, const DynamicRasterCell* cell);
39 
40  bool IsPixelPosInVolume(const Vec3f& pixelPos) const;
41 
42  KyUInt32 GetNavTagIdx() const { return m_tagVolume->m_navTagIdx; }
43 
44 private:
45  // compute the value of the 3 bools used to speedup IsPixelPosInVolume()
46  // automatically called in Ctor()
47  void ComputeStatus();
48 
49  bool TestIntersectionWithTagVolume(const Vec3f* corners);
50  KY_INLINE bool IsInsideTagVolume2d(const Vec2f& position) const { return GeometryFunctions::IsInside2d_Polyline(position, m_tagVolume->m_points.GetValues(), m_tagVolume->m_points.GetCount()); }
51  KY_INLINE bool IsInsideTagVolume3d(const Vec3f& position) const { return (position.z <= m_tagVolume->m_aabb.m_max.z) && (position.z >= m_tagVolume->m_aabb.m_min.z) && IsInsideTagVolume2d(position.Get2d()); }
52 
53 private:
54  const TagVolumeBlob* m_tagVolume;
55  const DynamicRasterCell* m_cell;
56  KyInt32 m_pixelSize;
57  KyFloat32 m_rasterPrecision;
58  PixelBox m_pixelBox;
59 
60  bool m_cellFullyContained;
61  bool m_cellFullyOutside;
62 };
63 
64 
65 } // namespace Kaim
66 
67 #endif //GwNavGen_RasterCellTagVolume_H
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
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