VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
opcodeTerrainIntersectorImpl.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2008 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 /*******************************************************************************
6 ** $RCSfile: opcodeTerrainIntersectorImpl.h,v $ $Revision: 1.5 $ $State: Exp $
7 *******************************************************************************/
8 
11 
12 #ifndef opcodeTerrainIntersectorImpl_h
13 #define opcodeTerrainIntersectorImpl_h
14 
15 #define BAN_OPCODE_AUTOLINK
16 
17 #include "Opcode.h"
18 #include <vector>
19 #include "gdb/triangleIndirect.h"
20 #include <vlutil/vlMutex.h>
21 
22 // Enable this to create a log of all the chord intersection calls that
23 // are made though this interface.
24 // The resulting file can be used in the terrainPerformance test program.
25 //#define LOG_INTERSECTIONS
26 
27 #ifdef LOG_INTERSECTIONS
28 #include <list>
29 #include "geometry/chord.h"
30 #endif
31 
32 
33 class DtTerrainDatabase;
34 class DtPoint;
35 class DtGdbNode;
37 class DtChord;
38 class DtSphere;
39 class DtFileNode;
40 
42 {
43 public:
46 
47  // Builds the opcode model based on this terrain. The terrain
48  // must triangularized before this is done.
49  virtual bool initFromGdb(DtTerrainDatabase* terrain);
50 
51  // \return A text string specifying the initialization state of the interface.
52  // This will contain error text if initFromGdb() fails.
53  virtual DtString initStateText() const;
54 
55  // \return The number of bytes used by the opcode interface and model.
56  virtual unsigned int memoryUsage() const;
57 
58  // \return Information about the first intersection of the specified Chord.
59  virtual bool chordIntersect(const DtChord& chord,
62 
63  virtual bool allIntersectsAlongChord(const DtChord& chord,
66  const DtFileNode* visitedFileNode = 0) const;
67 
68  virtual bool sphereIntersect(const DtSphere& sphere, DtSphereIntersectionRecord& record,
70 
71 protected:
72  typedef std::pair<DtChordIntersectionRecord*, DtOpcodeTerrainIntersectorImpl*> RecordMeshPair;
73 
74  virtual bool makeOpcodeTriangleIndex(DtGdbNode* node);
75 
76  // \throws std::bad_alloc if there is not enough memory
77  virtual void makeIndexedTriangleArray();
78 
79  // Returns the list of file nodes that intersects with the chord
80  virtual bool intersectAnyFileNode(const DtChord& chord, std::vector<DtFileNode*>& vec) const;
81 
82  // Returns the list of file nodes whose extent intersects with the sphere's extent
83  // or contain the sphere's center.
84  virtual bool intersectAnyFileNode(const DtSphere& sphere, std::vector<DtFileNode*>& vec) const;
85 
86  // \brief Used to insert items inside a map in order
87  virtual bool lessDistance(const Opcode::CollisionFace& c1, const Opcode::CollisionFace& c2);
88 
89 protected:
90 
91  typedef std::vector<DtTriangleIndirect*> TriangleIndexType;
92 
93  IndexedTriangle* myIndexedTriangleArray;
95  unsigned int myNumberOfVertices;
96  unsigned int myNumberOfTriangles;
97  Opcode::Model myOpcodeModel;
98 
99  Opcode::OPCODECREATE myOPC;
100  Opcode::MeshInterface myMeshInterface;
102 
103 #ifdef LOG_INTERSECTIONS
104  typedef std::list<std::pair<DtChord, DtGdbNode::DtIntersectRecordType> > DtIntersectionHistoryList;
105  mutable DtIntersectionHistoryList myIntersectionHistory;
106  mutable bool myIntersectionHistoryStarted;
107 
108  void writeIntersectionHistory() const;
109  void addIntersectionHistory(const DtChord& chord, DtGdbNode::DtIntersectRecordType irtFlag) const;
110 #endif
111 
112  // Since OPCODE is not thread safe, use this mutex to protect
113  // against multiple threads inside the intersection methods.
114  mutable DtMutex myIntersectMutex;
116  std::vector<DtFileNode*> myFileNodes;
117 };
118 
119 #endif
TriangleIndexType myTriangleIndex
Definition: opcodeTerrainIntersectorImpl.h:94
Opcode::Model myOpcodeModel
Definition: opcodeTerrainIntersectorImpl.h:97
DtTerrainDatabase * myTerrainDb
Definition: opcodeTerrainIntersectorImpl.h:115
NOTE: This entire class is deprecated, in favor of Dt3dChord.
Definition: chord.h:40
Definition: chordIntersectionRecord.h:23
Definition: sphere.h:22
DtString myInitStateText
Definition: opcodeTerrainIntersectorImpl.h:101
Definition: chordIntersectRecordList.h:29
std::pair< DtChordIntersectionRecord *, DtOpcodeTerrainIntersectorImpl * > RecordMeshPair
Definition: opcodeTerrainIntersectorImpl.h:72
IndexedTriangle * myIndexedTriangleArray
Definition: opcodeTerrainIntersectorImpl.h:93
Definition: gdbNode.h:44
Opcode::OPCODECREATE myOPC
Definition: opcodeTerrainIntersectorImpl.h:99
Definition: sphereIntersectionRecord.h:19
DtIntersectRecordType
Definition: gdbNode.h:74
#define DT_DLL_gdb
Definition: gdbDefines.h:25
unsigned int myNumberOfTriangles
Definition: opcodeTerrainIntersectorImpl.h:96
std::vector< DtFileNode * > myFileNodes
Definition: opcodeTerrainIntersectorImpl.h:116
unsigned int myNumberOfVertices
Definition: opcodeTerrainIntersectorImpl.h:95
Definition: fileNode.h:36
Definition: gdbNode.h:94
A DtChord is a finite line segment in 3-space, represented by two points. Data derived from the two e...
Opcode::MeshInterface myMeshInterface
Definition: opcodeTerrainIntersectorImpl.h:100
std::vector< DtTriangleIndirect * > TriangleIndexType
Definition: opcodeTerrainIntersectorImpl.h:91
Definition: terrainDatabase.h:148
DtMutex myIntersectMutex
Definition: opcodeTerrainIntersectorImpl.h:114
Definition: point.h:34
Definition: opcodeTerrainIntersectorImpl.h:41

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)