[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54496] trunk/blender/source/blender/ editors/physics/rigidbody_object.c: rigidbody: Don' t cancel add operator if rigid body already exists

Sergej Reich sergej.reich at googlemail.com
Tue Feb 12 15:45:57 CET 2013


Revision: 54496
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54496
Author:   sergof
Date:     2013-02-12 14:45:57 +0000 (Tue, 12 Feb 2013)
Log Message:
-----------
rigidbody: Don't cancel add operator if rigid body already exists

In some cases objects might have rigid bodies but aren't in the rigid
body group, just add objects to the group then.

Also allow changing the rigid body type by using the add acive/passive
buttons. This avoids having to remove objects just to change type.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/physics/rigidbody_object.c

Modified: trunk/blender/source/blender/editors/physics/rigidbody_object.c
===================================================================
--- trunk/blender/source/blender/editors/physics/rigidbody_object.c	2013-02-12 14:45:55 UTC (rev 54495)
+++ trunk/blender/source/blender/editors/physics/rigidbody_object.c	2013-02-12 14:45:57 UTC (rev 54496)
@@ -93,11 +93,6 @@
 {
 	RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
 
-	/* check that object doesn't already belong to the current simulation */
-	if (ob->rigidbody_object) {
-		BKE_reportf(op->reports, RPT_INFO, "Object '%s' already has a Rigid Body", ob->id.name + 2);
-		return;
-	}
 	if (ob->type != OB_MESH) {
 		BKE_report(op->reports, RPT_ERROR, "Can't add Rigid Body to non mesh object");
 		return;
@@ -118,11 +113,16 @@
 	}
 
 	/* make rigidbody object settings */
-	ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type);
+	if (ob->rigidbody_object == NULL) {
+		ob->rigidbody_object = BKE_rigidbody_create_object(scene, ob, type);
+	}
+	ob->rigidbody_object->type = type;
 	ob->rigidbody_object->flag |= RBO_FLAG_NEEDS_VALIDATE;
 
 	/* add object to rigid body group */
 	add_to_group(rbw->group, ob, scene, NULL);
+
+	DAG_id_tag_update(&ob->id, OB_RECALC_OB);
 }
 
 void ED_rigidbody_ob_remove(Scene *scene, Object *ob)




More information about the Bf-blender-cvs mailing list