diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-07-26 15:57:27 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-07-26 15:57:27 +0400 |
commit | 4e024a1e6e41640d2f70624bb15778dc6a6c6695 (patch) | |
tree | 19c0d3a42dd78d9a6c38cb54e4f3ac0adc8be8d2 /source/blender | |
parent | 812530aca81385af5a34fab851b4031521a1abe0 (diff) |
2.5 - 'Reset' buttons for Limit Distance and Stretch To Constraints
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/object/editconstraint.c | 52 | ||||
-rw-r--r-- | source/blender/editors/object/object_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 2 |
3 files changed, 56 insertions, 0 deletions
diff --git a/source/blender/editors/object/editconstraint.c b/source/blender/editors/object/editconstraint.c index 437beda324b..9e8205e58ab 100644 --- a/source/blender/editors/object/editconstraint.c +++ b/source/blender/editors/object/editconstraint.c @@ -462,6 +462,58 @@ void object_test_constraints (Object *owner) /* ********************** CONSTRAINT-SPECIFIC STUFF ********************* */ +/* ---------- Distance-Dependent Constraints ---------- */ +/* StretchTo, Limit Distance */ + +static int stretchto_reset_exec (bContext *C, wmOperator *op) +{ + PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_StretchToConstraint); + + /* just set original length to 0.0, which will cause a reset on next recalc */ + RNA_float_set(&ptr, "original_length", 0.0f); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + return OPERATOR_FINISHED; +} + +void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Reset Original Length"; + ot->idname= "CONSTRAINT_OT_stretchto_reset"; + ot->description= "Reset original length of bone for Stretch To Constraint."; + + ot->exec= stretchto_reset_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + + +static int limitdistance_reset_exec (bContext *C, wmOperator *op) +{ + PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_LimitDistanceConstraint); + + /* just set distance to 0.0, which will cause a reset on next recalc */ + RNA_float_set(&ptr, "distance", 0.0f); + + WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL); + return OPERATOR_FINISHED; +} + +void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Reset Distance"; + ot->idname= "CONSTRAINT_OT_limitdistance_reset"; + ot->description= "Reset limiting distance for Limit Distance Constraint."; + + ot->exec= limitdistance_reset_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /* ------------- Child-Of Constraint ------------------ */ /* ChildOf Constraint - set inverse callback */ diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index da1dd458555..29076d9f32a 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -120,6 +120,8 @@ void CONSTRAINT_OT_delete(struct wmOperatorType *ot); void CONSTRAINT_OT_move_up(struct wmOperatorType *ot); void CONSTRAINT_OT_move_down(struct wmOperatorType *ot); +void CONSTRAINT_OT_stretchto_reset(struct wmOperatorType *ot); +void CONSTRAINT_OT_limitdistance_reset(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_set_inverse(struct wmOperatorType *ot); void CONSTRAINT_OT_childof_clear_inverse(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 27d481ef509..c54a8cef8dc 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -125,6 +125,8 @@ void ED_operatortypes_object(void) WM_operatortype_append(CONSTRAINT_OT_delete); WM_operatortype_append(CONSTRAINT_OT_move_up); WM_operatortype_append(CONSTRAINT_OT_move_down); + WM_operatortype_append(CONSTRAINT_OT_stretchto_reset); + WM_operatortype_append(CONSTRAINT_OT_limitdistance_reset); WM_operatortype_append(CONSTRAINT_OT_childof_set_inverse); WM_operatortype_append(CONSTRAINT_OT_childof_clear_inverse); |