VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
bvhTriangleMeshShape.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
13 #include <BulletCollision/CollisionDispatch/btCollisionObject.h>
14 #include <BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h>
15 #include <BulletCollision/CollisionShapes/btTriangleMesh.h>
16 
17 #include <boost/shared_ptr.hpp>
18 #include <boost/enable_shared_from_this.hpp>
19 
20 #include <tbb/spin_mutex.h>
21 
22 class DtSurface;
23 class btVector3;
24 
27 {
28 public:
29  DtTriangleMeshWithSoil(bool use32bitIndices = true, bool use4componentVertices = true);
30  virtual ~DtTriangleMeshWithSoil();
31 
32  bool valid(const btVector3& vertex0, const btVector3& vertex1, const btVector3& vertex2) const;
33  bool valid(const btVector3& vertex) const;
34  bool valid(const btScalar& val) const;
35 
36  bool checkAddTriangle(const btVector3& vertex0, const btVector3& vertex1, const btVector3& vertex2,
37  bool removeDuplicateVertices = false);
38 
39  void addTriangle(const btVector3& vertex0, const btVector3& vertex1, const btVector3& vertex2,
40  bool removeDuplicateVertices = false);
41 
42  void addTriangleWithSurface(const btVector3& vertex0, const btVector3& vertex1, const btVector3& vertex2,
43  const DtSurface& surface, bool removeDuplicateVertices = false);
44 
45  DtSurface triangleSurface(unsigned int triangleIndex) const;
46 
47  const btVector3& max() const;
48  const btVector3& min() const;
49 
50  bool isAabbValid() const;
51 
52  double maxDistance() const;
53 
54 protected:
55  void updateBounds(const btVector3& val);
56 
59  void initializeSurfaceArray();
60 
63  void syncSurfaceArray();
64 
70  btAlignedObjectArray<DtSurface> mySurfaceTypes;
71  btVector3 myMin;
72  btVector3 myMax;
74 };
75 
77  : public btBvhTriangleMeshShape
78  , public boost::enable_shared_from_this<DtBvhTriangleMeshShape>
79 {
80 public:
81  typedef boost::shared_ptr<DtBvhTriangleMeshShape> Ptr;
82 
85  bool useQuantization = true, bool buildBvhNow = false,
86  bool filterTransparentPolygons = false);
87 
89 
92  bool buildBvh();
93 
95  int getNumTriangles() const;
96 
97 private:
98  typedef tbb::spin_mutex Mutex;
99 
100  mutable Mutex myMutex;
102 
104 };
105 
107  : public btCollisionObject
109 {
110 public:
112 
113  void setCollisionShape(btCollisionShape* shape);
114 
115  bool buildBvh();
116  bool enabled() const;
117 
118  boost::shared_ptr<btCollisionShape> bulletCollisionShape() const;
119 
120  unsigned int numberOfTriangles() const;
121  double radius() const;
122  DtSurface triangleSurface(unsigned int triangleIndex) const;
123 
125 
126  const btTransform& worldTransform() const;
127 
128 protected:
130 };
virtual double radius() const =0
Returns the maximum distance of all points from the origin of this object.
bool myUseSurfaceArray
When this is false, mySurfaceTypes is empty, and all triangles are considered to have &quot;Unspecified&quot; a...
Definition: bvhTriangleMeshShape.h:69
virtual DtSurface triangleSurface(unsigned int triangleIndex) const =0
Return the surface of a triangle at a given index.
A version of btTriangleMesh that also holds soil type for each polygon.
Definition: bvhTriangleMeshShape.h:26
virtual bool enabled() const =0
Intersections will ignore this object if this returns true.
Definition: surface.h:179
DtBvhTriangleMeshShape::Ptr myShape
Definition: bvhTriangleMeshShape.h:129
Definition: bvhTriangleMeshShape.h:76
std::vector< boost::shared_ptr< makVrv::DtDynamicTerrainFeature > > DynamicFeatures
Definition: osgToBullet.h:67
virtual bool buildBvh()=0
Build the bvh with mutex locked. Call as many times as you like, will only build once.
double myMaxPointDistanceSq
Definition: bvhTriangleMeshShape.h:73
virtual unsigned int numberOfTriangles() const =0
Return number of triangles in this object (ignores instancing).
btVector3 myMin
Definition: bvhTriangleMeshShape.h:71
boost::shared_ptr< DtBvhTriangleMeshShape > Ptr
Definition: bvhTriangleMeshShape.h:81
int myTrianglesCount
Definition: bvhTriangleMeshShape.h:103
btVector3 myMax
Definition: bvhTriangleMeshShape.h:72
tbb::spin_mutex Mutex
Definition: bvhTriangleMeshShape.h:98
Definition: bvhTriangleMeshShape.h:106
virtual boost::shared_ptr< btCollisionShape > bulletCollisionShape() const =0
Access the underlying bullet collision shape.
Mutex myMutex
Definition: bvhTriangleMeshShape.h:100
Definition: osgToBullet.h:63
virtual DynamicFeatures dynamicFeatures() const =0
Return all the dynamic features which contain this object.
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
DtTriangleMeshWithSoil * myMesh
Definition: bvhTriangleMeshShape.h:101
virtual const btTransform & worldTransform() const =0
Access the world transform of the collision object.
btAlignedObjectArray< DtSurface > mySurfaceTypes
Definition: bvhTriangleMeshShape.h:70

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)