Bullet Collision Detection & Physics Library
btBvhTriangleMeshShape.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
4 
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose,
8 including commercial applications, and to alter it and redistribute it freely,
9 subject to the following restrictions:
10 
11 1. 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.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. 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"
22 #include "btTriangleInfoMap.h"
23 
29 {
30 
33 
35  bool m_ownsBvh;
36  bool m_pad[11];
37 
38 public:
39 
41 
42 
43  btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
44 
46  btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true);
47 
48  virtual ~btBvhTriangleMeshShape();
49 
50  bool getOwnsBvh () const
51  {
52  return m_ownsBvh;
53  }
54 
55 
56 
57  void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget);
58  void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
59 
60  virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
61 
62  void refitTree(const btVector3& aabbMin,const btVector3& aabbMax);
63 
65  void partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax);
66 
67  //debugging
68  virtual const char* getName()const {return "BVHTRIANGLEMESH";}
69 
70 
71  virtual void setLocalScaling(const btVector3& scaling);
72 
74  {
75  return m_bvh;
76  }
77 
78  void setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
79 
80  void buildOptimizedBvh();
81 
83  {
84  return m_useQuantizedAabbCompression;
85  }
86 
87  void setTriangleInfoMap(btTriangleInfoMap* triangleInfoMap)
88  {
89  m_triangleInfoMap = triangleInfoMap;
90  }
91 
93  {
94  return m_triangleInfoMap;
95  }
96 
98  {
99  return m_triangleInfoMap;
100  }
101 
102  virtual int calculateSerializeBufferSize() const;
103 
105  virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
106 
107  virtual void serializeSingleBvh(btSerializer* serializer) const;
108 
109  virtual void serializeSingleTriangleInfoMap(btSerializer* serializer) const;
110 
111 };
112 
115 {
117 
119 
122 
124 
126 
127  char m_pad3[4];
128 
129 };
130 
131 
133 {
134  return sizeof(btTriangleMeshShapeData);
135 }
136 
137 
138 
139 #endif //BT_BVH_TRIANGLE_MESH_SHAPE_H