2.5 - 'Reset' buttons for Limit Distance and Stretch To Constraints

This commit is contained in:
Joshua Leung 2009-07-26 11:57:27 +00:00
parent 812530aca8
commit 4e024a1e6e
5 changed files with 69 additions and 6 deletions

@ -96,20 +96,24 @@ class DATA_PT_bone_groups(DataButtonsPanel):
row.template_list(pose, "bone_groups", pose, "active_bone_group_index")
col = row.column(align=True)
col.active = (ob.proxy == None)
col.itemO("pose.group_add", icon="ICON_ZOOMIN", text="")
col.itemO("pose.group_remove", icon="ICON_ZOOMOUT", text="")
group = pose.active_bone_group
if group:
col = layout.column()
col.active= (ob.proxy == None)
col.itemR(group, "name")
split = layout.split(0.5)
split.active= (ob.proxy == None)
split.itemR(group, "color_set")
if group.color_set:
split.template_triColorSet(group, "colors")
row = layout.row(align=True)
row.active= (ob.proxy == None)
row.itemO("pose.group_assign", text="Assign")
row.itemO("pose.group_remove", text="Remove") #row.itemO("pose.bone_group_remove_from", text="Remove")

@ -379,26 +379,29 @@ class ConstraintButtonsPanel(bpy.types.Panel):
def limit_distance(self, layout, con):
self.target_template(layout, con)
layout.itemR(con, "distance")
col = layout.column(align=True);
col.itemR(con, "distance")
col.itemO("constraint.limitdistance_reset")
row = layout.row()
row.itemL(text="Clamp Region:")
row.itemR(con, "limit_mode", text="")
#Missing: Recalculate Button
def stretch_to(self, layout, con):
self.target_template(layout, con)
row = layout.row()
row.itemR(con, "original_length", text="Rest Length")
row.itemR(con, "bulge", text="Volume Variation")
col = layout.column(align=True)
col.itemR(con, "original_length", text="Rest Length")
col.itemO("constraint.stretchto_reset")
col = layout.column()
col.itemR(con, "bulge", text="Volume Variation")
row = layout.row()
row.itemL(text="Volume:")
row.itemR(con, "volume", expand=True)
row.itemL(text="Plane:")
row.itemR(con, "keep_axis", expand=True)
#Missing: Recalculate Button
def floor(self, layout, con):
self.target_template(layout, con)

@ -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 */

@ -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);

@ -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);