Rigidbody: Allow triangle mesh shapes to deform during simulation
[blender.git] / source / blender / blenkernel / intern / rigidbody.c
index 22126b7e45d9c5c0094f3e71508c84a7fb4bc125..868fa41b5c739ec188166a46c47fbed21e55288b 100644 (file)
@@ -1030,6 +1030,17 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o
        if (rbo->physics_object == NULL)
                return;
 
        if (rbo->physics_object == NULL)
                return;
 
+       if (rbo->shape == RB_SHAPE_TRIMESH && rbo->flag & RBO_FLAG_USE_DEFORM) {
+               DerivedMesh *dm = ob->derivedDeform;
+               if (dm) {
+                       MVert *mvert = dm->getVertArray(dm);
+                       int totvert = dm->getNumVerts(dm);
+                       BoundBox *bb = BKE_object_boundbox_get(ob);
+
+                       RB_shape_trimesh_update(rbo->physics_shape, (float*)mvert, totvert, sizeof(MVert), bb->vec[0], bb->vec[6]);
+               }
+       }
+
        mat4_decompose(loc, rot, scale, ob->obmat);
 
        /* update scale for all objects */
        mat4_decompose(loc, rot, scale, ob->obmat);
 
        /* update scale for all objects */