Back to index

supertuxkart  0.5+dfsg1
btBvhTriangleMeshShape.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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 
00026 ATTRIBUTE_ALIGNED16(class) btBvhTriangleMeshShape : public btTriangleMeshShape
00027 {
00028 
00029        btOptimizedBvh*      m_bvh;
00030        bool m_useQuantizedAabbCompression;
00031        bool m_ownsBvh;
00032        bool m_pad[11];
00033 
00034 public:
00035 
00036        BT_DECLARE_ALIGNED_ALLOCATOR();
00037 
00038        btBvhTriangleMeshShape() :btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {};
00039        btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
00040 
00042        btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true);
00043        
00044        virtual ~btBvhTriangleMeshShape();
00045 
00046        virtual int   getShapeType() const
00047        {
00048               return TRIANGLE_MESH_SHAPE_PROXYTYPE;
00049        }
00050        
00051        void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget);
00052        void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
00053 
00054        virtual void  processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
00055 
00056        void   refitTree(const btVector3& aabbMin,const btVector3& aabbMax);
00057 
00059        void   partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax);
00060 
00061        //debugging
00062        virtual const char*  getName()const {return "BVHTRIANGLEMESH";}
00063 
00064 
00065        virtual void  setLocalScaling(const btVector3& scaling);
00066        
00067        btOptimizedBvh*      getOptimizedBvh()
00068        {
00069               return m_bvh;
00070        }
00071 
00072 
00073        void   setOptimizedBvh(btOptimizedBvh* bvh)
00074        {
00075               btAssert(!m_bvh);
00076               btAssert(!m_ownsBvh);
00077 
00078               m_bvh = bvh;
00079               m_ownsBvh = false;
00080        }
00081 
00082        bool   usesQuantizedAabbCompression() const
00083        {
00084               return m_useQuantizedAabbCompression;
00085        }
00086 }
00087 ;
00088 
00089 #endif //BVH_TRIANGLE_MESH_SHAPE_H