btBvhTriangleMeshShape.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef BVH_TRIANGLE_MESH_SHAPE_H
00017 #define BVH_TRIANGLE_MESH_SHAPE_H
00018 
00019 #include "btTriangleMeshShape.h"
00020 #include "btOptimizedBvh.h"
00021 #include "LinearMath/btAlignedAllocator.h"
00022 
00023 
00028 class btBvhTriangleMeshShape : public btTriangleMeshShape
00029 {
00030 
00031         btOptimizedBvh* m_bvh;
00032         bool m_useQuantizedAabbCompression;
00033         bool m_ownsBvh;
00034         bool m_pad[11];
00035 
00036 public:
00037 
00038         BT_DECLARE_ALIGNED_ALLOCATOR();
00039 
00040         btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
00041         btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
00042 
00044         btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true);
00045         
00046         virtual ~btBvhTriangleMeshShape();
00047 
00048         bool getOwnsBvh () const
00049         {
00050                 return m_ownsBvh;
00051         }
00052 
00053 
00054         
00055         void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget);
00056         void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
00057 
00058         virtual void    processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
00059 
00060         void    refitTree(const btVector3& aabbMin,const btVector3& aabbMax);
00061 
00063         void    partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax);
00064 
00065         //debugging
00066         virtual const char*     getName()const {return "BVHTRIANGLEMESH";}
00067 
00068 
00069         virtual void    setLocalScaling(const btVector3& scaling);
00070         
00071         btOptimizedBvh* getOptimizedBvh()
00072         {
00073                 return m_bvh;
00074         }
00075 
00076 
00077         void    setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
00078 
00079         void    buildOptimizedBvh();
00080 
00081         bool    usesQuantizedAabbCompression() const
00082         {
00083                 return  m_useQuantizedAabbCompression;
00084         }
00085 
00086         //virtual       int     calculateSerializeBufferSize();
00087 
00089         //virtual       const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
00090 
00091 
00092 };
00093 
00094 #if 0
00095 struct  btBvhTriangleMeshShapeData
00096 {
00097 
00098         btTriangleMeshShapeData m_trimeshData;
00099         
00100         //btOptimizedBvhData    m_bvh;
00101 
00102         char    m_useQuantizedAabbCompression;
00103         char    m_ownsBvh;
00104         
00105 };
00106 
00107 SIMD_FORCE_INLINE       int     btBvhTriangleMeshShape::calculateSerializeBufferSize()
00108 {
00109         return sizeof(btBvhTriangleMeshShapeData);
00110 }
00111 
00112 #endif 
00113 
00114 #endif //BVH_TRIANGLE_MESH_SHAPE_H

Generated on Mon Feb 15 22:17:02 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1