Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2012-12-15 05:01:35 +0400
committerErwin Coumans <blender@erwincoumans.com>2012-12-15 05:01:35 +0400
commit1b37f8dca85578ad2bf5f8202568d00b91d194b8 (patch)
treefd8074f3749a166256a7a75688d07f0fbe272e52 /extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h
parent96f6a5cf207c31afefa9faf63bdc76a072cb078c (diff)
Hi there, it has been a while, just curious if my SVN account still works :)
This commit is an attempt to improve collisions between moving Bullet rigid bodies using (concave) triangle mesh bounds. Instead of using Gimpact, this we create a btCompoundShape with child shape tetrahedra derived from the surface triangles. For each triangle, we add a fourth vertex using the centroid, shifting inwards using the triangle normal. If the centroid hits an internal triangle, we stop. The default depth could be exposed as 'advanced' setting in the user interface. This solution will be a slower than the original/gimpact solution, but a bit more reliable. In the future, it is better to add HACD, convex decomposition to Blender, for moving concave meshes. See http://kmamou.blogspot.com and the Bullet SDK's Demos/ConvexDecompositionDemo.
Diffstat (limited to 'extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h')
-rw-r--r--extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h27
1 files changed, 20 insertions, 7 deletions
diff --git a/extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h b/extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h
index 90015bb9ac0..3d1f48d4776 100644
--- a/extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h
+++ b/extern/bullet2/src/BulletCollision/Gimpact/btGImpactShape.h
@@ -51,6 +51,7 @@ enum eGIMPACT_SHAPE_TYPE
};
+
//! Helper class for tetrahedrons
class btTetrahedronShapeEx:public btBU_Simplex1to4
{
@@ -192,7 +193,7 @@ public:
virtual eGIMPACT_SHAPE_TYPE getGImpactShapeType() const = 0 ;
//! gets boxset
- SIMD_FORCE_INLINE btGImpactBoxSet * getBoxSet()
+ SIMD_FORCE_INLINE const btGImpactBoxSet * getBoxSet() const
{
return &m_box_set;
}
@@ -288,6 +289,15 @@ public:
(void) callback; (void) aabbMin; (void) aabbMax;
}
+ //! Function for retrieve triangles.
+ /*!
+ It gives the triangles in local space
+ */
+ virtual void processAllTrianglesRay(btTriangleCallback* /*callback*/,const btVector3& /*rayFrom*/, const btVector3& /*rayTo*/) const
+ {
+
+ }
+
//!@}
};
@@ -635,25 +645,25 @@ public:
return (int )numverts;
}
- SIMD_FORCE_INLINE void get_indices(int face_index,int &i0,int &i1,int &i2) const
+ SIMD_FORCE_INLINE void get_indices(int face_index,unsigned int &i0,unsigned int &i1,unsigned int &i2) const
{
if(indicestype == PHY_SHORT)
{
- short * s_indices = (short *)(indexbase + face_index*indexstride);
+ unsigned short* s_indices = (unsigned short *)(indexbase + face_index * indexstride);
i0 = s_indices[0];
i1 = s_indices[1];
i2 = s_indices[2];
}
else
{
- int * i_indices = (int *)(indexbase + face_index*indexstride);
+ unsigned int * i_indices = (unsigned int *)(indexbase + face_index*indexstride);
i0 = i_indices[0];
i1 = i_indices[1];
i2 = i_indices[2];
}
}
- SIMD_FORCE_INLINE void get_vertex(int vertex_index, btVector3 & vertex) const
+ SIMD_FORCE_INLINE void get_vertex(unsigned int vertex_index, btVector3 & vertex) const
{
if(type == PHY_DOUBLE)
{
@@ -682,7 +692,7 @@ public:
virtual void get_primitive_triangle(int prim_index,btPrimitiveTriangle & triangle) const
{
- int indices[3];
+ unsigned int indices[3];
get_indices(prim_index,indices[0],indices[1],indices[2]);
get_vertex(indices[0],triangle.m_vertices[0]);
get_vertex(indices[1],triangle.m_vertices[1]);
@@ -692,7 +702,7 @@ public:
SIMD_FORCE_INLINE void get_bullet_triangle(int prim_index,btTriangleShapeEx & triangle) const
{
- int indices[3];
+ unsigned int indices[3];
get_indices(prim_index,indices[0],indices[1],indices[2]);
get_vertex(indices[0],triangle.m_vertices1[0]);
get_vertex(indices[1],triangle.m_vertices1[1]);
@@ -885,6 +895,7 @@ public:
}
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+ virtual void processAllTrianglesRay(btTriangleCallback* callback,const btVector3& rayFrom,const btVector3& rayTo) const;
};
@@ -1141,6 +1152,8 @@ public:
*/
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
+ virtual void processAllTrianglesRay (btTriangleCallback* callback,const btVector3& rayFrom,const btVector3& rayTo) const;
+
virtual int calculateSerializeBufferSize() const;
///fills the dataBuffer and returns the struct name (and 0 on failure)