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:
authorSergej Reich <sergej.reich@googlemail.com>2013-12-26 21:15:56 +0400
committerSergej Reich <sergej.reich@googlemail.com>2013-12-26 21:38:06 +0400
commitceb2430dd7b54c31d267eb2be8d412e6d7f1b13a (patch)
treeac959a55f993ab404a2d33327b7856a6206297bc /intern/rigidbody
parentc96601138dfe08705fd4375527d322176b8fa126 (diff)
Rigidbody: Allow triangle mesh shapes to deform during simulation
Only supported when using the "Deform" mesh source.
Diffstat (limited to 'intern/rigidbody')
-rw-r--r--intern/rigidbody/RBI_api.h2
-rw-r--r--intern/rigidbody/rb_bullet_api.cpp23
2 files changed, 25 insertions, 0 deletions
diff --git a/intern/rigidbody/RBI_api.h b/intern/rigidbody/RBI_api.h
index 97e8e6891ff..2e7a996781b 100644
--- a/intern/rigidbody/RBI_api.h
+++ b/intern/rigidbody/RBI_api.h
@@ -247,6 +247,8 @@ extern void RB_shape_delete(rbCollisionShape *shape);
extern float RB_shape_get_margin(rbCollisionShape *shape);
extern void RB_shape_set_margin(rbCollisionShape *shape, float value);
+extern void RB_shape_trimesh_update(rbCollisionShape *shape, float *vertices, int num_verts, int vert_stride, float min[3], float max[3]);
+
/* ********************************** */
/* Constraints */
diff --git a/intern/rigidbody/rb_bullet_api.cpp b/intern/rigidbody/rb_bullet_api.cpp
index 31f7f386663..ef35d3b257b 100644
--- a/intern/rigidbody/rb_bullet_api.cpp
+++ b/intern/rigidbody/rb_bullet_api.cpp
@@ -763,6 +763,29 @@ rbCollisionShape *RB_shape_new_trimesh(rbMeshData *mesh)
return shape;
}
+void RB_shape_trimesh_update(rbCollisionShape *shape, float *vertices, int num_verts, int vert_stride, float min[3], float max[3])
+{
+ if (shape->mesh == NULL || num_verts != shape->mesh->num_vertices)
+ return;
+
+ for (int i = 0; i < num_verts; i++) {
+ float *vert = (float*)(((char*)vertices + i * vert_stride));
+ shape->mesh->vertices[i].x = vert[0];
+ shape->mesh->vertices[i].y = vert[1];
+ shape->mesh->vertices[i].z = vert[2];
+ }
+
+ if (shape->cshape->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE) {
+ btScaledBvhTriangleMeshShape *scaled_shape = (btScaledBvhTriangleMeshShape *)shape->cshape;
+ btBvhTriangleMeshShape *mesh_shape = scaled_shape->getChildShape();
+ mesh_shape->refitTree(btVector3(min[0], min[1], min[2]), btVector3(max[0], max[1], max[2]));
+ }
+ else if (shape->cshape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE) {
+ btGImpactMeshShape *mesh_shape = (btGImpactMeshShape*)shape->cshape;
+ mesh_shape->updateBound();
+ }
+}
+
rbCollisionShape *RB_shape_new_gimpact_mesh(rbMeshData *mesh)
{
rbCollisionShape *shape = new rbCollisionShape;