[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59898] branches/soc-2013-rigid_body_sim/ intern/rigidbody/rb_bullet_api.cpp: rigidbody: Add internal edge info for triangle mesh shapes
Sergej Reich
sergej.reich at googlemail.com
Fri Sep 6 19:59:04 CEST 2013
Revision: 59898
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59898
Author: sergof
Date: 2013-09-06 17:59:04 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
rigidbody: Add internal edge info for triangle mesh shapes
This is necessary so that triangle edges don't create erroneous
collisions.
TODO: Fix issues when using compound shapes
Modified Paths:
--------------
branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp
Modified: branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp
===================================================================
--- branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp 2013-09-06 17:59:03 UTC (rev 59897)
+++ branches/soc-2013-rigid_body_sim/intern/rigidbody/rb_bullet_api.cpp 2013-09-06 17:59:04 UTC (rev 59898)
@@ -75,6 +75,8 @@
#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
+#include <BulletCollision/CollisionDispatch/btInternalEdgeUtility.h>
+
#include "hacdHACD.h"
struct rbDynamicsWorld {
@@ -106,6 +108,7 @@
btCollisionShape *cshape;
btCollisionShape *compound;
btTriangleMesh *mesh;
+ btTriangleInfoMap *triangle_info_map;
};
struct rbFilterCallback : public btOverlapFilterCallback
@@ -141,6 +144,12 @@
dispatcher.defaultNearCallback(collisionPair, dispatcher, dispatchInfo);
}
+static bool contactAddedCallback(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1)
+{
+ btAdjustInternalEdgeContacts(cp, colObj1Wrap, colObj0Wrap, partId1, index1);
+ return true;
+}
+
class rbDebugDraw : public btIDebugDraw {
private:
int debug_mode;
@@ -230,6 +239,8 @@
RB_dworld_set_gravity(world, gravity);
+ gContactAddedCallback = contactAddedCallback;
+
// HACK set debug drawer, this is only temporary
btIDebugDraw *debugDrawer = new rbDebugDraw();
debugDrawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe |
@@ -416,6 +427,9 @@
object->is_trigger = false;
object->suspended = false;
+ if (shape->cshape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
+ object->body->setCollisionFlags(object->body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
+
return object;
}
@@ -782,6 +796,7 @@
rbCollisionShape *shape = new rbCollisionShape;
shape->cshape = cshape;
shape->mesh = NULL;
+ shape->triangle_info_map = NULL;
btTransform world_transform = btTransform();
world_transform.setIdentity();
@@ -843,6 +858,7 @@
shape->cshape = hull_shape;
shape->mesh = NULL;
+ shape->triangle_info_map = NULL;
shape->compound = new btCompoundShape();
btTransform compound_transform;
@@ -894,6 +910,9 @@
// RB_TODO perhaps we need to allow saving out this for performance when rebuilding?
btBvhTriangleMeshShape *unscaledShape = new btBvhTriangleMeshShape(tmesh, true, true);
+ shape->triangle_info_map = new btTriangleInfoMap();
+ btGenerateInternalEdgeInfo(unscaledShape, shape->triangle_info_map);
+
shape->cshape = new btScaledBvhTriangleMeshShape(unscaledShape, btVector3(1.0f, 1.0f, 1.0f));
shape->mesh = tmesh;
@@ -916,6 +935,7 @@
shape->cshape = gimpactShape;
shape->mesh = tmesh;
+ shape->triangle_info_map = NULL;
shape->compound = new btCompoundShape();
btTransform compound_transform;
@@ -984,6 +1004,7 @@
}
shape->mesh = NULL;
+ shape->triangle_info_map = NULL;
shape->compound = compound;
shape->cshape = compound;
@@ -1014,6 +1035,8 @@
}
if (shape->mesh)
delete shape->mesh;
+ if (shape->triangle_info_map)
+ delete shape->triangle_info_map;
if (shape->cshape != shape->compound)
delete shape->cshape;
delete shape->compound;
More information about the Bf-blender-cvs
mailing list