diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-11 15:52:20 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-11 15:52:20 +0400 |
commit | 10d14e72599e891ce253e37826ce6ed3c0aecd8d (patch) | |
tree | 3b07a2f0eeb44cae5e4120719237fcd8bf7e374d /source/blender/editors/object | |
parent | 8a1caaed32717f88218ea0c6222c749c14648ab3 (diff) |
2.5 - Restored Set/Clear Inverse Buttons for ChildOf Constraint
I've tagged these operators with CONSTRAINT_OT_* not OBJECT_OT_constraint_* since constraints can operate on Bones too (and do so more often)
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/editconstraint.c | 108 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 2 |
3 files changed, 50 insertions, 63 deletions
diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index ff2f79e7cdb..4c9a0bf4c67 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -117,63 +117,6 @@ bConstraint *get_active_constraint (Object *ob) return NULL; } - -/* single channel, for ipo */ -bConstraintChannel *get_active_constraint_channel (Scene *scene, Object *ob) -{ - bConstraint *con; - - if (ob->flag & OB_POSEMODE) { - //if (ob->action) { // XXX old animation system - bPoseChannel *pchan; - - pchan = get_active_posechannel(ob); - if (pchan) { - for (con= pchan->constraints.first; con; con= con->next) { - if (con->flag & CONSTRAINT_ACTIVE) - break; - } - - if (con) { -#if 0 // XXX old animation system - bActionChannel *achan = get_action_channel(ob->action, pchan->name); - if (achan) { - for (chan= achan->constraintChannels.first; chan; chan= chan->next) { - if (!strcmp(chan->name, con->name)) - break; - } - return chan; - } -#endif // XXX old animation system - } - } - //} // xxx old animation system - } - else { - for (con= ob->constraints.first; con; con= con->next) { - if (con->flag & CONSTRAINT_ACTIVE) - break; - } - - if (con) { -#if 0 // XXX old animation system - ListBase *lb= get_active_constraint_channels(scene, ob, 0); - - if (lb) { - for (chan= lb->first; chan; chan= chan->next) { - if (!strcmp(chan->name, con->name)) - break; - } - - return chan; - } -#endif // XXX old animation system - } - } - - return NULL; -} - /* -------------- Constraint Management (Add New, Remove, Rename) -------------------- */ /* ------------- PyConstraints ------------------ */ @@ -790,15 +733,17 @@ void object_test_constraints (Object *owner) /* ------------- Child-Of Constraint ------------------ */ /* ChildOf Constraint - set inverse callback */ -void childof_const_setinv (void *conv, void *scenev) +static int childof_set_inverse_exec (bContext *C, wmOperator *op) { - bConstraint *con= (bConstraint *)conv; - Scene *scene= (Scene *)scenev; + PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_ChildOfConstraint); + Scene *scene= CTX_data_scene(C); + Object *ob= ptr.id.data; + bConstraint *con= ptr.data; bChildOfConstraint *data= (bChildOfConstraint *)con->data; - Object *ob= OBACT; bPoseChannel *pchan= NULL; /* try to find a pose channel */ + // TODO: get from context instead? if (ob && ob->pose) pchan= get_active_posechannel(ob); @@ -839,16 +784,53 @@ void childof_const_setinv (void *conv, void *scenev) } else Mat4One(data->invmat); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + + return OPERATOR_FINISHED; } +void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Set Inverse"; + ot->idname= "CONSTRAINT_OT_childof_set_inverse"; + ot->description= "Set inverse correction for ChildOf constraint."; + + ot->exec= childof_set_inverse_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + + /* ChildOf Constraint - clear inverse callback */ -void childof_const_clearinv (void *conv, void *unused) +static int childof_clear_inverse_exec (bContext *C, wmOperator *op) { - bConstraint *con= (bConstraint *)conv; + PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_ChildOfConstraint); + Object *ob= ptr.id.data; + bConstraint *con= ptr.data; bChildOfConstraint *data= (bChildOfConstraint *)con->data; /* simply clear the matrix */ Mat4One(data->invmat); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + + return OPERATOR_FINISHED; +} + +void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Clear Inverse"; + ot->idname= "CONSTRAINT_OT_childof_clear_inverse"; + ot->description= "Clear inverse correction for ChildOf constraint."; + + ot->exec= childof_clear_inverse_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } /***************************** BUTTONS ****************************/ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 748e8f7b396..0ad5bd7d08e 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -102,6 +102,9 @@ void OBJECT_OT_modifier_mdef_bind(struct wmOperatorType *ot); /* editconstraint.c */ void OBJECT_OT_constraint_add(struct wmOperatorType *ot); +void CONSTRAINT_OT_childof_set_inverse(struct wmOperatorType *ot); +void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot); + /* object_vgroup.c */ void OBJECT_OT_vertex_group_add(struct wmOperatorType *ot); void OBJECT_OT_vertex_group_remove(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 258fc3386cf..66dd1b8fbb9 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -111,6 +111,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_modifier_mdef_bind); WM_operatortype_append(OBJECT_OT_constraint_add); + WM_operatortype_append(CONSTRAINT_OT_childof_set_inverse); + WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse); WM_operatortype_append(OBJECT_OT_vertex_group_add); WM_operatortype_append(OBJECT_OT_vertex_group_remove); |