Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-04-09 05:36:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-04-09 05:36:44 +0400
commit9e5a670b1d2285826bf33a177b32eb5862c771db (patch)
tree2a463556e2f8823e7e3561c36064df5c2600c84f /source/blender/editors/physics/rigidbody_constraint.c
parent9eca407a18d8c0109d67fa4feed837dfe97d2de1 (diff)
code cleanup: abbreviations ob, con - aren't normally used in global identifiers.
Diffstat (limited to 'source/blender/editors/physics/rigidbody_constraint.c')
-rw-r--r--source/blender/editors/physics/rigidbody_constraint.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c
index d38ffa491e2..698d530c22d 100644
--- a/source/blender/editors/physics/rigidbody_constraint.c
+++ b/source/blender/editors/physics/rigidbody_constraint.c
@@ -77,14 +77,14 @@ static int ED_operator_rigidbody_con_active_poll(bContext *C)
}
-void ED_rigidbody_con_add(wmOperator *op, Scene *scene, Object *ob, int type)
+bool ED_rigidbody_constraint_add(Scene *scene, Object *ob, int type, ReportList *reports)
{
RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
/* check that object doesn't already have a constraint */
if (ob->rigidbody_constraint) {
- BKE_reportf(op->reports, RPT_INFO, "Object '%s' already has a Rigid Body Constraint", ob->id.name + 2);
- return;
+ BKE_reportf(reports, RPT_INFO, "Object '%s' already has a Rigid Body Constraint", ob->id.name + 2);
+ return false;
}
/* create constraint group if it doesn't already exits */
if (rbw->constraints == NULL) {
@@ -98,9 +98,10 @@ void ED_rigidbody_con_add(wmOperator *op, Scene *scene, Object *ob, int type)
BKE_group_object_add(rbw->constraints, ob, scene, NULL);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
+ return true;
}
-void ED_rigidbody_con_remove(Scene *scene, Object *ob)
+void ED_rigidbody_constraint_remove(Scene *scene, Object *ob)
{
RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
@@ -122,6 +123,7 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op)
RigidBodyWorld *rbw = BKE_rigidbody_get_world(scene);
Object *ob = (scene) ? OBACT : NULL;
int type = RNA_enum_get(op->ptr, "type");
+ bool change;
/* sanity checks */
if (ELEM(NULL, scene, rbw)) {
@@ -129,13 +131,18 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
/* apply to active object */
- ED_rigidbody_con_add(op, scene, ob, type);
+ change = ED_rigidbody_constraint_add(scene, ob, type, op->reports);
- /* send updates */
- WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
+ if (change) {
+ /* send updates */
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
- /* done */
- return OPERATOR_FINISHED;
+ /* done */
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
+ }
}
void RIGIDBODY_OT_constraint_add(wmOperatorType *ot)
@@ -153,7 +160,7 @@ void RIGIDBODY_OT_constraint_add(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
- ot->prop = RNA_def_enum(ot->srna, "type", rigidbody_con_type_items, RBC_TYPE_FIXED, "Rigid Body Constraint Type", "");
+ ot->prop = RNA_def_enum(ot->srna, "type", rigidbody_constraint_type_items, RBC_TYPE_FIXED, "Rigid Body Constraint Type", "");
}
/* ************ Remove Rigid Body Constraint ************** */
@@ -173,7 +180,7 @@ static int rigidbody_con_remove_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
else {
- ED_rigidbody_con_remove(scene, ob);
+ ED_rigidbody_constraint_remove(scene, ob);
}
/* send updates */