Bullet Collision Detection & Physics Library: btBvhTriangleMeshShape.h Source File

Bullet Collision Detection & Physics Library

btBvhTriangleMeshShape.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef BT_BVH_TRIANGLE_MESH_SHAPE_H
17#define BT_BVH_TRIANGLE_MESH_SHAPE_H
18
19#include "btTriangleMeshShape.h"
20#include "btOptimizedBvh.h"
21#include "LinearMath/btAlignedAllocator.h"
22#include "btTriangleInfoMap.h"
23
34 ATTRIBUTE_ALIGNED16(class)
35 btBvhTriangleMeshShape : public btTriangleMeshShape
36{
37 btOptimizedBvh* m_bvh;
38 btTriangleInfoMap* m_triangleInfoMap;
39
40 bool m_useQuantizedAabbCompression;
41 bool m_ownsBvh;
42#ifdef __clang__
43 bool m_pad[11] __attribute__((unused));
44#else
45 bool m_pad[11];
46#endif
47
48public:
49 BT_DECLARE_ALIGNED_ALLOCATOR();
50
51 btBvhTriangleMeshShape(btStridingMeshInterface * meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
52
54 btBvhTriangleMeshShape(btStridingMeshInterface * meshInterface, bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax, bool buildBvh = true);
55
56 virtual ~btBvhTriangleMeshShape();
57
58 bool getOwnsBvh() const
59 {
60 return m_ownsBvh;
61 }
62
63 void performRaycast(btTriangleCallback * callback, const btVector3& raySource, const btVector3& rayTarget);
64 void performConvexcast(btTriangleCallback * callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
65
66 virtual void processAllTriangles(btTriangleCallback * callback, const btVector3& aabbMin, const btVector3& aabbMax) const;
67
68 void refitTree(const btVector3& aabbMin, const btVector3& aabbMax);
69
71 void partialRefitTree(const btVector3& aabbMin, const btVector3& aabbMax);
72
73 //debugging
74 virtual const char* getName() const { return "BVHTRIANGLEMESH"; }
75
76 virtual void setLocalScaling(const btVector3& scaling);
77
78 btOptimizedBvh* getOptimizedBvh()
79 {
80 return m_bvh;
81 }
82
83 void setOptimizedBvh(btOptimizedBvh * bvh, const btVector3& localScaling = btVector3(1, 1, 1));
84
85 void buildOptimizedBvh();
86
87 bool usesQuantizedAabbCompression() const
88 {
89 return m_useQuantizedAabbCompression;
90 }
91
92 void setTriangleInfoMap(btTriangleInfoMap * triangleInfoMap)
93 {
94 m_triangleInfoMap = triangleInfoMap;
95 }
96
97 const btTriangleInfoMap* getTriangleInfoMap() const
98 {
99 return m_triangleInfoMap;
100 }
101
102 btTriangleInfoMap* getTriangleInfoMap()
103 {
104 return m_triangleInfoMap;
105 }
106
107 virtual int calculateSerializeBufferSize() const;
108
110 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
111
112 virtual void serializeSingleBvh(btSerializer * serializer) const;
113
114 virtual void serializeSingleTriangleInfoMap(btSerializer * serializer) const;
115};
116
117// clang-format off
118
120 struct btTriangleMeshShapeData
121{
122 btCollisionShapeData m_collisionShapeData;
123
124 btStridingMeshInterfaceData m_meshInterface;
125
126 btQuantizedBvhFloatData *m_quantizedFloatBvh;
127 btQuantizedBvhDoubleData *m_quantizedDoubleBvh;
128
129 btTriangleInfoMapData *m_triangleInfoMap;
130
131 float m_collisionMargin;
132
133 char m_pad3[4];
134
135};
136
137// clang-format on
138
139 SIMD_FORCE_INLINE int btBvhTriangleMeshShape::calculateSerializeBufferSize() const
140{
141 return sizeof(btTriangleMeshShapeData);
142}
143
144#endif //BT_BVH_TRIANGLE_MESH_SHAPE_H
btAlignedAllocator.h
btOptimizedBvh.h
ATTRIBUTE_ALIGNED16
#define ATTRIBUTE_ALIGNED16(a)
Definition btScalar.h:99
SIMD_FORCE_INLINE
#define SIMD_FORCE_INLINE
Definition btScalar.h:98
btTriangleInfoMap.h
btTriangleMeshShape.h
btBvhTriangleMeshShape::m_ownsBvh
bool m_ownsBvh
Definition btBvhTriangleMeshShape.h:41
btBvhTriangleMeshShape::getName
virtual const char * getName() const
Definition btBvhTriangleMeshShape.h:74
btBvhTriangleMeshShape::m_triangleInfoMap
btTriangleInfoMap * m_triangleInfoMap
Definition btBvhTriangleMeshShape.h:38
btBvhTriangleMeshShape::m_useQuantizedAabbCompression
bool m_useQuantizedAabbCompression
Definition btBvhTriangleMeshShape.h:40
btBvhTriangleMeshShape::getTriangleInfoMap
btTriangleInfoMap * getTriangleInfoMap()
Definition btBvhTriangleMeshShape.h:102
btBvhTriangleMeshShape::usesQuantizedAabbCompression
bool usesQuantizedAabbCompression() const
Definition btBvhTriangleMeshShape.h:87
btBvhTriangleMeshShape::getOwnsBvh
bool getOwnsBvh() const
Definition btBvhTriangleMeshShape.h:58
btBvhTriangleMeshShape::getOptimizedBvh
btOptimizedBvh * getOptimizedBvh()
Definition btBvhTriangleMeshShape.h:78
btBvhTriangleMeshShape::calculateSerializeBufferSize
virtual int calculateSerializeBufferSize() const
Definition btBvhTriangleMeshShape.h:139
btBvhTriangleMeshShape::getTriangleInfoMap
const btTriangleInfoMap * getTriangleInfoMap() const
Definition btBvhTriangleMeshShape.h:97
btBvhTriangleMeshShape::m_pad
bool m_pad[11]
Definition btBvhTriangleMeshShape.h:45
btBvhTriangleMeshShape::m_bvh
btOptimizedBvh * m_bvh
Definition btBvhTriangleMeshShape.h:37
btBvhTriangleMeshShape::BT_DECLARE_ALIGNED_ALLOCATOR
BT_DECLARE_ALIGNED_ALLOCATOR()
btBvhTriangleMeshShape::btBvhTriangleMeshShape
btBvhTriangleMeshShape(btStridingMeshInterface *meshInterface, bool useQuantizedAabbCompression, bool buildBvh=true)
Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization...
Definition btBvhTriangleMeshShape.cpp:24
btBvhTriangleMeshShape::setTriangleInfoMap
void setTriangleInfoMap(btTriangleInfoMap *triangleInfoMap)
Definition btBvhTriangleMeshShape.h:92
btOptimizedBvh
The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes,...
Definition btOptimizedBvh.h:28
btSerializer
Definition btSerializer.h:66
btStridingMeshInterface
The btStridingMeshInterface is the interface class for high performance generic access to triangle me...
Definition btStridingMeshInterface.h:28
btTriangleCallback
The btTriangleCallback provides a callback for each overlapping triangle when calling processAllTrian...
Definition btTriangleCallback.h:24
btTriangleMeshShape::btTriangleMeshShape
btTriangleMeshShape(btStridingMeshInterface *meshInterface)
btTriangleMeshShape constructor has been disabled/protected, so that users will not mistakenly use th...
Definition btTriangleMeshShape.cpp:23
btVector3
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:82
btCollisionShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition btCollisionShape.h:163
btQuantizedBvhDoubleData
Definition btQuantizedBvh.h:521
btQuantizedBvhFloatData
Definition btQuantizedBvh.h:504
btStridingMeshInterfaceData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition btStridingMeshInterface.h:139
btTriangleInfoMapData
Definition btTriangleInfoMap.h:93
btTriangleInfoMap
The btTriangleInfoMap stores edge angle information for some triangles. You can compute this informat...
Definition btTriangleInfoMap.h:54
btTriangleMeshShapeData
do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
Definition btBvhTriangleMeshShape.h:121
btTriangleMeshShapeData::m_meshInterface
btStridingMeshInterfaceData m_meshInterface
Definition btBvhTriangleMeshShape.h:124
btTriangleMeshShapeData::m_quantizedDoubleBvh
btQuantizedBvhDoubleData * m_quantizedDoubleBvh
Definition btBvhTriangleMeshShape.h:127
btTriangleMeshShapeData::m_pad3
char m_pad3[4]
Definition btBvhTriangleMeshShape.h:133
btTriangleMeshShapeData::m_quantizedFloatBvh
btQuantizedBvhFloatData * m_quantizedFloatBvh
Definition btBvhTriangleMeshShape.h:126
btTriangleMeshShapeData::m_collisionShapeData
btCollisionShapeData m_collisionShapeData
Definition btBvhTriangleMeshShape.h:122
btTriangleMeshShapeData::m_collisionMargin
float m_collisionMargin
Definition btBvhTriangleMeshShape.h:131
btTriangleMeshShapeData::m_triangleInfoMap
btTriangleInfoMapData * m_triangleInfoMap
Definition btBvhTriangleMeshShape.h:129