diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-12-26 21:15:56 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-12-26 21:38:06 +0400 |
commit | ceb2430dd7b54c31d267eb2be8d412e6d7f1b13a (patch) | |
tree | ac959a55f993ab404a2d33327b7856a6206297bc /source/blender | |
parent | c96601138dfe08705fd4375527d322176b8fa126 (diff) |
Rigidbody: Allow triangle mesh shapes to deform during simulation
Only supported when using the "Deform" mesh source.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/rigidbody.c | 11 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_rigidbody_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rigidbody.c | 5 |
3 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index 22126b7e45d..868fa41b5c7 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1030,6 +1030,17 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o 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 */ diff --git a/source/blender/makesdna/DNA_rigidbody_types.h b/source/blender/makesdna/DNA_rigidbody_types.h index de23a3c2370..5d76ffe57b5 100644 --- a/source/blender/makesdna/DNA_rigidbody_types.h +++ b/source/blender/makesdna/DNA_rigidbody_types.h @@ -149,7 +149,9 @@ typedef enum eRigidBodyOb_Flag { /* rigidbody is not dynamically simulated */ RBO_FLAG_DISABLED = (1 << 5), /* collision margin is not embedded (only used by convex hull shapes for now) */ - RBO_FLAG_USE_MARGIN = (1 << 6) + RBO_FLAG_USE_MARGIN = (1 << 6), + /* collision shape deforms during simulation (only for passive triangle mesh shapes) */ + RBO_FLAG_USE_DEFORM = (1 << 7) } eRigidBodyOb_Flag; /* RigidBody Collision Shape */ diff --git a/source/blender/makesrna/intern/rna_rigidbody.c b/source/blender/makesrna/intern/rna_rigidbody.c index 34b0f6a335a..58fc9ab25d4 100644 --- a/source/blender/makesrna/intern/rna_rigidbody.c +++ b/source/blender/makesrna/intern/rna_rigidbody.c @@ -804,6 +804,11 @@ static void rna_def_rigidbody_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Kinematic", "Allow rigid body to be controlled by the animation system"); RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset"); + prop = RNA_def_property(srna, "use_deform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEFORM); + RNA_def_property_ui_text(prop, "Deforming", "Rigid body deforms during simulation"); + RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset"); + /* Physics Parameters */ prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS); RNA_def_property_float_sdna(prop, NULL, "mass"); |