rigidbody: Flag bodies for validation when changing shape
authorSergej Reich <sergej.reich@googlemail.com>
Thu, 3 Oct 2013 16:12:02 +0000 (16:12 +0000)
committerSergej Reich <sergej.reich@googlemail.com>
Thu, 3 Oct 2013 16:12:02 +0000 (16:12 +0000)
This fixes a pretty old crash that occurs when changing the collision
shape to a mesh shape during simulation.

Thanks to Thomas Beck (plasmasolutions) for the report.

svn merge -r60310:60311 ^/branches/soc-2013-rigid_body_sim

source/blender/makesrna/intern/rna_rigidbody.c

index cb27261c7bff7b5f12db0c272d0386e89c53009e..cc14e60f45a900618819fa5234afbf019734b7fa 100644 (file)
@@ -167,6 +167,14 @@ static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value)
        rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
 }
 
+static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value)
+{
+       RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
+
+       rbo->shape = value;
+       rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
+}
+
 static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value)
 {
        RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
@@ -771,6 +779,7 @@ static void rna_def_rigidbody_object(BlenderRNA *brna)
        prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "shape");
        RNA_def_property_enum_items(prop, rigidbody_object_shape_items);
+       RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyOb_shape_set", NULL);
        RNA_def_property_ui_text(prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations");
        RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
        RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");