diff options
Diffstat (limited to 'intern/rigidbody/rb_bullet_api.cpp')
-rw-r--r-- | intern/rigidbody/rb_bullet_api.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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; |