diff options
Diffstat (limited to 'intern/rigidbody')
-rw-r--r-- | intern/rigidbody/RBI_api.h | 2 | ||||
-rw-r--r-- | intern/rigidbody/rb_bullet_api.cpp | 23 |
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; |