VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
spatialSubdivisionTerrainIntersector.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2008 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: spatialSubdivisionTerrainIntersector.h,v $ $Revision: 1.3 $ $State: Exp $
7 *******************************************************************************/
8 
11 
12 #ifndef spatialSubdivisionTerrainIntersector_h
13 #define spatialSubdivisionTerrainIntersector_h
14 
15 #include "gdb/terrainIntersector.h"
17 
18 #include "gdb/gdbNode.h"
19 
20 // Enable this to test the spatial subdivision against the spatial index
21 // Causes a significant performance hit
22 #define TEST_SPATIAL_SUBDIVISION 0
23 
24 #if TEST_SPATIAL_SUBDIVISION
25 class DtSpatialIndex;
26 #endif
27 
29 
30 // An intersector for DtTerrainDatabase class.
31 // Uses the spatial subdivision methodology for providing fast terrain
32 // intersections
33 
34 // This is the descriptor class that will set up some basic information for the spatial
35 // subdivision
36 
38 {
39 private:
40  // Not implemented.
42  // Not implemented.
44  // Not implemented.
46 
47 public:
49  const DtTerrainIntersectorDescriptor* desc);
51 
52  virtual bool init();
53 
54  // Calls init()
55  virtual bool reinitialize();
56 
57  // \return The total number of bytes of memory used by this intersector
58  // and any of its internal indexing into the terrain.
59  virtual unsigned int memoryUsage() const;
60 
61  virtual bool chordIntersect(const DtChord& chord,
64 
65  virtual bool allIntersectsAlongChord(const DtChord& chord,
68 
69  virtual bool sphereIntersect(const DtSphere& sphere, DtSphereIntersectionRecord& record,
71 
72  virtual int terrainIntersectorType() const;
73 
74  // \return A new instance of a descriptor for this terrain intersector.
75  static DtSpatialSubdivisionTerrainIntersectorDescriptor* createDescriptor();
76 
77 public:
78 
79  virtual DtSpatialSubdivision<DtGdbNode*>* spatialSubdivision();
80  virtual const DtSpatialSubdivision<DtGdbNode*>* spatialSubdivision() const;
81 
82  // These are only used during init or reinitialization. If you set
83  // one (or more) of these values, be sure to call reinitialize after
84  // you are done changing values
85  int cellCountX() const { return myCellCountX; };
86  void setCellCountX(int x) { myCellCountX = x ;};
87 
88  int cellCountY() const { return myCellCountY; };
89  void setCellCountY(int y) { myCellCountY = y; };
90 
91  int cellCountZ() const { return myCellCountZ; };
92  void setCellCountZ(int z) { myCellCountZ = z; };
93 
94 protected:
95  virtual void buildSpatialSubdivision(unsigned int cellCountX,
96  unsigned int cellCountY,
97  unsigned int cellCountZ = 1);
98 
99 #if TEST_SPATIAL_SUBDIVISION
100 public:
101  DtSpatialIndex* spatialIndex();
102  void setSpatialIndex(DtSpatialIndex* spatialIndex);
103 protected:
104 #endif
105 
106 protected:
108 
109  // These are only used during initialization.
113 
114 private:
115 #if TEST_SPATIAL_SUBDIVISION
116  DtSpatialIndex* mySpatialIndex;
117 #endif
118 };
119 
121 {
123 }
124 
126 {
128 }
129 
130 #if TEST_SPATIAL_SUBDIVISION
131 inline DtSpatialIndex* DtTerrainDatabase::spatialIndex()
132 {
133  return mySpatialIndex;
134 }
135 inline void DtTerrainDatabase::setSpatialIndex(DtSpatialIndex* newSpatialIndex)
136 {
137  mySpatialIndex = newSpatialIndex;
138 }
139 #endif
140 
141 #endif
int cellCountY() const
Definition: spatialSubdivisionTerrainIntersector.h:88
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
int myCellCountZ
Definition: spatialSubdivisionTerrainIntersector.h:112
Definition: chordIntersectionRecord.h:23
Definition: sphere.h:22
virtual bool init()=0
Definition: chordIntersectRecordList.h:29
int myCellCountX
Definition: spatialSubdivisionTerrainIntersector.h:110
int myCellCountY
Definition: spatialSubdivisionTerrainIntersector.h:111
virtual bool chordIntersect(const DtChord &chord, DtChordIntersectionRecord &record, DtGdbNode::DtIntersectRecordType irtFlag=DtGdbNode::IRT_ALL_DATA_TERRAIN) const =0
virtual bool allIntersectsAlongChord(const DtChord &chord, DtChordIntersectRecordList &intList, DtGdbNode::DtIntersectRecordType irtFlag=DtGdbNode::IRT_ALL_DATA_TERRAIN) const =0
Definition: sphereIntersectionRecord.h:19
DtIntersectRecordType
Definition: gdbNode.h:74
Definition: spatialSubdivisionTerrainIntersectorDescriptor.h:21
#define DT_DLL_gdb
Definition: gdbDefines.h:25
DtTerrainIntersector & operator=(const DtTerrainIntersector &orig)
void setCellCountY(int y)
Definition: spatialSubdivisionTerrainIntersector.h:89
Definition: terrainIntersectorDescriptor.h:22
virtual int terrainIntersectorType() const =0
void setCellCountZ(int z)
Definition: spatialSubdivisionTerrainIntersector.h:92
virtual bool sphereIntersect(const DtSphere &sphere, DtSphereIntersectionRecord &record, DtGdbNode::DtIntersectRecordType irtFlag=DtGdbNode::IRT_ALL_DATA_TERRAIN) const =0
Definition: spatialSubdivisionTerrainIntersector.h:37
Definition: gdbNode.h:94
virtual bool reinitialize()=0
Definition: terrainIntersector.h:33
Definition: terrainDatabase.h:148
virtual unsigned int memoryUsage() const =0
virtual DtSpatialSubdivision< DtGdbNode * > * spatialSubdivision()
Definition: spatialSubdivisionTerrainIntersector.h:120
int cellCountX() const
Definition: spatialSubdivisionTerrainIntersector.h:85
int cellCountZ() const
Definition: spatialSubdivisionTerrainIntersector.h:91
DtSpatialSubdivision< DtGdbNode * > * myTerrainSpatialSubdivision
Definition: spatialSubdivisionTerrainIntersector.h:107
void setCellCountX(int x)
Definition: spatialSubdivisionTerrainIntersector.h:86

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)