Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h @ 5733

Last change on this file since 5733 was 2662, checked in by rgrieder, 16 years ago

Merged presentation branch back to trunk.

  • Property svn:eol-style set to native
File size: 3.7 KB
RevLine 
[1963]1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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 BVH_TRIANGLE_MESH_SHAPE_H
17#define BVH_TRIANGLE_MESH_SHAPE_H
18
19#include "btTriangleMeshShape.h"
20#include "btOptimizedBvh.h"
21#include "LinearMath/btAlignedAllocator.h"
22
23
24///The btBvhTriangleMeshShape is a static-triangle mesh shape with several optimizations, such as bounding volume hierarchy and cache friendly traversal for PlayStation 3 Cell SPU. It is recommended to enable useQuantizedAabbCompression for better memory usage.
25///It takes a triangle mesh as input, for example a btTriangleMesh or btTriangleIndexVertexArray. The btBvhTriangleMeshShape class allows for triangle mesh deformations by a refit or partialRefit method.
26///Instead of building the bounding volume hierarchy acceleration structure, it is also possible to serialize (save) and deserialize (load) the structure from disk.
27///See Demos\ConcaveDemo\ConcavePhysicsDemo.cpp for an example.
28ATTRIBUTE_ALIGNED16(class) btBvhTriangleMeshShape : public btTriangleMeshShape
29{
30
31        btOptimizedBvh* m_bvh;
32        bool m_useQuantizedAabbCompression;
33        bool m_ownsBvh;
34        bool m_pad[11];////need padding due to alignment
35
36public:
37
38        BT_DECLARE_ALIGNED_ALLOCATOR();
39
40        btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
41        btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
42
43        ///optionally pass in a larger bvh aabb, used for quantization. This allows for deformations within this aabb
44        btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression,const btVector3& bvhAabbMin,const btVector3& bvhAabbMax, bool buildBvh = true);
45       
46        virtual ~btBvhTriangleMeshShape();
47
48        bool getOwnsBvh () const
49        {
50                return m_ownsBvh;
51        }
52
53
54       
55        void performRaycast (btTriangleCallback* callback, const btVector3& raySource, const btVector3& rayTarget);
56        void performConvexcast (btTriangleCallback* callback, const btVector3& boxSource, const btVector3& boxTarget, const btVector3& boxMin, const btVector3& boxMax);
57
58        virtual void    processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
59
60        void    refitTree(const btVector3& aabbMin,const btVector3& aabbMax);
61
62        ///for a fast incremental refit of parts of the tree. Note: the entire AABB of the tree will become more conservative, it never shrinks
63        void    partialRefitTree(const btVector3& aabbMin,const btVector3& aabbMax);
64
65        //debugging
66        virtual const char*     getName()const {return "BVHTRIANGLEMESH";}
67
68
69        virtual void    setLocalScaling(const btVector3& scaling);
70       
71        btOptimizedBvh* getOptimizedBvh()
72        {
73                return m_bvh;
74        }
75
76
77        void    setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
78
79        bool    usesQuantizedAabbCompression() const
80        {
81                return  m_useQuantizedAabbCompression;
82        }
83}
84;
85
86#endif //BVH_TRIANGLE_MESH_SHAPE_H
Note: See TracBrowser for help on using the repository browser.