VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)