VR-Forces 4.1 Class Documentation
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

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)