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.
This commit is contained in:
Sergej Reich
2013-02-12 14:45:57 +00:00
parent ca0e18f88b
commit 92b6a54e50

View File

@@ -93,11 +93,6 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type)
{
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 @@ void ED_rigidbody_ob_add(wmOperator *op, Scene *scene, Object *ob, int type)
}
/* 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)