VR-Forces 4.8 Class Documentation
 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) 2017 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 
94 private:
95  typedef tbb::spin_mutex Mutex;
96 
97  mutable Mutex myMutex;
99 };
100 
102  : public btCollisionObject
104 {
105 public:
107 
108  void setCollisionShape(btCollisionShape* shape);
109 
110  bool buildBvh();
111  bool enabled() const;
112 
113  boost::shared_ptr<btCollisionShape> bulletCollisionShape() const;
114 
115  unsigned int numberOfTriangles() const;
116  double radius() const;
117  DtSurface triangleSurface(unsigned int triangleIndex) const;
118 
120 
121  const btTransform& worldTransform() const;
122 
123 protected:
125 };
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:124
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.
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
btVector3 myMax
Definition: bvhTriangleMeshShape.h:72
tbb::spin_mutex Mutex
Definition: bvhTriangleMeshShape.h:95
Definition: bvhTriangleMeshShape.h:101
virtual boost::shared_ptr< btCollisionShape > bulletCollisionShape() const =0
Access the underlying bullet collision shape.
Mutex myMutex
Definition: bvhTriangleMeshShape.h:97
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:98
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 Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)