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:
Diffstat (limited to 'source/blender/editors/object/object_constraint.c')
-rw-r--r--source/blender/editors/object/object_constraint.c465
1 files changed, 229 insertions, 236 deletions
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index ec3567454df..a865b1d015d 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -81,7 +81,7 @@
/* -------------- Get Active Constraint Data ---------------------- */
/* if object in posemode, active bone constraints, else object constraints */
-ListBase *get_active_constraints (Object *ob)
+ListBase *get_active_constraints(Object *ob)
{
if (ob == NULL)
return NULL;
@@ -100,10 +100,10 @@ ListBase *get_active_constraints (Object *ob)
}
/* Find the list that a given constraint belongs to, and/or also get the posechannel this is from (if applicable) */
-ListBase *get_constraint_lb (Object *ob, bConstraint *con, bPoseChannel **pchan_r)
+ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **pchan_r)
{
if (pchan_r)
- *pchan_r= NULL;
+ *pchan_r = NULL;
if (ELEM(NULL, ob, con))
return NULL;
@@ -120,11 +120,11 @@ ListBase *get_constraint_lb (Object *ob, bConstraint *con, bPoseChannel **pchan_
/* try each bone in order
* NOTE: it's not possible to directly look up the active bone yet, so this will have to do
*/
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((BLI_findindex(&pchan->constraints, con) != -1)) {
if (pchan_r)
- *pchan_r= pchan;
+ *pchan_r = pchan;
return &pchan->constraints;
}
@@ -136,7 +136,7 @@ ListBase *get_constraint_lb (Object *ob, bConstraint *con, bPoseChannel **pchan_
}
/* single constraint */
-bConstraint *get_active_constraint (Object *ob)
+bConstraint *get_active_constraint(Object *ob)
{
return constraints_get_active(get_active_constraints(ob));
}
@@ -146,25 +146,25 @@ bConstraint *get_active_constraint (Object *ob)
/* ------------- PyConstraints ------------------ */
/* this callback sets the text-file to be used for selected menu item */
-static void validate_pyconstraint_cb (void *arg1, void *arg2)
+static void validate_pyconstraint_cb(void *arg1, void *arg2)
{
bPythonConstraint *data = arg1;
- Text *text= NULL;
+ Text *text = NULL;
int index = *((int *)arg2);
int i;
/* exception for no script */
if (index) {
/* innovative use of a for...loop to search */
- for (text=G.main->text.first, i=1; text && index!=i; i++, text=text->id.next);
+ for (text = G.main->text.first, i = 1; text && index != i; i++, text = text->id.next) ;
}
data->text = text;
}
/* this returns a string for the list of usable pyconstraint script names */
-static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex)
+static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex)
{
- DynStr *pupds= BLI_dynstr_new();
+ DynStr *pupds = BLI_dynstr_new();
Text *text;
char *str;
char buf[64];
@@ -176,16 +176,16 @@ static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex)
/* init active-index first */
if (con_text == NULL)
- *pyconindex= 0;
+ *pyconindex = 0;
/* loop through markers, adding them */
- for (text=G.main->text.first, i=1; text; i++, text=text->id.next) {
+ for (text = G.main->text.first, i = 1; text; i++, text = text->id.next) {
/* this is important to ensure that right script is shown as active */
if (text == con_text) *pyconindex = i;
/* only include valid pyconstraint scripts */
if (BPY_is_pyconstraint(text)) {
- BLI_dynstr_append(pupds, text->id.name+2);
+ BLI_dynstr_append(pupds, text->id.name + 2);
sprintf(buf, "%%x%d", i);
BLI_dynstr_append(pupds, buf);
@@ -196,7 +196,7 @@ static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex)
}
/* convert to normal MEM_malloc'd string */
- str= BLI_dynstr_get_cstring(pupds);
+ str = BLI_dynstr_get_cstring(pupds);
BLI_dynstr_free(pupds);
return str;
@@ -205,14 +205,14 @@ static char *buildmenu_pyconstraints (Text *con_text, int *pyconindex)
#if 0 // UNUSED, until pyconstraints are added back.
/* this callback gets called when the 'refresh' button of a pyconstraint gets pressed */
-static void update_pyconstraint_cb (void *arg1, void *arg2)
+static void update_pyconstraint_cb(void *arg1, void *arg2)
{
#ifndef WITH_PYTHON
(void)arg1; /* unused */
(void)arg2; /* unused */
#else
- Object *owner= (Object *)arg1;
- bConstraint *con= (bConstraint *)arg2;
+ Object *owner = (Object *)arg1;
+ bConstraint *con = (bConstraint *)arg2;
if (owner && con)
BPY_pyconstraint_update(owner, con);
#endif
@@ -220,30 +220,30 @@ static void update_pyconstraint_cb (void *arg1, void *arg2)
#endif // UNUSED
/* helper function for add_constriant - sets the last target for the active constraint */
-static void set_constraint_nth_target (bConstraint *con, Object *target, const char subtarget[], int index)
+static void set_constraint_nth_target(bConstraint *con, Object *target, const char subtarget[], int index)
{
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
int num_targets, i;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- num_targets= BLI_countlist(&targets);
+ num_targets = BLI_countlist(&targets);
if (index < 0) {
if (abs(index) < num_targets)
- index= num_targets - abs(index);
+ index = num_targets - abs(index);
else
- index= num_targets - 1;
+ index = num_targets - 1;
}
else if (index >= num_targets) {
- index= num_targets - 1;
+ index = num_targets - 1;
}
- for (ct=targets.first, i=0; ct; ct= ct->next, i++) {
+ for (ct = targets.first, i = 0; ct; ct = ct->next, i++) {
if (i == index) {
- ct->tar= target;
+ ct->tar = target;
BLI_strncpy(ct->subtarget, subtarget, sizeof(ct->subtarget));
break;
}
@@ -259,13 +259,13 @@ static void set_constraint_nth_target (bConstraint *con, Object *target, const c
/* checks validity of object pointers, and NULLs,
* if Bone doesnt exist it sets the CONSTRAINT_DISABLE flag.
*/
-static void test_constraints (Object *owner, bPoseChannel *pchan)
+static void test_constraints(Object *owner, bPoseChannel *pchan)
{
bConstraint *curcon;
- ListBase *conlist= NULL;
+ ListBase *conlist = NULL;
int type;
- if (owner==NULL) return;
+ if (owner == NULL) return;
/* Check parents */
if (pchan) {
@@ -293,8 +293,8 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
/* Check all constraints - is constraint valid? */
if (conlist) {
- for (curcon = conlist->first; curcon; curcon=curcon->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
+ for (curcon = conlist->first; curcon; curcon = curcon->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -339,7 +339,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
bPivotConstraint *data = curcon->data;
/* target doesn't have to exist, but if it is non-null, it must exist! */
- if (data->tar && exist_object(data->tar)==0) {
+ if (data->tar && exist_object(data->tar) == 0) {
data->tar = NULL;
curcon->flag |= CONSTRAINT_DISABLE;
}
@@ -363,26 +363,26 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
bFollowPathConstraint *data = curcon->data;
/* don't allow track/up axes to be the same */
- if (data->upflag==data->trackflag)
+ if (data->upflag == data->trackflag)
curcon->flag |= CONSTRAINT_DISABLE;
- if (data->upflag+3==data->trackflag)
+ if (data->upflag + 3 == data->trackflag)
curcon->flag |= CONSTRAINT_DISABLE;
}
else if (curcon->type == CONSTRAINT_TYPE_TRACKTO) {
bTrackToConstraint *data = curcon->data;
/* don't allow track/up axes to be the same */
- if (data->reserved2==data->reserved1)
+ if (data->reserved2 == data->reserved1)
curcon->flag |= CONSTRAINT_DISABLE;
- if (data->reserved2+3==data->reserved1)
+ if (data->reserved2 + 3 == data->reserved1)
curcon->flag |= CONSTRAINT_DISABLE;
}
else if (curcon->type == CONSTRAINT_TYPE_LOCKTRACK) {
bLockTrackConstraint *data = curcon->data;
- if (data->lockflag==data->trackflag)
+ if (data->lockflag == data->trackflag)
curcon->flag |= CONSTRAINT_DISABLE;
- if (data->lockflag+3==data->trackflag)
+ if (data->lockflag + 3 == data->trackflag)
curcon->flag |= CONSTRAINT_DISABLE;
}
else if (curcon->type == CONSTRAINT_TYPE_SPLINEIK) {
@@ -391,7 +391,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
/* if the number of points does not match the amount required by the chain length,
* free the points array and request a rebind...
*/
- if ((data->points == NULL) || (data->numpoints != data->chainlen+1)) {
+ if ((data->points == NULL) || (data->numpoints != data->chainlen + 1)) {
/* free the points array */
if (data->points) {
MEM_freeN(data->points);
@@ -405,15 +405,15 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
else if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) {
bFollowTrackConstraint *data = curcon->data;
- if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0) {
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0) {
if (data->clip != NULL && data->track[0]) {
- MovieTracking *tracking= &data->clip->tracking;
+ MovieTracking *tracking = &data->clip->tracking;
MovieTrackingObject *tracking_object;
if (data->object[0])
- tracking_object= BKE_tracking_named_object(tracking, data->object);
+ tracking_object = BKE_tracking_named_object(tracking, data->object);
else
- tracking_object= BKE_tracking_get_camera_object(tracking);
+ tracking_object = BKE_tracking_get_camera_object(tracking);
if (!tracking_object) {
curcon->flag |= CONSTRAINT_DISABLE;
@@ -429,13 +429,13 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
else if (curcon->type == CONSTRAINT_TYPE_CAMERASOLVER) {
bCameraSolverConstraint *data = curcon->data;
- if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && data->clip == NULL)
curcon->flag |= CONSTRAINT_DISABLE;
}
else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) {
bObjectSolverConstraint *data = curcon->data;
- if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL)
+ if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && data->clip == NULL)
curcon->flag |= CONSTRAINT_DISABLE;
}
@@ -444,7 +444,7 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
cti->get_constraint_targets(curcon, &targets);
/* disable and clear constraints targets that are incorrect */
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
/* general validity checks (for those constraints that need this) */
if (exist_object(ct->tar) == 0) {
/* object doesn't exist, but constraint requires target */
@@ -475,11 +475,11 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
if (ELEM3(curcon->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) {
if (ct->tar) {
if (ct->tar->type != OB_CURVE) {
- ct->tar= NULL;
+ ct->tar = NULL;
curcon->flag |= CONSTRAINT_DISABLE;
}
else {
- Curve *cu= ct->tar->data;
+ Curve *cu = ct->tar->data;
/* auto-set 'Path' setting on curve so this works */
cu->flag |= CU_PATH;
@@ -496,15 +496,15 @@ static void test_constraints (Object *owner, bPoseChannel *pchan)
}
}
-void object_test_constraints (Object *owner)
+void object_test_constraints(Object *owner)
{
if (owner->constraints.first)
test_constraints(owner, NULL);
- if (owner->type==OB_ARMATURE && owner->pose) {
+ if (owner->type == OB_ARMATURE && owner->pose) {
bPoseChannel *pchan;
- for (pchan= owner->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->constraints.first)
test_constraints(owner, pchan);
}
@@ -514,8 +514,8 @@ void object_test_constraints (Object *owner)
/************************ generic functions for operators using constraint names and data context *********************/
-#define EDIT_CONSTRAINT_OWNER_OBJECT 0
-#define EDIT_CONSTRAINT_OWNER_BONE 1
+#define EDIT_CONSTRAINT_OWNER_OBJECT 0
+#define EDIT_CONSTRAINT_OWNER_BONE 1
static EnumPropertyItem constraint_owner_items[] = {
{EDIT_CONSTRAINT_OWNER_OBJECT, "OBJECT", 0, "Object", "Edit a constraint on the active object"},
@@ -525,11 +525,11 @@ static EnumPropertyItem constraint_owner_items[] = {
static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", rna_type);
- Object *ob= (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", rna_type);
+ Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
if (!ob || ob->id.lib) return 0;
- if (ptr.id.data && ((ID*)ptr.id.data)->lib) return 0;
+ if (ptr.id.data && ((ID *)ptr.id.data)->lib) return 0;
return 1;
}
@@ -547,8 +547,8 @@ static void edit_constraint_properties(wmOperatorType *ot)
static int edit_constraint_invoke_properties(bContext *C, wmOperator *op)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
- Object *ob= (ptr.id.data)?ptr.id.data:ED_object_active_context(C);
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
+ Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
bConstraint *con;
ListBase *list;
@@ -577,7 +577,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
char constraint_name[MAX_NAME];
int owner = RNA_enum_get(op->ptr, "owner");
bConstraint *con;
- ListBase *list=NULL;
+ ListBase *list = NULL;
RNA_string_get(op->ptr, "constraint", constraint_name);
@@ -585,7 +585,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
list = &ob->constraints;
}
else if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
- bPoseChannel *pchan= get_active_posechannel(ob);
+ bPoseChannel *pchan = get_active_posechannel(ob);
if (pchan)
list = &pchan->constraints;
else {
@@ -615,11 +615,11 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int
/* ---------- Distance-Dependent Constraints ---------- */
/* StretchTo, Limit Distance */
-static int stretchto_reset_exec (bContext *C, wmOperator *op)
+static int stretchto_reset_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO);
- bStretchToConstraint *data= (con) ? (bStretchToConstraint *)con->data : NULL;
+ bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL)
@@ -629,7 +629,7 @@ static int stretchto_reset_exec (bContext *C, wmOperator *op)
data->orglength = 0.0f;
ED_object_constraint_update(ob);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
return OPERATOR_FINISHED;
}
@@ -641,7 +641,7 @@ static int stretchto_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot)
+void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Reset Original Length";
@@ -653,16 +653,16 @@ void CONSTRAINT_OT_stretchto_reset (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
-static int limitdistance_reset_exec (bContext *C, wmOperator *op)
+static int limitdistance_reset_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT);
- bDistLimitConstraint *data= (con) ? (bDistLimitConstraint *)con->data : NULL;
+ bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL)
@@ -672,7 +672,7 @@ static int limitdistance_reset_exec (bContext *C, wmOperator *op)
data->dist = 0.0f;
ED_object_constraint_update(ob);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
return OPERATOR_FINISHED;
}
@@ -684,7 +684,7 @@ static int limitdistance_reset_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot)
+void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Reset Distance";
@@ -696,16 +696,16 @@ void CONSTRAINT_OT_limitdistance_reset (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
/* ------------- Child-Of Constraint ------------------ */
-static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con, float invmat[4][4])
+static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, float invmat[4][4])
{
bConstraint *lastcon = NULL;
- bPoseChannel *pchan= NULL;
+ bPoseChannel *pchan = NULL;
/* nullify inverse matrix first */
unit_m4(invmat);
@@ -713,13 +713,13 @@ static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con
/* try to find a pose channel - assume that this is the constraint owner */
// TODO: get from context instead?
if (ob && ob->pose)
- pchan= get_active_posechannel(ob);
+ pchan = get_active_posechannel(ob);
/* calculate/set inverse matrix:
- * We just calculate all transform-stack eval up to but not including this constraint.
- * This is because inverse should just inverse correct for just the constraint's influence
- * when it gets applied; that is, at the time of application, we don't know anything about
- * what follows.
+ * We just calculate all transform-stack eval up to but not including this constraint.
+ * This is because inverse should just inverse correct for just the constraint's influence
+ * when it gets applied; that is, at the time of application, we don't know anything about
+ * what follows.
*/
if (pchan) {
float imat[4][4], tmat[4][4];
@@ -781,23 +781,23 @@ static void child_get_inverse_matrix (Scene *scene, Object *ob, bConstraint *con
}
/* ChildOf Constraint - set inverse callback */
-static int childof_set_inverse_exec (bContext *C, wmOperator *op)
+static int childof_set_inverse_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
- bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL;
+ bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL) {
- printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>");
+ printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>");
BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse");
return OPERATOR_CANCELLED;
}
child_get_inverse_matrix(scene, ob, con, data->invmat);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -810,7 +810,7 @@ static int childof_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot)
+void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Inverse";
@@ -822,18 +822,18 @@ void CONSTRAINT_OT_childof_set_inverse (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
/* ChildOf Constraint - clear inverse callback */
-static int childof_clear_inverse_exec (bContext *C, wmOperator *op)
+static int childof_clear_inverse_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
- bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL;
+ bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL;
- if (data==NULL) {
+ if (data == NULL) {
BKE_report(op->reports, RPT_ERROR, "Childof constraint not found");
return OPERATOR_CANCELLED;
}
@@ -841,7 +841,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op)
/* simply clear the matrix */
unit_m4(data->invmat);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -854,7 +854,7 @@ static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, wmEvent *UN
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot)
+void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clear Inverse";
@@ -866,29 +866,29 @@ void CONSTRAINT_OT_childof_clear_inverse (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
/* ------------- Object Solver Constraint ------------------ */
-static int objectsolver_set_inverse_exec (bContext *C, wmOperator *op)
+static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
- bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL;
+ bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL;
/* despite 3 layers of checks, we may still not be able to find a constraint */
if (data == NULL) {
- printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob)? ob->id.name+2 : "<None>");
+ printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>");
BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse");
return OPERATOR_CANCELLED;
}
child_get_inverse_matrix(scene, ob, con, data->invmat);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -901,7 +901,7 @@ static int objectsolver_set_inverse_invoke(bContext *C, wmOperator *op, wmEvent
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_objectsolver_set_inverse (wmOperatorType *ot)
+void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Inverse";
@@ -913,17 +913,17 @@ void CONSTRAINT_OT_objectsolver_set_inverse (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
-static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op)
+static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
- bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL;
+ bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL;
- if (data==NULL) {
+ if (data == NULL) {
BKE_report(op->reports, RPT_ERROR, "Childof constraint not found");
return OPERATOR_CANCELLED;
}
@@ -931,7 +931,7 @@ static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op)
/* simply clear the matrix */
unit_m4(data->invmat);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -944,7 +944,7 @@ static int objectsolver_clear_inverse_invoke(bContext *C, wmOperator *op, wmEven
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_objectsolver_clear_inverse (wmOperatorType *ot)
+void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Clear Inverse";
@@ -956,7 +956,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -981,7 +981,7 @@ void ED_object_constraint_update(Object *ob)
object_test_constraints(ob);
- if (ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB);
+ if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
else DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
@@ -989,23 +989,23 @@ void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *o
{
ED_object_constraint_update(ob);
- if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
+ if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels
DAG_scene_sort(bmain, scene);
}
static int constraint_poll(bContext *C)
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
return (ptr.id.data && ptr.data);
}
-static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op))
+static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op))
{
- PointerRNA ptr= CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
- Object *ob= ptr.id.data;
- bConstraint *con= ptr.data;
+ PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint);
+ Object *ob = ptr.id.data;
+ bConstraint *con = ptr.data;
ListBase *lb = get_constraint_lb(ob, con, NULL);
- const short is_ik= ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
+ const short is_ik = ELEM(con->type, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK);
/* free the constraint */
if (remove_constraint(lb, con)) {
@@ -1020,7 +1020,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op))
}
/* notifiers */
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
return OPERATOR_FINISHED;
}
@@ -1030,7 +1030,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op))
}
}
-void CONSTRAINT_OT_delete (wmOperatorType *ot)
+void CONSTRAINT_OT_delete(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Delete Constraint";
@@ -1042,23 +1042,23 @@ void CONSTRAINT_OT_delete (wmOperatorType *ot)
ot->poll = constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int constraint_move_down_exec (bContext *C, wmOperator *op)
+static int constraint_move_down_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
if (con && con->next) {
- ListBase *conlist= get_constraint_lb(ob, con, NULL);
- bConstraint *nextCon= con->next;
+ ListBase *conlist = get_constraint_lb(ob, con, NULL);
+ bConstraint *nextCon = con->next;
/* insert the nominated constraint after the one that used to be after it */
BLI_remlink(conlist, con);
BLI_insertlinkafter(conlist, nextCon, con);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -1075,7 +1075,7 @@ static int constraint_move_down_invoke(bContext *C, wmOperator *op, wmEvent *UNU
}
-void CONSTRAINT_OT_move_down (wmOperatorType *ot)
+void CONSTRAINT_OT_move_down(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Move Constraint Down";
@@ -1088,25 +1088,25 @@ void CONSTRAINT_OT_move_down (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
-static int constraint_move_up_exec (bContext *C, wmOperator *op)
+static int constraint_move_up_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, 0);
if (con && con->prev) {
- ListBase *conlist= get_constraint_lb(ob, con, NULL);
- bConstraint *prevCon= con->prev;
+ ListBase *conlist = get_constraint_lb(ob, con, NULL);
+ bConstraint *prevCon = con->prev;
/* insert the nominated constraint before the one that used to be before it */
BLI_remlink(conlist, con);
BLI_insertlinkbefore(conlist, prevCon, con);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -1122,7 +1122,7 @@ static int constraint_move_up_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE
return OPERATOR_CANCELLED;
}
-void CONSTRAINT_OT_move_up (wmOperatorType *ot)
+void CONSTRAINT_OT_move_up(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Move Constraint Up";
@@ -1135,7 +1135,7 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot)
ot->poll = edit_constraint_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edit_constraint_properties(ot);
}
@@ -1145,26 +1145,25 @@ void CONSTRAINT_OT_move_up (wmOperatorType *ot)
static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = object_pose_armature_get(CTX_data_active_object(C));
/* free constraints for all selected bones */
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
- {
+ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
free_constraints(&pchan->constraints);
- pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_SPLINEIK|PCHAN_HAS_CONST);
+ pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST);
}
CTX_DATA_END;
/* force depsgraph to get recalculated since relationships removed */
- DAG_scene_sort(bmain, scene); /* sort order of objects */
+ DAG_scene_sort(bmain, scene); /* sort order of objects */
/* note, calling BIK_clear_data() isn't needed here */
/* do updates */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob);
return OPERATOR_FINISHED;
}
@@ -1184,22 +1183,21 @@ void POSE_OT_constraints_clear(wmOperatorType *ot)
static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
/* do freeing */
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
- {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
free_constraints(&ob->constraints);
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
CTX_DATA_END;
/* force depsgraph to get recalculated since relationships removed */
- DAG_scene_sort(bmain, scene); /* sort order of objects */
+ DAG_scene_sort(bmain, scene); /* sort order of objects */
/* do updates */
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
return OPERATOR_FINISHED;
}
@@ -1220,7 +1218,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot)
static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
{
- Main *bmain= CTX_data_main(C);
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
bPoseChannel *pchan = CTX_data_active_pose_bone(C);
@@ -1231,8 +1229,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
}
/* copy all constraints from active posebone to all selected posebones */
- CTX_DATA_BEGIN(C, bPoseChannel*, chan, selected_pose_bones)
- {
+ CTX_DATA_BEGIN (C, bPoseChannel *, chan, selected_pose_bones) {
/* if we're not handling the object we're copying from, copy all constraints over */
if (pchan != chan) {
copy_constraints(&chan->constraints, &pchan->constraints, TRUE);
@@ -1243,9 +1240,9 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* force depsgraph to get recalculated since new relationships added */
- DAG_scene_sort(bmain, scene); /* sort order of objects/bones */
+ DAG_scene_sort(bmain, scene); /* sort order of objects/bones */
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL);
return OPERATOR_FINISHED;
}
@@ -1262,18 +1259,17 @@ void POSE_OT_constraints_copy(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
+ Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *obact = ED_object_active_context(C);
/* copy all constraints from active object to all selected objects */
- CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects)
- {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
/* if we're not handling the object we're copying from, copy all constraints over */
if (obact != ob) {
copy_constraints(&ob->constraints, &obact->constraints, TRUE);
@@ -1283,10 +1279,10 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_END;
/* force depsgraph to get recalculated since new relationships added */
- DAG_scene_sort(bmain, scene); /* sort order of objects */
+ DAG_scene_sort(bmain, scene); /* sort order of objects */
/* notifiers for updates */
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL);
return OPERATOR_FINISHED;
}
@@ -1303,7 +1299,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/************************ add constraint operators *********************/
@@ -1311,25 +1307,25 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot)
/* get the Object and/or PoseChannel to use as target */
static short get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, short add)
{
- Object *obact= ED_object_active_context(C);
- bPoseChannel *pchanact= get_active_posechannel(obact);
- short only_curve= 0, only_mesh= 0, only_ob= 0;
- short found= 0;
+ Object *obact = ED_object_active_context(C);
+ bPoseChannel *pchanact = get_active_posechannel(obact);
+ short only_curve = 0, only_mesh = 0, only_ob = 0;
+ short found = 0;
/* clear tar_ob and tar_pchan fields before use
* - assume for now that both always exist...
*/
- *tar_ob= NULL;
- *tar_pchan= NULL;
+ *tar_ob = NULL;
+ *tar_pchan = NULL;
/* check if constraint type doesn't requires a target
* - if so, no need to get any targets
*/
switch (con_type) {
/* no-target constraints --------------------------- */
- /* null constraint - shouldn't even be added! */
+ /* null constraint - shouldn't even be added! */
case CONSTRAINT_TYPE_NULL:
- /* limit constraints - no targets needed */
+ /* limit constraints - no targets needed */
case CONSTRAINT_TYPE_LOCLIMIT:
case CONSTRAINT_TYPE_ROTLIMIT:
case CONSTRAINT_TYPE_SIZELIMIT:
@@ -1338,38 +1334,37 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
/* restricted target-type constraints -------------- */
/* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */
- /* curve-based constraints - set the only_curve and only_ob flags */
+ /* curve-based constraints - set the only_curve and only_ob flags */
case CONSTRAINT_TYPE_CLAMPTO:
case CONSTRAINT_TYPE_FOLLOWPATH:
case CONSTRAINT_TYPE_SPLINEIK:
- only_curve= 1;
- only_ob= 1;
- add= 0;
+ only_curve = 1;
+ only_ob = 1;
+ add = 0;
break;
- /* mesh only? */
+ /* mesh only? */
case CONSTRAINT_TYPE_SHRINKWRAP:
- only_mesh= 1;
- only_ob= 1;
- add= 0;
+ only_mesh = 1;
+ only_ob = 1;
+ add = 0;
break;
- /* object only - add here is ok? */
+ /* object only - add here is ok? */
case CONSTRAINT_TYPE_RIGIDBODYJOINT:
- only_ob= 1;
+ only_ob = 1;
break;
}
/* if the active Object is Armature, and we can search for bones, do so... */
if ((obact->type == OB_ARMATURE) && (only_ob == 0)) {
/* search in list of selected Pose-Channels for target */
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
- {
+ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
/* just use the first one that we encounter, as long as it is not the active one */
if (pchan != pchanact) {
- *tar_ob= obact;
- *tar_pchan= pchan;
- found= 1;
+ *tar_ob = obact;
+ *tar_pchan = pchan;
+ found = 1;
break;
}
@@ -1380,23 +1375,22 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
/* if not yet found, try selected Objects... */
if (found == 0) {
/* search in selected objects context */
- CTX_DATA_BEGIN(C, Object*, ob, selected_objects)
- {
+ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
/* just use the first object we encounter (that isn't the active object)
* and which fulfills the criteria for the object-target that we've got
*/
if ( (ob != obact) &&
- ((!only_curve) || (ob->type == OB_CURVE)) &&
- ((!only_mesh) || (ob->type == OB_MESH)) )
+ ((!only_curve) || (ob->type == OB_CURVE)) &&
+ ((!only_mesh) || (ob->type == OB_MESH)) )
{
/* set target */
- *tar_ob= ob;
- found= 1;
+ *tar_ob = ob;
+ found = 1;
/* perform some special operations on the target */
if (only_curve) {
/* Curve-Path option must be enabled for follow-path constraints to be able to work */
- Curve *cu= (Curve *)ob->data;
+ Curve *cu = (Curve *)ob->data;
cu->flag |= CU_PATH;
}
@@ -1408,17 +1402,17 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
/* if still not found, add a new empty to act as a target (if allowed) */
if ((found == 0) && (add)) {
- Scene *scene= CTX_data_scene(C);
- Base *base= BASACT, *newbase=NULL;
+ Scene *scene = CTX_data_scene(C);
+ Base *base = BASACT, *newbase = NULL;
Object *obt;
/* add new target object */
- obt= add_object(scene, OB_EMPTY);
+ obt = add_object(scene, OB_EMPTY);
/* set layers OK */
- newbase= BASACT;
- newbase->lay= base->lay;
- obt->lay= newbase->lay;
+ newbase = BASACT;
+ newbase->lay = base->lay;
+ obt->lay = newbase->lay;
/* transform cent to global coords for loc */
if (pchanact) {
@@ -1435,12 +1429,12 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
}
/* restore, add_object sets active */
- BASACT= base;
+ BASACT = base;
base->flag |= SELECT;
/* make our new target the new object */
- *tar_ob= obt;
- found= 1;
+ *tar_ob = obt;
+ found = 1;
}
/* return whether there's any target */
@@ -1450,16 +1444,16 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o
/* used by add constraint operators to add the constraint required */
static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget)
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
bPoseChannel *pchan;
bConstraint *con;
if (list == &ob->constraints) {
- pchan= NULL;
+ pchan = NULL;
}
else {
- pchan= get_active_posechannel(ob);
+ pchan = get_active_posechannel(ob);
/* ensure not to confuse object/pose adding */
if (pchan == NULL) {
@@ -1494,8 +1488,8 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
* - apart from the buttons-window add buttons, we shouldn't add in this way
*/
if (setTarget) {
- Object *tar_ob= NULL;
- bPoseChannel *tar_pchan= NULL;
+ Object *tar_ob = NULL;
+ bPoseChannel *tar_pchan = NULL;
/* get the target objects, adding them as need be */
if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) {
@@ -1515,7 +1509,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
{
#ifdef WITH_PYTHON
char *menustr;
- int scriptint= 0;
+ int scriptint = 0;
/* popup a list of usable scripts */
menustr = buildmenu_pyconstraints(NULL, &scriptint);
// XXX scriptint = pupmenu(menustr);
@@ -1545,17 +1539,17 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
/* force depsgraph to get recalculated since new relationships added */
- DAG_scene_sort(bmain, scene); /* sort order of objects */
+ DAG_scene_sort(bmain, scene); /* sort order of objects */
- if ((ob->type==OB_ARMATURE) && (pchan)) {
- ob->pose->flag |= POSE_RECALC; /* sort pose channels */
- DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB);
+ if ((ob->type == OB_ARMATURE) && (pchan)) {
+ ob->pose->flag |= POSE_RECALC; /* sort pose channels */
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB);
}
else
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* notifiers for updates */
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_ADDED, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob);
return OPERATOR_FINISHED;
}
@@ -1565,9 +1559,9 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase
/* dummy operator callback */
static int object_constraint_add_exec(bContext *C, wmOperator *op)
{
- Object *ob=ED_object_active_context(C);
- int type= RNA_enum_get(op->ptr, "type");
- short with_targets= 0;
+ Object *ob = ED_object_active_context(C);
+ int type = RNA_enum_get(op->ptr, "type");
+ short with_targets = 0;
if (!ob) {
BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to");
@@ -1578,7 +1572,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
if (strstr(op->idname, "with_targets"))
- with_targets= 1;
+ with_targets = 1;
return constraint_add_exec(C, op, ob, &ob->constraints, type, with_targets);
}
@@ -1586,9 +1580,9 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op)
/* dummy operator callback */
static int pose_constraint_add_exec(bContext *C, wmOperator *op)
{
- Object *ob= object_pose_armature_get(ED_object_active_context(C));
- int type= RNA_enum_get(op->ptr, "type");
- short with_targets= 0;
+ Object *ob = object_pose_armature_get(ED_object_active_context(C));
+ int type = RNA_enum_get(op->ptr, "type");
+ short with_targets = 0;
if (!ob) {
BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to");
@@ -1599,7 +1593,7 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op)
* operator name included 'with_targets', since the menu doesn't allow multiple properties
*/
if (strstr(op->idname, "with_targets"))
- with_targets= 1;
+ with_targets = 1;
return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets);
}
@@ -1619,7 +1613,7 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
@@ -1638,7 +1632,7 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot)
ot->poll = ED_operator_object_active_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
@@ -1657,7 +1651,7 @@ void POSE_OT_constraint_add(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
@@ -1676,7 +1670,7 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", constraint_type_items, 0, "Type", "");
@@ -1689,14 +1683,14 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot)
/* present menu with options + validation for targets to use */
static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
{
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
- bPoseChannel *pchan= get_active_posechannel(ob);
- bConstraint *con= NULL;
+ Object *ob = object_pose_armature_get(CTX_data_active_object(C));
+ bPoseChannel *pchan = get_active_posechannel(ob);
+ bConstraint *con = NULL;
uiPopupMenu *pup;
uiLayout *layout;
- Object *tar_ob= NULL;
- bPoseChannel *tar_pchan= NULL;
+ Object *tar_ob = NULL;
+ bPoseChannel *tar_pchan = NULL;
/* must have active bone */
if (ELEM(NULL, ob, pchan)) {
@@ -1705,8 +1699,8 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
}
/* bone must not have any constraints already */
- for (con= pchan->constraints.first; con; con= con->next) {
- if (con->type==CONSTRAINT_TYPE_KINEMATIC) break;
+ for (con = pchan->constraints.first; con; con = con->next) {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) break;
}
if (con) {
BKE_report(op->reports, RPT_ERROR, "Bone already has IK Constraint");
@@ -1714,8 +1708,8 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
}
/* prepare popup menu to choose targetting options */
- pup= uiPupMenuBegin(C, "Add IK", ICON_NONE);
- layout= uiPupMenuLayout(pup);
+ pup = uiPupMenuBegin(C, "Add IK", ICON_NONE);
+ layout = uiPupMenuLayout(pup);
/* the type of targets we'll set determines the menu entries to show... */
if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) {
@@ -1742,8 +1736,8 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
/* call constraint_add_exec() to add the IK constraint */
static int pose_ik_add_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_active_object(C);
- int with_targets= RNA_boolean_get(op->ptr, "with_targets");
+ Object *ob = CTX_data_active_object(C);
+ int with_targets = RNA_boolean_get(op->ptr, "with_targets");
/* add the constraint - all necessary checks should have been done by the invoke() callback already... */
return constraint_add_exec(C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets);
@@ -1762,7 +1756,7 @@ void POSE_OT_ik_add(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "with_targets", 1, "With Targets", "Assign IK Constraint with targets derived from the select bones/objects");
@@ -1773,21 +1767,20 @@ void POSE_OT_ik_add(wmOperatorType *ot)
/* remove IK constraints from selected bones */
static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = object_pose_armature_get(CTX_data_active_object(C));
/* only remove IK Constraints */
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
- {
+ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
bConstraint *con, *next;
// TODO: should we be checking if these contraints were local before we try and remove them?
- for (con= pchan->constraints.first; con; con= next) {
- next= con->next;
- if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
+ for (con = pchan->constraints.first; con; con = next) {
+ next = con->next;
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
remove_constraint(&pchan->constraints, con);
}
}
- pchan->constflag &= ~(PCHAN_HAS_IK|PCHAN_HAS_TARGET);
+ pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET);
}
CTX_DATA_END;
@@ -1795,7 +1788,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op))
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT|NA_REMOVED, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob);
return OPERATOR_FINISHED;
}
@@ -1812,6 +1805,6 @@ void POSE_OT_ik_clear(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}