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>2018-06-04 10:31:30 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-06-04 10:31:30 +0300
commit44505b38df557a5711703613685a1dec9fc2c3d9 (patch)
tree3f05bebcc7bfadf56569f2dcca7f95fc56b1b0d0 /source/blender/editors/armature
parent6654e109df952be3a3128fae2508a02c196ae593 (diff)
Cleanup: strip trailing space in editors
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/BIF_generate.h6
-rw-r--r--source/blender/editors/armature/BIF_retarget.h16
-rw-r--r--source/blender/editors/armature/armature_add.c176
-rw-r--r--source/blender/editors/armature/armature_edit.c264
-rw-r--r--source/blender/editors/armature/armature_intern.h10
-rw-r--r--source/blender/editors/armature/armature_naming.c64
-rw-r--r--source/blender/editors/armature/armature_ops.c102
-rw-r--r--source/blender/editors/armature/armature_relations.c236
-rw-r--r--source/blender/editors/armature/armature_select.c88
-rw-r--r--source/blender/editors/armature/armature_skinning.c62
-rw-r--r--source/blender/editors/armature/armature_utils.c90
-rw-r--r--source/blender/editors/armature/editarmature_generate.c92
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c752
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c8
-rw-r--r--source/blender/editors/armature/meshlaplacian.c50
-rw-r--r--source/blender/editors/armature/pose_edit.c290
-rw-r--r--source/blender/editors/armature/pose_group.c96
-rw-r--r--source/blender/editors/armature/pose_lib.c468
-rw-r--r--source/blender/editors/armature/pose_select.c190
-rw-r--r--source/blender/editors/armature/pose_slide.c432
-rw-r--r--source/blender/editors/armature/pose_transform.c216
-rw-r--r--source/blender/editors/armature/pose_utils.c78
-rw-r--r--source/blender/editors/armature/reeb.c848
-rw-r--r--source/blender/editors/armature/reeb.h14
24 files changed, 2324 insertions, 2324 deletions
diff --git a/source/blender/editors/armature/BIF_generate.h b/source/blender/editors/armature/BIF_generate.h
index 71109574fe0..e229b0f342a 100644
--- a/source/blender/editors/armature/BIF_generate.h
+++ b/source/blender/editors/armature/BIF_generate.h
@@ -22,7 +22,7 @@
* \ingroup edarmature
*/
-
+
#ifndef __BIF_GENERATE_H__
#define __BIF_GENERATE_H__
@@ -33,7 +33,7 @@ struct bArmature;
struct ListBase;
typedef int (NextSubdivisionFunc)(struct ToolSettings *, struct BArcIterator *, int, int, float[3], float[3]);
-
+
float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]);
int nextFixedSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
@@ -44,6 +44,6 @@ struct EditBone *subdivideArcBy(struct ToolSettings *toolsettings, struct bArmat
float invmat[4][4], float tmat[3][3], NextSubdivisionFunc next_subdividion);
void setBoneRollFromNormal(struct EditBone *bone, const float no[3], float invmat[4][4], float tmat[3][3]);
-
+
#endif /* __BIF_GENERATE_H__ */
diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h
index aa56f847f00..2bd2b80190b 100644
--- a/source/blender/editors/armature/BIF_retarget.h
+++ b/source/blender/editors/armature/BIF_retarget.h
@@ -52,28 +52,28 @@ typedef struct RigGraph {
ListBase nodes;
float length;
-
+
FreeArc free_arc;
FreeNode free_node;
RadialSymmetry radial_symmetry;
AxialSymmetry axial_symmetry;
/*********************************/
-
+
int flag;
ListBase controls;
ListBase *editbones;
-
+
struct RigNode *head;
ReebGraph *link_mesh;
-
-
+
+
TaskScheduler *task_scheduler;
TaskPool *task_pool;
-
+
GHash *bones_map; /* map of editbones by name */
GHash *controls_map; /* map of rigcontrols by bone pointer */
-
+
struct Object *ob;
} RigGraph;
@@ -106,7 +106,7 @@ typedef struct RigArc {
int symmetry_group;
int symmetry_flag;
/*********************************/
-
+
ListBase edges;
int count;
ReebArc *link_mesh;
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index c8939380bd9..b268baf0f97 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -66,12 +66,12 @@
EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
{
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
-
+
BLI_strncpy(bone->name, name, sizeof(bone->name));
ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL);
-
+
BLI_addtail(arm->edbo, bone);
-
+
bone->flag |= BONE_TIPSEL;
bone->weight = 1.0f;
bone->dist = 0.25f;
@@ -81,7 +81,7 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name)
bone->rad_tail = 0.05f;
bone->segments = 1;
bone->layer = arm->layer;
-
+
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;
bone->roll2 = 0.0f;
@@ -103,7 +103,7 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool
EditBone *bone;
ED_armature_edit_deselect_all(obedit_arm);
-
+
/* Create a bone */
bone = ED_armature_ebone_add(arm, "Bone");
@@ -135,7 +135,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
v3d = CTX_wm_view3d(C);
obedit = CTX_data_edit_object(C);
arm = obedit->data;
-
+
/* find the active or selected bone */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
@@ -143,7 +143,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
-
+
if (ebone == NULL) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
@@ -151,14 +151,14 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
break;
}
}
- if (ebone == NULL)
+ if (ebone == NULL)
return OPERATOR_CANCELLED;
-
+
to_root = 1;
}
-
+
ED_armature_edit_deselect_all(obedit);
-
+
/* we re-use code for mirror editing... */
flipbone = NULL;
if (arm->flag & ARM_MIRROR_EDIT)
@@ -172,10 +172,10 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
SWAP(EditBone *, flipbone, ebone);
}
}
-
+
newbone = ED_armature_ebone_add(arm, ebone->name);
arm->act_edbone = newbone;
-
+
if (to_root) {
copy_v3_v3(newbone->head, ebone->head);
newbone->rad_head = ebone->rad_tail;
@@ -187,28 +187,28 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
newbone->parent = ebone;
newbone->flag |= BONE_CONNECTED;
}
-
+
curs = ED_view3d_cursor3d_get(scene, v3d);
copy_v3_v3(newbone->tail, curs);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
-
+
if (a == 1)
newbone->tail[0] = -newbone->tail[0];
-
+
copy_m3_m4(mat, obedit->obmat);
invert_m3_m3(imat, mat);
mul_m3_v3(imat, newbone->tail);
-
+
newbone->length = len_v3v3(newbone->head, newbone->tail);
newbone->rad_tail = newbone->length * 0.05f;
newbone->dist = newbone->length * 0.25f;
-
+
}
-
+
ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -227,9 +227,9 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv
scene = CTX_data_scene(C);
ar = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);
-
+
fp = ED_view3d_cursor3d_get(scene, v3d);
-
+
copy_v3_v3(oldcurs, fp);
VECCOPY2D(mval_f, event->mval);
@@ -251,12 +251,12 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
ot->name = "Click-Extrude";
ot->idname = "ARMATURE_OT_click_extrude";
ot->description = "Create a new bone going from the last selected joint to the mouse position";
-
+
/* api callbacks */
ot->invoke = armature_click_extrude_invoke;
ot->exec = armature_click_extrude_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -267,12 +267,12 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
EditBone *add_points_bone(Object *obedit, float head[3], float tail[3])
{
EditBone *ebo;
-
+
ebo = ED_armature_ebone_add(obedit->data, "Bone");
-
+
copy_v3_v3(ebo->head, head);
copy_v3_v3(ebo->tail, tail);
-
+
return ebo;
}
@@ -378,7 +378,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
bPoseChannel *pchan;
bConstraint *curcon;
ListBase *conlist;
-
+
if ((pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name))) {
if ((conlist = &pchan->constraints)) {
for (curcon = conlist->first; curcon; curcon = curcon->next) {
@@ -388,17 +388,17 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if ((ct->tar == src_ob) && (ct->subtarget[0])) {
- ct->tar = dst_ob; /* update target */
+ ct->tar = dst_ob; /* update target */
oldtarget = get_named_editbone(editbones, ct->subtarget);
if (oldtarget) {
/* was the subtarget bone duplicated too? If
- * so, update the constraint to point at the
+ * so, update the constraint to point at the
* duplicate of the old subtarget.
*/
if (oldtarget->temp.ebone) {
@@ -408,7 +408,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(curcon, &targets, 0);
}
@@ -427,20 +427,20 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
Object *src_ob, Object *dst_ob)
{
EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone");
-
+
/* Copy data from old bone to new bone */
memcpy(eBone, curBone, sizeof(EditBone));
-
+
curBone->temp.ebone = eBone;
eBone->temp.ebone = curBone;
-
+
if (name != NULL) {
BLI_strncpy(eBone->name, name, sizeof(eBone->name));
}
ED_armature_ebone_unique_name(editbones, eBone->name, NULL);
BLI_addtail(editbones, eBone);
-
+
/* copy the ID property */
if (curBone->prop)
eBone->prop = IDP_CopyProperty(curBone->prop);
@@ -450,7 +450,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
*/
if (src_ob->pose) {
bPoseChannel *chanold, *channew;
-
+
chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name);
if (chanold) {
/* WARNING: this creates a new posechannel, but there will not be an attached bone
@@ -463,7 +463,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
}
}
}
-
+
return eBone;
}
@@ -507,7 +507,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
}
}
-
+
/* Find the selected bones and duplicate them as needed */
for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) {
if (EBONE_VISIBLE(arm, ebone_iter) &&
@@ -568,7 +568,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
updateDuplicateSubtarget(ebone, arm->edbo, obedit);
}
}
-
+
/* correct the active bone */
if (arm->act_edbone && arm->act_edbone->temp.ebone) {
arm->act_edbone = arm->act_edbone->temp.ebone;
@@ -586,7 +586,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
ED_armature_edit_validate_active(arm);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -597,11 +597,11 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
ot->name = "Duplicate Selected Bone(s)";
ot->idname = "ARMATURE_OT_duplicate";
ot->description = "Make copies of the selected bones within the same armature";
-
+
/* api callbacks */
ot->exec = armature_duplicate_selected_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -847,7 +847,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* Duplicate the necessary bones */
for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
@@ -865,7 +865,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
do_extrude = 2;
}
}
-
+
if (do_extrude) {
/* we re-use code for mirror editing... */
flipbone = NULL;
@@ -880,7 +880,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if ((flipbone == NULL) && (forked))
flipbone = ebone;
}
-
+
for (a = 0; a < 2; a++) {
if (a == 1) {
if (flipbone == NULL)
@@ -889,31 +889,31 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
SWAP(EditBone *, flipbone, ebone);
}
}
-
+
totbone++;
newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
-
+
if (do_extrude == true) {
copy_v3_v3(newbone->head, ebone->tail);
copy_v3_v3(newbone->tail, newbone->head);
newbone->parent = ebone;
-
+
newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING); // copies it, in case mirrored bone
-
+
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
}
else {
copy_v3_v3(newbone->head, ebone->head);
copy_v3_v3(newbone->tail, ebone->head);
newbone->parent = ebone->parent;
-
+
newbone->flag = BONE_TIPSEL;
-
+
if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
newbone->flag |= BONE_CONNECTED;
}
}
-
+
newbone->weight = ebone->weight;
newbone->dist = ebone->dist;
newbone->xwidth = ebone->xwidth;
@@ -922,7 +922,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
newbone->rad_tail = ebone->rad_tail;
newbone->segments = 1;
newbone->layer = ebone->layer;
-
+
/* Bendy-Bone parameters */
newbone->roll1 = ebone->roll1;
newbone->roll2 = ebone->roll2;
@@ -937,7 +937,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
-
+
if (flipbone && forked) { // only set if mirror edit
if (strlen(newbone->name) < (MAXBONENAME - 2)) {
if (a == 0) strcat(newbone->name, "_L");
@@ -945,18 +945,18 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
}
}
ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
-
+
/* Add the new bone to the list */
BLI_addtail(arm->edbo, newbone);
if (!first)
first = newbone;
-
+
/* restore ebone if we were flipping */
if (a == 1 && flipbone)
SWAP(EditBone *, flipbone, ebone);
}
}
-
+
/* Deselect the old bone */
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
}
@@ -987,14 +987,14 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
ot->name = "Extrude";
ot->idname = "ARMATURE_OT_extrude";
ot->description = "Create new bones from the selected joints";
-
+
/* api callbacks */
ot->exec = armature_extrude_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "forked", 0, "Forked", "");
}
@@ -1003,16 +1003,16 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
/*op makes a new bone and returns it with its tip selected */
-static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
+static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Object *obedit = CTX_data_edit_object(C);
EditBone *bone;
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
char name[MAXBONENAME];
-
+
RNA_string_get(op->ptr, "name", name);
-
+
copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C)));
/* Get inverse point for head and orientation for tail */
@@ -1022,18 +1022,18 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
copy_m3_m4(obmat, rv3d->viewmat);
else unit_m3(obmat);
-
+
copy_m3_m4(viewmat, obedit->obmat);
mul_m3_m3m3(totmat, obmat, viewmat);
invert_m3_m3(imat, totmat);
-
+
ED_armature_edit_deselect_all(obedit);
-
+
/* Create a bone */
bone = ED_armature_ebone_add(obedit->data, name);
copy_v3_v3(bone->head, curs);
-
+
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
@@ -1051,16 +1051,16 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
ot->name = "Add Bone";
ot->idname = "ARMATURE_OT_bone_primitive_add";
ot->description = "Add a new bone located at the 3D-Cursor";
-
+
/* api callbacks */
ot->exec = armature_bone_primitive_add_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone");
-
+
}
/* ********************** Subdivide *******************************/
@@ -1077,10 +1077,10 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
EditBone *newbone, *tbone;
int cuts, i;
-
+
/* there may not be a number_cuts property defined (for 'simple' subdivide) */
cuts = RNA_int_get(op->ptr, "number_cuts");
-
+
/* loop over all editable bones */
// XXX the old code did this in reverse order though!
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
@@ -1089,37 +1089,37 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
/* compute cut ratio first */
float cutratio = 1.0f / (float)i;
float cutratioI = 1.0f - cutratio;
-
+
float val1[3];
float val2[3];
float val3[3];
-
+
newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv");
*newbone = *ebone;
BLI_addtail(arm->edbo, newbone);
-
+
/* calculate location of newbone->head */
copy_v3_v3(val1, ebone->head);
copy_v3_v3(val2, ebone->tail);
copy_v3_v3(val3, newbone->head);
-
+
val3[0] = val1[0] * cutratio + val2[0] * cutratioI;
val3[1] = val1[1] * cutratio + val2[1] * cutratioI;
val3[2] = val1[2] * cutratio + val2[2] * cutratioI;
-
+
copy_v3_v3(newbone->head, val3);
copy_v3_v3(newbone->tail, ebone->tail);
copy_v3_v3(ebone->tail, newbone->head);
-
+
newbone->rad_head = ((ebone->rad_head * cutratio) + (ebone->rad_tail * cutratioI));
ebone->rad_tail = newbone->rad_head;
-
+
newbone->flag |= BONE_CONNECTED;
newbone->prop = NULL;
ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL);
-
+
/* correct parent bones */
for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
if (tbone->parent == ebone)
@@ -1129,10 +1129,10 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -1144,14 +1144,14 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
ot->name = "Subdivide Multi";
ot->idname = "ARMATURE_OT_subdivide";
ot->description = "Break selected bones into chains of smaller bones";
-
+
/* api callbacks */
ot->exec = armature_subdivide_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* Properties */
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, 1000, "Number of Cuts", "", 1, 10);
/* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 4562329706f..539d56a4ede 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -29,7 +29,7 @@
* \ingroup edarmature
*/
-#include <assert.h>
+#include <assert.h>
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
@@ -92,20 +92,20 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const b
/* Do the rotations */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
float tmat[3][3];
-
+
/* find the current bone's roll matrix */
ED_armature_ebone_to_mat3(ebone, tmat);
-
+
/* transform the roll matrix */
mul_m3_m3m3(tmat, mat3, tmat);
-
+
/* transform the bone */
mul_m4_v3(mat, ebone->head);
mul_m4_v3(mat, ebone->tail);
/* apply the transformed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
-
+
if (do_props) {
ebone->rad_head *= scale;
ebone->rad_tail *= scale;
@@ -180,13 +180,13 @@ void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int cente
mid_v3_v3v3(cent, min, max);
}
}
-
+
/* Do the adjustments */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
sub_v3_v3(ebone->head, cent);
sub_v3_v3(ebone->tail, cent);
}
-
+
/* Turn the list into an armature */
if (obedit == NULL) {
ED_armature_from_edit(arm);
@@ -291,7 +291,7 @@ static const EnumPropertyItem prop_calc_roll_types[] = {
};
-static int armature_calc_roll_exec(bContext *C, wmOperator *op)
+static int armature_calc_roll_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
eCalcRollTypes type = RNA_enum_get(op->ptr, "type");
@@ -318,12 +318,12 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
const float *cursor = ED_view3d_cursor3d_get(scene, v3d);
-
+
invert_m4_m4(ob->imat, ob->obmat);
copy_v3_v3(cursor_local, cursor);
mul_m4_v3(ob->imat, cursor_local);
-
+
/* cursor */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
@@ -392,7 +392,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No region view3d available");
return OPERATOR_CANCELLED;
}
-
+
copy_v3_v3(vec, rv3d->viewinv[2]);
mul_m3_v3(imat, vec);
}
@@ -403,7 +403,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active bone set");
return OPERATOR_CANCELLED;
}
-
+
ED_armature_ebone_to_mat3(ebone, mat);
copy_v3_v3(vec, mat[2]);
}
@@ -414,9 +414,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
mul_m3_v3(imat, vec);
normalize_v3(vec);
}
-
+
if (axis_flip) negate_v3(vec);
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* roll func is a callback which assumes that all is well */
@@ -424,7 +424,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
}
}
-
+
if (arm->flag & ARM_MIRROR_EDIT) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
@@ -435,10 +435,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -448,12 +448,12 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
ot->name = "Recalculate Roll";
ot->idname = "ARMATURE_OT_calculate_roll";
ot->description = "Automatically fix alignment of select bones' axes";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_calc_roll_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -520,10 +520,10 @@ void ARMATURE_OT_roll_clear(wmOperatorType *ot)
/* temporary data-structure for merge/fill bones */
typedef struct EditBonePoint {
struct EditBonePoint *next, *prev;
-
+
EditBone *head_owner; /* EditBone which uses this point as a 'head' point */
EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */
-
+
float vec[3]; /* the actual location of the point in local/EditMode space */
} EditBonePoint;
@@ -532,11 +532,11 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
{
EditBone *curBone, *ebo;
LinkData *ld;
-
+
/* note: this is potentially very slow ... there's got to be a better way */
for (curBone = edbo->first; curBone; curBone = curBone->next) {
short stop = 0;
-
+
/* is this bone contained within any existing chain? (skip if so) */
for (ld = list->first; ld; ld = ld->next) {
for (ebo = ld->data; ebo; ebo = ebo->parent) {
@@ -545,12 +545,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
break;
}
}
-
+
if (stop) break;
}
/* skip current bone if it is part of an existing chain */
if (stop) continue;
-
+
/* is any existing chain part of the chain formed by this bone? */
stop = 0;
for (ebo = curBone->parent; ebo; ebo = ebo->parent) {
@@ -561,12 +561,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list)
break;
}
}
-
+
if (stop) break;
}
/* current bone has already been added to a chain? */
if (stop) continue;
-
+
/* add current bone to a new chain */
ld = MEM_callocN(sizeof(LinkData), "BoneChain");
ld->data = curBone;
@@ -581,14 +581,14 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
EditBonePoint *ebp;
float vec[3];
short found = 0;
-
+
if (eb_tail) {
copy_v3_v3(vec, ebo->tail);
}
else {
copy_v3_v3(vec, ebo->head);
}
-
+
for (ebp = points->first; ebp; ebp = ebp->next) {
if (equals_v3v3(ebp->vec, vec)) {
if (eb_tail) {
@@ -609,11 +609,11 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
}
}
}
-
+
/* allocate a new point if no existing point was related */
if (found == 0) {
ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
-
+
if (eb_tail) {
copy_v3_v3(ebp->vec, ebo->tail);
ebp->tail_owner = ebo;
@@ -622,7 +622,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
copy_v3_v3(ebp->vec, ebo->head);
ebp->head_owner = ebo;
}
-
+
BLI_addtail(points, ebp);
}
}
@@ -647,18 +647,18 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
{
if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL))
fill_add_joint(ebone, 0, &points);
- if (ebone->flag & BONE_TIPSEL)
+ if (ebone->flag & BONE_TIPSEL)
fill_add_joint(ebone, 1, &points);
}
CTX_DATA_END;
-
+
/* the number of joints determines how we fill:
* 1) between joint and cursor (joint=head, cursor=tail)
* 2) between the two joints (order is dependent on active-bone/hierarchy)
* 3+) error (a smarter method involving finding chains needs to be worked out
*/
count = BLI_listbase_count(&points);
-
+
if (count == 0) {
BKE_report(op->reports, RPT_ERROR, "No joints selected");
return OPERATOR_CANCELLED;
@@ -666,14 +666,14 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
else if (count == 1) {
EditBonePoint *ebp;
float curs[3];
-
+
/* Get Points - selected joint */
ebp = points.first;
-
+
/* Get points - cursor (tail) */
invert_m4_m4(obedit->imat, obedit->obmat);
mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d));
-
+
/* Create a bone */
newbone = add_points_bone(obedit, ebp->vec, curs);
}
@@ -681,11 +681,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
EditBonePoint *ebp_a, *ebp_b;
float head[3], tail[3];
short headtail = 0;
-
+
/* check that the points don't belong to the same bone */
ebp_a = (EditBonePoint *)points.first;
ebp_b = ebp_a->next;
-
+
if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != NULL)) ||
((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL)))
{
@@ -693,7 +693,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
BLI_freelistN(&points);
return OPERATOR_CANCELLED;
}
-
+
/* find which one should be the 'head' */
if ((ebp_a->head_owner && ebp_b->head_owner) || (ebp_a->tail_owner && ebp_b->tail_owner)) {
/* use active, nice predictable */
@@ -726,7 +726,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
else if (ebp_b->head_owner) {
headtail = 2;
}
-
+
/* assign head/tail combinations */
if (headtail == 2) {
copy_v3_v3(head, ebp_a->vec);
@@ -736,11 +736,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
copy_v3_v3(head, ebp_b->vec);
copy_v3_v3(tail, ebp_a->vec);
}
-
+
/* add new bone and parent it to the appropriate end */
if (headtail) {
newbone = add_points_bone(obedit, head, tail);
-
+
/* do parenting (will need to set connected flag too) */
if (headtail == 2) {
/* ebp tail or head - tail gets priority */
@@ -775,13 +775,13 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op)
arm->act_edbone = newbone;
newbone->flag |= BONE_TIPSEL;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
-
+
/* free points */
BLI_freelistN(&points);
-
+
return OPERATOR_FINISHED;
}
@@ -791,18 +791,18 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
ot->name = "Fill Between Joints";
ot->idname = "ARMATURE_OT_fill";
ot->description = "Add bone between selected joint(s) and/or 3D-Cursor";
-
+
/* callbacks */
ot->exec = armature_fill_bones_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* --------------------- */
-/* this function merges between two bones, removes them and those in-between,
+/* this function merges between two bones, removes them and those in-between,
* and adjusts the parent relationships for those in-between
*/
static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains)
@@ -811,7 +811,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
EditBone *ebo, *ebone, *newbone;
LinkData *chain;
float head[3], tail[3];
-
+
/* check if same bone */
if (start == end) {
if (G.debug & G_DEBUG) {
@@ -819,7 +819,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
printf("\tstart = %s, end = %s\n", start->name, end->name);
}
}
-
+
/* step 1: add a new bone
* - head = head/tail of start (default head)
* - tail = head/tail of end (default tail)
@@ -843,17 +843,17 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
/* TODO, copy more things to the new bone */
newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE |
BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
-
- /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
+
+ /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
* - potentially several tips for side chains leading to some tree exist...
*/
for (chain = chains->first; chain; chain = chain->next) {
- /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're
- * merging (need to stop in this case to avoid corrupting this chain too!)
+ /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're
+ * merging (need to stop in this case to avoid corrupting this chain too!)
*/
for (ebone = chain->data; (ebone) && (ebone != end); ebone = ebone->parent) {
short found = 0;
-
+
/* check if this bone is parented to one in the merging chain
* ! WATCHIT: must only go check until end of checking chain
*/
@@ -865,23 +865,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
break;
}
}
-
+
/* carry on to the next tip now */
- if (found)
+ if (found)
break;
}
}
-
+
/* step 2b: parent child of end to newbone (child from this chain) */
if (endchild)
endchild->parent = newbone;
-
+
/* step 3: delete all bones between and including start and end */
for (ebo = end; ebo; ebo = ebone) {
ebone = (ebo == start) ? (NULL) : (ebo->parent);
bone_free(arm, ebo);
}
-
+
newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
ED_armature_edit_sync_selection(arm->edbo);
}
@@ -892,33 +892,33 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
bArmature *arm = (obedit) ? obedit->data : NULL;
short type = RNA_enum_get(op->ptr, "type");
-
+
/* sanity checks */
if (ELEM(NULL, obedit, arm))
return OPERATOR_CANCELLED;
-
+
/* for now, there's only really one type of merging that's performed... */
if (type == 1) {
/* go down chains, merging bones */
ListBase chains = {NULL, NULL};
LinkData *chain, *nchain;
EditBone *ebo;
-
+
armature_tag_select_mirrored(arm);
-
+
/* get chains (ends on chains) */
chains_find_tips(arm->edbo, &chains);
if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;
-
+
/* each 'chain' is the last bone in the chain (with no children) */
for (chain = chains.first; chain; chain = nchain) {
EditBone *bstart = NULL, *bend = NULL;
EditBone *bchild = NULL, *child = NULL;
-
+
/* temporarily remove chain from list of chains */
nchain = chain->next;
BLI_remlink(&chains, chain);
-
+
/* only consider bones that are visible and selected */
for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) {
/* check if visible + selected */
@@ -931,37 +931,37 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
bend = ebo;
bchild = child;
}
- else
+ else
bstart = ebo;
}
else {
/* chain is broken... merge any continous segments then clear */
if (bstart && bend)
bones_merge(obedit, bstart, bend, bchild, &chains);
-
+
bstart = NULL;
bend = NULL;
bchild = NULL;
}
}
-
+
/* merge from bstart to bend if something not merged */
if (bstart && bend)
bones_merge(obedit, bstart, bend, bchild, &chains);
-
+
/* put back link */
BLI_insertlinkbefore(&chains, nchain, chain);
}
-
+
armature_tag_unselect(arm);
-
+
BLI_freelistN(&chains);
}
-
+
/* updates */
ED_armature_edit_sync_selection(arm->edbo);
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -976,15 +976,15 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
ot->name = "Merge Bones";
ot->idname = "ARMATURE_OT_merge";
ot->description = "Merge continuous chains of selected bones";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_merge_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", "");
}
@@ -996,41 +996,41 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
* easy to retrieve any hierarchical/chain relationships which are necessary for
* this to be done easily.
*/
-
+
/* helper to clear BONE_TRANSFORM flags */
static void armature_clear_swap_done_flags(bArmature *arm)
{
EditBone *ebone;
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
ebone->flag &= ~BONE_TRANSFORM;
}
}
-static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
+static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
ListBase chains = {NULL, NULL};
LinkData *chain;
-
+
/* get chains of bones (ends on chains) */
chains_find_tips(arm->edbo, &chains);
if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;
-
+
/* ensure that mirror bones will also be operated on */
armature_tag_select_mirrored(arm);
-
- /* clear BONE_TRANSFORM flags
+
+ /* clear BONE_TRANSFORM flags
* - used to prevent duplicate/canceling operations from occurring [#34123]
* - BONE_DONE cannot be used here as that's already used for mirroring
*/
armature_clear_swap_done_flags(arm);
-
+
/* loop over chains, only considering selected and visible bones */
for (chain = chains.first; chain; chain = chain->next) {
EditBone *ebo, *child = NULL, *parent = NULL;
-
+
/* loop over bones in chain */
for (ebo = chain->data; ebo; ebo = parent) {
/* parent is this bone's original parent
@@ -1038,14 +1038,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
* but the value of ebo->parent may change here...
*/
parent = ebo->parent;
-
+
/* skip bone if already handled... [#34123] */
if ((ebo->flag & BONE_TRANSFORM) == 0) {
/* only if selected and editable */
if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
/* swap head and tail coordinates */
swap_v3_v3(ebo->head, ebo->tail);
-
+
/* do parent swapping:
* - use 'child' as new parent
* - connected flag is only set if points are coincidental
@@ -1055,44 +1055,44 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
ebo->flag |= BONE_CONNECTED;
else
ebo->flag &= ~BONE_CONNECTED;
-
- /* get next bones
+
+ /* get next bones
* - child will become the new parent of next bone
*/
child = ebo;
}
else {
- /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it
+ /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it
* as it will be facing in opposite direction
*/
if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) {
ebo->parent = NULL;
ebo->flag &= ~BONE_CONNECTED;
}
-
+
/* get next bones
- * - child will become new parent of next bone (not swapping occurred,
+ * - child will become new parent of next bone (not swapping occurred,
* so set to NULL to prevent infinite-loop)
*/
child = NULL;
}
-
+
/* tag as done (to prevent double-swaps) */
ebo->flag |= BONE_TRANSFORM;
}
}
}
-
+
/* free chains */
BLI_freelistN(&chains);
-
+
/* clear temp flags */
armature_clear_swap_done_flags(arm);
armature_tag_unselect(arm);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1102,11 +1102,11 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
ot->name = "Switch Direction";
ot->idname = "ARMATURE_OT_switch_direction";
ot->description = "Change the direction that a chain of bones points in (head <-> tail swap)";
-
+
/* api callbacks */
ot->exec = armature_switch_direction_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1117,10 +1117,10 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
static void fix_connected_bone(EditBone *ebone)
{
float diff[3];
-
+
if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || equals_v3v3(ebone->parent->tail, ebone->head))
return;
-
+
/* if the parent has moved we translate child's head and tail accordingly */
sub_v3_v3v3(diff, ebone->parent->tail, ebone->head);
add_v3_v3(ebone->head, diff);
@@ -1131,14 +1131,14 @@ static void fix_connected_bone(EditBone *ebone)
static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
{
EditBone *selbone;
-
+
for (selbone = edbo->first; selbone; selbone = selbone->next) {
if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) {
fix_connected_bone(selbone);
fix_editbone_connected_children(edbo, selbone);
}
}
-}
+}
static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actbone)
{
@@ -1153,21 +1153,21 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb
mul_v3_fl(actboneaxis, length);
add_v3_v3v3(selbone->tail, selbone->head, actboneaxis);
selbone->roll = actbone->roll;
-
+
/* if the bone being aligned has connected descendants they must be moved
* according to their parent new position, otherwise they would be left
* in an inconsistent state: connected but away from the parent*/
fix_editbone_connected_children(edbo, selbone);
}
-static int armature_align_bones_exec(bContext *C, wmOperator *op)
+static int armature_align_bones_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
EditBone *actbone = CTX_data_active_bone(C);
EditBone *actmirb = NULL;
int num_selected_bones;
-
+
/* there must be an active bone */
if (actbone == NULL) {
BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
@@ -1175,28 +1175,28 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
}
else if (arm->flag & ARM_MIRROR_EDIT) {
/* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
- * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
+ * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
* This is useful for arm-chains, for example parenting lower arm to upper arm
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL)
actmirb = actbone;
}
-
- /* if there is only 1 selected bone, we assume that that is the active bone,
+
+ /* if there is only 1 selected bone, we assume that that is the active bone,
* since a user will need to have clicked on a bone (thus selecting it) to make it active
*/
num_selected_bones = CTX_DATA_COUNT(C, selected_editable_bones);
if (num_selected_bones <= 1) {
/* When only the active bone is selected, and it has a parent,
- * align it to the parent, as that is the only possible outcome.
+ * align it to the parent, as that is the only possible outcome.
*/
if (actbone->parent) {
bone_align_to_bone(arm->edbo, actbone, actbone->parent);
-
+
if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
bone_align_to_bone(arm->edbo, actmirb, actmirb->parent);
@@ -1207,11 +1207,11 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* Align 'selected' bones to the active one
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
- * - since the active one (and/or its mirror) will also be selected, we also need
+ * - since the active one (and/or its mirror) will also be selected, we also need
* to check that we are not trying to operate on them, since such an operation
* would cause errors
*/
-
+
/* align selected bones to the active one */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
@@ -1229,7 +1229,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1239,11 +1239,11 @@ void ARMATURE_OT_align(wmOperatorType *ot)
ot->name = "Align Bones";
ot->idname = "ARMATURE_OT_align";
ot->description = "Align selected bones to the active bone (or to their parent)";
-
+
/* api callbacks */
ot->exec = armature_align_bones_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1310,9 +1310,9 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
/* cancel if nothing selected */
if (CTX_DATA_COUNT(C, selected_bones) == 0)
return OPERATOR_CANCELLED;
-
+
armature_select_mirrored(arm);
-
+
BKE_pose_channels_remove(obedit, armature_delete_ebone_cb, arm);
for (curBone = arm->edbo->first; curBone; curBone = ebone_next) {
@@ -1325,10 +1325,10 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
}
}
}
-
+
if (!changed)
return OPERATOR_CANCELLED;
-
+
ED_armature_edit_sync_selection(arm->edbo);
BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose);
@@ -1343,12 +1343,12 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
ot->name = "Delete Selected Bone(s)";
ot->idname = "ARMATURE_OT_delete";
ot->description = "Remove selected bones from the armature";
-
+
/* api callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = armature_delete_selected_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1552,11 +1552,11 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
ot->name = "Hide Selected Bones";
ot->idname = "ARMATURE_OT_hide";
ot->description = "Tag selected bones to not be visible in Edit Mode";
-
+
/* api callbacks */
ot->exec = armature_hide_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1570,7 +1570,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op)
bArmature *arm = obedit->data;
EditBone *ebone;
const bool select = RNA_boolean_get(op->ptr, "select");
-
+
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_HIDDEN_A) {
@@ -1595,11 +1595,11 @@ void ARMATURE_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal Bones";
ot->idname = "ARMATURE_OT_reveal";
ot->description = "Reveal all bones hidden in Edit Mode";
-
+
/* api callbacks */
ot->exec = armature_reveal_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 36d571e1be8..288d9f0f86b 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -157,25 +157,25 @@ void SKETCH_OT_select(struct wmOperatorType *ot);
/* Temporary data linking PoseChannels with the F-Curves they affect */
typedef struct tPChanFCurveLink {
struct tPChanFCurveLink *next, *prev;
-
+
ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */
struct bPoseChannel *pchan; /* Pose Channel which data is attached to */
-
+
char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */
-
+
float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */
float oldrot[3];
float oldscale[3];
float oldquat[4];
float oldangle;
float oldaxis[3];
-
+
float roll1, roll2; /* old bbone values (to be restored along with the transform properties) */
float curveInX, curveInY; /* (NOTE: we haven't renamed these this time, as their names are already long enough) */
float curveOutX, curveOutY;
float ease1, ease2;
float scaleIn, scaleOut;
-
+
struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */
} tPChanFCurveLink;
diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c
index d5ed1380a7e..c49e9a2b820 100644
--- a/source/blender/editors/armature/armature_naming.c
+++ b/source/blender/editors/armature/armature_naming.c
@@ -104,15 +104,15 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
{
bConstraint *curcon;
bConstraintTarget *ct;
-
+
for (curcon = conlist->first; curcon; curcon = curcon->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon);
ListBase targets = {NULL, NULL};
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob) {
if (STREQ(ct->subtarget, oldname)) {
@@ -120,11 +120,11 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char *
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(curcon, &targets, 0);
}
-
+
/* action constraints */
if (curcon->type == CONSTRAINT_TYPE_ACTION) {
bActionConstraint *actcon = (bActionConstraint *)curcon->data;
@@ -141,19 +141,19 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
Object *ob;
char newname[MAXBONENAME];
char oldname[MAXBONENAME];
-
+
/* names better differ! */
if (!STREQLEN(oldnamep, newnamep, MAXBONENAME)) {
-
+
/* we alter newname string... so make copy */
BLI_strncpy(newname, newnamep, MAXBONENAME);
/* we use oldname for search... so make copy */
BLI_strncpy(oldname, oldnamep, MAXBONENAME);
-
+
/* now check if we're in editmode, we need to find the unique name */
if (arm->edbo) {
EditBone *eBone = ED_armature_ebone_find_name(arm->edbo, oldname);
-
+
if (eBone) {
ED_armature_ebone_unique_name(arm->edbo, newname, NULL);
BLI_strncpy(eBone->name, newname, MAXBONENAME);
@@ -164,7 +164,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
else {
Bone *bone = BKE_armature_find_bone_name(arm, oldname);
-
+
if (bone) {
unique_bone_name(arm, newname);
BLI_strncpy(bone->name, newname, MAXBONENAME);
@@ -173,15 +173,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
return;
}
}
-
+
/* do entire dbase - objects */
for (ob = G.main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
-
+
/* we have the object using the armature */
if (arm == ob->data) {
Object *cob;
-
+
/* Rename the pose channel, if it exists */
if (ob->pose) {
bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname);
@@ -203,7 +203,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
BLI_assert(BKE_pose_channels_is_valid(ob->pose) == true);
}
-
+
/* Update any object constraints to use the new bone name */
for (cob = G.main->object.first; cob; cob = cob->id.next) {
if (cob->constraints.first)
@@ -216,7 +216,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent->data == arm)) {
if (ob->partype == PARBONE) {
@@ -225,14 +225,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
BLI_strncpy(ob->parsubstr, newname, MAXBONENAME);
}
}
-
+
if (modifiers_usesArmature(ob, arm)) {
bDeformGroup *dg = defgroup_find_name(ob, oldname);
if (dg) {
BLI_strncpy(dg->name, newname, MAXBONENAME);
}
}
-
+
/* fix modifiers that might be using this name */
for (md = ob->modifiers.first; md; md = md->next) {
switch (md->type) {
@@ -265,16 +265,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
}
}
-
+
/* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since
* other ID-blocks may have drivers referring to this bone [#29822]
*/
// XXX: the ID here is for armatures, but most bone drivers are actually on the object instead...
{
-
+
BKE_animdata_fix_paths_rename_all(&arm->id, "pose.bones", oldname, newname);
}
-
+
/* correct view locking */
{
bScreen *screen;
@@ -376,7 +376,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op)
ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
BLI_freelistN(&bones_names);
-
+
/* since we renamed stuff... */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -396,11 +396,11 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
ot->name = "Flip Names";
ot->idname = "ARMATURE_OT_flip_names";
ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones";
-
+
/* api callbacks */
ot->exec = armature_flip_names_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -416,12 +416,12 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
bArmature *arm;
char newname[MAXBONENAME];
short axis = RNA_enum_get(op->ptr, "type");
-
+
/* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
arm = ob->data;
-
+
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
@@ -430,13 +430,13 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op)
ED_armature_bone_rename(arm, ebone->name, newname);
}
CTX_DATA_END;
-
+
/* since we renamed stuff... */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -448,20 +448,20 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "AutoName by Axis";
ot->idname = "ARMATURE_OT_autoside_names";
ot->description = "Automatically renames the selected bones according to which side of the target axis they fall on";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_autoside_names_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* settings */
ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with");
}
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index e63d197ca15..31a22b41f54 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -46,16 +46,16 @@ void ED_operatortypes_armature(void)
{
/* EDIT ARMATURE */
WM_operatortype_append(ARMATURE_OT_bone_primitive_add);
-
+
WM_operatortype_append(ARMATURE_OT_align);
WM_operatortype_append(ARMATURE_OT_calculate_roll);
WM_operatortype_append(ARMATURE_OT_roll_clear);
WM_operatortype_append(ARMATURE_OT_switch_direction);
WM_operatortype_append(ARMATURE_OT_subdivide);
-
+
WM_operatortype_append(ARMATURE_OT_parent_set);
WM_operatortype_append(ARMATURE_OT_parent_clear);
-
+
WM_operatortype_append(ARMATURE_OT_select_all);
WM_operatortype_append(ARMATURE_OT_select_mirror);
WM_operatortype_append(ARMATURE_OT_select_more);
@@ -77,10 +77,10 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(ARMATURE_OT_merge);
WM_operatortype_append(ARMATURE_OT_separate);
WM_operatortype_append(ARMATURE_OT_split);
-
+
WM_operatortype_append(ARMATURE_OT_autoside_names);
WM_operatortype_append(ARMATURE_OT_flip_names);
-
+
WM_operatortype_append(ARMATURE_OT_layers_show_all);
WM_operatortype_append(ARMATURE_OT_armature_layers);
WM_operatortype_append(ARMATURE_OT_bone_layers);
@@ -98,19 +98,19 @@ void ED_operatortypes_armature(void)
/* POSE */
WM_operatortype_append(POSE_OT_hide);
WM_operatortype_append(POSE_OT_reveal);
-
+
WM_operatortype_append(POSE_OT_armature_apply);
WM_operatortype_append(POSE_OT_visual_transform_apply);
-
+
WM_operatortype_append(POSE_OT_rot_clear);
WM_operatortype_append(POSE_OT_loc_clear);
WM_operatortype_append(POSE_OT_scale_clear);
WM_operatortype_append(POSE_OT_transforms_clear);
WM_operatortype_append(POSE_OT_user_transforms_clear);
-
+
WM_operatortype_append(POSE_OT_copy);
WM_operatortype_append(POSE_OT_paste);
-
+
WM_operatortype_append(POSE_OT_select_all);
WM_operatortype_append(POSE_OT_select_parent);
@@ -119,7 +119,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_select_constraint_target);
WM_operatortype_append(POSE_OT_select_grouped);
WM_operatortype_append(POSE_OT_select_mirror);
-
+
WM_operatortype_append(POSE_OT_group_add);
WM_operatortype_append(POSE_OT_group_remove);
WM_operatortype_append(POSE_OT_group_move);
@@ -128,36 +128,36 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_group_unassign);
WM_operatortype_append(POSE_OT_group_select);
WM_operatortype_append(POSE_OT_group_deselect);
-
+
WM_operatortype_append(POSE_OT_paths_calculate);
WM_operatortype_append(POSE_OT_paths_update);
WM_operatortype_append(POSE_OT_paths_clear);
-
+
WM_operatortype_append(POSE_OT_autoside_names);
WM_operatortype_append(POSE_OT_flip_names);
-
+
WM_operatortype_append(POSE_OT_rotation_mode_set);
WM_operatortype_append(POSE_OT_quaternions_flip);
-
+
WM_operatortype_append(POSE_OT_bone_layers);
-
+
WM_operatortype_append(POSE_OT_propagate);
-
+
/* POSELIB */
WM_operatortype_append(POSELIB_OT_browse_interactive);
WM_operatortype_append(POSELIB_OT_apply_pose);
-
+
WM_operatortype_append(POSELIB_OT_pose_add);
WM_operatortype_append(POSELIB_OT_pose_remove);
WM_operatortype_append(POSELIB_OT_pose_rename);
WM_operatortype_append(POSELIB_OT_pose_move);
-
+
WM_operatortype_append(POSELIB_OT_new);
WM_operatortype_append(POSELIB_OT_unlink);
-
+
WM_operatortype_append(POSELIB_OT_action_sanitize);
-
+
/* POSE SLIDING */
WM_operatortype_append(POSE_OT_push);
WM_operatortype_append(POSE_OT_relax);
@@ -199,11 +199,11 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
{
wmKeyMap *keymap;
wmKeyMapItem *kmi;
-
+
/* Armature ------------------------ */
keymap = WM_keymap_find(keyconf, "Armature", 0, 0);
keymap->poll = ED_operator_editarmature;
-
+
/* Armature -> Etch-A-Ton ------------------------ */
WM_keymap_add_item(keymap, "SKETCH_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0);
@@ -231,14 +231,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_roll_clear", RKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_bone_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
@@ -246,14 +246,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "extend", false);
-
+
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
RNA_boolean_set(kmi->ptr, "extend", false);
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -269,7 +269,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", DELKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0);
@@ -280,19 +280,19 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_split", YKEY, KM_PRESS, 0, 0);
-
+
WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, 0, 0);
-
+
/* set flags */
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0);
-
+
/* armature/bone layers */
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
-
+
/* special transforms: */
/* 1) envelope/b-bone size */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
@@ -303,7 +303,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* 3) set roll */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", RKEY, KM_PRESS, KM_CTRL, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL);
-
+
/* menus */
WM_keymap_add_menu(keymap, "VIEW3D_MT_armature_specials", WKEY, KM_PRESS, 0, 0);
@@ -311,36 +311,36 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* only set in posemode, by space_view3d listener */
keymap = WM_keymap_find(keyconf, "Pose", 0, 0);
keymap->poll = ED_operator_posemode;
-
+
/* set parent and add object are object-based operators, but we make them
* available here because it's useful to do in pose mode too */
WM_keymap_add_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
-
+
kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0);
RNA_boolean_set(kmi->ptr, "unselected", false);
kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", true);
WM_keymap_add_item(keymap, "POSE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_apply", AKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* TODO: clear pose */
WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_quaternions_flip", FKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_rotation_mode_set", RKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "flipped", false);
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "flipped", true);
-
+
#ifdef __APPLE__
WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0);
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0);
@@ -362,7 +362,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
RNA_boolean_set(kmi->ptr, "extend", true);
-
+
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
RNA_boolean_set(kmi->ptr, "extend", false);
@@ -373,14 +373,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/ KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_group", GKEY, KM_PRESS, KM_CTRL, 0);
-
+
/* set flags */
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
@@ -390,25 +390,25 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
-
+
/* special transforms: */
/* 1) envelope/b-bone size */
kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE);
-
+
/* keyframes management */
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
-
+
/* Pose -> PoseLib ------------- */
/* only set in posemode, by space_view3d listener */
WM_keymap_add_item(keymap, "POSELIB_OT_browse_interactive", LKEY, KM_PRESS, KM_CTRL, 0);
-
+
WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0);
WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
-
+
/* Pose -> Pose Sliding ------------- */
/* only set in posemode, by space_view3d listener */
WM_keymap_add_item(keymap, "POSE_OT_push", EKEY, KM_PRESS, KM_CTRL, 0);
diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c
index 3c272d52d1c..95c8b1d5460 100644
--- a/source/blender/editors/armature/armature_relations.c
+++ b/source/blender/editors/armature/armature_relations.c
@@ -107,7 +107,7 @@ static void joined_armature_fix_links_constraints(
bActionConstraint *data = con->data;
if (data->act) {
- BKE_action_fix_paths_rename(&tarArm->id, data->act, "pose.bones[",
+ BKE_action_fix_paths_rename(&tarArm->id, data->act, "pose.bones[",
pchan->name, curbone->name, 0, 0, false);
}
}
@@ -119,7 +119,7 @@ static void joined_armature_fix_links_constraints(
typedef struct tJoinArmature_AdtFixData {
Object *srcArm;
Object *tarArm;
-
+
GHash *names_map;
} tJoinArmature_AdtFixData;
@@ -132,34 +132,34 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
tJoinArmature_AdtFixData *afd = (tJoinArmature_AdtFixData *)user_data;
ID *src_id = &afd->srcArm->id;
ID *dst_id = &afd->tarArm->id;
-
+
GHashIterator gh_iter;
-
+
/* Fix paths - If this is the target object, it will have some "dirty" paths */
if ((id == src_id) && strstr(fcu->rna_path, "pose.bones[")) {
GHASH_ITER(gh_iter, afd->names_map) {
const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
-
+
/* only remap if changed; this still means there will be some waste if there aren't many drivers/keys */
if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) {
fcu->rna_path = BKE_animsys_fix_rna_path_rename(id, fcu->rna_path, "pose.bones",
old_name, new_name, 0, 0, false);
-
- /* we don't want to apply a second remapping on this driver now,
+
+ /* we don't want to apply a second remapping on this driver now,
* so stop trying names, but keep fixing drivers
*/
break;
}
}
}
-
-
+
+
/* Driver targets */
if (fcu->driver) {
ChannelDriver *driver = fcu->driver;
DriverVar *dvar;
-
+
/* Fix driver references to invalid ID's */
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
/* only change the used targets, since the others will need fixing manually anyway */
@@ -168,7 +168,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
/* change the ID's used... */
if (dtar->id == src_id) {
dtar->id = dst_id;
-
+
/* also check on the subtarget...
* XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own
* little twists so that we know that it isn't going to clobber the wrong data
@@ -177,7 +177,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data
GHASH_ITER(gh_iter, afd->names_map) {
const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
-
+
/* only remap if changed */
if (!STREQ(old_name, new_name)) {
if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
@@ -207,7 +207,7 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr
Object *ob;
bPose *pose;
bPoseChannel *pchant;
-
+
/* let's go through all objects in database */
for (ob = bmain->object.first; ob; ob = ob->id.next) {
/* do some object-type specific things */
@@ -217,12 +217,12 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr
joined_armature_fix_links_constraints(tarArm, srcArm, pchan, curbone, &pchant->constraints);
}
}
-
+
/* fix object-level constraints */
if (ob != srcArm) {
joined_armature_fix_links_constraints(tarArm, srcArm, pchan, curbone, &ob->constraints);
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent == srcArm)) {
/* Is object parented to a bone of this src armature? */
@@ -232,7 +232,7 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr
BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr));
}
}
-
+
/* make tar armature be new parent */
ob->parent = tarArm;
}
@@ -251,13 +251,13 @@ int join_armature_exec(bContext *C, wmOperator *op)
EditBone *curbone;
float mat[4][4], oimat[4][4];
bool ok = false;
-
+
/* Ensure we're not in editmode and that the active object is an armature*/
if (!ob || ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
if (!arm || arm->edbo)
return OPERATOR_CANCELLED;
-
+
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
if (base->object == ob) {
@@ -275,7 +275,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
/* Get editbones of active armature to add editbones to */
ED_armature_to_edit(arm);
-
+
/* get pose of active object and move it out of posemode */
pose = ob->pose;
ob->mode &= ~OB_MODE_POSE;
@@ -285,36 +285,36 @@ int join_armature_exec(bContext *C, wmOperator *op)
if ((base->object->type == OB_ARMATURE) && (base->object != ob)) {
tJoinArmature_AdtFixData afd = {NULL};
bArmature *curarm = base->object->data;
-
+
/* we assume that each armature datablock is only used in a single place */
BLI_assert(ob->data != base->object->data);
-
+
/* init callback data for fixing up AnimData links later */
afd.srcArm = base->object;
afd.tarArm = ob;
afd.names_map = BLI_ghash_str_new("join_armature_adt_fix");
-
+
/* Make a list of editbones in current armature */
ED_armature_to_edit(base->object->data);
-
+
/* Get Pose of current armature */
opose = base->object->pose;
base->object->mode &= ~OB_MODE_POSE;
//BASACT->flag &= ~OB_MODE_POSE;
-
+
/* Find the difference matrix */
invert_m4_m4(oimat, ob->obmat);
mul_m4_m4m4(mat, oimat, base->object->obmat);
-
+
/* Copy bones and posechannels from the object to the edit armature */
for (pchan = opose->chanbase.first; pchan; pchan = pchann) {
pchann = pchan->next;
curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name);
-
+
/* Get new name */
ED_armature_ebone_unique_name(arm->edbo, curbone->name, NULL);
BLI_ghash_insert(afd.names_map, BLI_strdup(pchan->name), curbone->name);
-
+
/* Transform the bone */
{
float premat[4][4];
@@ -322,48 +322,48 @@ int join_armature_exec(bContext *C, wmOperator *op)
float difmat[4][4];
float imat[4][4];
float temp[3][3];
-
+
/* Get the premat */
ED_armature_ebone_to_mat3(curbone, temp);
-
+
unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */
mul_m4_m3m4(premat, temp, mat);
-
+
mul_m4_v3(mat, curbone->head);
mul_m4_v3(mat, curbone->tail);
-
+
/* Get the postmat */
ED_armature_ebone_to_mat3(curbone, temp);
copy_m4_m3(postmat, temp);
-
+
/* Find the roll */
invert_m4_m4(imat, premat);
mul_m4_m4m4(difmat, imat, postmat);
-
+
curbone->roll -= atan2f(difmat[2][0], difmat[2][2]);
}
-
+
/* Fix Constraints and Other Links to this Bone and Armature */
joined_armature_fix_links(bmain, ob, base->object, pchan, curbone);
-
+
/* Rename pchan */
BLI_strncpy(pchan->name, curbone->name, sizeof(pchan->name));
-
+
/* Jump Ship! */
BLI_remlink(curarm->edbo, curbone);
BLI_addtail(arm->edbo, curbone);
-
+
BLI_remlink(&opose->chanbase, pchan);
BLI_addtail(&pose->chanbase, pchan);
BKE_pose_channels_hash_free(opose);
BKE_pose_channels_hash_free(pose);
}
-
+
/* Fix all the drivers (and animation data) */
BKE_fcurves_main_cb(bmain, joined_armature_fix_animdata_cb, &afd);
BLI_ghash_free(afd.names_map, MEM_freeN, NULL);
-
- /* Only copy over animdata now, after all the remapping has been done,
+
+ /* Only copy over animdata now, after all the remapping has been done,
* so that we don't have to worry about ambiguities re which armature
* a bone came from!
*/
@@ -377,7 +377,7 @@ int join_armature_exec(bContext *C, wmOperator *op)
BKE_animdata_merge_copy(&ob->id, &base->object->id, ADT_MERGECOPY_KEEP_DST, false);
}
}
-
+
if (curarm->adt) {
if (arm->adt == NULL) {
/* no animdata, so just use a copy of the whole thing */
@@ -388,20 +388,20 @@ int join_armature_exec(bContext *C, wmOperator *op)
BKE_animdata_merge_copy(&arm->id, &curarm->id, ADT_MERGECOPY_KEEP_DST, false);
}
}
-
+
/* Free the old object data */
ED_base_object_free_and_unlink(bmain, scene, base);
}
}
CTX_DATA_END;
-
+
DAG_relations_tag_update(bmain); /* because we removed object(s) */
ED_armature_from_edit(arm);
ED_armature_edit_free(arm);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
-
+
return OPERATOR_FINISHED;
}
@@ -414,11 +414,11 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
bPoseChannel *pchan;
bConstraint *con;
ListBase *opchans, *npchans;
-
+
/* get reference to list of bones in original and new armatures */
opchans = &origArm->pose->chanbase;
npchans = &newArm->pose->chanbase;
-
+
/* let's go through all objects in database */
for (ob = G.main->object.first; ob; ob = ob->id.next) {
/* do some object-type specific things */
@@ -428,11 +428,11 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
@@ -459,18 +459,18 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
}
-
+
/* fix object-level constraints */
if (ob != origArm) {
for (con = ob->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
@@ -489,14 +489,14 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
}
-
+
if (cti->flush_constraint_targets) {
cti->flush_constraint_targets(con, &targets, 0);
}
}
}
}
-
+
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent == origArm)) {
/* Is object parented to a bone of this src armature? */
@@ -509,31 +509,31 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
}
}
-/* Helper function for armature separating - remove certain bones from the given armature
+/* Helper function for armature separating - remove certain bones from the given armature
* sel: remove selected bones from the armature, otherwise the unselected bones are removed
* (ob is not in editmode)
*/
-static void separate_armature_bones(Object *ob, short sel)
+static void separate_armature_bones(Object *ob, short sel)
{
bArmature *arm = (bArmature *)ob->data;
bPoseChannel *pchan, *pchann;
EditBone *curbone;
-
+
/* make local set of editbones to manipulate here */
ED_armature_to_edit(arm);
-
+
/* go through pose-channels, checking if a bone should be removed */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) {
pchann = pchan->next;
curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
-
+
/* check if bone needs to be removed */
if ( (sel && (curbone->flag & BONE_SELECTED)) ||
(!sel && !(curbone->flag & BONE_SELECTED)) )
{
EditBone *ebo;
bPoseChannel *pchn;
-
+
/* clear the bone->parent var of any bone that had this as its parent */
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
if (ebo->parent == curbone) {
@@ -542,23 +542,23 @@ static void separate_armature_bones(Object *ob, short sel)
ebo->flag &= ~BONE_CONNECTED;
}
}
-
+
/* clear the pchan->parent var of any pchan that had this as its parent */
for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) {
if (pchn->parent == pchan)
pchn->parent = NULL;
}
-
+
/* free any of the extra-data this pchan might have */
BKE_pose_channel_free(pchan);
BKE_pose_channels_hash_free(ob->pose);
-
+
/* get rid of unneeded bone */
bone_free(arm, curbone);
BLI_freelinkN(&ob->pose->chanbase, pchan);
}
}
-
+
/* exit editmode (recalculates pchans too) */
ED_armature_from_edit(ob->data);
ED_armature_edit_free(ob->data);
@@ -572,14 +572,14 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
Object *obedit = CTX_data_edit_object(C);
Object *oldob, *newob;
Base *oldbase, *newbase;
-
+
/* sanity checks */
if (obedit == NULL)
return OPERATOR_CANCELLED;
-
+
/* set wait cursor in case this takes a while */
WM_cursor_wait(1);
-
+
/* we are going to do this as follows (unlike every other instance of separate):
* 1. exit editmode +posemode for active armature/base. Take note of what this is.
* 2. duplicate base - BASACT is the new one now
@@ -596,41 +596,41 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
else base->flag &= ~SELECT;
}
CTX_DATA_END;
-
+
/* 1) store starting settings and exit editmode */
oldob = obedit;
oldbase = BASACT;
oldob->mode &= ~OB_MODE_POSE;
//oldbase->flag &= ~OB_POSEMODE;
-
+
ED_armature_from_edit(obedit->data);
ED_armature_edit_free(obedit->data);
-
+
/* 2) duplicate base */
newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
DAG_relations_tag_update(bmain);
newob = newbase->object;
newbase->flag &= ~SELECT;
-
-
+
+
/* 3) remove bones that shouldn't still be around on both armatures */
separate_armature_bones(oldob, 1);
separate_armature_bones(newob, 0);
-
-
+
+
/* 4) fix links before depsgraph flushes */ // err... or after?
separated_armature_fix_links(oldob, newob);
-
+
DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
-
-
+
+
/* 5) restore original conditions */
obedit = oldob;
-
+
ED_armature_to_edit(obedit->data);
-
+
/* parents tips remain selected when connected children are removed. */
ED_armature_edit_deselect_all(obedit);
@@ -638,10 +638,10 @@ static int separate_armature_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
-
+
/* recalc/redraw + cleanup */
WM_cursor_wait(0);
-
+
return OPERATOR_FINISHED;
}
@@ -651,12 +651,12 @@ void ARMATURE_OT_separate(wmOperatorType *ot)
ot->name = "Separate Bones";
ot->idname = "ARMATURE_OT_separate";
ot->description = "Isolate selected bones into a separate armature";
-
+
/* callbacks */
ot->invoke = WM_operator_confirm;
ot->exec = separate_armature_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -680,13 +680,13 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
{
EditBone *ebone;
float offset[3];
-
+
if ((selbone->parent) && (selbone->flag & BONE_CONNECTED))
selbone->parent->flag &= ~(BONE_TIPSEL);
-
+
/* make actbone the parent of selbone */
selbone->parent = actbone;
-
+
/* in actbone tree we cannot have a loop */
for (ebone = actbone->parent; ebone; ebone = ebone->parent) {
if (ebone->parent == selbone) {
@@ -694,21 +694,21 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
ebone->flag &= ~BONE_CONNECTED;
}
}
-
+
if (mode == ARM_PAR_CONNECT) {
/* Connected: Child bones will be moved to the parent tip */
selbone->flag |= BONE_CONNECTED;
sub_v3_v3v3(offset, actbone->tail, selbone->head);
-
+
copy_v3_v3(selbone->head, actbone->tail);
selbone->rad_head = actbone->rad_tail;
-
+
add_v3_v3(selbone->tail, offset);
-
+
/* offset for all its children */
for (ebone = edbo->first; ebone; ebone = ebone->next) {
EditBone *par;
-
+
for (par = ebone->parent; par; par = par->parent) {
if (par == selbone) {
add_v3_v3(ebone->head, offset);
@@ -731,14 +731,14 @@ static const EnumPropertyItem prop_editarm_make_parent_types[] = {
{0, NULL, 0, NULL, NULL}
};
-static int armature_parent_set_exec(bContext *C, wmOperator *op)
+static int armature_parent_set_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
EditBone *actbone = CTX_data_active_bone(C);
EditBone *actmirb = NULL;
short val = RNA_enum_get(op->ptr, "type");
-
+
/* there must be an active bone */
if (actbone == NULL) {
BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone");
@@ -746,27 +746,27 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
}
else if (arm->flag & ARM_MIRROR_EDIT) {
/* For X-Axis Mirror Editing option, we may need a mirror copy of actbone
- * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
+ * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone
* (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R").
* This is useful for arm-chains, for example parenting lower arm to upper arm
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone);
- if (actmirb == NULL)
+ if (actmirb == NULL)
actmirb = actbone;
}
-
- /* if there is only 1 selected bone, we assume that that is the active bone,
+
+ /* if there is only 1 selected bone, we assume that that is the active bone,
* since a user will need to have clicked on a bone (thus selecting it) to make it active
*/
if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) {
/* When only the active bone is selected, and it has a parent,
- * connect it to the parent, as that is the only possible outcome.
+ * connect it to the parent, as that is the only possible outcome.
*/
if (actbone->parent) {
bone_connect_to_existing_parent(actbone);
-
+
if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent))
bone_connect_to_existing_parent(actmirb);
}
@@ -775,16 +775,16 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
/* Parent 'selected' bones to the active one
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
- * - since the active one (and/or its mirror) will also be selected, we also need
+ * - since the active one (and/or its mirror) will also be selected, we also need
* to check that we are not trying to operate on them, since such an operation
* would cause errors
*/
-
+
/* parent selected bones to the active one */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
if (ELEM(ebone, actbone, actmirb) == 0) {
- if (ebone->flag & BONE_SELECTED)
+ if (ebone->flag & BONE_SELECTED)
bone_connect_to_new_parent(arm->edbo, ebone, actbone, val);
else
bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val);
@@ -792,11 +792,11 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -806,7 +806,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const
uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE);
uiLayout *layout = UI_popup_menu_layout(pup);
int allchildbones = 0;
-
+
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
if (ebone != actbone) {
@@ -816,13 +816,13 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const
CTX_DATA_END;
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT);
-
+
/* ob becomes parent, make the associated menus */
if (allchildbones)
uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET);
-
+
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
@@ -832,15 +832,15 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
ot->name = "Make Parent";
ot->idname = "ARMATURE_OT_parent_set";
ot->description = "Set the active bone as the parent of the selected bones";
-
+
/* api callbacks */
ot->invoke = armature_parent_set_invoke;
ot->exec = armature_parent_set_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting");
}
@@ -858,28 +858,28 @@ static void editbone_clear_parent(EditBone *ebone, int mode)
/* for nice selection */
ebone->parent->flag &= ~(BONE_TIPSEL);
}
-
+
if (mode == 1) ebone->parent = NULL;
ebone->flag &= ~BONE_CONNECTED;
}
-static int armature_parent_clear_exec(bContext *C, wmOperator *op)
+static int armature_parent_clear_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_edit_object(C);
bArmature *arm = (bArmature *)ob->data;
int val = RNA_enum_get(op->ptr, "type");
-
+
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
editbone_clear_parent(ebone, val);
}
CTX_DATA_END;
-
+
ED_armature_edit_sync_selection(arm->edbo);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -889,15 +889,15 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
ot->name = "Clear Parent";
ot->idname = "ARMATURE_OT_parent_clear";
ot->description = "Remove the parent-child relationship between selected bones and their parents";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = armature_parent_clear_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting");
}
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c
index ba856d4e964..a4e916b8e63 100644
--- a/source/blender/editors/armature/armature_select.c
+++ b/source/blender/editors/armature/armature_select.c
@@ -67,7 +67,7 @@ Bone *ED_armature_bone_find_index(Object *ob, int index)
bPoseChannel *pchan;
if (ob->pose == NULL) return NULL;
index >>= 16; // bone selection codes use left 2 bytes
-
+
pchan = BLI_findlink(&ob->pose->chanbase, index);
return pchan ? pchan->bone : NULL;
}
@@ -86,21 +86,21 @@ void *get_bone_from_selectbuffer(
short i;
bool takeNext = false;
int minsel = 0xffffffff, minunsel = 0xffffffff;
-
+
for (i = 0; i < hits; i++) {
hitresult = buffer[3 + (i * 4)];
-
+
if (!(hitresult & BONESEL_NOSEL)) {
if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */
bool sel;
-
+
hitresult &= ~(BONESEL_ANY);
/* Determine what the current bone is */
if (obedit == NULL || base->object != obedit) {
/* no singular posemode, so check for correct object */
if (base->selcol == (hitresult & 0xFFFF)) {
bone = ED_armature_bone_find_index(base->object, hitresult);
-
+
if (findunsel)
sel = (bone->flag & BONE_SELECTED);
else
@@ -115,16 +115,16 @@ void *get_bone_from_selectbuffer(
}
else {
bArmature *arm = obedit->data;
-
+
ebone = BLI_findlink(arm->edbo, hitresult);
if (findunsel)
sel = (ebone->flag & BONE_SELECTED);
else
sel = !(ebone->flag & BONE_SELECTED);
-
+
data = ebone;
}
-
+
if (data) {
if (sel) {
if (do_nearest) {
@@ -154,10 +154,10 @@ void *get_bone_from_selectbuffer(
}
}
}
-
+
if (firstunSel)
return firstunSel;
- else
+ else
return firstSel;
}
@@ -170,18 +170,18 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel)
rcti rect;
unsigned int buffer[MAXPICKBUF];
short hits;
-
+
ED_view3d_viewcontext_init(C, &vc);
-
+
// rect.xmin = ... mouseco!
rect.xmin = rect.xmax = xy[0];
rect.ymin = rect.ymax = xy[1];
-
+
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST);
if (hits > 0)
return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel, true);
-
+
return NULL;
}
@@ -214,7 +214,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
-
+
if (curBone->flag & BONE_CONNECTED)
next = curBone->parent;
else
@@ -243,11 +243,11 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv
if (!curBone)
bone = NULL;
}
-
+
ED_armature_edit_sync_selection(arm->edbo);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
-
+
return OPERATOR_FINISHED;
}
@@ -262,15 +262,15 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Connected";
ot->idname = "ARMATURE_OT_select_linked";
ot->description = "Select bones related to selected ones by parent/child relationships";
-
+
/* api callbacks */
/* leave 'exec' unset */
ot->invoke = armature_select_linked_invoke;
ot->poll = armature_select_linked_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -380,9 +380,9 @@ cache_end:
hitresult = buffer[3 + (i * 4)];
if (!(hitresult & BONESEL_NOSEL)) {
int dep;
-
+
ebone = BLI_findlink(arm->edbo, hitresult & ~BONESEL_ANY);
-
+
/* clicks on bone points get advantage */
if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) {
/* but also the unselected one */
@@ -391,7 +391,7 @@ cache_end:
dep = 1;
else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0)
dep = 1;
- else
+ else
dep = 2;
}
else {
@@ -422,11 +422,11 @@ cache_end:
}
}
}
-
+
if (!(besthitresult & BONESEL_NOSEL)) {
-
+
ebone = BLI_findlink(arm->edbo, besthitresult & ~BONESEL_ANY);
-
+
*r_selmask = 0;
if (besthitresult & BONESEL_ROOT)
*r_selmask |= BONE_ROOTSEL;
@@ -500,10 +500,10 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b
if (!extend && !deselect && !toggle) {
ED_armature_edit_deselect_all(obedit);
}
-
+
/* by definition the non-root connected bones have no root point drawn,
* so a root selection needs to be delivered to the parent tip */
-
+
if (selmask & BONE_SELECTED) {
if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) {
/* click in a chain */
@@ -568,16 +568,16 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b
else
nearBone->flag |= selmask;
}
-
+
ED_armature_edit_sync_selection(arm->edbo);
-
+
if (nearBone) {
/* then now check for active status */
if (ebone_select_flag(nearBone)) {
arm->act_edbone = nearBone;
}
}
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
return true;
}
@@ -605,7 +605,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
}
-
+
/* Set the flags */
CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones)
{
@@ -640,7 +640,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -650,14 +650,14 @@ void ARMATURE_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All";
ot->idname = "ARMATURE_OT_select_all";
ot->description = "Toggle selection status of all bones";
-
+
/* api callbacks */
ot->exec = armature_de_select_all_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_select_all(ot);
}
@@ -1085,7 +1085,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
int direction = RNA_enum_get(op->ptr, "direction");
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
-
+
ob = obedit;
arm = (bArmature *)ob->data;
@@ -1143,15 +1143,15 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
changed = true;
}
}
-
+
if (changed == false) {
return OPERATOR_CANCELLED;
}
ED_armature_edit_sync_selection(arm->edbo);
-
+
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1162,16 +1162,16 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Select Hierarchy";
ot->idname = "ARMATURE_OT_select_hierarchy";
ot->description = "Select immediate parent/children of selected bones";
-
+
/* api callbacks */
ot->exec = armature_select_hierarchy_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c
index 0458fc4ed1b..8ab8d60af75 100644
--- a/source/blender/editors/armature/armature_skinning.c
+++ b/source/blender/editors/armature/armature_skinning.c
@@ -72,7 +72,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
* This function performs 2 functions:
*
* a) It returns 1 if the bone is skinnable.
- * If we loop over all bones with this
+ * If we loop over all bones with this
* function, we can count the number of
* skinnable bones.
* b) If the pointer data is non null,
@@ -97,10 +97,10 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
segments = bone->segments;
else
segments = 1;
-
+
if (data->list != NULL) {
hbone = (Bone ***) &data->list;
-
+
for (a = 0; a < segments; a++) {
**hbone = bone;
++*hbone;
@@ -112,10 +112,10 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
return 0;
}
-static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
+static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
/* This group creates a vertex group to ob that has the
- * same name as bone (provided the bone is skinnable).
+ * same name as bone (provided the bone is skinnable).
* If such a vertex group already exist the routine exits.
*/
if (!(bone->flag & BONE_NO_DEFORM)) {
@@ -127,7 +127,7 @@ static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
return 0;
}
-static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
+static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
{
/* Bones that are deforming
* are regarded to be "skinnable" and are eligible for
@@ -135,16 +135,16 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
*
* This function performs 2 functions:
*
- * a) If the bone is skinnable, it creates
+ * a) If the bone is skinnable, it creates
* a vertex group for ob that has
* the name of the skinnable bone
* (if one doesn't exist already).
* b) If the pointer data is non null,
* it is treated like a handle to a
- * bDeformGroup pointer -- the
+ * bDeformGroup pointer -- the
* bDeformGroup pointer is set to point
* to the deform group with the bone's
- * name, and the pointer the handle
+ * name, and the pointer the handle
* points to is incremented to point to the
* next member of an array of pointers
* to bDeformGroups. This way we can loop using
@@ -164,7 +164,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
segments = bone->segments;
else
segments = 1;
-
+
if (!wpmode || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) {
if (!(defgroup = defgroup_find_name(ob, bone->name))) {
defgroup = BKE_object_defgroup_add_name(ob, bone->name);
@@ -174,10 +174,10 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
defgroup = NULL;
}
}
-
+
if (data->list != NULL) {
hgroup = (bDeformGroup ***) &data->list;
-
+
for (a = 0; a < segments; a++) {
**hgroup = defgroup;
++*hgroup;
@@ -216,25 +216,25 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
}
iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1;
-
+
/* for each skinnable bone */
for (j = 0; j < numbones; ++j) {
if (!selected[j])
continue;
-
+
bone = bonelist[j];
dgroup = dgrouplist[j];
-
+
/* store the distance-factor from the vertex to the bone */
distance = distfactor_to_bone(verts[i], root[j], tip[j],
bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
-
+
/* add the vert to the deform group if (weight != 0.0) */
if (distance != 0.0f)
ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE);
else
ED_vgroup_vert_remove(ob, dgroup, i);
-
+
/* do same for mirror */
if (dgroupflip && dgroupflip[j] && iflip != -1) {
if (distance != 0.0f)
@@ -281,10 +281,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
/* count the number of skinnable bones */
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
-
+
if (numbones == 0)
return;
-
+
if (BKE_object_defgroup_data_create(ob->data) == NULL)
return;
@@ -312,13 +312,13 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
for (j = 0; j < numbones; ++j) {
bone = bonelist[j];
dgroup = dgrouplist[j];
-
+
/* handle bbone */
if (heat) {
if (segments == 0) {
segments = 1;
bbone = NULL;
-
+
if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) {
if (bone->segments > 1) {
segments = bone->segments;
@@ -327,10 +327,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
}
}
}
-
+
segments--;
}
-
+
/* compute root and tip */
if (bbone) {
mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]);
@@ -345,10 +345,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
copy_v3_v3(root[j], bone->arm_head);
copy_v3_v3(tip[j], bone->arm_tail);
}
-
+
mul_m4_v3(par->obmat, root[j]);
mul_m4_v3(par->obmat, tip[j]);
-
+
/* set selected */
if (wpmode) {
if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))
@@ -356,7 +356,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
}
else
selected[j] = 1;
-
+
/* find flipped group */
if (dgroup && mirror) {
char name_flip[MAXBONENAME];
@@ -373,12 +373,12 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
if (wpmode) {
/* if in weight paint mode, use final verts from derivedmesh */
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
-
+
if (dm->foreachMappedVert) {
mesh_get_mapped_verts_coords(dm, verts, mesh->totvert);
vertsfilled = 1;
}
-
+
dm->release(dm);
}
else if (modifiers_findByType(ob, eModifierType_Subsurf)) {
@@ -427,7 +427,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
void ED_object_vgroup_calc_from_armature(ReportList *reports, Scene *scene, Object *ob, Object *par,
const int mode, const bool mirror)
{
- /* Lets try to create some vertex groups
+ /* Lets try to create some vertex groups
* based on the bones of the parent armature.
*/
bArmature *arm = par->data;
@@ -435,7 +435,7 @@ void ED_object_vgroup_calc_from_armature(ReportList *reports, Scene *scene, Obje
if (mode == ARM_GROUPS_NAME) {
const int defbase_tot = BLI_listbase_count(&ob->defbase);
int defbase_add;
- /* Traverse the bone list, trying to create empty vertex
+ /* Traverse the bone list, trying to create empty vertex
* groups corresponding to the bone.
*/
defbase_add = bone_looper(ob, arm->bonebase.first, NULL, vgroup_add_unique_bone_cb);
@@ -447,7 +447,7 @@ void ED_object_vgroup_calc_from_armature(ReportList *reports, Scene *scene, Obje
}
}
else if (ELEM(mode, ARM_GROUPS_ENVELOPE, ARM_GROUPS_AUTO)) {
- /* Traverse the bone list, trying to create vertex groups
+ /* Traverse the bone list, trying to create vertex groups
* that are populated with the vertices for which the
* bone is closest.
*/
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 8867189baef..f0e4d5e1102 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -56,7 +56,7 @@
void ED_armature_edit_sync_selection(ListBase *edbo)
{
EditBone *ebo;
-
+
for (ebo = edbo->first; ebo; ebo = ebo->next) {
/* if bone is not selectable, we shouldn't alter this setting... */
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
@@ -66,7 +66,7 @@ void ED_armature_edit_sync_selection(ListBase *edbo)
else
ebo->flag &= ~BONE_ROOTSEL;
}
-
+
if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL))
ebo->flag |= BONE_SELECTED;
else
@@ -93,27 +93,27 @@ void ED_armature_edit_validate_active(struct bArmature *arm)
int bone_looper(Object *ob, Bone *bone, void *data,
int (*bone_func)(Object *, Bone *, void *))
{
- /* We want to apply the function bone_func to every bone
- * in an armature -- feed bone_looper the first bone and
- * a pointer to the bone_func and watch it go!. The int count
+ /* We want to apply the function bone_func to every bone
+ * in an armature -- feed bone_looper the first bone and
+ * a pointer to the bone_func and watch it go!. The int count
* can be useful for counting bones with a certain property
* (e.g. skinnable)
*/
int count = 0;
-
+
if (bone) {
/* only do bone_func if the bone is non null */
count += bone_func(ob, bone, data);
-
+
/* try to execute bone_func for the first child */
count += bone_looper(ob, bone->childbase.first, data, bone_func);
-
+
/* try to execute bone_func for the next bone at this
* depth of the recursion.
*/
count += bone_looper(ob, bone->next, data, bone_func);
}
-
+
return count;
}
@@ -272,13 +272,13 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo)
if (ebo == NULL)
return NULL;
-
+
BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip));
-
+
if (!STREQ(name_flip, ebo->name)) {
return ED_armature_ebone_find_name(edbo, name_flip);
}
-
+
return NULL;
}
@@ -292,7 +292,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
EditBone *curBone, *ebone_mirr;
-
+
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (curBone->flag & flag) {
@@ -303,7 +303,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag)
}
}
}
-
+
}
void armature_select_mirrored(bArmature *arm)
@@ -332,7 +332,7 @@ void armature_tag_select_mirrored(bArmature *arm)
}
}
}
-
+
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (curBone->flag & BONE_DONE) {
EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone);
@@ -362,17 +362,17 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
{
bArmature *arm = obedit->data;
EditBone *ebo, *eboflip;
-
+
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
/* no layer check, correct mirror is more important */
if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo);
-
+
if (eboflip) {
/* we assume X-axis flipping for now */
if (ebo->flag & BONE_TIPSEL) {
EditBone *children;
-
+
eboflip->tail[0] = -ebo->tail[0];
eboflip->tail[1] = ebo->tail[1];
eboflip->tail[2] = ebo->tail[2];
@@ -380,7 +380,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->roll = -ebo->roll;
eboflip->curveOutX = -ebo->curveOutX;
eboflip->roll2 = -ebo->roll2;
-
+
/* Also move connected children, in case children's name aren't mirrored properly */
for (children = arm->edbo->first; children; children = children->next) {
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
@@ -397,7 +397,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->roll = -ebo->roll;
eboflip->curveInX = -ebo->curveInX;
eboflip->roll1 = -ebo->roll1;
-
+
/* Also move connected parent, in case parent's name isn't mirrored properly */
if (eboflip->parent && eboflip->flag & BONE_CONNECTED) {
EditBone *parent = eboflip->parent;
@@ -410,7 +410,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
eboflip->roll = -ebo->roll;
eboflip->xwidth = ebo->xwidth;
eboflip->zwidth = ebo->zwidth;
-
+
eboflip->curveInX = -ebo->curveInX;
eboflip->curveOutX = -ebo->curveOutX;
eboflip->roll1 = -ebo->roll1;
@@ -431,17 +431,17 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
EditBone *eBoneAct = NULL;
EditBone *eBoneTest = NULL;
Bone *curBone;
-
+
for (curBone = bones->first; curBone; curBone = curBone->next) {
eBone = MEM_callocN(sizeof(EditBone), "make_editbone");
-
+
/* Copy relevant data from bone to eBone
* Keep selection logic in sync with ED_armature_edit_sync_selection.
*/
eBone->parent = parent;
BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name));
eBone->flag = curBone->flag;
-
+
/* fix selection flags */
if (eBone->flag & BONE_SELECTED) {
/* if the bone is selected the copy its root selection to the parents tip */
@@ -461,11 +461,11 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->flag &= ~BONE_ROOTSEL;
}
}
-
+
copy_v3_v3(eBone->head, curBone->arm_head);
copy_v3_v3(eBone->tail, curBone->arm_tail);
eBone->roll = curBone->arm_roll;
-
+
/* rest of stuff copy */
eBone->length = curBone->length;
eBone->dist = curBone->dist;
@@ -491,20 +491,20 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
if (curBone->prop)
eBone->prop = IDP_CopyProperty(curBone->prop);
-
+
BLI_addtail(edbo, eBone);
-
+
/* Add children if necessary */
if (curBone->childbase.first) {
eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone);
if (eBoneTest)
eBoneAct = eBoneTest;
}
-
+
if (curBone == actBone)
eBoneAct = eBone;
}
-
+
return eBoneAct;
}
@@ -589,18 +589,18 @@ void ED_armature_from_edit(bArmature *arm)
EditBone *eBone, *neBone;
Bone *newBone;
Object *obt;
-
+
/* armature bones */
BKE_armature_bonelist_free(&arm->bonebase);
arm->act_bone = NULL;
-
+
/* remove zero sized bones, this gives unstable restposes */
for (eBone = arm->edbo->first; eBone; eBone = neBone) {
float len_sq = len_squared_v3v3(eBone->head, eBone->tail);
neBone = eBone->next;
if (len_sq <= SQUARE(0.000001f)) { /* FLT_EPSILON is too large? */
EditBone *fBone;
-
+
/* Find any bones that refer to this bone */
for (fBone = arm->edbo->first; fBone; fBone = fBone->next) {
if (fBone->parent == eBone)
@@ -611,19 +611,19 @@ void ED_armature_from_edit(bArmature *arm)
bone_free(arm, eBone);
}
}
-
+
/* Copy the bones from the editData into the armature */
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
newBone = MEM_callocN(sizeof(Bone), "bone");
eBone->temp.bone = newBone; /* Associate the real Bones with the EditBones */
-
+
BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name));
copy_v3_v3(newBone->arm_head, eBone->head);
copy_v3_v3(newBone->arm_tail, eBone->tail);
newBone->arm_roll = eBone->roll;
-
+
newBone->flag = eBone->flag;
-
+
if (eBone == arm->act_edbone) {
/* don't change active selection, this messes up separate which uses
* editmode toggle and can separate active bone which is de-selected originally */
@@ -631,10 +631,10 @@ void ED_armature_from_edit(bArmature *arm)
arm->act_bone = newBone;
}
newBone->roll = 0.0f;
-
+
newBone->weight = eBone->weight;
newBone->dist = eBone->dist;
-
+
newBone->xwidth = eBone->xwidth;
newBone->zwidth = eBone->zwidth;
newBone->rad_head = eBone->rad_head;
@@ -658,7 +658,7 @@ void ED_armature_from_edit(bArmature *arm)
if (eBone->prop)
newBone->prop = IDP_CopyProperty(eBone->prop);
}
-
+
/* Fix parenting in a separate pass to ensure ebone->bone connections are valid at this point.
* Do not set bone->head/tail here anymore, using EditBone data for that is not OK since our later fiddling
* with parent's arm_mat (for roll conversion) may have some small but visible impact on locations (T46010). */
@@ -673,24 +673,24 @@ void ED_armature_from_edit(bArmature *arm)
BLI_addtail(&arm->bonebase, newBone);
}
}
-
+
/* Finalize definition of restpose data (roll, bone_mat, arm_mat, head/tail...). */
armature_finalize_restpose(&arm->bonebase, arm->edbo);
-
+
/* so all users of this armature should get rebuilt */
for (obt = G.main->object.first; obt; obt = obt->id.next) {
if (obt->data == arm) {
BKE_pose_rebuild(obt, arm);
}
}
-
+
DAG_id_tag_update(&arm->id, 0);
}
void ED_armature_edit_free(struct bArmature *arm)
{
EditBone *eBone;
-
+
/* Clear the editbones list */
if (arm->edbo) {
if (arm->edbo->first) {
@@ -700,7 +700,7 @@ void ED_armature_edit_free(struct bArmature *arm)
MEM_freeN(eBone->prop);
}
}
-
+
BLI_freelistN(arm->edbo);
}
MEM_freeN(arm->edbo);
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c
index 57843265496..f0135676523 100644
--- a/source/blender/editors/armature/editarmature_generate.c
+++ b/source/blender/editors/armature/editarmature_generate.c
@@ -38,7 +38,7 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma
copy_v3_v3(normal, no);
mul_m3_v3(tmat, normal);
-
+
bone->roll = ED_armature_ebone_roll_to_vector(bone, normal, false);
}
}
@@ -46,46 +46,46 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma
float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], float n[3])
{
int len = 2 + abs(end - start);
-
+
if (len > 2) {
float avg_t = 0.0f;
float s_t = 0.0f;
float s_xyz = 0.0f;
int i;
-
+
/* First pass, calculate average */
for (i = start; i <= end; i++) {
float v[3];
-
+
IT_peek(iter, i);
sub_v3_v3v3(v, iter->p, v0);
avg_t += dot_v3v3(v, n);
}
-
+
avg_t /= dot_v3v3(n, n);
avg_t += 1.0f; /* adding start (0) and end (1) values */
avg_t /= len;
-
+
/* Second pass, calculate s_xyz and s_t */
for (i = start; i <= end; i++) {
float v[3], d[3];
float dt;
-
+
IT_peek(iter, i);
sub_v3_v3v3(v, iter->p, v0);
project_v3_v3v3(d, v, n);
sub_v3_v3(v, d);
-
+
dt = len_v3(d) - avg_t;
-
+
s_t += dt * dt;
s_xyz += dot_v3v3(v, v);
}
-
+
/* adding start(0) and end(1) values to s_t */
s_t += (avg_t * avg_t) + (1 - avg_t) * (1 - avg_t);
-
- return 1.0f - s_xyz / s_t;
+
+ return 1.0f - s_xyz / s_t;
}
else {
return 1.0f;
@@ -100,30 +100,30 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta
float *v1, *v2;
float length_threshold;
int i;
-
+
if (stroke_length == 0) {
current_length = 0;
IT_peek(iter, start);
v1 = iter->p;
-
+
for (i = start + 1; i <= end; i++) {
IT_peek(iter, i);
v2 = iter->p;
stroke_length += len_v3v3(v1, v2);
-
+
v1 = v2;
}
-
+
n = 0;
current_length = 0;
}
-
+
n++;
-
+
length_threshold = n * stroke_length / toolsettings->skgen_subdivision_number;
-
+
IT_peek(iter, start);
v1 = iter->p;
@@ -138,12 +138,12 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta
copy_v3_v3(p, v2);
return i;
}
-
+
v1 = v2;
}
-
+
stroke_length = 0;
-
+
return -1;
}
int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int start, int end, float head[3], float p[3])
@@ -152,7 +152,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in
float *start_p;
float n[3];
int i;
-
+
IT_peek(iter, start);
start_p = iter->p;
@@ -167,7 +167,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in
return i - 1;
}
}
-
+
return -1;
}
@@ -176,37 +176,37 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
float lengthLimit = toolsettings->skgen_length_limit;
int same = 1;
int i;
-
+
i = start + 1;
while (i <= end) {
float *vec0;
float *vec1;
-
+
IT_peek(iter, i - 1);
vec0 = iter->p;
IT_peek(iter, i);
vec1 = iter->p;
-
+
/* If lengthLimit hits the current segment */
if (len_v3v3(vec1, head) > lengthLimit) {
if (same == 0) {
float dv[3], off[3];
float a, b, c, f;
-
+
/* Solve quadratic distance equation */
sub_v3_v3v3(dv, vec1, vec0);
a = dot_v3v3(dv, dv);
-
+
sub_v3_v3v3(off, vec0, head);
b = 2 * dot_v3v3(dv, off);
-
+
c = dot_v3v3(off, off) - (lengthLimit * lengthLimit);
-
+
f = (-b + sqrtf(b * b - 4 * a * c)) / (2 * a);
-
+
//printf("a %f, b %f, c %f, f %f\n", a, b, c, f);
-
+
if (isnan(f) == 0 && f < 1.0f) {
copy_v3_v3(p, dv);
mul_v3_fl(p, f);
@@ -218,15 +218,15 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
}
else {
float dv[3];
-
+
sub_v3_v3v3(dv, vec1, vec0);
normalize_v3(dv);
-
+
copy_v3_v3(p, dv);
mul_v3_fl(p, lengthLimit);
add_v3_v3(p, head);
}
-
+
return i - 1; /* restart at lower bound */
}
else {
@@ -234,7 +234,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
same = 0; // Reset same
}
}
-
+
return -1;
}
@@ -249,18 +249,18 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U
int bone_start = 0;
int end = iter->length;
int index;
-
+
IT_head(iter);
-
+
parent = ED_armature_ebone_add(arm, "Bone");
copy_v3_v3(parent->head, iter->p);
-
+
if (iter->size > FLT_EPSILON) {
parent->rad_head = iter->size * size_buffer;
}
-
+
normal = iter->no;
-
+
index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
while (index != -1) {
IT_peek(iter, index);
@@ -269,7 +269,7 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U
copy_v3_v3(child->head, parent->tail);
child->parent = parent;
child->flag |= BONE_CONNECTED;
-
+
if (iter->size > FLT_EPSILON) {
child->rad_head = iter->size * size_buffer;
parent->rad_tail = iter->size * size_buffer;
@@ -287,19 +287,19 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U
index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
}
-
+
iter->tail(iter);
copy_v3_v3(parent->tail, iter->p);
if (iter->size > FLT_EPSILON) {
parent->rad_tail = iter->size * size_buffer;
}
-
+
/* fix last bone */
mul_m4_v3(invmat, parent->tail);
mul_m4_v3(invmat, parent->head);
setBoneRollFromNormal(parent, iter->no, invmat, tmat);
lastBone = parent;
-
+
return lastBone;
}
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index 6b2893780d7..ad0025955c2 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -65,7 +65,7 @@ typedef struct RetargetParam {
typedef enum {
RETARGET_LENGTH,
RETARGET_AGGRESSIVE
-} RetargetMode;
+} RetargetMode;
typedef enum {
METHOD_BRUTE_FORCE = 0,
@@ -88,7 +88,7 @@ static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second);
float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]);
/* two levels */
-#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX)
+#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX)
/*********************************** EDITBONE UTILS ****************************************************/
@@ -96,20 +96,20 @@ static int countEditBoneChildren(ListBase *list, EditBone *parent)
{
EditBone *ebone;
int count = 0;
-
+
for (ebone = list->first; ebone; ebone = ebone->next) {
if (ebone->parent == parent) {
count++;
}
}
-
+
return count;
}
static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n)
{
EditBone *ebone;
-
+
for (ebone = list->first; ebone; ebone = ebone->next) {
if (ebone->parent == parent) {
if (n == 0) {
@@ -118,7 +118,7 @@ static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n)
n--;
}
}
-
+
return NULL;
}
@@ -127,7 +127,7 @@ static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3])
float mat[3][3], nor[3];
sub_v3_v3v3(nor, bone->tail, bone->head);
-
+
vec_roll_to_mat3(nor, roll, mat);
copy_v3_v3(up_axis, mat[2]);
}
@@ -135,27 +135,27 @@ static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3])
static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
{
float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
-
+
copy_v3_v3(new_up_axis, old_up_axis);
mul_qt_v3(qrot, new_up_axis);
-
+
sub_v3_v3v3(nor, bone->tail, bone->head);
-
+
cross_v3_v3v3(x_axis, nor, aligned_axis);
cross_v3_v3v3(z_axis, x_axis, nor);
-
+
normalize_v3(new_up_axis);
normalize_v3(x_axis);
normalize_v3(z_axis);
-
+
if (dot_v3v3(new_up_axis, x_axis) < 0) {
negate_v3(x_axis);
}
-
+
if (dot_v3v3(new_up_axis, z_axis) < 0) {
negate_v3(z_axis);
}
-
+
if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) {
rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */
return ED_armature_ebone_roll_to_vector(bone, x_axis, false);
@@ -175,7 +175,7 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4]
else {
float new_up_axis[3];
float vec_first[3], vec_second[3], normal[3];
-
+
if (previous->bone) {
sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head);
}
@@ -186,24 +186,24 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4]
/* default to up_axis if first bone in the chain is an offset */
return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
}
-
+
sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head);
-
+
normalize_v3(vec_first);
normalize_v3(vec_second);
-
+
cross_v3_v3v3(normal, vec_first, vec_second);
normalize_v3(normal);
-
+
axis_angle_to_quat(qroll, vec_second, edge->up_angle);
-
+
mul_qt_v3(qroll, normal);
-
+
copy_v3_v3(new_up_axis, edge->up_axis);
mul_qt_v3(qrot, new_up_axis);
-
+
normalize_v3(new_up_axis);
-
+
/* real qroll between normal and up_axis */
rotation_between_vecs_to_quat(qroll, new_up_axis, normal);
@@ -214,10 +214,10 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4]
float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4])
{
float new_up_axis[3];
-
+
copy_v3_v3(new_up_axis, old_up_axis);
mul_qt_v3(qrot, new_up_axis);
-
+
return ED_armature_ebone_roll_to_vector(bone, new_up_axis, false);
}
@@ -233,34 +233,34 @@ void RIG_freeRigGraph(BGraph *rg)
RigGraph *rigg = (RigGraph *)rg;
BNode *node;
BArc *arc;
-
+
BLI_task_pool_free(rigg->task_pool);
BLI_task_scheduler_free(rigg->task_scheduler);
-
+
if (rigg->link_mesh) {
REEB_freeGraph(rigg->link_mesh);
}
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
RIG_freeRigArc(arc);
}
BLI_freelistN(&rg->arcs);
-
+
for (node = rg->nodes.first; node; node = node->next) {
BLI_freeNode(rg, (BNode *)node);
}
BLI_freelistN(&rg->nodes);
-
+
BLI_freelistN(&rigg->controls);
BLI_ghash_free(rigg->bones_map, NULL, NULL);
BLI_ghash_free(rigg->controls_map, NULL, NULL);
-
+
if (rigg->flag & RIG_FREE_BONELIST) {
BLI_freelistN(rigg->editbones);
MEM_freeN(rigg->editbones);
}
-
+
MEM_freeN(rg);
}
@@ -270,17 +270,17 @@ static RigGraph *newRigGraph(void)
{
RigGraph *rg;
int totthread;
-
+
rg = MEM_callocN(sizeof(RigGraph), "rig graph");
-
+
rg->head = NULL;
-
+
rg->bones_map = BLI_ghash_str_new("newRigGraph bones gh");
rg->controls_map = BLI_ghash_str_new("newRigGraph cont gh");
-
+
rg->free_arc = RIG_freeRigArc;
rg->free_node = NULL;
-
+
#ifdef USE_THREADS
totthread = TASK_SCHEDULER_AUTO_THREADS;
#else
@@ -296,22 +296,22 @@ static RigGraph *newRigGraph(void)
static RigArc *newRigArc(RigGraph *rg)
{
RigArc *arc;
-
+
arc = MEM_callocN(sizeof(RigArc), "rig arc");
arc->count = 0;
BLI_addtail(&rg->arcs, arc);
-
+
return arc;
}
static RigControl *newRigControl(RigGraph *rg)
{
RigControl *ctrl;
-
+
ctrl = MEM_callocN(sizeof(RigControl), "rig control");
-
+
BLI_addtail(&rg->controls, ctrl);
-
+
return ctrl;
}
@@ -324,9 +324,9 @@ static RigNode *newRigNodeHead(RigGraph *rg, RigArc *arc, float p[3])
copy_v3_v3(node->p, p);
node->degree = 1;
node->arcs = NULL;
-
+
arc->head = node;
-
+
return node;
}
@@ -346,14 +346,14 @@ static RigNode *newRigNode(RigGraph *rg, float p[3])
copy_v3_v3(node->p, p);
node->degree = 0;
node->arcs = NULL;
-
+
return node;
}
static RigNode *newRigNodeTail(RigGraph *rg, RigArc *arc, float p[3])
{
RigNode *node = newRigNode(rg, p);
-
+
node->degree = 1;
arc->tail = node;
@@ -372,11 +372,11 @@ static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge)
copy_v3_v3(edge->head, last_edge->tail);
RIG_calculateEdgeAngles(last_edge, edge);
}
-
+
edge->length = len_v3v3(edge->head, edge->tail);
-
+
arc->length += edge->length;
-
+
arc->count += 1;
}
@@ -388,11 +388,11 @@ static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
copy_v3_v3(edge->tail, tail);
edge->bone = bone;
-
+
if (bone) {
getEditBoneRollUpAxis(bone, bone->roll, edge->up_axis);
}
-
+
RIG_appendEdgeToArc(arc, edge);
}
/************************************** CLONING TEMPLATES **********************************************/
@@ -400,7 +400,7 @@ static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
static void renameTemplateBone(char *name, char *template_name, ListBase *editbones, char *side_string, char *num_string)
{
int i, j;
-
+
for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) {
if (template_name[i] == '&') {
if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') {
@@ -421,9 +421,9 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo
j++;
}
}
-
+
name[j] = '\0';
-
+
ED_armature_ebone_unique_name(editbones, name, NULL);
}
@@ -431,14 +431,14 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_
{
RigControl *ctrl;
char name[MAXBONENAME];
-
+
ctrl = newRigControl(rg);
-
+
copy_v3_v3(ctrl->head, src_ctrl->head);
copy_v3_v3(ctrl->tail, src_ctrl->tail);
copy_v3_v3(ctrl->up_axis, src_ctrl->up_axis);
copy_v3_v3(ctrl->offset, src_ctrl->offset);
-
+
ctrl->tail_mode = src_ctrl->tail_mode;
ctrl->flag = src_ctrl->flag;
@@ -446,10 +446,10 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_
ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob);
ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone);
-
+
ctrl->link = src_ctrl->link;
ctrl->link_tail = src_ctrl->link_tail;
-
+
return ctrl;
}
@@ -457,32 +457,32 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
{
RigEdge *src_edge;
RigArc *arc;
-
+
arc = newRigArc(rg);
-
+
arc->head = BLI_ghash_lookup(ptr_hash, src_arc->head);
arc->tail = BLI_ghash_lookup(ptr_hash, src_arc->tail);
-
+
arc->head->degree++;
arc->tail->degree++;
-
+
arc->length = src_arc->length;
arc->count = src_arc->count;
-
+
for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next) {
RigEdge *edge;
-
+
edge = MEM_callocN(sizeof(RigEdge), "rig edge");
copy_v3_v3(edge->head, src_edge->head);
copy_v3_v3(edge->tail, src_edge->tail);
copy_v3_v3(edge->up_axis, src_edge->up_axis);
-
+
edge->length = src_edge->length;
edge->angle = src_edge->angle;
edge->up_angle = src_edge->up_angle;
-
+
if (src_edge->bone != NULL) {
char name[MAXBONENAME];
renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
@@ -493,7 +493,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
BLI_addtail(&arc->edges, edge);
}
-
+
return arc;
}
@@ -504,54 +504,54 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
RigArc *arc;
RigControl *ctrl;
RigGraph *rg;
-
+
ptr_hash = BLI_ghash_ptr_new("cloneRigGraph gh");
rg = newRigGraph();
-
+
rg->ob = ob;
rg->editbones = editbones;
-
+
preEditBoneDuplicate(rg->editbones); /* prime bones for duplication */
preEditBoneDuplicate(src->editbones); /* prime bones for duplication */
-
+
/* Clone nodes */
for (node = src->nodes.first; node; node = node->next) {
RigNode *cloned_node = newRigNode(rg, node->p);
BLI_ghash_insert(ptr_hash, node, cloned_node);
}
-
+
rg->head = BLI_ghash_lookup(ptr_hash, src->head);
-
+
/* Clone arcs */
for (arc = src->arcs.first; arc; arc = arc->next) {
cloneArc(rg, src, arc, ptr_hash, side_string, num_string);
}
-
+
/* Clone controls */
for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next) {
cloneControl(rg, src, ctrl, ptr_hash, side_string, num_string);
}
-
+
/* Relink bones properly */
for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge;
-
+
for (edge = arc->edges.first; edge; edge = edge->next) {
if (edge->bone != NULL) {
EditBone *bone;
-
+
updateDuplicateSubtargetObjects(edge->bone, src->editbones, src->ob, rg->ob);
if (edge->bone->parent) {
bone = BLI_ghash_lookup(ptr_hash, edge->bone->parent);
-
+
if (bone != NULL) {
edge->bone->parent = bone;
}
else {
/* disconnect since parent isn't cloned
- * this will only happen when cloning from selected bones
+ * this will only happen when cloning from selected bones
* */
edge->bone->flag &= ~BONE_CONNECTED;
}
@@ -559,21 +559,21 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
}
}
}
-
+
for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
EditBone *bone;
-
+
updateDuplicateSubtargetObjects(ctrl->bone, src->editbones, src->ob, rg->ob);
if (ctrl->bone->parent) {
bone = BLI_ghash_lookup(ptr_hash, ctrl->bone->parent);
-
+
if (bone != NULL) {
ctrl->bone->parent = bone;
}
else {
/* disconnect since parent isn't cloned
- * this will only happen when cloning from selected bones
+ * this will only happen when cloning from selected bones
* */
ctrl->bone->flag &= ~BONE_CONNECTED;
}
@@ -582,9 +582,9 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
ctrl->link = BLI_ghash_lookup(ptr_hash, ctrl->link);
ctrl->link_tail = BLI_ghash_lookup(ptr_hash, ctrl->link_tail);
}
-
+
BLI_ghash_free(ptr_hash, NULL, NULL);
-
+
return rg;
}
@@ -594,15 +594,15 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second)
{
float vec_first[3], vec_second[3];
-
- sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head);
+
+ sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head);
sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head);
normalize_v3(vec_first);
normalize_v3(vec_second);
-
+
edge_first->angle = angle_normalized_v3v3(vec_first, vec_second);
-
+
if (edge_second->bone != NULL) {
float normal[3];
@@ -623,7 +623,7 @@ static void RIG_addControlBone(RigGraph *rg, EditBone *bone)
copy_v3_v3(ctrl->tail, bone->tail);
getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis);
ctrl->tail_mode = TL_NONE;
-
+
BLI_ghash_insert(rg->controls_map, bone->name, ctrl);
}
@@ -632,64 +632,64 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
if (link) {
float offset[3];
int flag = 0;
-
+
sub_v3_v3v3(offset, ctrl->bone->head, link->head);
/* if root matches, check for direction too */
if (dot_v3v3(offset, offset) < 0.0001f) {
float vbone[3], vparent[3];
-
+
flag |= RIG_CTRL_FIT_ROOT;
-
+
sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head);
sub_v3_v3v3(vparent, link->tail, link->head);
-
+
/* test for opposite direction */
if (dot_v3v3(vbone, vparent) > 0) {
float nor[3];
float len;
-
+
cross_v3_v3v3(nor, vbone, vparent);
-
+
len = dot_v3v3(nor, nor);
if (len < 0.0001f) {
flag |= RIG_CTRL_FIT_BONE;
}
}
}
-
+
/* Bail out if old one is automatically better */
if (flag < ctrl->flag) {
return 0;
}
-
+
/* if there's already a link
* overwrite only if new link is higher in the chain */
if (ctrl->link && flag == ctrl->flag) {
EditBone *bone = NULL;
-
+
for (bone = ctrl->link; bone; bone = bone->parent) {
/* if link is in the chain, break and use that one */
if (bone == link) {
break;
}
}
-
+
/* not in chain, don't update link */
if (bone == NULL) {
return 0;
}
}
-
-
+
+
ctrl->link = link;
ctrl->flag = flag;
-
+
copy_v3_v3(ctrl->offset, offset);
-
+
return 1;
}
-
+
return 0;
}
@@ -697,31 +697,31 @@ static void RIG_reconnectControlBones(RigGraph *rg)
{
RigControl *ctrl;
bool changed = true;
-
+
/* first pass, link to deform bones */
for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
bPoseChannel *pchan;
bConstraint *con;
int found = 0;
-
+
/* DO SOME MAGIC HERE */
for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
int target_index;
-
+
cti->get_constraint_targets(con, &targets);
-
+
for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) {
if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
/* SET bone link to bone corresponding to pchan */
EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name);
-
+
/* Making sure bone is in this armature */
if (link != NULL) {
/* for pole targets, link to parent bone instead, if possible */
@@ -730,12 +730,12 @@ static void RIG_reconnectControlBones(RigGraph *rg)
link = link->parent;
}
}
-
+
found = RIG_parentControl(ctrl, link);
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 0);
}
@@ -749,25 +749,25 @@ static void RIG_reconnectControlBones(RigGraph *rg)
* NULL if not
* */
EditBone *link = BLI_ghash_lookup(rg->bones_map, ctrl->bone->parent->name);
-
+
found = RIG_parentControl(ctrl, link);
}
-
+
/* check if bone is not superposed on another one */
{
RigArc *arc;
RigArc *best_arc = NULL;
EditBone *link = NULL;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge;
for (edge = arc->edges.first; edge; edge = edge->next) {
if (edge->bone) {
int fit = 0;
-
+
fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f;
fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f;
-
+
if (fit) {
/* pick the bone on the arc with the lowest symmetry level
* means you connect control to the trunk of the skeleton */
@@ -779,17 +779,17 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
}
-
+
found = RIG_parentControl(ctrl, link);
}
}
-
+
/* if not found yet, check child */
if (found == 0) {
RigArc *arc;
RigArc *best_arc = NULL;
EditBone *link = NULL;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge;
for (edge = arc->edges.first; edge; edge = edge->next) {
@@ -803,17 +803,17 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
}
-
+
found = RIG_parentControl(ctrl, link);
}
}
-
-
+
+
/* second pass, make chains in control bones */
while (changed) {
changed = false;
-
+
for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
/* if control is not linked yet */
if (ctrl->link == NULL) {
@@ -828,18 +828,18 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
/* check constraints first */
-
+
/* DO SOME MAGIC HERE */
for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (con = pchan->constraints.first; con; con = con->next) {
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
/* constraint targets */
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) {
/* SET bone link to ctrl corresponding to pchan */
@@ -853,7 +853,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 0);
}
@@ -881,19 +881,19 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
}
-
+
/* third pass, link control tails */
for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
/* fit bone already means full match, so skip those */
if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0) {
GHashIterator ghi;
-
+
/* look on deform bones first */
BLI_ghashIterator_init(&ghi, rg->bones_map);
-
+
for (; !BLI_ghashIterator_done(&ghi); BLI_ghashIterator_step(&ghi)) {
EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi);
-
+
/* don't link with parent */
if (bone->parent != ctrl->bone) {
if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f) {
@@ -908,14 +908,14 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
}
-
+
/* if we haven't found one yet, look in control bones */
if (ctrl->tail_mode == TL_NONE) {
/* pass */
}
}
}
-
+
}
/*******************************************************************************************************/
@@ -923,44 +923,44 @@ static void RIG_reconnectControlBones(RigGraph *rg)
static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigArc *joined_arc2)
{
RigEdge *edge, *next_edge;
-
+
/* ignore cases where joint is at start or end */
if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail) {
return;
}
-
+
/* swap arcs to make sure arc1 is before arc2 */
if (joined_arc1->head == joined_arc2->tail) {
RigArc *tmp = joined_arc1;
joined_arc1 = joined_arc2;
joined_arc2 = tmp;
}
-
+
for (edge = joined_arc2->edges.first; edge; edge = next_edge) {
next_edge = edge->next;
-
+
RIG_appendEdgeToArc(joined_arc1, edge);
}
-
+
joined_arc1->tail = joined_arc2->tail;
-
+
BLI_listbase_clear(&joined_arc2->edges);
-
+
BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2);
-
+
BLI_removeNode((BGraph *)rg, (BNode *)node);
}
static void RIG_removeNormalNodes(RigGraph *rg)
{
RigNode *node, *next_node;
-
+
for (node = rg->nodes.first; node; node = next_node) {
next_node = node->next;
-
+
if (node->degree == 2) {
RigArc *arc, *joined_arc1 = NULL, *joined_arc2 = NULL;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
if (arc->head == node || arc->tail == node) {
if (joined_arc1 == NULL) {
@@ -972,7 +972,7 @@ static void RIG_removeNormalNodes(RigGraph *rg)
}
}
}
-
+
RIG_joinArcs(rg, node, joined_arc1, joined_arc2);
}
}
@@ -981,13 +981,13 @@ static void RIG_removeNormalNodes(RigGraph *rg)
static void RIG_removeUneededOffsets(RigGraph *rg)
{
RigArc *arc;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *first_edge, *last_edge;
-
+
first_edge = arc->edges.first;
last_edge = arc->edges.last;
-
+
if (first_edge->bone == NULL) {
if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f) {
BLI_remlink(&arc->edges, first_edge);
@@ -995,7 +995,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
else if (arc->head->degree == 1) {
RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f);
-
+
if (new_node) {
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
@@ -1003,11 +1003,11 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
else {
RigEdge *next_edge = first_edge->next;
-
+
if (next_edge) {
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
-
+
copy_v3_v3(arc->head->p, next_edge->head);
}
}
@@ -1020,24 +1020,24 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
RigEdge *test_edge;
if (other_arc->head == arc->head) {
test_edge = other_arc->edges.first;
-
+
if (test_edge->bone != NULL) {
break;
}
}
else if (other_arc->tail == arc->head) {
test_edge = other_arc->edges.last;
-
+
if (test_edge->bone != NULL) {
break;
}
}
}
}
-
+
if (other_arc == NULL) {
RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001);
-
+
if (new_node) {
/* remove null edge in other arcs too */
for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
@@ -1057,20 +1057,20 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
}
}
-
+
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
}
else {
RigEdge *next_edge = first_edge->next;
-
+
if (next_edge) {
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
-
+
copy_v3_v3(arc->head->p, next_edge->head);
-
+
/* remove null edge in other arcs too */
for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
if (other_arc != arc) {
@@ -1092,7 +1092,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
}
}
-
+
if (last_edge->bone == NULL) {
if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f) {
BLI_remlink(&arc->edges, last_edge);
@@ -1100,14 +1100,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
else if (arc->tail->degree == 1) {
RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f);
-
+
if (new_node) {
RigEdge *previous_edge = last_edge->prev;
-
+
BLI_remlink(&arc->edges, last_edge);
MEM_freeN(last_edge);
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail);
-
+
/* set previous angle to 0, since there's no following edges */
if (previous_edge) {
previous_edge->angle = 0;
@@ -1115,11 +1115,11 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
else {
RigEdge *previous_edge = last_edge->prev;
-
+
if (previous_edge) {
BLI_remlink(&arc->edges, last_edge);
MEM_freeN(last_edge);
-
+
copy_v3_v3(arc->tail->p, previous_edge->tail);
previous_edge->angle = 0;
}
@@ -1134,17 +1134,17 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
EditBone *bone, *last_bone = root_bone;
RigArc *arc = NULL;
int contain_head = 0;
-
+
for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) {
int nb_children;
-
+
if (selected == 0 || (bone->flag & BONE_SELECTED)) {
if ((bone->flag & BONE_NO_DEFORM) == 0) {
BLI_ghash_insert(rg->bones_map, bone->name, bone);
-
+
if (arc == NULL) {
arc = newRigArc(rg);
-
+
if (starting_node == NULL) {
starting_node = newRigNodeHead(rg, arc, root_bone->head);
}
@@ -1152,15 +1152,15 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
addRigNodeHead(rg, arc, starting_node);
}
}
-
+
if (bone->parent && (bone->flag & BONE_CONNECTED) == 0) {
RIG_addEdgeToArc(arc, bone->head, NULL);
}
-
+
RIG_addEdgeToArc(arc, bone->tail, bone);
-
+
last_bone = bone;
-
+
if (STREQ(bone->name, "head")) {
contain_head = 1;
}
@@ -1169,12 +1169,12 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
RIG_addControlBone(rg, bone);
}
}
-
+
nb_children = countEditBoneChildren(list, bone);
if (nb_children > 1) {
RigNode *end_node = NULL;
int i;
-
+
if (arc != NULL) {
end_node = newRigNodeTail(rg, arc, bone->tail);
}
@@ -1186,12 +1186,12 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
root_bone = nextEditBoneChild(list, bone, i);
RIG_arcFromBoneChain(rg, list, root_bone, end_node, selected);
}
-
+
/* arc ends here, break */
break;
}
}
-
+
/* If the loop exited without forking */
if (arc != NULL && bone == NULL) {
newRigNodeTail(rg, arc, last_bone->tail);
@@ -1208,22 +1208,22 @@ static void RIG_findHead(RigGraph *rg)
if (rg->head == NULL) {
if (BLI_listbase_is_single(&rg->arcs)) {
RigArc *arc = rg->arcs.first;
-
+
rg->head = (RigNode *)arc->head;
}
else {
RigArc *arc;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge = arc->edges.last;
-
+
if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
rg->head = arc->tail;
break;
}
}
}
-
+
if (rg->head == NULL) {
rg->head = rg->nodes.first;
}
@@ -1235,13 +1235,13 @@ static void RIG_findHead(RigGraph *rg)
static void RIG_printNode(RigNode *node, const char name[])
{
printf("%s %p %i <%0.3f, %0.3f, %0.3f>\n", name, (void *)node, node->degree, node->p[0], node->p[1], node->p[2]);
-
+
if (node->symmetry_flag & SYM_TOPOLOGICAL) {
if (node->symmetry_flag & SYM_AXIAL)
printf("Symmetry AXIAL\n");
else if (node->symmetry_flag & SYM_RADIAL)
printf("Symmetry RADIAL\n");
-
+
print_v3("symmetry axis", node->symmetry_axis);
}
}
@@ -1262,13 +1262,13 @@ void RIG_printArcBones(RigArc *arc)
static void RIG_printCtrl(RigControl *ctrl, char *indent)
{
char text[128];
-
+
printf("%sBone: %s\n", indent, ctrl->bone->name);
printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
-
+
BLI_snprintf(text, sizeof(text), "%soffset", indent);
print_v3(text, ctrl->offset);
-
+
printf("%sFlag: %i\n", indent, ctrl->flag);
}
@@ -1278,13 +1278,13 @@ static void RIG_printLinkedCtrl(RigGraph *rg, EditBone *bone, int tabs)
char indent[64];
char *s = indent;
int i;
-
+
for (i = 0; i < tabs; i++) {
s[0] = '\t';
s++;
}
s[0] = 0;
-
+
for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
if (ctrl->link == bone) {
RIG_printCtrl(ctrl, indent);
@@ -1341,7 +1341,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
RigGraph *rg;
rg = newRigGraph();
-
+
if (obedit == ob) {
rg->editbones = ((bArmature *)obedit->data)->edbo;
}
@@ -1350,7 +1350,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
rg->flag |= RIG_FREE_BONELIST;
}
-
+
rg->ob = ob;
/* Do the rotations */
@@ -1359,25 +1359,25 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0);
}
}
-
+
BLI_removeDoubleNodes((BGraph *)rg, 0.001);
-
+
RIG_removeNormalNodes(rg);
-
+
RIG_removeUneededOffsets(rg);
-
+
BLI_buildAdjacencyList((BGraph *)rg);
-
+
RIG_findHead(rg);
BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
-
+
RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
-
+
if (BLI_isGraphCyclic((BGraph *)rg)) {
printf("armature cyclic\n");
}
-
+
return rg;
}
@@ -1389,7 +1389,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
RigGraph *rg;
rg = newRigGraph();
-
+
if (obedit == ob) {
rg->editbones = arm->edbo;
}
@@ -1407,25 +1407,25 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1);
}
}
-
+
BLI_removeDoubleNodes((BGraph *)rg, 0.001);
-
+
RIG_removeNormalNodes(rg);
-
+
RIG_removeUneededOffsets(rg);
-
+
BLI_buildAdjacencyList((BGraph *)rg);
-
+
RIG_findHead(rg);
BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
-
+
RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
-
+
if (BLI_isGraphCyclic((BGraph *)rg)) {
printf("armature cyclic\n");
}
-
+
return rg;
}
/************************************ GENERATING *****************************************************/
@@ -1434,12 +1434,12 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
static EditBone *add_editbonetolist(char *name, ListBase *list)
{
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
-
+
BLI_strncpy(bone->name, name, sizeof(bone->name));
ED_armature_ebone_unique_name(list, bone->name, NULL);
-
+
BLI_addtail(list, bone);
-
+
bone->flag |= BONE_TIPSEL;
bone->weight = 1.0F;
bone->dist = 0.25F;
@@ -1449,7 +1449,7 @@ static EditBone *add_editbonetolist(char *name, ListBase *list)
bone->rad_tail = 0.05;
bone->segments = 1;
bone->layer = 1; //arm->layer;
-
+
/* Bendy-Bone parameters */
bone->roll1 = 0.0f;
bone->roll2 = 0.0f;
@@ -1473,26 +1473,26 @@ static void generateMissingArcsFromNode(RigGraph *rigg, ReebNode *node, int mult
{
node = node->link_up;
}
-
+
while (node->multi_level < multi_level_limit && node->link_down)
{
node = node->link_down;
}
-
+
if (node->multi_level == multi_level_limit)
{
int i;
-
+
for (i = 0; i < node->degree; i++)
{
ReebArc *earc = node->arcs[i];
-
+
if (earc->flag == ARC_FREE && earc->head == node)
{
ReebNode *other = BIF_otherNodeFromIndex(earc, node);
-
+
earc->flag = ARC_USED;
-
+
//generateBonesForArc(rigg, earc, node, other);
generateMissingArcsFromNode(rigg, other, multi_level_limit);
}
@@ -1504,11 +1504,11 @@ static void generateMissingArcs(RigGraph *rigg)
{
ReebGraph *reebg;
int multi_level_limit = 5;
-
+
for (reebg = rigg->link_mesh; reebg; reebg = reebg->link_up)
{
ReebArc *earc;
-
+
for (earc = reebg->arcs.first; earc; earc = earc->next)
{
if (earc->flag == ARC_USED)
@@ -1532,42 +1532,42 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) {
RigControl *ctrl_child;
-#if 0
+#if 0
printf("CTRL: %s LINK: %s", ctrl->bone->name, ctrl->link->name);
-
+
if (ctrl->link_tail)
{
printf(" TAIL: %s", ctrl->link_tail->name);
}
-
+
printf("\n");
#endif
-
+
/* if there was a tail link: apply link, recalc resize factor and qrot */
if (ctrl->tail_mode != TL_NONE) {
float *tail_vec = NULL;
float v1[3], v2[3], qtail[4];
-
+
if (ctrl->tail_mode == TL_TAIL) {
tail_vec = ctrl->link_tail->tail;
}
else if (ctrl->tail_mode == TL_HEAD) {
tail_vec = ctrl->link_tail->head;
}
-
+
sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head);
sub_v3_v3v3(v2, tail_vec, ctrl->bone->head);
-
+
copy_v3_v3(ctrl->bone->tail, tail_vec);
-
+
rotation_between_vecs_to_quat(qtail, v1, v2);
mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot);
-
+
resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail);
}
-
+
ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot);
-
+
/* Cascade to connected control bones */
for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
if (ctrl_child->link == ctrl->bone) {
@@ -1590,12 +1590,12 @@ static void repositionTailControl(RigGraph *rigg, RigControl *ctrl)
static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float UNUSED(tail[3]), float qrot[4], float resize)
{
float parent_offset[3], tail_offset[3];
-
+
copy_v3_v3(parent_offset, ctrl->offset);
mul_v3_fl(parent_offset, resize);
mul_qt_v3(qrot, parent_offset);
-
- add_v3_v3v3(ctrl->bone->head, head, parent_offset);
+
+ add_v3_v3v3(ctrl->bone->head, head, parent_offset);
ctrl->flag |= RIG_CTRL_HEAD_DONE;
@@ -1607,7 +1607,7 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f
mul_qt_v3(qrot, tail_offset);
add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset);
-
+
ctrl->flag |= RIG_CTRL_TAIL_DONE;
}
@@ -1622,22 +1622,22 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec
float qrot[4], resize;
float v1[3], v2[3];
float l1, l2;
-
+
bone = edge->bone;
-
+
sub_v3_v3v3(v1, edge->tail, edge->head);
sub_v3_v3v3(v2, vec1, vec0);
-
+
l1 = normalize_v3(v1);
l2 = normalize_v3(v2);
resize = l2 / l1;
-
+
rotation_between_vecs_to_quat(qrot, v1, v2);
-
+
copy_v3_v3(bone->head, vec0);
copy_v3_v3(bone->tail, vec1);
-
+
if (!is_zero_v3(up_axis)) {
float qroll[4];
@@ -1650,7 +1650,7 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec
else {
unit_qt(qroll);
}
-
+
mul_qt_qtqt(qrot, qroll, qrot);
}
else {
@@ -1680,18 +1680,18 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
float avg_angle = 0;
/* float avg_length = 0; */ /* UNUSED */
int nb_edges = 0;
-
-
+
+
for (edge = iarc->edges.first; edge; edge = edge->next) {
avg_angle += edge->angle;
nb_edges++;
}
-
+
avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */
/* avg_length = iarc->length / nb_edges; */ /* UNUSED */
-
-
+
+
if (nb_edges > 2) {
for (edge = iarc->edges.first; edge; edge = edge->next) {
if (fabsf(edge->angle - avg_angle) > (float)(M_PI / 6)) {
@@ -1702,16 +1702,16 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
else if (nb_edges == 2 && avg_angle > 0) {
large_angle = 1;
}
-
-
+
+
if (large_angle == 0) {
mode = RETARGET_LENGTH;
}
-
+
if (earc->bcount <= (iarc->count - 1)) {
mode = RETARGET_LENGTH;
}
-
+
return mode;
}
@@ -1720,18 +1720,18 @@ static void printMovesNeeded(int *positions, int nb_positions)
{
int moves = 0;
int i;
-
+
for (i = 0; i < nb_positions; i++) {
moves += positions[i] - (i + 1);
}
-
+
printf("%i moves needed\n", moves);
}
static void printPositions(int *positions, int nb_positions)
{
int i;
-
+
for (i = 0; i < nb_positions; i++) {
printf("%i ", positions[i]);
}
@@ -1750,25 +1750,25 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0,
if (distance_weight > 0) {
sub_v3_v3v3(v1, vec0, vec1);
-
+
v1_inpf = dot_v3v3(v1, v1);
-
+
if (v1_inpf > 0) {
int j;
for (j = i0 + 1; j < i1 - 1; j++) {
float dist;
-
+
bucket = IT_peek(iter, j);
-
+
sub_v3_v3v3(v2, bucket->p, vec1);
-
+
cross_v3_v3v3(c, v1, v2);
-
+
dist = dot_v3v3(c, c) / v1_inpf;
-
+
max_dist = dist > max_dist ? dist : max_dist;
}
-
+
return distance_weight * max_dist;
}
else {
@@ -1784,7 +1784,7 @@ static float costAngle(float original_angle, float vec_first[3], float vec_secon
{
if (angle_weight > 0) {
float current_angle;
-
+
if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) {
current_angle = saacos(dot_v3v3(vec_first, vec_second));
@@ -1837,9 +1837,9 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_
/* Angle cost */
if (edge->prev) {
- sub_v3_v3v3(vec_first, vec1, vec0);
+ sub_v3_v3v3(vec_first, vec1, vec0);
normalize_v3(vec_first);
-
+
new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight);
}
@@ -1861,13 +1861,13 @@ static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions,
{
int previous = 0, current = 0;
int i = 0;
-
+
for (i = 0; joints_left > 0; joints_left--, i++) {
MemoNode *node;
node = table + indexMemoNode(nb_positions, previous, current, joints_left);
-
+
positions[i] = node->next;
-
+
previous = current;
current = node->next;
}
@@ -1879,9 +1879,9 @@ static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_ca
{
MemoNode *node;
int index = indexMemoNode(nb_positions, previous, current, joints_left);
-
+
node = table + index;
-
+
if (node->weight != 0) {
return node;
}
@@ -1901,30 +1901,30 @@ static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_ca
float min_weight = 0.0f;
int min_next = 0;
int next;
-
+
for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) {
MemoNode *next_node;
float *vec2 = vec_cache[next];
float weight = 0.0f;
-
+
/* ADD WEIGHT OF PREVIOUS - CURRENT - NEXT triple */
weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, next, angle_weight, length_weight, distance_weight);
-
+
if (weight >= MAX_COST) {
continue;
}
-
+
/* add node weight */
next_node = solveJoints(table, iter, vec_cache, nb_joints, nb_positions, current, next, edge->next, joints_left - 1, angle_weight, length_weight, distance_weight);
weight += next_node->weight;
-
+
if (min_node == NULL || weight < min_weight) {
min_weight = weight;
min_node = next_node;
min_next = next;
}
}
-
+
if (min_node) {
node->weight = min_weight;
node->next = min_next;
@@ -1935,14 +1935,14 @@ static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_ca
return node;
}
}
-
+
}
static int testFlipArc(RigArc *iarc, RigNode *inode_start)
{
ReebArc *earc = iarc->link_mesh;
ReebNode *enode_start = BIF_NodeFromIndex(earc, inode_start->link_mesh);
-
+
/* no flip needed if both nodes are the same */
if ((enode_start == earc->head && inode_start == iarc->head) ||
(enode_start == earc->tail && inode_start == iarc->tail))
@@ -1973,14 +1973,14 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
int nb_joints = nb_edges - 1;
RetargetMethod method = METHOD_MEMOIZE;
int i;
-
+
if (nb_joints > earc->bcount) {
printf("NOT ENOUGH BUCKETS!\n");
return;
}
best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions");
-
+
if (testFlipArc(iarc, inode_start)) {
node_start = earc->tail;
node_end = earc->head;
@@ -2005,10 +2005,10 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
MemoNode *result;
#endif
float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache");
-
+
positions_cache[0] = node_start->p;
positions_cache[nb_positions + 1] = node_end->p;
-
+
initArcIterator(iter, earc, node_start);
for (i = 1; i <= nb_positions; i++) {
@@ -2031,7 +2031,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
vec0 = node_start->p;
initArcIterator(iter, earc, node_start);
-
+
#ifndef USE_THREADS
printPositions(best_positions, nb_joints);
printMovesNeeded(best_positions, nb_joints);
@@ -2054,11 +2054,11 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
vec1 = node_end->p;
no = node_end->no;
}
-
+
if (edge->bone) {
repositionBone(C, rigg, edge, vec0, vec1, no);
}
-
+
vec0 = vec1;
}
@@ -2078,7 +2078,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
float *vec1 = NULL;
float *previous_vec = NULL;
-
+
if (testFlipArc(iarc, inode_start)) {
node_start = (ReebNode *)earc->tail;
node_end = (ReebNode *)earc->head;
@@ -2087,24 +2087,24 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
node_start = (ReebNode *)earc->head;
node_end = (ReebNode *)earc->tail;
}
-
+
initArcIterator(iter, earc, node_start);
bucket = IT_next(iter);
-
+
vec0 = node_start->p;
-
+
while (bucket != NULL) {
vec1 = bucket->p;
-
+
embedding_length += len_v3v3(vec0, vec1);
-
+
vec0 = vec1;
bucket = IT_next(iter);
}
-
+
embedding_length += len_v3v3(node_end->p, vec1);
-
+
/* fit bones */
initArcIterator(iter, earc, node_start);
@@ -2113,7 +2113,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
vec0 = node_start->p;
previous_vec = vec0;
vec1 = bucket->p;
-
+
for (edge = iarc->edges.first; edge; edge = edge->next) {
float new_bone_length = edge->length / iarc->length * embedding_length;
float *no = NULL;
@@ -2126,7 +2126,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
vec1 = bucket->p;
no = bucket->no;
}
-
+
if (bucket == NULL) {
vec1 = node_end->p;
no = node_end->no;
@@ -2136,7 +2136,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
if (edge->bone) {
repositionBone(C, rigg, edge, vec0, vec1, no);
}
-
+
vec0 = vec1;
previous_vec = vec1;
}
@@ -2145,12 +2145,12 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
{
RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam");
-
+
p->rigg = rigg;
p->iarc = iarc;
p->inode_start = inode_start;
p->context = C;
-
+
BLI_task_pool_push(rigg->task_pool, exec_retargetArctoArc, p, true, TASK_PRIORITY_HIGH);
}
@@ -2162,7 +2162,7 @@ void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, i
bContext *C = p->context;
RigNode *inode_start = p->inode_start;
ReebArc *earc = iarc->link_mesh;
-
+
if (BLI_listbase_is_single(&iarc->edges)) {
RigEdge *edge = iarc->edges.first;
@@ -2175,7 +2175,7 @@ void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, i
}
else {
RetargetMode mode = detectArcRetargetMode(iarc);
-
+
if (mode == RETARGET_AGGRESSIVE) {
retargetArctoArcAggresive(C, rigg, iarc, inode_start);
}
@@ -2190,10 +2190,10 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t
ReebNode *enode = top_node;
ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
int ishape, eshape;
-
+
ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
-
+
inode->link_mesh = enode;
while (ishape == eshape && enode->link_down) {
@@ -2208,13 +2208,13 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t
static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
{
int i;
-
+
for (i = 0; i < enode->degree; i++) {
ReebArc *earc = (ReebArc *)enode->arcs[i];
-
+
if (earc->flag == ARC_FREE) {
earc->flag = ARC_TAKEN;
-
+
if (earc->tail->degree > 1 && earc->tail != end_enode) {
markMultiResolutionChildArc(end_enode, earc->tail);
}
@@ -2229,7 +2229,7 @@ static void markMultiResolutionArc(ReebArc *start_earc)
ReebArc *earc;
for (earc = start_earc->link_up; earc; earc = earc->link_up) {
earc->flag = ARC_TAKEN;
-
+
if (earc->tail->index != start_earc->tail->index) {
markMultiResolutionChildArc(earc->tail, earc->tail);
}
@@ -2245,10 +2245,10 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc
ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS;
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
-
+
while (ishape != eshape && next_earc->link_up) {
next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels
-
+
next_earc = next_earc->link_up;
reebg = reebg->link_up;
enode = next_earc->head;
@@ -2257,7 +2257,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc
next_earc->flag = ARC_USED;
next_iarc->link_mesh = next_earc;
-
+
/* mark all higher levels as taken too */
markMultiResolutionArc(next_earc);
// while (next_earc->link_up)
@@ -2271,17 +2271,17 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R
{
ReebNode *enode;
int ishape, eshape;
-
+
enode = reebg->nodes.first;
-
+
ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
-
+
while (ishape != eshape && reebg->link_up) {
reebg = reebg->link_up;
-
+
enode = reebg->nodes.first;
-
+
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
}
@@ -2296,27 +2296,27 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
int symmetry_group = next_iarc->symmetry_group;
int symmetry_flag = next_iarc->symmetry_flag;
int i;
-
+
next_iarc->link_mesh = NULL;
-
+
// if (root)
// {
// printf("-----------------------\n");
// printf("MATCHING LIMB\n");
// RIG_printArcBones(next_iarc);
// }
-
+
for (i = 0; i < enode->degree; i++) {
next_earc = (ReebArc *)enode->arcs[i];
-
+
// if (next_earc->flag == ARC_FREE)
// {
// printf("candidate (level %i ?= %i) (flag %i ?= %i) (group %i ?= %i)\n",
// symmetry_level, next_earc->symmetry_level,
-// symmetry_flag, next_earc->symmetry_flag,
+// symmetry_flag, next_earc->symmetry_flag,
// symmetry_group, next_earc->symmetry_flag);
// }
-
+
if (next_earc->flag == ARC_FREE &&
next_earc->symmetry_flag == symmetry_flag &&
next_earc->symmetry_group == symmetry_group &&
@@ -2324,16 +2324,16 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
{
// printf("CORRESPONDING ARC FOUND\n");
// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
-
+
matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
break;
}
}
-
+
/* not found, try at higher nodes (lower node might have filtered internal arcs, messing shape of tree */
if (next_iarc->link_mesh == NULL) {
// printf("NO CORRESPONDING ARC FOUND - GOING TO HIGHER LEVELS\n");
-
+
if (enode->link_up) {
start_node->link_mesh = enode->link_up;
findCorrespondingArc(rigg, start_arc, start_node, next_iarc, 0);
@@ -2343,26 +2343,26 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
/* still not found, print debug info */
if (root && next_iarc->link_mesh == NULL) {
start_node->link_mesh = enode; /* linking back with root node */
-
+
// printf("NO CORRESPONDING ARC FOUND\n");
// RIG_printArcBones(next_iarc);
-//
+//
// printf("ON NODE %i, multilevel %i\n", enode->index, enode->multi_level);
-//
+//
// printf("LOOKING FOR\n");
// printf("flag %i -- level %i -- flag %i -- group %i\n", ARC_FREE, symmetry_level, symmetry_flag, symmetry_group);
-//
+//
// printf("CANDIDATES\n");
// for (i = 0; i < enode->degree; i++)
// {
// next_earc = (ReebArc *)enode->arcs[i];
// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
// }
-
+
/* Emergency matching */
for (i = 0; i < enode->degree; i++) {
next_earc = (ReebArc *)enode->arcs[i];
-
+
if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) {
// printf("USING:\n");
// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
@@ -2383,19 +2383,19 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig
if (start_arc) {
ReebNode *enode = start_node->link_mesh;
ReebArc *earc = start_arc->link_mesh;
-
+
retargetArctoArc(C, rigg, start_arc, start_node);
-
+
enode = BIF_otherNodeFromIndex(earc, enode);
inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode);
-
+
/* match with lowest node with correct shape */
matchMultiResolutionNode(rigg, inode, enode);
}
-
+
for (i = 0; i < inode->degree; i++) {
RigArc *next_iarc = (RigArc *)inode->arcs[i];
-
+
/* no back tracking */
if (next_iarc != start_arc) {
findCorrespondingArc(rigg, start_arc, inode, next_iarc, 1);
@@ -2415,7 +2415,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg)
{
bArmature *arm = rigg->ob->data;
RigArc *arc;
-
+
for (arc = rigg->arcs.first; arc; arc = arc->next) {
if (arc->link_mesh) {
retargetArctoArc(C, rigg, arc, arc->head);
@@ -2427,7 +2427,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg)
/* Turn the list into an armature */
arm->edbo = rigg->editbones;
ED_armature_from_edit(arm);
-
+
ED_undo_push(C, "Retarget Skeleton");
}
@@ -2436,19 +2436,19 @@ static void retargetGraphs(bContext *C, RigGraph *rigg)
bArmature *arm = rigg->ob->data;
ReebGraph *reebg = rigg->link_mesh;
RigNode *inode;
-
+
/* flag all ReebArcs as free */
BIF_flagMultiArcs(reebg, ARC_FREE);
-
+
/* return to first level */
inode = rigg->head;
-
+
matchMultiResolutionStartingNode(rigg, reebg, inode);
retargetSubgraph(C, rigg, NULL, inode);
-
+
//generateMissingArcs(rigg);
-
+
finishRetarget(rigg);
/* Turn the list into an armature */
@@ -2464,21 +2464,21 @@ const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index)
if (arc == NULL) {
return "None";
}
-
+
if (bone_index == BLI_listbase_count(&arc->edges)) {
return "Last joint";
}
iedge = BLI_findlink(&arc->edges, bone_index);
-
+
if (iedge == NULL) {
return "Done";
}
-
+
if (iedge->bone == NULL) {
return "Bone offset";
}
-
+
return iedge->bone->name;
}
@@ -2486,13 +2486,13 @@ int RIG_nbJoints(RigGraph *rg)
{
RigArc *arc;
int total = 0;
-
+
total += BLI_listbase_count(&rg->nodes);
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
total += BLI_listbase_count(&arc->edges) - 1; /* -1 because end nodes are already counted */
}
-
+
return total;
}
@@ -2510,14 +2510,14 @@ void BIF_retargetArmature(bContext *C)
double start_time, end_time;
double gstart_time, gend_time;
double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time;
-
+
gstart_time = start_time = PIL_check_seconds_timer();
-
+
reebg = BIF_ReebGraphMultiFromEditMesh(C);
-
+
end_time = PIL_check_seconds_timer();
reeb_time = end_time - start_time;
-
+
printf("Reeb Graph created\n");
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
@@ -2529,42 +2529,42 @@ void BIF_retargetArmature(bContext *C)
bArmature *arm;
arm = ob->data;
-
+
/* Put the armature into editmode */
-
-
+
+
start_time = PIL_check_seconds_timer();
rigg = RIG_graphFromArmature(C, ob, arm);
-
+
end_time = PIL_check_seconds_timer();
rig_time = end_time - start_time;
printf("Armature graph created\n");
-
+
//RIG_printGraph(rigg);
-
+
rigg->link_mesh = reebg;
-
+
printf("retargetting %s\n", ob->id.name);
-
+
start_time = PIL_check_seconds_timer();
retargetGraphs(C, rigg);
-
+
end_time = PIL_check_seconds_timer();
retarget_time = end_time - start_time;
BIF_freeRetarget();
-
+
GLOBAL_RIGG = rigg;
-
+
break; /* only one armature at a time */
}
}
CTX_DATA_END;
-
+
gend_time = PIL_check_seconds_timer();
total_time = gend_time - gstart_time;
@@ -2575,7 +2575,7 @@ void BIF_retargetArmature(bContext *C)
printf("rig: \t\t%.3f (%.1f%%)\n", rig_time, rig_time / total_time * 100);
printf("retarget: \t%.3f (%.1f%%)\n", retarget_time, retarget_time / total_time * 100);
printf("-----------\n");
-
+
ED_undo_push(C, "Retarget Skeleton");
// XXX
@@ -2593,7 +2593,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
char *side_string = scene->toolsettings->skgen_side_string;
char *num_string = scene->toolsettings->skgen_num_string;
int free_template = 0;
-
+
if (template_rigg) {
ob = template_rigg->ob;
}
@@ -2602,31 +2602,31 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
ob = obedit;
template_rigg = armatureSelectedToGraph(C, ob, ob->data);
}
-
+
if (BLI_listbase_is_empty(&template_rigg->arcs)) {
// XXX
// error("No Template and no deforming bones selected");
return;
}
-
+
rigg = cloneRigGraph(template_rigg, armedit->edbo, obedit, side_string, num_string);
-
+
iarc = rigg->arcs.first;
-
+
iarc->link_mesh = earc;
iarc->head->link_mesh = earc->head;
iarc->tail->link_mesh = earc->tail;
-
+
retargetArctoArc(C, rigg, iarc, iarc->head);
-
+
finishRetarget(rigg);
-
+
/* free template if it comes from the edit armature */
if (free_template) {
RIG_freeRigGraph((BGraph *)template_rigg);
}
RIG_freeRigGraph((BGraph *)rigg);
-
+
ED_armature_edit_validate_active(armedit);
// XXX
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index a08898a37f6..84eb780b56b 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -465,7 +465,7 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig
{
float vec2[3] = {0, 0, 1}, axis[3];
float angle;
-
+
glPushMatrix();
cross_v3_v3v3(axis, vec2, pt->no);
@@ -2126,7 +2126,7 @@ static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra
sk_addStrokePoint(C, sketch, stk, dd, snap);
sk_updateDrawData(dd);
sk_updateNextPoint(sketch, stk);
-
+
return 1;
}
@@ -2246,7 +2246,7 @@ SK_Sketch *contextSketch(const bContext *C, int create)
if (obedit && obedit->type == OB_ARMATURE) {
bArmature *arm = obedit->data;
-
+
if (arm->sketch == NULL && create) {
arm->sketch = createSketch();
}
@@ -2263,7 +2263,7 @@ SK_Sketch *viewcontextSketch(ViewContext *vc, int create)
if (obedit && obedit->type == OB_ARMATURE) {
bArmature *arm = obedit->data;
-
+
if (arm->sketch == NULL && create) {
arm->sketch = createSketch();
}
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index c0177d41d4a..4e31fcc7a11 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -94,7 +94,7 @@ struct LaplacianSystem {
float *H; /* diagonal H matrix */
float *p; /* values from all p vectors */
float *mindist; /* minimum distance to a bone for all vertices */
-
+
BVHTree *bvhtree; /* ray tracing acceleration structure */
const MLoopTri **vltree; /* a looptri that the vertex belongs to */
} heat;
@@ -259,7 +259,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
if (sys->areaweights)
for (a = 0, face = sys->faces; a < sys->totface; a++, face++)
laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]);
-
+
for (a = 0; a < totvert; a++) {
if (sys->areaweights) {
if (sys->varea[a] != 0.0f)
@@ -275,7 +275,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
if (sys->storeweights)
sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight");
-
+
for (a = 0, face = sys->faces; a < totface; a++, face++)
laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]);
@@ -403,7 +403,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
const MLoopTri *lt = &looptri[a];
float bb[6];
int vtri[3];
-
+
vtri[0] = mloop[lt->tri[0]].v;
vtri[1] = mloop[lt->tri[1]].v;
vtri[2] = mloop[lt->tri[2]].v;
@@ -414,14 +414,14 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
minmax_v3v3_v3(bb, bb + 3, verts[vtri[2]]);
BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2);
-
+
//Setup inverse pointers to use on isect.orig
sys->heat.vltree[vtri[0]] = lt;
sys->heat.vltree[vtri[1]] = lt;
sys->heat.vltree[vtri[2]] = lt;
}
- BLI_bvhtree_balance(sys->heat.bvhtree);
+ BLI_bvhtree_balance(sys->heat.bvhtree);
}
static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
@@ -457,7 +457,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
static float heat_source_distance(LaplacianSystem *sys, int vertex, int source)
{
float closest[3], d[3], dist, cosine;
-
+
/* compute euclidian distance */
closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[source], sys->heat.tip[source]);
@@ -479,7 +479,7 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source)
if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON))
if (heat_ray_source_visible(sys, vertex, source))
return 1;
-
+
return 0;
}
@@ -514,7 +514,7 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
}
else
h = 0.0f;
-
+
sys->heat.H[vertex] = h;
}
@@ -531,7 +531,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
v3 = (*face)[2];
normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]);
-
+
add_v3_v3(sys->heat.vnors[v1], fnor);
add_v3_v3(sys->heat.vnors[v2], fnor);
add_v3_v3(sys->heat.vnors[v3], fnor);
@@ -677,7 +677,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
for (a = 0; a < me->totvert; a++)
vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology);
}
-
+
/* compute weights per bone */
for (j = 0; j < numsource; j++) {
if (!selected[j])
@@ -715,7 +715,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
continue;
solution = laplacian_system_get_solution(sys, a);
-
+
if (bbone) {
if (solution > 0.0f)
ED_vgroup_vert_add(ob, dgrouplist[j], a, solution,
@@ -850,7 +850,7 @@ typedef struct MeshDeformBind {
/* direct solver */
int *varidx;
-
+
BVHTree *bvhtree;
BVHTreeFromMesh bvhdata;
@@ -871,7 +871,7 @@ typedef struct MeshDeformIsect {
bool isect;
float u, v;
-
+
} MeshDeformIsect;
/* ray intersection */
@@ -891,9 +891,9 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
MeshDeformIsect *isec = data->isec;
float no[3], co[3], dist;
float *face[3];
-
+
lt = &looptri[index];
-
+
face[0] = mdb->cagecos[mloop[lt->tri[0]].v];
face[1] = mdb->cagecos[mloop[lt->tri[1]].v];
face[2] = mdb->cagecos[mloop[lt->tri[2]].v];
@@ -917,7 +917,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r
hit->index = index;
hit->dist = dist;
copy_v3_v3(hit->co, co);
-
+
isec->isect = (dot_v3v3(no, ray->direction) <= 0.0f);
isec->lambda = dist;
}
@@ -1000,7 +1000,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
copy_v3_v3(start, co);
sub_v3_v3v3(dir, outside, start);
normalize_v3(dir);
-
+
isect = meshdeform_ray_tree_intersect(mdb, start, outside);
if (isect && !isect->facing)
return 1;
@@ -1014,7 +1014,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
BLI_INLINE int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n)
{
int size = mdb->size;
-
+
x += MESHDEFORM_OFFSET[n][0];
y += MESHDEFORM_OFFSET[n][1];
z += MESHDEFORM_OFFSET[n][2];
@@ -1118,7 +1118,7 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb)
if (mdb->semibound[a])
ts++;
}
-
+
printf("interior %d exterior %d boundary %d semi-boundary %d\n", ti, te, tb, ts);
}
#endif
@@ -1227,7 +1227,7 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, LinearSolver *contex
return;
EIG_linear_solver_matrix_add(context, mdb->varidx[acenter], mdb->varidx[acenter], 1.0f);
-
+
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
for (i = 1; i <= 6; i++) {
a = meshdeform_index(mdb, x, y, z, i);
@@ -1277,7 +1277,7 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int
a = meshdeform_index(mdb, x, y, z, 0);
if (!mdb->semibound[a])
return;
-
+
mdb->phi[a] = 0.0f;
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
@@ -1415,7 +1415,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
printf("totalphi deficiency [%s|%d] %d: %.10f\n",
(mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]);
#endif
-
+
/* free */
MEM_freeN(mdb->varidx);
@@ -1501,7 +1501,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
/* start with all cells untyped */
for (a = 0; a < mdb->size3; a++)
mdb->tag[a] = MESHDEFORM_TAG_UNTYPED;
-
+
/* detect intersections and tag boundary cells */
for (z = 0; z < mdb->size; z++)
for (y = 0; y < mdb->size; y++)
@@ -1588,7 +1588,7 @@ void ED_mesh_deform_bind_callback(
/* get mesh and cage mesh */
mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos");
mdb.totvert = totvert;
-
+
mdb.cagedm = cagedm;
mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm);
mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos");
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 01ff436fa1e..da328ee485f 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -85,7 +85,7 @@ bool ED_object_posemode_enter_ex(Object *ob)
{
BLI_assert(!ID_IS_LINKED(ob));
bool ok = false;
-
+
switch (ob->type) {
case OB_ARMATURE:
ob->restore_mode = ob->mode;
@@ -170,11 +170,11 @@ static bool pose_has_protected_selected(Object *ob, short warn)
void ED_pose_recalculate_paths(Scene *scene, Object *ob)
{
ListBase targets = {NULL, NULL};
-
+
/* set flag to force recalc, then grab the relevant bones to target */
ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS;
animviz_get_object_motionpaths(ob, &targets);
-
+
/* recalculate paths, then free */
animviz_calc_motionpaths(scene, &targets);
BLI_freelistN(&targets);
@@ -183,52 +183,52 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob)
/* show popup to determine settings */
static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
-{
+{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
-
+
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* set default settings from existing/stored settings */
{
bAnimVizSettings *avs = &ob->pose->avs;
PointerRNA avs_ptr;
-
+
RNA_int_set(op->ptr, "start_frame", avs->path_sf);
RNA_int_set(op->ptr, "end_frame", avs->path_ef);
-
+
RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location"));
}
-
+
/* show popup dialog to allow editing of range... */
// FIXME: hardcoded dimensions here are just arbitrary
return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y);
}
-/* For the object with pose/action: create path curves for selected bones
+/* For the object with pose/action: create path curves for selected bones
* This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
*/
static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
-
+
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* grab baking settings from operator settings */
{
bAnimVizSettings *avs = &ob->pose->avs;
PointerRNA avs_ptr;
-
+
avs->path_sf = RNA_int_get(op->ptr, "start_frame");
avs->path_ef = RNA_int_get(op->ptr, "end_frame");
-
+
RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr);
RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location"));
}
-
+
/* set up path data for bones being calculated */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -244,7 +244,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
- return OPERATOR_FINISHED;
+ return OPERATOR_FINISHED;
}
void POSE_OT_paths_calculate(wmOperatorType *ot)
@@ -253,23 +253,23 @@ void POSE_OT_paths_calculate(wmOperatorType *ot)
ot->name = "Calculate Bone Paths";
ot->idname = "POSE_OT_paths_calculate";
ot->description = "Calculate paths for the selected bones";
-
+
/* api callbacks */
ot->invoke = pose_calculate_paths_invoke;
ot->exec = pose_calculate_paths_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
+ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
"First frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0);
- RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
+ RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
"Last frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0);
-
- RNA_def_enum(ot->srna, "bake_location", rna_enum_motionpath_bake_location_items, 0,
- "Bake Location",
+
+ RNA_def_enum(ot->srna, "bake_location", rna_enum_motionpath_bake_location_items, 0,
+ "Bake Location",
"Which point on the bones is used when calculating paths");
}
@@ -281,7 +281,7 @@ static int pose_update_paths_poll(bContext *C)
Object *ob = CTX_data_active_object(C);
return (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0;
}
-
+
return false;
}
@@ -289,17 +289,17 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
Scene *scene = CTX_data_scene(C);
-
+
if (ELEM(NULL, ob, scene))
return OPERATOR_CANCELLED;
/* calculate the bones that now have motionpaths... */
/* TODO: only make for the selected bones? */
ED_pose_recalculate_paths(scene, ob);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -309,11 +309,11 @@ void POSE_OT_paths_update(wmOperatorType *ot)
ot->name = "Update Bone Paths";
ot->idname = "POSE_OT_paths_update";
ot->description = "Recalculate paths for bones that already have them";
-
+
/* api callbakcs */
ot->exec = pose_update_paths_exec;
ot->poll = pose_update_paths_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -325,10 +325,10 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
{
bPoseChannel *pchan;
bool skipped = false;
-
+
if (ELEM(NULL, ob, ob->pose))
return;
-
+
/* free the motionpath blocks for all bones - This is easier for users to quickly clear all */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->mpath) {
@@ -341,7 +341,7 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected)
}
}
}
-
+
/* if nothing was skipped, there should be no paths left! */
if (skipped == false)
ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS;
@@ -352,18 +352,18 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bool only_selected = RNA_boolean_get(op->ptr, "only_selected");
-
+
/* only continue if there's an object */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* use the backend function for this */
ED_pose_clear_paths(ob, only_selected);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
- return OPERATOR_FINISHED;
+
+ return OPERATOR_FINISHED;
}
/* operator callback/wrapper */
@@ -381,17 +381,17 @@ void POSE_OT_paths_clear(wmOperatorType *ot)
ot->name = "Clear Bone Paths";
ot->idname = "POSE_OT_paths_clear";
ot->description = "Clear path caches for all bones, hold Shift key for selected bones only";
-
+
/* api callbacks */
ot->invoke = pose_clear_paths_invoke;
ot->exec = pose_clear_paths_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
- ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
+ ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected",
"Only clear paths from selected bones");
RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE);
}
@@ -406,13 +406,13 @@ static void pose_copy_menu(Scene *scene)
bPoseChannel *pchan, *pchanact;
short nr = 0;
int i = 0;
-
+
/* paranoia checks */
if (ELEM(NULL, ob, ob->pose)) return;
if ((ob == obedit) || (ob->mode & OB_MODE_POSE) == 0) return;
-
+
pchan = BKE_pose_channel_active(ob);
-
+
if (pchan == NULL) return;
pchanact = pchan;
arm = ob->data;
@@ -434,10 +434,10 @@ static void pose_copy_menu(Scene *scene)
else
nr = pupmenu("Copy Pose Attributes %t|Local Location %x1|Local Rotation %x2|Local Size %x3|%l|Visual Location %x9|Visual Rotation %x10|Visual Size %x11|%l|Constraints (All) %x4|%l|Transform Locks %x6|IK Limits %x7|Bone Shape %x8");
}
-
- if (nr <= 0)
+
+ if (nr <= 0)
return;
-
+
if (nr != 5) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((arm->layer & pchan->bone->layer) &&
@@ -458,23 +458,23 @@ static void pose_copy_menu(Scene *scene)
case 4: /* All Constraints */
{
ListBase tmp_constraints = {NULL, NULL};
-
- /* copy constraints to tmpbase and apply 'local' tags before
+
+ /* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
BKE_constraints_copy(&tmp_constraints, &pchanact->constraints, true);
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
bConstraint *con;
-
+
/* add proxy-local tags */
for (con = tmp_constraints.first; con; con = con->next)
con->flag |= CONSTRAINT_PROXY_LOCAL;
}
BLI_movelisttolist(&pchan->constraints, &tmp_constraints);
-
+
/* update flags (need to add here, not just copy) */
pchan->constflag |= pchanact->constflag;
-
+
if (ob->pose)
BKE_pose_tag_recalc(bmain, ob->pose);
}
@@ -505,12 +505,12 @@ static void pose_copy_menu(Scene *scene)
case 10: /* Visual Rotation */
{
float delta_mat[4][4];
-
+
BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
-
+
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float tmp_quat[4];
-
+
/* need to convert to quat first (in temp var)... */
mat4_to_quat(tmp_quat, delta_mat);
quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, tmp_quat);
@@ -524,7 +524,7 @@ static void pose_copy_menu(Scene *scene)
case 11: /* Visual Size */
{
float delta_mat[4][4], size[4];
-
+
BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat);
mat4_to_size(size, delta_mat);
copy_v3_v3(pchan->size, size);
@@ -537,20 +537,20 @@ static void pose_copy_menu(Scene *scene)
bConstraint *con, *con_back;
int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */
ListBase const_copy = {NULL, NULL};
-
+
BLI_duplicatelist(&const_copy, &(pchanact->constraints));
-
+
/* build the puplist of constraints */
for (con = pchanact->constraints.first, i = 0; con; con = con->next, i++) {
const_toggle[i] = 1;
// add_numbut(i, UI_BTYPE_TOGGLE|INT, con->name, 0, 0, &(const_toggle[i]), "");
}
-
+
// if (!do_clever_numbuts("Select Constraints", i, REDRAW)) {
// BLI_freelistN(&const_copy);
// return;
// }
-
+
/* now build a new listbase from the options selected */
for (i = 0, con = const_copy.first; con; i++) {
/* if not selected, free/remove it from the list */
@@ -562,7 +562,7 @@ static void pose_copy_menu(Scene *scene)
else
con = con->next;
}
-
+
/* Copy the temo listbase to the selected posebones */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if ((arm->layer & pchan->bone->layer) &&
@@ -570,8 +570,8 @@ static void pose_copy_menu(Scene *scene)
(pchan != pchanact) )
{
ListBase tmp_constraints = {NULL, NULL};
-
- /* copy constraints to tmpbase and apply 'local' tags before
+
+ /* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
BKE_constraints_copy(&tmp_constraints, &const_copy, true);
@@ -581,22 +581,22 @@ static void pose_copy_menu(Scene *scene)
con->flag |= CONSTRAINT_PROXY_LOCAL;
}
BLI_movelisttolist(&pchan->constraints, &tmp_constraints);
-
+
/* update flags (need to add here, not just copy) */
pchan->constflag |= pchanact->constflag;
}
}
BLI_freelistN(&const_copy);
BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */
-
+
if (ob->pose)
BKE_pose_tag_recalc(bmain, ob->pose);
}
-
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
-
+
BIF_undo_push("Copy Pose Attributes");
-
+
}
#endif
@@ -608,7 +608,7 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op)
bArmature *arm;
/* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers");
@@ -626,13 +626,13 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op)
ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers);
BLI_freelistN(&bones_names);
-
+
/* since we renamed stuff... */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -642,11 +642,11 @@ void POSE_OT_flip_names(wmOperatorType *ot)
ot->name = "Flip Names";
ot->idname = "POSE_OT_flip_names";
ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones";
-
+
/* api callbacks */
ot->exec = pose_flip_names_exec;
ot->poll = ED_operator_posemode_local;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -663,12 +663,12 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op)
bArmature *arm;
char newname[MAXBONENAME];
short axis = RNA_enum_get(op->ptr, "axis");
-
+
/* paranoia checks */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
arm = ob->data;
-
+
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -677,13 +677,13 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op)
ED_armature_bone_rename(arm, pchan->name, newname);
}
CTX_DATA_END;
-
+
/* since we renamed stuff... */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -695,20 +695,20 @@ void POSE_OT_autoside_names(wmOperatorType *ot)
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "AutoName by Axis";
ot->idname = "POSE_OT_autoside_names";
ot->description = "Automatically renames the selected bones according to which side of the target axis they fall on";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_autoside_names_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* settings */
ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with");
}
@@ -719,18 +719,18 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
int mode = RNA_enum_get(op->ptr, "type");
-
+
/* set rotation mode of selected bones */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
pchan->rotmode = mode;
}
CTX_DATA_END;
-
+
/* notifiers and updates */
DAG_id_tag_update((ID *)ob, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -740,15 +740,15 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot)
ot->name = "Set Rotation Mode";
ot->idname = "POSE_OT_rotation_mode_set";
ot->description = "Set the rotation representation used by selected bones";
-
+
/* callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_bone_rotmode_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_posebone_rotmode_items, 0, "Rotation Mode", "");
}
@@ -790,25 +790,25 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16;
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
int i;
-
+
/* sanity checking */
if (arm == NULL)
return OPERATOR_CANCELLED;
-
+
/* use RNA to set the layers
* although it would be faster to just set directly using bitflags, we still
* need to setup a RNA pointer so that we get the "update" callbacks for free...
*/
RNA_id_pointer_create(&arm->id, &ptr);
-
+
for (i = 0; i < maxLayers; i++)
layers[i] = 1;
-
+
RNA_boolean_set_array(&ptr, "layers", layers);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -819,14 +819,14 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
ot->name = "Show All Layers";
ot->idname = "ARMATURE_OT_layers_show_all";
ot->description = "Make all armature layers visible";
-
+
/* callbacks */
ot->exec = pose_armature_layers_showall_exec;
ot->poll = armature_layers_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)");
}
@@ -840,16 +840,16 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev
bArmature *arm = armature_layers_get_data(&ob);
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* sanity checking */
if (arm == NULL)
return OPERATOR_CANCELLED;
-
+
/* get RNA pointer to armature data to use that to retrieve the layers as ints to init the operator */
RNA_id_pointer_create((ID *)arm, &ptr);
RNA_boolean_get_array(&ptr, "layers", layers);
RNA_boolean_set_array(op->ptr, "layers", layers);
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
@@ -885,15 +885,15 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
ot->name = "Change Armature Layers";
ot->idname = "ARMATURE_OT_armature_layers";
ot->description = "Change the visible armature layers";
-
+
/* callbacks */
ot->invoke = armature_layers_invoke;
ot->exec = armature_layers_exec;
ot->poll = armature_layers_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
}
@@ -904,22 +904,22 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* get layers that are active already */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
short bit;
-
+
/* loop over the bits for this pchan's layers, adding layers where they're needed */
for (bit = 0; bit < 32; bit++) {
layers[bit] = (pchan->bone->layer & (1u << bit)) != 0;
}
}
CTX_DATA_END;
-
+
/* copy layers to operator */
RNA_boolean_set_array(op->ptr, "layers", layers);
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
@@ -959,15 +959,15 @@ void POSE_OT_bone_layers(wmOperatorType *ot)
ot->name = "Change Bone Layers";
ot->idname = "POSE_OT_bone_layers";
ot->description = "Change the layers that the selected bones belong to";
-
+
/* callbacks */
ot->invoke = pose_bone_layers_invoke;
ot->exec = pose_bone_layers_exec;
ot->poll = ED_operator_posemode_exclusive;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
}
@@ -978,12 +978,12 @@ void POSE_OT_bone_layers(wmOperatorType *ot)
static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* get layers that are active already */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
{
short bit;
-
+
/* loop over the bits for this pchan's layers, adding layers where they're needed */
for (bit = 0; bit < 32; bit++) {
if (ebone->layer & (1u << bit)) {
@@ -992,10 +992,10 @@ static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEven
}
}
CTX_DATA_END;
-
+
/* copy layers to operator */
RNA_boolean_set_array(op->ptr, "layers", layers);
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
@@ -1007,10 +1007,10 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op)
bArmature *arm = (ob) ? ob->data : NULL;
PointerRNA ptr;
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
-
+
/* get the values set in the operator properties */
RNA_boolean_get_array(op->ptr, "layers", layers);
-
+
/* set layers of pchans based on the values set in the operator props */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
{
@@ -1019,10 +1019,10 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op)
RNA_boolean_set_array(&ptr, "layers", layers);
}
CTX_DATA_END;
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1032,15 +1032,15 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
ot->name = "Change Bone Layers";
ot->idname = "ARMATURE_OT_bone_layers";
ot->description = "Change the layers that the selected bones belong to";
-
+
/* callbacks */
ot->invoke = armature_bone_layers_invoke;
ot->exec = armature_bone_layers_exec;
ot->poll = ED_operator_editarmature;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
}
@@ -1048,10 +1048,10 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
/* ********************************************** */
/* Show/Hide Bones */
-static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
+static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
bArmature *arm = ob->data;
-
+
if (arm->layer & bone->layer) {
if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_HIDDEN_P;
@@ -1063,10 +1063,10 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
return 0;
}
-static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
+static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
bArmature *arm = ob->data;
-
+
if (arm->layer & bone->layer) {
/* hrm... typo here? */
if ((bone->flag & BONE_SELECTED) == 0) {
@@ -1079,7 +1079,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr
}
/* active object is armature in posemode, poll checked */
-static int pose_hide_exec(bContext *C, wmOperator *op)
+static int pose_hide_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm = ob->data;
@@ -1092,10 +1092,10 @@ static int pose_hide_exec(bContext *C, wmOperator *op)
bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb);
else
bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1105,24 +1105,24 @@ void POSE_OT_hide(wmOperatorType *ot)
ot->name = "Hide Selected";
ot->idname = "POSE_OT_hide";
ot->description = "Tag selected bones to not be visible in Pose Mode";
-
+
/* api callbacks */
ot->exec = pose_hide_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "");
}
-static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
+static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
{
const bool select = GET_INT_FROM_POINTER(data);
bArmature *arm = ob->data;
-
+
if (arm->layer & bone->layer) {
if (bone->flag & BONE_HIDDEN_P) {
if (!(bone->flag & BONE_UNSELECTABLE)) {
@@ -1131,19 +1131,19 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *data)
bone->flag &= ~BONE_HIDDEN_P;
}
}
-
+
return 0;
}
/* active object is armature in posemode, poll checked */
-static int pose_reveal_exec(bContext *C, wmOperator *op)
+static int pose_reveal_exec(bContext *C, wmOperator *op)
{
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bArmature *arm = ob->data;
const bool select = RNA_boolean_get(op->ptr, "select");
-
+
bone_looper(ob, arm->bonebase.first, SET_INT_IN_POINTER(select), show_pose_bone_cb);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
@@ -1156,11 +1156,11 @@ void POSE_OT_reveal(wmOperatorType *ot)
ot->name = "Reveal Selected";
ot->idname = "POSE_OT_reveal";
ot->description = "Reveal all bones hidden in Pose Mode";
-
+
/* api callbacks */
ot->exec = pose_reveal_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -1175,7 +1175,7 @@ static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
-
+
/* loop through all selected pchans, flipping and keying (as needed) */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -1188,11 +1188,11 @@ static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
}
}
CTX_DATA_END;
-
+
/* notifiers and updates */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1202,11 +1202,11 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot)
ot->name = "Flip Quats";
ot->idname = "POSE_OT_quaternions_flip";
ot->description = "Flip quaternion values to achieve desired rotations, while maintaining the same orientations";
-
+
/* callbacks */
ot->exec = pose_flip_quats_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 3463cf856a2..9648bb99c05 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -65,13 +65,13 @@ static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
/* only continue if there's an object and pose */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* for now, just call the API function for this */
BKE_pose_add_group(ob->pose, NULL);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -81,11 +81,11 @@ void POSE_OT_group_add(wmOperatorType *ot)
ot->name = "Add Bone Group";
ot->idname = "POSE_OT_group_add";
ot->description = "Add a new bone group";
-
+
/* api callbacks */
ot->exec = pose_group_add_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -94,17 +94,17 @@ void POSE_OT_group_add(wmOperatorType *ot)
static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
-
+
/* only continue if there's an object and pose */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* for now, just call the API function for this */
BKE_pose_remove_group_index(ob->pose, ob->pose->active_group);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -114,11 +114,11 @@ void POSE_OT_group_remove(wmOperatorType *ot)
ot->name = "Remove Bone Group";
ot->idname = "POSE_OT_group_remove";
ot->description = "Remove the active bone group";
-
+
/* api callbacks */
ot->exec = pose_group_remove_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -131,14 +131,14 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
Object *ob = ED_pose_object_from_context(C);
bPose *pose;
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type");
-
+
uiPopupMenu *pup;
uiLayout *layout;
bActionGroup *grp;
int i;
-
+
/* only continue if there's an object, and a pose there too */
- if (ELEM(NULL, ob, ob->pose))
+ if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
pose = ob->pose;
@@ -152,28 +152,28 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
return op->type->exec(C, op);
}
}
-
+
/* if there's no active group (or active is invalid), create a new menu to find it */
if (pose->active_group <= 0) {
/* create a new menu, and start populating it with group names */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
-
- /* special entry - allow to create new group, then use that
+
+ /* special entry - allow to create new group, then use that
* (not to be used for removing though)
*/
if (strstr(op->idname, "assign")) {
uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0);
uiItemS(layout);
}
-
+
/* add entries for each group */
for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++)
uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i);
-
+
/* finish building the menu, and process it (should result in calling self again) */
UI_popup_menu_end(C, pup);
-
+
return OPERATOR_INTERFACE;
}
else {
@@ -195,14 +195,14 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
pose = ob->pose;
-
- /* set the active group number to the one from operator props
+
+ /* set the active group number to the one from operator props
* - if 0 after this, make a new group...
*/
pose->active_group = RNA_int_get(op->ptr, "type");
if (pose->active_group == 0)
BKE_pose_add_group(ob->pose, NULL);
-
+
/* add selected bones to group then */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -213,7 +213,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op)
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
/* report done status */
if (done)
return OPERATOR_FINISHED;
@@ -227,15 +227,15 @@ void POSE_OT_group_assign(wmOperatorType *ot)
ot->name = "Add Selected to Bone Group";
ot->idname = "POSE_OT_group_assign";
ot->description = "Add selected bones to the chosen bone group";
-
+
/* api callbacks */
ot->invoke = pose_groups_menu_invoke;
ot->exec = pose_group_assign_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_int(ot->srna, "type", 0, 0, INT_MAX, "Bone Group Index", "", 0, 10);
}
@@ -245,11 +245,11 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
bool done = false;
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
/* find selected bones to remove from all bone groups */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
@@ -259,10 +259,10 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
}
}
CTX_DATA_END;
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
/* report done status */
if (done)
return OPERATOR_FINISHED;
@@ -276,11 +276,11 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
ot->name = "Remove Selected from Bone Groups";
ot->idname = "POSE_OT_group_unassign";
ot->description = "Remove selected bones from all bone groups";
-
+
/* api callbacks */
ot->exec = pose_group_unassign_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -435,16 +435,16 @@ void POSE_OT_group_sort(wmOperatorType *ot)
static void pose_group_select(bContext *C, Object *ob, bool select)
{
bPose *pose = ob->pose;
-
+
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
if (select) {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group)
pchan->bone->flag |= BONE_SELECTED;
}
else {
- if (pchan->agrp_index == pose->active_group)
+ if (pchan->agrp_index == pose->active_group)
pchan->bone->flag &= ~BONE_SELECTED;
}
}
@@ -455,16 +455,16 @@ static void pose_group_select(bContext *C, Object *ob, bool select)
static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
pose_group_select(C, ob, 1);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -474,11 +474,11 @@ void POSE_OT_group_select(wmOperatorType *ot)
ot->name = "Select Bones of Bone Group";
ot->idname = "POSE_OT_group_select";
ot->description = "Select bones in active Bone Group";
-
+
/* api callbacks */
ot->exec = pose_group_select_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -486,16 +486,16 @@ void POSE_OT_group_select(wmOperatorType *ot)
static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = ED_pose_object_from_context(C);
-
+
/* only continue if there's an object, and a pose there too */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
-
+
pose_group_select(C, ob, 0);
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -505,11 +505,11 @@ void POSE_OT_group_deselect(wmOperatorType *ot)
ot->name = "Deselect Bone Group";
ot->idname = "POSE_OT_group_deselect";
ot->description = "Deselect bones of active Bone Group";
-
+
/* api callbacks */
ot->exec = pose_group_deselect_exec;
ot->poll = ED_operator_posemode_context;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index e77561234c5..fd5db84873b 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -80,7 +80,7 @@
static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUSED(c)) {}
/* ************************************************************* */
-/* == POSE-LIBRARY TOOL FOR BLENDER ==
+/* == POSE-LIBRARY TOOL FOR BLENDER ==
*
* Overview:
* This tool allows animators to store a set of frequently used poses to dump into
@@ -99,7 +99,7 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
/* ************************************************************* */
-/* gets the first available frame in poselib to store a pose on
+/* gets the first available frame in poselib to store a pose on
* - frames start from 1, and a pose should occur on every frame... 0 is error!
*/
static int poselib_get_free_index(bAction *act)
@@ -107,17 +107,17 @@ static int poselib_get_free_index(bAction *act)
TimeMarker *marker;
int low = 0, high = 0;
bool changed = false;
-
+
/* sanity checks */
if (ELEM(NULL, act, act->markers.first)) return 1;
-
- /* As poses are not stored in chronological order, we must iterate over this list
+
+ /* As poses are not stored in chronological order, we must iterate over this list
* a few times until we don't make any new discoveries (mostly about the lower bound).
* Prevents problems with deleting then trying to add new poses [#27412]
*/
do {
changed = false;
-
+
for (marker = act->markers.first; marker; marker = marker->next) {
/* only increase low if value is 1 greater than low, to find "gaps" where
* poses were removed from the poselib
@@ -126,7 +126,7 @@ static int poselib_get_free_index(bAction *act)
low++;
changed = true;
}
-
+
/* value replaces high if it is the highest value encountered yet */
if (marker->frame > high) {
high = marker->frame;
@@ -134,19 +134,19 @@ static int poselib_get_free_index(bAction *act)
}
}
} while (changed != 0);
-
- /* - if low is not equal to high, then low+1 is a gap
- * - if low is equal to high, then high+1 is the next index (add at end)
+
+ /* - if low is not equal to high, then low+1 is a gap
+ * - if low is equal to high, then high+1 is the next index (add at end)
*/
- if (low < high)
+ if (low < high)
return (low + 1);
- else
+ else
return (high + 1);
}
/* returns the active pose for a poselib */
static TimeMarker *poselib_get_active_pose(bAction *act)
-{
+{
if ((act) && (act->active_marker))
return BLI_findlink(&act->markers, act->active_marker - 1);
else
@@ -158,14 +158,14 @@ static TimeMarker *poselib_get_active_pose(bAction *act)
static Object *get_poselib_object(bContext *C)
{
ScrArea *sa;
-
+
/* sanity check */
if (C == NULL)
return NULL;
-
+
sa = CTX_wm_area(C);
-
- if (sa && (sa->spacetype == SPACE_BUTS))
+
+ if (sa && (sa->spacetype == SPACE_BUTS))
return ED_object_context(C);
else
return BKE_object_pose_armature_get(CTX_data_active_object(C));
@@ -195,14 +195,14 @@ static bAction *poselib_init_new(Object *ob)
/* sanity checks - only for armatures */
if (ELEM(NULL, ob, ob->pose))
return NULL;
-
+
/* init object's poselib action (unlink old one if there) */
if (ob->poselib)
id_us_min(&ob->poselib->id);
-
+
ob->poselib = BKE_action_add(G.main, "PoseLib");
ob->poselib->idroot = ID_OB;
-
+
return ob->poselib;
}
@@ -223,17 +223,17 @@ static bAction *poselib_validate(Object *ob)
static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = get_poselib_object(C);
-
+
/* sanity checks */
if (ob == NULL)
return OPERATOR_CANCELLED;
-
+
/* new method here deals with the rest... */
poselib_init_new(ob);
-
+
/* notifier here might evolve? */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -243,11 +243,11 @@ void POSELIB_OT_new(wmOperatorType *ot)
ot->name = "New Pose Library";
ot->idname = "POSELIB_OT_new";
ot->description = "Add New Pose Library to active Object";
-
+
/* callbacks */
ot->exec = poselib_new_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -257,18 +257,18 @@ void POSELIB_OT_new(wmOperatorType *ot)
static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = get_poselib_object(C);
-
+
/* sanity checks */
if (ELEM(NULL, ob, ob->poselib))
return OPERATOR_CANCELLED;
-
+
/* there should be a poselib (we just checked above!), so just lower its user count and remove */
id_us_min(&ob->poselib->id);
ob->poselib = NULL;
-
+
/* notifier here might evolve? */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -278,11 +278,11 @@ void POSELIB_OT_unlink(wmOperatorType *ot)
ot->name = "Unlink Pose Library";
ot->idname = "POSELIB_OT_unlink";
ot->description = "Remove Pose Library from active Object";
-
+
/* callbacks */
ot->exec = poselib_unlink_exec;
ot->poll = has_poselib_pose_data_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -290,7 +290,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot)
/* ************************************************************* */
/* Pose Editing Operators */
-/* This tool automagically generates/validates poselib data so that it corresponds to the data
+/* This tool automagically generates/validates poselib data so that it corresponds to the data
* in the action. This is for use in making existing actions usable as poselibs.
*/
static int poselib_sanitize_exec(bContext *C, wmOperator *op)
@@ -300,13 +300,13 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
DLRBT_Tree keys;
ActKeyColumn *ak;
TimeMarker *marker, *markern;
-
+
/* validate action */
if (act == NULL) {
BKE_report(op->reports, RPT_WARNING, "No action to validate");
return OPERATOR_CANCELLED;
}
-
+
/* determine which frames have keys */
BLI_dlrbTree_init(&keys);
action_to_keylist(NULL, act, &keys, NULL);
@@ -322,39 +322,39 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op)
break;
}
}
-
+
/* add new if none found */
if (marker == NULL) {
/* add pose to poselib */
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
-
+
BLI_snprintf(marker->name, sizeof(marker->name), "F%d Pose", (int)ak->cfra);
-
+
marker->frame = (int)ak->cfra;
marker->flag = -1;
-
+
BLI_addtail(&act->markers, marker);
}
}
-
+
/* remove all untagged poses (unused), and remove all tags */
for (marker = act->markers.first; marker; marker = markern) {
markern = marker->next;
-
+
if (marker->flag != -1)
BLI_freelinkN(&act->markers, marker);
else
marker->flag = 0;
}
-
+
/* free temp memory */
BLI_dlrbTree_free(&keys);
-
- /* send notifiers for this - using keyframe editing notifiers, since action
- * may be being shown in anim editors as active action
+
+ /* send notifiers for this - using keyframe editing notifiers, since action
+ * may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
return OPERATOR_FINISHED;
}
@@ -364,11 +364,11 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot)
ot->name = "Sanitize Pose Library Action";
ot->idname = "POSELIB_OT_action_sanitize";
ot->description = "Make action suitable for use as a Pose Library";
-
+
/* callbacks */
ot->exec = poselib_sanitize_exec;
ot->poll = has_poselib_pose_data_for_editing_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -399,14 +399,14 @@ static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout,
Object *ob = get_poselib_object(C);
bAction *act = ob->poselib; /* never NULL */
TimeMarker *marker;
-
+
wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1);
BLI_assert(ot != NULL);
/* set the operator execution context correctly */
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-
+
/* add each marker to this menu */
for (marker = act->markers.first; marker; marker = marker->next) {
PointerRNA props_ptr;
@@ -426,30 +426,30 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U
bPose *pose = (ob) ? ob->pose : NULL;
uiPopupMenu *pup;
uiLayout *layout;
-
+
/* sanity check */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose))
return OPERATOR_CANCELLED;
-
+
/* start building */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
-
+
/* add new (adds to the first unoccupied frame) */
uiItemIntO(layout, IFACE_("Add New"), ICON_NONE, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib));
-
+
/* check if we have any choices to add a new pose in any other way */
if ((ob->poselib) && (ob->poselib->markers.first)) {
/* add new (on current frame) */
uiItemIntO(layout, IFACE_("Add New (Current Frame)"), ICON_NONE, "POSELIB_OT_pose_add", "frame", CFRA);
-
+
/* replace existing - submenu */
uiItemMenuF(layout, IFACE_("Replace Existing..."), 0, poselib_add_menu_invoke__replacemenu, NULL);
}
-
+
UI_popup_menu_end(C, pup);
-
+
/* this operator is only for a menu, not used further */
return OPERATOR_INTERFACE;
}
@@ -464,14 +464,14 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
KeyingSet *ks;
int frame = RNA_int_get(op->ptr, "frame");
char name[64];
-
+
/* sanity check (invoke should have checked this anyway) */
- if (ELEM(NULL, ob, pose))
+ if (ELEM(NULL, ob, pose))
return OPERATOR_CANCELLED;
-
+
/* get name to give to pose */
RNA_string_get(op->ptr, "name", name);
-
+
/* add pose to poselib - replaces any existing pose there
* - for the 'replace' option, this should end up finding the appropriate marker,
* so no new one will be added
@@ -484,23 +484,23 @@ static int poselib_add_exec(bContext *C, wmOperator *op)
}
if (marker == NULL) {
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
-
+
BLI_strncpy(marker->name, name, sizeof(marker->name));
marker->frame = frame;
-
+
BLI_addtail(&act->markers, marker);
}
-
+
/* validate name */
BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name));
-
+
/* use Keying Set to determine what to store for the pose */
ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_SELECTED_ID); /* this includes custom props :)*/
ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame);
-
+
/* store new 'active' pose number */
act->active_marker = BLI_listbase_count(&act->markers);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -511,15 +511,15 @@ void POSELIB_OT_pose_add(wmOperatorType *ot)
ot->name = "PoseLib Add Pose";
ot->idname = "POSELIB_OT_pose_add";
ot->description = "Add the current Pose to the active Pose Library";
-
+
/* api callbacks */
ot->invoke = poselib_add_menu_invoke;
ot->exec = poselib_add_exec;
ot->poll = poselib_add_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX);
RNA_def_string(ot->srna, "name", "Pose", 64, "Pose Name", "Name of newly added Pose");
@@ -540,7 +540,7 @@ static const EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA
if (C == NULL) {
return DummyRNA_NULL_items;
}
-
+
/* check that the action exists */
if (act) {
/* add each marker to the list */
@@ -587,12 +587,12 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index);
return OPERATOR_CANCELLED;
}
-
+
/* remove relevant keyframes */
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
BezTriple *bezt;
unsigned int i;
-
+
if (fcu->bezt) {
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
/* check if remove */
@@ -603,18 +603,18 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
}
}
}
-
+
/* remove poselib from list */
BLI_freelinkN(&act->markers, marker);
-
+
/* fix active pose number */
act->active_marker = 0;
-
- /* send notifiers for this - using keyframe editing notifiers, since action
- * may be being shown in anim editors as active action
+
+ /* send notifiers for this - using keyframe editing notifiers, since action
+ * may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -622,20 +622,20 @@ static int poselib_remove_exec(bContext *C, wmOperator *op)
void POSELIB_OT_pose_remove(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "PoseLib Remove Pose";
ot->idname = "POSELIB_OT_pose_remove";
ot->description = "Remove nth pose from the active Pose Library";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = poselib_remove_exec;
ot->poll = has_poselib_pose_data_for_editing_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove");
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
@@ -648,13 +648,13 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve
Object *ob = get_poselib_object(C);
bAction *act = (ob) ? ob->poselib : NULL;
TimeMarker *marker;
-
+
/* check if valid poselib */
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
-
+
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, act->active_marker - 1);
if (marker == NULL) {
@@ -666,7 +666,7 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve
RNA_enum_set(op->ptr, "pose", act->active_marker - 1);
RNA_string_set(op->ptr, "name", marker->name);
}
-
+
/* part to sync with other similar operators... */
return WM_operator_props_popup_confirm(C, op, event);
}
@@ -677,32 +677,32 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
bAction *act = (ob) ? ob->poselib : NULL;
TimeMarker *marker;
char newname[64];
-
+
/* check if valid poselib */
if (act == NULL) {
BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data");
return OPERATOR_CANCELLED;
}
-
+
/* get index (and pointer) of pose to remove */
marker = BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose"));
if (marker == NULL) {
BKE_report(op->reports, RPT_ERROR, "Invalid index for pose");
return OPERATOR_CANCELLED;
}
-
+
/* get new name */
RNA_string_get(op->ptr, "name", newname);
-
+
/* copy name and validate it */
BLI_strncpy(marker->name, newname, sizeof(marker->name));
BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name));
-
- /* send notifiers for this - using keyframe editing notifiers, since action
- * may be being shown in anim editors as active action
+
+ /* send notifiers for this - using keyframe editing notifiers, since action
+ * may be being shown in anim editors as active action
*/
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
-
+
/* done */
return OPERATOR_FINISHED;
}
@@ -710,20 +710,20 @@ static int poselib_rename_exec(bContext *C, wmOperator *op)
void POSELIB_OT_pose_rename(wmOperatorType *ot)
{
PropertyRNA *prop;
-
+
/* identifiers */
ot->name = "PoseLib Rename Pose";
ot->idname = "POSELIB_OT_pose_rename";
ot->description = "Rename specified pose from the active Pose Library";
-
+
/* api callbacks */
ot->invoke = poselib_rename_invoke;
ot->exec = poselib_rename_exec;
ot->poll = has_poselib_pose_data_for_editing_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
/* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */
ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
@@ -822,10 +822,10 @@ void POSELIB_OT_pose_move(wmOperatorType *ot)
typedef struct tPoseLib_PreviewData {
ListBase backups; /* tPoseLib_Backup structs for restoring poses */
ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */
-
+
Scene *scene; /* active scene */
ScrArea *sa; /* active area */
-
+
PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */
Object *ob; /* object to work on */
bArmature *arm; /* object's armature data */
@@ -842,7 +842,7 @@ typedef struct tPoseLib_PreviewData {
short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */
char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */
char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */
-
+
char headerstr[UI_MAX_DRAW_STR]; /* Info-text to print in header */
} tPoseLib_PreviewData;
@@ -852,7 +852,7 @@ enum {
PL_PREVIEW_RUNNING,
PL_PREVIEW_CONFIRM,
PL_PREVIEW_CANCEL,
- PL_PREVIEW_RUNONCE
+ PL_PREVIEW_RUNONCE
};
/* defines for tPoseLib_PreviewData->redraw values */
@@ -874,9 +874,9 @@ enum {
/* simple struct for storing backup info */
typedef struct tPoseLib_Backup {
struct tPoseLib_Backup *next, *prev;
-
+
bPoseChannel *pchan; /* pose channel backups are for */
-
+
bPoseChannel olddata; /* copy of pose channel's old data (at start) */
IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */
} tPoseLib_Backup;
@@ -904,22 +904,22 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) {
/* try to find posechannel */
pchan = BKE_pose_channel_find_name(pld->pose, agrp->name);
-
+
/* backup data if available */
if (pchan) {
tPoseLib_Backup *plb;
-
+
/* store backup */
plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup");
-
+
plb->pchan = pchan;
memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel));
-
+
if (pchan->prop)
plb->oldprops = IDP_CopyProperty(pchan->prop);
-
+
BLI_addtail(&pld->backups, plb);
-
+
/* mark as being affected */
pld->totcount++;
}
@@ -930,7 +930,7 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
static void poselib_backup_restore(tPoseLib_PreviewData *pld)
{
tPoseLib_Backup *plb;
-
+
for (plb = pld->backups.first; plb; plb = plb->next) {
/* copy most of data straight back */
memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel));
@@ -956,7 +956,7 @@ static void poselib_backup_free_data(tPoseLib_PreviewData *pld)
IDP_FreeProperty(plb->oldprops);
MEM_freeN(plb->oldprops);
}
-
+
/* free backup element now */
BLI_freelinkN(&pld->backups, plb);
}
@@ -977,19 +977,19 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
bPoseChannel *pchan;
bAction *act = pld->act;
bActionGroup *agrp;
-
+
KeyframeEditData ked = {{NULL}};
KeyframeEditFunc group_ok_cb;
int frame = 1;
const bool any_bone_selected = pld->flag & PL_PREVIEW_ANY_BONE_SELECTED;
-
+
/* get the frame */
if (pld->marker)
frame = pld->marker->frame;
else
return;
-
-
+
+
/* init settings for testing groups for keyframes */
group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
ked.f1 = ((float)frame) - 0.5f;
@@ -1001,10 +1001,10 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) {
/* has keyframe on this frame, so try to get a PoseChannel with this name */
pchan = BKE_pose_channel_find_name(pose, agrp->name);
-
+
if (pchan) {
bool ok = 0;
-
+
/* check if this bone should get any animation applied */
if (!any_bone_selected) {
/* if no bones are selected, then any bone is ok */
@@ -1020,7 +1020,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld)
}
}
- if (ok)
+ if (ok)
animsys_evaluate_action_group(ptr, act, agrp, NULL, (float)frame);
}
}
@@ -1034,7 +1034,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
bPoseChannel *pchan;
bAction *act = pld->act;
bActionGroup *agrp;
-
+
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
ListBase dsources = {NULL, NULL};
bool autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id);
@@ -1044,13 +1044,13 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
/* only for selected bones unless there aren't any selected, in which case all are included */
pchan = BKE_pose_channel_find_name(pose, agrp->name);
-
+
if (pchan) {
if (!any_bone_selected || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) {
if (autokey) {
/* add datasource override for the PoseChannel, to be used later */
- ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
-
+ ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
+
/* clear any unkeyed tags */
if (pchan->bone)
pchan->bone->flag &= ~BONE_UNKEYED;
@@ -1063,14 +1063,14 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
}
}
}
-
+
/* perform actual auto-keying now */
if (autokey) {
/* insert keyframes for all relevant bones in one go */
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
BLI_freelistN(&dsources);
}
-
+
/* send notifiers for this */
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
@@ -1079,7 +1079,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData
static void poselib_preview_apply(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata;
-
+
/* only recalc pose (and its dependencies) if pose has changed */
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
/* don't clear pose if firsttime */
@@ -1087,7 +1087,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
poselib_backup_restore(pld);
else
pld->flag &= ~PL_PREVIEW_FIRSTTIME;
-
+
/* pose should be the right one to draw (unless we're temporarily not showing it) */
if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) {
RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker));
@@ -1095,8 +1095,8 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
}
else
RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */
-
- /* old optimize trick... this enforces to bypass the depgraph
+
+ /* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
// FIXME: shouldn't this use the builtin stuff?
@@ -1105,7 +1105,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
else
BKE_pose_where_is(pld->scene, pld->ob);
}
-
+
/* do header print - if interactively previewing */
if (pld->state == PL_PREVIEW_RUNNING) {
if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
@@ -1118,10 +1118,10 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
char tempstr[65];
char markern[64];
short index;
-
+
/* get search-string */
index = pld->search_cursor;
-
+
if (index >= 0 && index < sizeof(tempstr) - 1) {
memcpy(&tempstr[0], &pld->searchstr[0], index);
tempstr[index] = '|';
@@ -1130,7 +1130,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
else {
BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
}
-
+
/* get marker name */
BLI_strncpy(markern, pld->marker ? pld->marker->name : "No Matches", sizeof(markern));
@@ -1149,7 +1149,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
ED_area_headerprint(pld->sa, pld->headerstr);
}
}
-
+
/* request drawing of view + clear redraw flag */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob);
pld->redraw = PL_PREVIEW_NOREDRAW;
@@ -1157,7 +1157,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op)
/* ---------------------------- */
-/* This helper function is called during poselib_preview_poses to find the
+/* This helper function is called during poselib_preview_poses to find the
* pose to preview next (after a change event)
*/
static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
@@ -1165,20 +1165,20 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
/* stop if not going anywhere, as we assume that there is a direction to move in */
if (step == 0)
return;
-
+
/* search-string dictates a special approach */
if (pld->searchstr[0]) {
TimeMarker *marker;
LinkData *ld, *ldn, *ldc;
-
+
/* free and rebuild if needed (i.e. if search-str changed) */
if (!STREQ(pld->searchstr, pld->searchold)) {
/* free list of temporary search matches */
BLI_freelistN(&pld->searchp);
-
+
/* generate a new list of search matches */
for (marker = pld->act->markers.first; marker; marker = marker->next) {
- /* does the name partially match?
+ /* does the name partially match?
* - don't worry about case, to make it easier for users to quickly input a name (or
* part of one), which is the whole point of this feature
*/
@@ -1189,17 +1189,17 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
BLI_addtail(&pld->searchp, ld);
}
}
-
+
/* set current marker to NULL (so that we start from first) */
pld->marker = NULL;
}
-
+
/* check if any matches */
if (BLI_listbase_is_empty(&pld->searchp)) {
pld->marker = NULL;
return;
}
-
+
/* find first match */
for (ldc = pld->searchp.first; ldc; ldc = ldc->next) {
if (ldc->data == pld->marker)
@@ -1207,8 +1207,8 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
}
if (ldc == NULL)
ldc = pld->searchp.first;
-
- /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
+
+ /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
@@ -1219,19 +1219,19 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
for (ld = ldc; ld && step; ld = ldn, step++)
ldn = (ld->prev) ? ld->prev : pld->searchp.last;
}
-
+
/* set marker */
if (ld)
pld->marker = ld->data;
}
else {
TimeMarker *marker, *next;
-
+
/* if no marker, because we just ended searching, then set that to the start of the list */
if (pld->marker == NULL)
pld->marker = pld->act->markers.first;
-
- /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
+
+ /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
* until step == 0. At this point, marker should be the correct marker.
*/
if (step > 0) {
@@ -1242,7 +1242,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
for (marker = pld->marker; marker && step; marker = next, step++)
next = (marker->prev) ? marker->prev : pld->act->markers.last;
}
-
+
/* it should be fairly impossible for marker to be NULL */
if (marker)
pld->marker = marker;
@@ -1259,28 +1259,28 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh
short len = strlen(pld->searchstr);
short index = pld->search_cursor;
short i;
-
- for (i = index; i <= len; i++)
+
+ for (i = index; i <= len; i++)
pld->searchstr[i - 1] = pld->searchstr[i];
-
+
pld->search_cursor--;
-
+
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
return;
}
break;
-
+
case DELKEY:
if (pld->searchstr[0] && pld->searchstr[1]) {
short len = strlen(pld->searchstr);
short index = pld->search_cursor;
int i;
-
+
if (index < len) {
- for (i = index; i < len; i++)
+ for (i = index; i < len; i++)
pld->searchstr[i] = pld->searchstr[i + 1];
-
+
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
return;
@@ -1288,23 +1288,23 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh
}
break;
}
-
+
if (ascii) {
/* character to add to the string */
short index = pld->search_cursor;
short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0;
short i;
-
+
if (len) {
- for (i = len; i > index; i--)
+ for (i = len; i > index; i--)
pld->searchstr[i] = pld->searchstr[i - 1];
}
else
pld->searchstr[1] = 0;
-
+
pld->searchstr[index] = ascii;
pld->search_cursor++;
-
+
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
}
@@ -1315,18 +1315,18 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
{
tPoseLib_PreviewData *pld = op->customdata;
int ret = OPERATOR_RUNNING_MODAL;
-
+
/* only accept 'press' event, and ignore 'release', so that we don't get double actions */
if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) {
//printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val);
- return ret;
+ return ret;
}
-
+
/* backup stuff that needs to occur before every operation
* - make a copy of searchstr, so that we know if cache needs to be rebuilt
*/
BLI_strncpy(pld->searchold, pld->searchstr, sizeof(pld->searchold));
-
+
/* if we're currently showing the original pose, only certain events are handled */
if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
switch (event->type) {
@@ -1335,7 +1335,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case RIGHTMOUSE:
pld->state = PL_PREVIEW_CANCEL;
break;
-
+
/* exit - confirm */
case LEFTMOUSE:
case RETKEY:
@@ -1343,30 +1343,30 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case SPACEKEY:
pld->state = PL_PREVIEW_CONFIRM;
break;
-
+
/* view manipulation */
- /* we add pass through here, so that the operators responsible for these can still run,
+ /* we add pass through here, so that the operators responsible for these can still run,
* even though we still maintain control (as RUNNING_MODAL flag is still set too)
*/
case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
- case PADPLUSKEY: case PADMINUS:
+ case PADPLUSKEY: case PADMINUS:
case MIDDLEMOUSE: case MOUSEMOVE:
//pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
-
+
/* quicky compare to original */
case TABKEY:
pld->flag &= ~PL_PREVIEW_SHOWORIGINAL;
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
}
-
+
/* EXITS HERE... */
return ret;
}
-
+
/* NORMAL EVENT HANDLING... */
/* searching takes priority over normal activity */
switch (event->type) {
@@ -1375,7 +1375,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case RIGHTMOUSE:
pld->state = PL_PREVIEW_CANCEL;
break;
-
+
/* exit - confirm */
case LEFTMOUSE:
case RETKEY:
@@ -1383,39 +1383,39 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
case SPACEKEY:
pld->state = PL_PREVIEW_CONFIRM;
break;
-
+
/* toggle between original pose and poselib pose*/
case TABKEY:
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* change to previous pose (cyclic) */
case PAGEUPKEY:
case WHEELUPMOUSE:
poselib_preview_get_next(pld, -1);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* change to next pose (cyclic) */
case PAGEDOWNKEY:
case WHEELDOWNMOUSE:
poselib_preview_get_next(pld, 1);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* jump 5 poses (cyclic, back) */
case DOWNARROWKEY:
poselib_preview_get_next(pld, -5);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* jump 5 poses (cyclic, forward) */
case UPARROWKEY:
poselib_preview_get_next(pld, 5);
pld->redraw = PL_PREVIEW_REDRAWALL;
break;
-
+
/* change to next pose or searching cursor control */
case RIGHTARROWKEY:
if (pld->searchstr[0]) {
@@ -1430,7 +1430,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* change to next pose or searching cursor control */
case LEFTARROWKEY:
if (pld->searchstr[0]) {
@@ -1445,7 +1445,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* change to first pose or start of searching string */
case HOMEKEY:
if (pld->searchstr[0]) {
@@ -1456,11 +1456,11 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
/* change to first pose */
pld->marker = pld->act->markers.first;
pld->act->active_marker = 1;
-
+
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* change to last pose or start of searching string */
case ENDKEY:
if (pld->searchstr[0]) {
@@ -1471,20 +1471,20 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
/* change to last pose */
pld->marker = pld->act->markers.last;
pld->act->active_marker = BLI_listbase_count(&pld->act->markers);
-
+
pld->redraw = PL_PREVIEW_REDRAWALL;
}
break;
-
+
/* view manipulation */
- /* we add pass through here, so that the operators responsible for these can still run,
+ /* we add pass through here, so that the operators responsible for these can still run,
* even though we still maintain control (as RUNNING_MODAL flag is still set too)
*/
case MIDDLEMOUSE: case MOUSEMOVE:
//pld->redraw = PL_PREVIEW_REDRAWHEADER;
ret = OPERATOR_PASS_THROUGH;
break;
-
+
/* view manipulation, or searching */
case PAD0: case PAD1: case PAD2: case PAD3: case PAD4:
case PAD5: case PAD6: case PAD7: case PAD8: case PAD9:
@@ -1499,13 +1499,13 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
ret = OPERATOR_PASS_THROUGH;
}
break;
-
+
/* otherwise, assume that searching might be able to handle it */
default:
poselib_preview_handle_search(pld, event->type, event->ascii);
break;
}
-
+
return ret;
}
@@ -1517,19 +1517,19 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
tPoseLib_PreviewData *pld;
Object *ob = get_poselib_object(C);
int pose_index = RNA_int_get(op->ptr, "pose_index");
-
+
/* set up preview state info */
op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data");
-
+
/* get basic data */
pld->ob = ob;
pld->arm = (ob) ? (ob->data) : NULL;
pld->pose = (ob) ? (ob->pose) : NULL;
pld->act = (ob) ? (ob->poselib) : NULL;
-
+
pld->scene = CTX_data_scene(C);
pld->sa = CTX_wm_area(C);
-
+
/* get starting pose based on RNA-props for this operator */
if (pose_index == -1)
pld->marker = poselib_get_active_pose(pld->act);
@@ -1537,7 +1537,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
else
pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL;
-
+
/* check if valid poselib */
if (ELEM(NULL, pld->ob, pld->pose, pld->arm)) {
BKE_report(op->reports, RPT_ERROR, "Pose lib is only for armatures in pose mode");
@@ -1553,7 +1553,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
if (pld->act->markers.first) {
/* just use first one then... */
pld->marker = pld->act->markers.first;
- if (pose_index > -2)
+ if (pose_index > -2)
BKE_report(op->reports, RPT_WARNING, "Pose lib had no active pose");
}
else {
@@ -1562,23 +1562,23 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op)
return;
}
}
-
+
/* get ID pointer for applying poses */
RNA_id_pointer_create(&ob->id, &pld->rna_ptr);
-
+
/* make backups for restoring pose */
poselib_backup_posecopy(pld);
-
+
/* set flags for running */
pld->state = PL_PREVIEW_RUNNING;
pld->redraw = PL_PREVIEW_REDRAWALL;
pld->flag |= PL_PREVIEW_FIRSTTIME;
-
+
/* set depsgraph flags */
/* make sure the lock is set OK, unlock can be accidentally saved? */
pld->pose->flag |= POSE_LOCKED;
pld->pose->flag &= ~POSE_DO_UNLOCK;
-
+
/* clear strings + search */
pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0';
pld->search_cursor = 0;
@@ -1594,18 +1594,18 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
bArmature *arm = pld->arm;
bAction *act = pld->act;
TimeMarker *marker = pld->marker;
-
+
/* redraw the header so that it doesn't show any of our stuff anymore */
ED_area_headerprint(pld->sa, NULL);
-
+
/* this signal does one recalc on pose, then unlocks, so ESC or edit will work */
pose->flag |= POSE_DO_UNLOCK;
-
+
/* clear pose if canceled */
if (pld->state == PL_PREVIEW_CANCEL) {
poselib_backup_restore(pld);
-
- /* old optimize trick... this enforces to bypass the depgraph
+
+ /* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
if ((arm->flag & ARM_DELAYDEFORM) == 0)
@@ -1616,14 +1616,14 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
else if (pld->state == PL_PREVIEW_CONFIRM) {
/* tag poses as appropriate */
poselib_keytag_pose(C, scene, pld);
-
+
/* change active pose setting */
act->active_marker = BLI_findindex(&act->markers, marker) + 1;
action_set_activemarker(act, marker, NULL);
-
+
/* Update event for pose and deformation children */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-
+
/* updates */
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
//remake_action_ipos(ob->action);
@@ -1631,14 +1631,14 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
else
BKE_pose_where_is(scene, ob);
}
-
+
/* Request final redraw of the view. */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob);
-
+
/* free memory used for backups and searching */
poselib_backup_free_data(pld);
BLI_freelistN(&pld->searchp);
-
+
/* free temp data for operator */
MEM_freeN(pld);
op->customdata = NULL;
@@ -1649,10 +1649,10 @@ static int poselib_preview_exit(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld = op->customdata;
int exit_state = pld->state;
-
+
/* finish up */
poselib_preview_cleanup(C, op);
-
+
if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR))
return OPERATOR_CANCELLED;
else
@@ -1670,18 +1670,18 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve
{
tPoseLib_PreviewData *pld = op->customdata;
int ret;
-
+
/* 1) check state to see if we're still running */
if (pld->state != PL_PREVIEW_RUNNING)
return poselib_preview_exit(C, op);
-
+
/* 2) handle events */
ret = poselib_preview_handle_event(C, op, event);
-
+
/* 3) apply changes and redraw, otherwise, confirming goes wrong */
if (pld->redraw)
poselib_preview_apply(C, op);
-
+
return ret;
}
@@ -1689,20 +1689,20 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve
static int poselib_preview_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{
tPoseLib_PreviewData *pld;
-
+
/* check if everything is ok, and init settings for modal operator */
poselib_preview_init_data(C, op);
pld = (tPoseLib_PreviewData *)op->customdata;
-
+
if (pld->state == PL_PREVIEW_ERROR) {
/* an error occurred, so free temp mem used */
poselib_preview_cleanup(C, op);
return OPERATOR_CANCELLED;
}
-
+
/* do initial apply to have something to look at */
poselib_preview_apply(C, op);
-
+
/* add temp handler if we're running as a modal operator */
WM_event_add_modal_handler(C, op);
@@ -1713,28 +1713,28 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, const wmEvent *UN
static int poselib_preview_exec(bContext *C, wmOperator *op)
{
tPoseLib_PreviewData *pld;
-
+
/* check if everything is ok, and init settings for modal operator */
poselib_preview_init_data(C, op);
pld = (tPoseLib_PreviewData *)op->customdata;
-
+
if (pld->state == PL_PREVIEW_ERROR) {
/* an error occurred, so free temp mem used */
poselib_preview_cleanup(C, op);
return OPERATOR_CANCELLED;
}
-
+
/* the exec() callback is effectively a 'run-once' scenario, so set the state to that
* so that everything draws correctly
*/
pld->state = PL_PREVIEW_RUNONCE;
-
+
/* apply the active pose */
poselib_preview_apply(C, op);
-
+
/* now, set the status to exit */
pld->state = PL_PREVIEW_CONFIRM;
-
+
/* cleanup */
return poselib_preview_exit(C, op);
}
@@ -1745,21 +1745,21 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
ot->name = "PoseLib Browse Poses";
ot->idname = "POSELIB_OT_browse_interactive";
ot->description = "Interactively browse poses in 3D-View";
-
+
/* callbacks */
ot->invoke = poselib_preview_invoke;
ot->modal = poselib_preview_modal;
ot->cancel = poselib_preview_cancel;
ot->exec = poselib_preview_exec;
ot->poll = has_poselib_pose_data_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* properties */
// TODO: make the pose_index into a proper enum instead of a cryptic int...
ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX);
-
+
// XXX: percentage vs factor?
/* not used yet */
/* RNA_def_float_factor(ot->srna, "blend_factor", 1.0f, 0.0f, 1.0f, "Blend Factor", "Amount that the pose is applied on top of the existing poses", 0.0f, 1.0f); */
@@ -1771,7 +1771,7 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot)
ot->name = "Apply Pose Library Pose";
ot->idname = "POSELIB_OT_apply_pose";
ot->description = "Apply specified Pose Library pose to the rig";
-
+
/* callbacks */
ot->exec = poselib_preview_exec;
ot->poll = has_poselib_pose_data_poll;
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 4b62fd15c04..1389b26a1e1 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -101,9 +101,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
// XXX: actually, we can probably still get away with no object - at most we have no updates
if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone))
return;
-
+
arm = ob->data;
-
+
/* can only change selection state if bone can be modified */
if (PBONE_SELECTABLE(arm, pchan->bone)) {
/* change selection state - activate too if selected */
@@ -115,16 +115,16 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select)
pchan->bone->flag &= ~BONE_SELECTED;
arm->act_bone = NULL;
}
-
+
// TODO: select and activate corresponding vgroup?
-
- /* tag necessary depsgraph updates
+
+ /* tag necessary depsgraph updates
* (see rna_Bone_select_update() in rna_armature.c for details)
*/
if (arm->flag & ARM_HAS_VIZ_DEPS) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
/* send necessary notifiers */
WM_main_add_notifier(NC_GEOM | ND_DATA, ob);
}
@@ -138,16 +138,16 @@ bool ED_armature_pose_select_pick_with_buffer(
{
Object *ob = base->object;
Bone *nearBone;
-
+
if (!ob || !ob->pose) return 0;
nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1, do_nearest);
-
+
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
Object *ob_act = OBACT;
bArmature *arm = ob->data;
-
+
/* since we do unified select, we don't shift+select a bone if the
* armature object was not active yet.
* note, special exception for armature mode so we can do multi-select
@@ -191,7 +191,7 @@ bool ED_armature_pose_select_pick_with_buffer(
}
}
}
-
+
if (ob_act) {
/* in weightpaint we select the associated vertex group too */
if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
@@ -200,18 +200,18 @@ bool ED_armature_pose_select_pick_with_buffer(
DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
}
}
- /* if there are some dependencies for visualizing armature state
- * (e.g. Mask Modifier in 'Armature' mode), force update
+ /* if there are some dependencies for visualizing armature state
+ * (e.g. Mask Modifier in 'Armature' mode), force update
*/
else if (arm->flag & ARM_HAS_VIZ_DEPS) {
- /* NOTE: ob not ob_act here is intentional - it's the source of the
+ /* NOTE: ob not ob_act here is intentional - it's the source of the
* bones being selected [T37247]
*/
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
}
}
-
+
return nearBone != NULL;
}
@@ -221,12 +221,12 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
{
bArmature *arm = ob->data;
bPoseChannel *pchan;
-
+
/* we call this from outliner too */
if (ob->pose == NULL) {
return;
}
-
+
/* Determine if we're selecting or deselecting */
if (select_mode == SEL_TOGGLE) {
select_mode = SEL_SELECT;
@@ -239,7 +239,7 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
}
}
}
-
+
/* Set the flags accordingly */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* ignore the pchan if it isn't visible or if its selection cannot be changed */
@@ -254,19 +254,19 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil
static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
{
Bone *curBone;
-
+
/* stop when unconnected child is encountered, or when unselectable bone is encountered */
if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE))
return;
-
+
/* XXX old cruft! use notifiers instead */
//select_actionchannel_by_name (ob->action, bone->name, !(shift));
-
+
if (extend)
bone->flag &= ~BONE_SELECTED;
else
bone->flag |= BONE_SELECTED;
-
+
for (curBone = bone->childbase.first; curBone; curBone = curBone->next)
selectconnected_posebonechildren(ob, curBone, extend);
}
@@ -286,7 +286,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
if (!bone)
return OPERATOR_CANCELLED;
-
+
/* Select parents */
for (curBone = bone; curBone; curBone = next) {
/* ignore bone if cannot be selected */
@@ -295,7 +295,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
curBone->flag &= ~BONE_SELECTED;
else
curBone->flag |= BONE_SELECTED;
-
+
if (curBone->flag & BONE_CONNECTED)
next = curBone->parent;
else
@@ -304,14 +304,14 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
else
next = NULL;
}
-
+
/* Select children */
for (curBone = bone->childbase.first; curBone; curBone = next)
selectconnected_posebonechildren(ob, curBone, extend);
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -331,15 +331,15 @@ void POSE_OT_select_linked(wmOperatorType *ot)
ot->name = "Select Connected";
ot->idname = "POSE_OT_select_linked";
ot->description = "Select bones related to selected ones by parent/child relationships";
-
+
/* api callbacks */
/* leave 'exec' unset */
ot->invoke = pose_select_connected_invoke;
ot->poll = pose_select_linked_poll;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
}
@@ -349,7 +349,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
static int pose_de_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
-
+
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
bArmature *arm = ob->data;
@@ -358,7 +358,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
if (action == SEL_TOGGLE) {
action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
}
-
+
/* Set the flags */
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones)
{
@@ -367,7 +367,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
-
+
/* weightpaint or mask modifiers need depsgraph updates */
if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -382,14 +382,14 @@ void POSE_OT_select_all(wmOperatorType *ot)
ot->name = "(De)select All";
ot->idname = "POSE_OT_select_all";
ot->description = "Toggle selection status of all bones";
-
+
/* api callbacks */
ot->exec = pose_de_select_all_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
WM_operator_properties_select_all(ot);
}
@@ -416,15 +416,15 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
else {
return OPERATOR_CANCELLED;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
return OPERATOR_FINISHED;
}
@@ -451,7 +451,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
bArmature *arm = (bArmature *)ob->data;
bConstraint *con;
int found = 0;
-
+
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
if (pchan->bone->flag & BONE_SELECTED) {
@@ -459,10 +459,10 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-
+
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
-
+
for (ct = targets.first; ct; ct = ct->next) {
if ((ct->tar == ob) && (ct->subtarget[0])) {
bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget);
@@ -472,7 +472,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
}
}
}
-
+
if (cti->flush_constraint_targets)
cti->flush_constraint_targets(con, &targets, 1);
}
@@ -480,18 +480,18 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
}
}
CTX_DATA_END;
-
+
if (!found)
return OPERATOR_CANCELLED;
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
return OPERATOR_FINISHED;
}
@@ -501,11 +501,11 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot)
ot->name = "Select Constraint Target";
ot->idname = "POSE_OT_select_constraint_target";
ot->description = "Select bones used as targets for the currently selected bones";
-
+
/* api callbacks */
ot->exec = pose_select_constraint_target_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -520,7 +520,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
int direction = RNA_enum_get(op->ptr, "direction");
const bool add_to_sel = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
-
+
pchan_act = BKE_pose_channel_active(ob);
if (pchan_act == NULL) {
return OPERATOR_CANCELLED;
@@ -577,15 +577,15 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
if (changed == false) {
return OPERATOR_CANCELLED;
}
-
+
/* updates */
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
return OPERATOR_FINISHED;
}
@@ -596,19 +596,19 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot)
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
{0, NULL, 0, NULL, NULL}
};
-
+
/* identifiers */
ot->name = "Select Hierarchy";
ot->idname = "POSE_OT_select_hierarchy";
ot->description = "Select immediate parent/children of selected bones";
-
+
/* api callbacks */
ot->exec = pose_select_hierarchy_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* props */
ot->prop = RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", "");
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
@@ -630,22 +630,22 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
char *group_flags;
int numGroups = 0;
bool changed = false, tagged = false;
-
+
/* sanity checks */
if (ELEM(NULL, ob, pose, arm))
return 0;
-
+
/* count the number of groups */
numGroups = BLI_listbase_count(&pose->agroups);
if (numGroups == 0)
return 0;
-
- /* alloc a small array to keep track of the groups to use
+
+ /* alloc a small array to keep track of the groups to use
* - each cell stores on/off state for whether group should be used
* - size is (numGroups + 1), since (index = 0) is used for no-group
*/
group_flags = MEM_callocN(numGroups + 1, "pose_select_same_group");
-
+
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
/* keep track of group as group to use later? */
@@ -653,13 +653,13 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
group_flags[pchan->agrp_index] = 1;
tagged = true;
}
-
+
/* deselect all bones before selecting new ones? */
if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
pchan->bone->flag &= ~BONE_SELECTED;
}
CTX_DATA_END;
-
+
/* small optimization: only loop through bones a second time if there are any groups tagged */
if (tagged) {
/* only if group matches (and is not selected or current bone) */
@@ -675,10 +675,10 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend)
}
CTX_DATA_END;
}
-
+
/* free temp info */
MEM_freeN(group_flags);
-
+
return changed;
}
@@ -688,25 +688,25 @@ static bool pose_select_same_layer(bContext *C, Object *ob, bool extend)
bArmature *arm = (ob) ? ob->data : NULL;
bool changed = false;
int layers = 0;
-
+
if (ELEM(NULL, ob, pose, arm))
return 0;
-
+
/* figure out what bones are selected */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
/* keep track of layers to use later? */
if (pchan->bone->flag & BONE_SELECTED)
layers |= pchan->bone->layer;
-
+
/* deselect all bones before selecting new ones? */
if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
pchan->bone->flag &= ~BONE_SELECTED;
}
CTX_DATA_END;
- if (layers == 0)
+ if (layers == 0)
return 0;
-
+
/* select bones that are on same layers as layers flag */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
@@ -717,7 +717,7 @@ static bool pose_select_same_layer(bContext *C, Object *ob, bool extend)
}
}
CTX_DATA_END;
-
+
return changed;
}
@@ -725,11 +725,11 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
{
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
KS_Path *ksp;
-
+
bArmature *arm = (ob) ? ob->data : NULL;
bPose *pose = (ob) ? ob->pose : NULL;
bool changed = false;
-
+
/* sanity checks: validate Keying Set and object */
if (ks == NULL) {
BKE_report(reports, RPT_ERROR, "No active Keying Set to use");
@@ -738,7 +738,7 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
else if (ANIM_validate_keyingset(C, NULL, ks) != 0) {
if (ks->paths.first == NULL) {
if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
- BKE_report(reports, RPT_ERROR,
+ BKE_report(reports, RPT_ERROR,
"Use another Keying Set, as the active one depends on the currently "
"selected items or cannot find any targets due to unsuitable context");
}
@@ -748,10 +748,10 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
}
return false;
}
-
+
if (ELEM(NULL, ob, pose, arm))
return false;
-
+
/* if not extending selection, deselect all selected first */
if (extend == false) {
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
@@ -761,8 +761,8 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
}
CTX_DATA_END;
}
-
- /* iterate over elements in the Keying Set, setting selection depending on whether
+
+ /* iterate over elements in the Keying Set, setting selection depending on whether
* that bone is visible or not...
*/
for (ksp = ks->paths.first; ksp; ksp = ksp->next) {
@@ -770,10 +770,10 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) {
if (strstr(ksp->rna_path, "bones")) {
char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones[");
-
+
if (boneName) {
bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName);
-
+
if (pchan) {
/* select if bone is visible and can be affected */
if (PBONE_SELECTABLE(arm, pchan->bone)) {
@@ -781,14 +781,14 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object
changed = true;
}
}
-
+
/* free temp memory */
MEM_freeN(boneName);
}
}
}
}
-
+
return changed;
}
@@ -799,38 +799,38 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
const ePose_SelectSame_Mode type = RNA_enum_get(op->ptr, "type");
const bool extend = RNA_boolean_get(op->ptr, "extend");
bool changed = false;
-
+
/* sanity check */
if (ob->pose == NULL)
return OPERATOR_CANCELLED;
-
+
/* selection types */
switch (type) {
case POSE_SEL_SAME_LAYER: /* layer */
changed = pose_select_same_layer(C, ob, extend);
break;
-
+
case POSE_SEL_SAME_GROUP: /* group */
changed = pose_select_same_group(C, ob, extend);
break;
-
+
case POSE_SEL_SAME_KEYINGSET: /* Keying Set */
changed = pose_select_same_keyingset(C, op->reports, ob, extend);
break;
-
+
default:
printf("pose_select_grouped() - Unknown selection type %u\n", type);
break;
}
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
if (arm->flag & ARM_HAS_VIZ_DEPS) {
/* mask modifier ('armature' mode), etc. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
}
-
+
/* report done status */
if (changed)
return OPERATOR_FINISHED;
@@ -851,15 +851,15 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
ot->name = "Select Grouped";
ot->description = "Select all visible bones grouped by similar properties";
ot->idname = "POSE_OT_select_grouped";
-
+
/* api callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = pose_select_grouped_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first");
ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
@@ -936,11 +936,11 @@ void POSE_OT_select_mirror(wmOperatorType *ot)
ot->name = "Flip Active/Selected Bone";
ot->idname = "POSE_OT_select_mirror";
ot->description = "Mirror the bone selection";
-
+
/* api callbacks */
ot->exec = pose_select_mirror_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 88203474d03..b82535f013b 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -63,7 +63,7 @@
#include "armature_intern.h"
/* **************************************************** */
-/* == POSE 'SLIDING' TOOLS ==
+/* == POSE 'SLIDING' TOOLS ==
*
* A) Push & Relax, Breakdowner
* These tools provide the animator with various capabilities
@@ -96,21 +96,21 @@ typedef struct tPoseSlideOp {
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
int cframe; /* current frame number - global time */
-
+
int prevFrame; /* frame before current frame (blend-from) - global time */
int nextFrame; /* frame after current frame (blend-to) - global time */
-
+
float prevFrameF; /* prevFrame, but in local action time (for F-Curve lookups to work) */
float nextFrameF; /* nextFrame, but in local action time (for F-Curve lookups to work) */
-
+
short mode; /* sliding mode (ePoseSlide_Modes) */
short flag; /* unused for now, but can later get used for storing runtime settings.... */
-
+
short channels; /* which transforms/channels are affected (ePoseSlide_Channels) */
short axislock; /* axis-limits for transforms (ePoseSlide_AxisLock) */
-
+
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
-
+
NumInput num; /* numeric input */
} tPoseSlideOp;
@@ -125,19 +125,19 @@ typedef enum ePoseSlide_Modes {
/* Transforms/Channels to Affect */
typedef enum ePoseSlide_Channels {
PS_TFM_ALL = 0, /* All transforms and properties */
-
+
PS_TFM_LOC, /* Loc/Rot/Scale */
PS_TFM_ROT,
PS_TFM_SIZE,
-
+
PS_TFM_BBONE_SHAPE, /* Bendy Bones */
-
+
PS_TFM_PROPS /* Custom Properties */
} ePoseSlide_Channels;
/* Property enum for ePoseSlide_Channels */
static const EnumPropertyItem prop_channels_types[] = {
- {PS_TFM_ALL, "ALL", 0, "All Properties",
+ {PS_TFM_ALL, "ALL", 0, "All Properties",
"All properties, including transforms, bendy bone shape, and custom properties"},
{PS_TFM_LOC, "LOC", 0, "Location", "Location only"},
{PS_TFM_ROT, "ROT", 0, "Rotation", "Rotation only"},
@@ -171,60 +171,60 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
{
tPoseSlideOp *pso;
bAction *act = NULL;
-
+
/* init slide-op data */
pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
-
+
/* get info from context */
pso->scene = CTX_data_scene(C);
pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
pso->arm = (pso->ob) ? pso->ob->data : NULL;
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */
-
+
pso->cframe = pso->scene->r.cfra;
pso->mode = mode;
-
+
/* set range info from property values - these may get overridden for the invoke() */
pso->percentage = RNA_float_get(op->ptr, "percentage");
pso->prevFrame = RNA_int_get(op->ptr, "prev_frame");
pso->nextFrame = RNA_int_get(op->ptr, "next_frame");
-
+
/* get the set of properties/axes that can be operated on */
pso->channels = RNA_enum_get(op->ptr, "channels");
pso->axislock = RNA_enum_get(op->ptr, "axis_lock");
-
+
/* ensure validity of the settings from the context */
if (ELEM(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action))
return 0;
-
+
act = pso->ob->adt->action;
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
-
- /* for each Pose-Channel which gets affected, get the F-Curves for that channel
+
+ /* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act);
-
+
/* set depsgraph flags */
/* make sure the lock is set OK, unlock can be accidentally saved? */
pso->ob->pose->flag |= POSE_LOCKED;
pso->ob->pose->flag &= ~POSE_DO_UNLOCK;
-
- /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
+
+ /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up
* to the caller of this (usually only invoke() will do it, to make things more efficient).
*/
BLI_dlrbTree_init(&pso->keys);
-
+
/* initialise numeric input */
initNumInput(&pso->num);
pso->num.idx_max = 0; /* one axis */
pso->num.val_flag[0] |= NUM_NO_NEGATIVE;
pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */
-
+
/* return status is whether we've got all the data we were requested to get */
return 1;
}
@@ -233,19 +233,19 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode)
static void pose_slide_exit(wmOperator *op)
{
tPoseSlideOp *pso = op->customdata;
-
+
/* if data exists, clear its data and exit */
if (pso) {
/* free the temp pchan links and their data */
poseAnim_mapping_free(&pso->pfLinks);
-
+
/* free RB-BST for keyframes (if it contained data) */
BLI_dlrbTree_free(&pso->keys);
-
+
/* free data itself */
MEM_freeN(pso);
}
-
+
/* cleanup */
op->customdata = NULL;
}
@@ -265,19 +265,19 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
float cframe = (float)pso->cframe;
float sVal, eVal;
float w1, w2;
-
+
/* get keyframe values for endpoint poses to blend with */
/* previous/start */
sVal = evaluate_fcurve(fcu, pso->prevFrameF);
/* next/end */
eVal = evaluate_fcurve(fcu, pso->nextFrameF);
-
+
/* if both values are equal, don't do anything */
if (IS_EQF(sVal, eVal)) {
(*val) = sVal;
return;
}
-
+
/* calculate the relative weights of the endpoints */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* get weights from the percentage control */
@@ -285,20 +285,20 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
w2 = 1.0f - w1; /* this must come first */
}
else {
- /* - these weights are derived from the relative distance of these
+ /* - these weights are derived from the relative distance of these
* poses from the current frame
* - they then get normalized so that they only sum up to 1
*/
- float wtot;
-
+ float wtot;
+
w1 = cframe - (float)pso->prevFrame;
w2 = (float)pso->nextFrame - cframe;
-
+
wtot = w1 + w2;
w1 = (w1 / wtot);
w2 = (w2 / wtot);
}
-
+
/* depending on the mode, calculate the new value
* - in all of these, the start+end values are multiplied by w2 and w1 (respectively),
* since multiplication in another order would decrease the value the current frame is closer to
@@ -311,7 +311,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
* - perform this weighting a number of times given by the percentage...
*/
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
while (iters-- > 0) {
(*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f;
}
@@ -324,7 +324,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
* - perform this weighting a number of times given by the percentage...
*/
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
while (iters-- > 0) {
(*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f;
}
@@ -345,19 +345,19 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
{
LinkData *ld = NULL;
char *path = NULL;
-
+
/* get the path to use... */
path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName);
-
+
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
FCurve *fcu = (FCurve *)ld->data;
const int idx = fcu->array_index;
const int lock = pso->axislock;
-
+
/* check if this F-Curve is ok given the current axis locks */
BLI_assert(fcu->array_index < 3);
-
+
if ((lock == 0) ||
((lock & PS_LOCK_X) && (idx == 0)) ||
((lock & PS_LOCK_Y) && (idx == 1)) ||
@@ -367,7 +367,7 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa
pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]);
}
}
-
+
/* free the temp path we got */
MEM_freeN(path);
}
@@ -378,11 +378,11 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
PointerRNA ptr = {{NULL}};
LinkData *ld;
int len = strlen(pfl->pchan_path);
-
+
/* setup pointer RNA for resolving paths */
RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr);
-
- /* - custom properties are just denoted using ["..."][etc.] after the end of the base path,
+
+ /* - custom properties are just denoted using ["..."][etc.] after the end of the base path,
* so just check for opening pair after the end of the path
* - bbone properties are similar, but they always start with a prefix "bbone_*",
* so a similar method should work here for those too
@@ -390,23 +390,23 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
const char *bPtr, *pPtr;
-
+
if (fcu->rna_path == NULL)
continue;
-
- /* do we have a match?
+
+ /* do we have a match?
* - bPtr is the RNA Path with the standard part chopped off
* - pPtr is the chunk of the path which is left over
*/
bPtr = strstr(fcu->rna_path, pfl->pchan_path) + len;
pPtr = strstr(bPtr, prop_prefix);
-
+
if (pPtr) {
/* use RNA to try and get a handle on this property, then, assuming that it is just
* numerical, try and grab the value as a float for temp editing before setting back
*/
PropertyRNA *prop = RNA_struct_find_property(&ptr, pPtr);
-
+
if (prop) {
switch (RNA_property_type(prop)) {
/* continuous values that can be smoothly interpolated... */
@@ -424,7 +424,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
RNA_property_int_set(&ptr, prop, (int)tval);
break;
}
-
+
/* values which can only take discrete values */
case PROP_BOOLEAN:
{
@@ -440,7 +440,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con
*/
break;
}
-
+
default:
/* cannot handle */
//printf("Cannot Pose Slide non-numerical property\n");
@@ -459,17 +459,17 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
LinkData *ld = NULL;
char *path = NULL;
float cframe;
-
+
/* get the path to use - this should be quaternion rotations only (needs care) */
path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
-
+
/* get the current frame number */
cframe = (float)pso->cframe;
-
+
/* using this path, find each matching F-Curve for the variables we're interested in */
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
FCurve *fcu = (FCurve *)ld->data;
-
+
/* assign this F-Curve to one of the relevant pointers... */
switch (fcu->array_index) {
case 3: /* z */
@@ -486,22 +486,22 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
break;
}
}
-
+
/* only if all channels exist, proceed */
if (fcu_w && fcu_x && fcu_y && fcu_z) {
float quat_prev[4], quat_next[4];
-
+
/* get 2 quats */
quat_prev[0] = evaluate_fcurve(fcu_w, pso->prevFrameF);
quat_prev[1] = evaluate_fcurve(fcu_x, pso->prevFrameF);
quat_prev[2] = evaluate_fcurve(fcu_y, pso->prevFrameF);
quat_prev[3] = evaluate_fcurve(fcu_z, pso->prevFrameF);
-
+
quat_next[0] = evaluate_fcurve(fcu_w, pso->nextFrameF);
quat_next[1] = evaluate_fcurve(fcu_x, pso->nextFrameF);
quat_next[2] = evaluate_fcurve(fcu_y, pso->nextFrameF);
quat_next[3] = evaluate_fcurve(fcu_z, pso->nextFrameF);
-
+
/* perform blending */
if (pso->mode == POSESLIDE_BREAKDOWN) {
/* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */
@@ -509,35 +509,35 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
}
else if (pso->mode == POSESLIDE_PUSH) {
float quat_diff[4], quat_orig[4];
-
+
/* calculate the delta transform from the previous to the current */
/* TODO: investigate ways to favour one transform more? */
sub_qt_qtqt(quat_diff, pchan->quat, quat_prev);
-
+
/* make a copy of the original rotation */
copy_qt_qt(quat_orig, pchan->quat);
-
+
/* increase the original by the delta transform, by an amount determined by percentage */
add_qt_qtqt(pchan->quat, quat_orig, quat_diff, pso->percentage);
}
else {
float quat_interp[4], quat_orig[4];
int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */
-
+
/* perform this blending several times until a satisfactory result is reached */
while (iters-- > 0) {
/* calculate the interpolation between the endpoints */
interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame));
-
+
/* make a copy of the original rotation */
copy_qt_qt(quat_orig, pchan->quat);
-
+
/* tricky interpolations - blending between original and new */
interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f);
}
}
}
-
+
/* free the path now */
MEM_freeN(path);
}
@@ -546,37 +546,37 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
{
tPChanFCurveLink *pfl;
-
+
/* sanitise the frame ranges */
if (pso->prevFrame == pso->nextFrame) {
/* move out one step either side */
pso->prevFrame--;
pso->nextFrame++;
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
}
-
+
/* for each link, handle each set of transforms */
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
- /* valid transforms for each PoseChannel should have been noted already
- * - sliding the pose should be a straightforward exercise for location+rotation,
- * but rotations get more complicated since we may want to use quaternion blending
+ /* valid transforms for each PoseChannel should have been noted already
+ * - sliding the pose should be a straightforward exercise for location+rotation,
+ * but rotations get more complicated since we may want to use quaternion blending
* for quaternions instead...
*/
bPoseChannel *pchan = pfl->pchan;
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_LOC) && (pchan->flag & POSE_LOC)) {
/* calculate these for the 'location' vector, and use location curves */
pose_slide_apply_vec3(pso, pfl, pchan->loc, "location");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) {
/* calculate these for the 'scale' vector, and use scale curves */
pose_slide_apply_vec3(pso, pfl, pchan->size, "scale");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) {
/* everything depends on the rotation mode */
if (pchan->rotmode > 0) {
@@ -591,12 +591,12 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_quat(pso, pfl);
}
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE) && (pchan->flag & POSE_BBONE_SHAPE)) {
/* bbone properties - they all start a "bbone_" prefix */
- pose_slide_apply_props(pso, pfl, "bbone_");
+ pose_slide_apply_props(pso, pfl, "bbone_");
}
-
+
if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) {
/* not strictly a transform, but custom properties contribute to the pose produced in many rigs
* (e.g. the facial rigs used in Sintel)
@@ -604,7 +604,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */
}
}
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
}
@@ -633,7 +633,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
char limits_str[UI_MAX_DRAW_STR];
char axis_str[50];
char mode_str[32];
-
+
switch (pso->mode) {
case POSESLIDE_PUSH:
strcpy(mode_str, "Push Pose");
@@ -644,13 +644,13 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
case POSESLIDE_BREAKDOWN:
strcpy(mode_str, "Breakdown");
break;
-
+
default:
/* unknown */
strcpy(mode_str, "Sliding-Tool");
break;
}
-
+
switch (pso->axislock) {
case PS_LOCK_X:
BLI_strncpy(axis_str, "[X]/Y/Z axis only (X to clear)", sizeof(axis_str));
@@ -661,7 +661,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
case PS_LOCK_Z:
BLI_strncpy(axis_str, "X/Y/[Z] axis only (Z to clear)", sizeof(axis_str));
break;
-
+
default:
if (ELEM(pso->channels, PS_TFM_LOC, PS_TFM_ROT, PS_TFM_SIZE)) {
BLI_strncpy(axis_str, "X/Y/Z = Axis Constraint", sizeof(axis_str));
@@ -671,7 +671,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
}
break;
}
-
+
switch (pso->channels) {
case PS_TFM_LOC:
BLI_snprintf(limits_str, sizeof(limits_str), "[G]/R/S/B/C - Location only (G to clear) | %s", axis_str);
@@ -692,19 +692,19 @@ static void pose_slide_draw_status(tPoseSlideOp *pso)
BLI_strncpy(limits_str, "G/R/S/B/C - Limit to Transform/Property Set", sizeof(limits_str));
break;
}
-
+
if (hasNumInput(&pso->num)) {
Scene *scene = pso->scene;
char str_offs[NUM_STR_REP_LEN];
-
+
outputNumInput(&pso->num, str_offs, &scene->unit);
-
+
BLI_snprintf(status_str, sizeof(status_str), "%s: %s | %s", mode_str, str_offs, limits_str);
}
else {
BLI_snprintf(status_str, sizeof(status_str), "%s: %d %% | %s", mode_str, (int)(pso->percentage * 100.0f), limits_str);
}
-
+
ED_area_headerprint(pso->sa, status_str);
}
@@ -714,34 +714,34 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
tPChanFCurveLink *pfl;
AnimData *adt = pso->ob->adt;
wmWindow *win = CTX_wm_window(C);
-
+
/* for each link, add all its keyframes to the search tree */
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
LinkData *ld;
-
+
/* do this for each F-Curve */
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &pso->keys, NULL);
}
}
-
+
/* consolidate these keyframes, and figure out the nearest ones */
BLI_dlrbTree_linkedlist_sync(&pso->keys);
-
+
/* cancel if no keyframes found... */
if (pso->keys.root) {
ActKeyColumn *ak;
float cframe = (float)pso->cframe;
-
+
/* firstly, check if the current frame is a keyframe... */
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe);
-
+
if (ak == NULL) {
/* current frame is not a keyframe, so search */
ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe);
ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe);
-
+
/* new set the frames */
/* prev frame */
pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1);
@@ -759,7 +759,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1);
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
}
-
+
/* apply NLA mapping corrections so the frame lookups work */
pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP);
pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP);
@@ -769,20 +769,20 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p
pose_slide_exit(op);
return OPERATOR_CANCELLED;
}
-
+
/* initial apply for operator... */
/* TODO: need to calculate percentage for initial round too... */
pose_slide_apply(C, pso);
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
-
+
/* set cursor to indicate modal */
WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR);
-
+
/* header print */
pose_slide_draw_status(pso);
-
+
/* add a modal handler for this operator */
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
@@ -810,8 +810,8 @@ static void pose_slide_toggle_channels_mode(wmOperator *op, tPoseSlideOp *pso, e
pso->channels = channel;
}
RNA_enum_set(op->ptr, "channels", pso->channels);
-
-
+
+
/* Reset axis limits too for good measure */
pso->axislock = 0;
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
@@ -826,7 +826,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
return false;
}
-
+
/* Turn on or off? */
if (pso->axislock == axis) {
/* Already limiting on this axis, so turn off */
@@ -837,7 +837,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos
pso->axislock = axis;
}
RNA_enum_set(op->ptr, "axis_lock", pso->axislock);
-
+
/* Setting changed, so pose update is needed */
return true;
}
@@ -848,9 +848,9 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
tPoseSlideOp *pso = op->customdata;
wmWindow *win = CTX_wm_window(C);
bool do_pose_update = false;
-
+
const bool has_numinput = hasNumInput(&pso->num);
-
+
switch (event->type) {
case LEFTMOUSE: /* confirm */
case RETKEY:
@@ -859,35 +859,35 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* insert keyframes as required... */
pose_slide_autoKeyframe(C, pso);
pose_slide_exit(op);
-
+
/* done! */
return OPERATOR_FINISHED;
}
-
+
case ESCKEY: /* cancel */
- case RIGHTMOUSE:
+ case RIGHTMOUSE:
{
/* return to normal cursor and header status */
ED_area_headerprint(pso->sa, NULL);
WM_cursor_modal_restore(win);
-
+
/* reset transforms back to original state */
pose_slide_reset(pso);
-
+
/* depsgraph updates + redraws */
pose_slide_refresh(C, pso);
-
+
/* clean up temp data */
pose_slide_exit(op);
-
+
/* canceled! */
return OPERATOR_CANCELLED;
}
-
+
/* Percentage Chane... */
case MOUSEMOVE: /* calculate new position */
{
@@ -895,7 +895,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (has_numinput == false) {
/* update percentage based on position of mouse */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* update pose to reflect the new values (see below) */
do_pose_update = true;
}
@@ -905,17 +905,17 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
if ((event->val == KM_PRESS) && handleNumInput(C, &pso->num, event)) {
float value;
-
- /* Grab percentage from numeric input, and store this new value for redo
+
+ /* Grab percentage from numeric input, and store this new value for redo
* NOTE: users see ints, while internally we use a 0-1 float
*/
value = pso->percentage * 100.0f;
applyNumInput(&pso->num, &value);
-
+
pso->percentage = value / 100.0f;
CLAMP(pso->percentage, 0.0f, 1.0f);
RNA_float_set(op->ptr, "percentage", pso->percentage);
-
+
/* Update pose to reflect the new values (see below) */
do_pose_update = true;
break;
@@ -954,8 +954,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
do_pose_update = true;
break;
}
-
-
+
+
/* Axis Locks */
/* XXX: Hardcoded... */
case XKEY:
@@ -979,8 +979,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
break;
}
-
-
+
+
default: /* Some other unhandled key... */
break;
}
@@ -992,20 +992,20 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
}
}
}
-
-
+
+
/* perform pose updates - in response to some user action (e.g. pressing a key or moving the mouse) */
if (do_pose_update) {
/* update percentage indicator in header */
pose_slide_draw_status(pso);
-
+
/* reset transforms (to avoid accumulation errors) */
pose_slide_reset(pso);
-
+
/* apply... */
pose_slide_apply(C, pso);
}
-
+
/* still running... */
return OPERATOR_RUNNING_MODAL;
}
@@ -1022,13 +1022,13 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
{
/* settings should have been set up ok for applying, so just apply! */
pose_slide_apply(C, pso);
-
+
/* insert keyframes if needed */
pose_slide_autoKeyframe(C, pso);
-
+
/* cleanup and done */
pose_slide_exit(op);
-
+
return OPERATOR_FINISHED;
}
@@ -1037,10 +1037,10 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso
static void pose_slide_opdef_properties(wmOperatorType *ot)
{
RNA_def_float_percentage(ot->srna, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Weighting factor for which keyframe is favored more", 0.3, 0.7);
-
+
RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50);
RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50);
-
+
RNA_def_enum(ot->srna, "channels", prop_channels_types, PS_TFM_ALL, "Channels", "Set of properties that are affected");
RNA_def_enum(ot->srna, "axis_lock", prop_axis_lock_types, 0, "Axis Lock", "Transform axis to restrict effects to");
}
@@ -1051,7 +1051,7 @@ static void pose_slide_opdef_properties(wmOperatorType *ot)
static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
@@ -1059,10 +1059,10 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1071,7 +1071,7 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev
static int pose_slide_push_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) {
pose_slide_exit(op);
@@ -1079,7 +1079,7 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1090,17 +1090,17 @@ void POSE_OT_push(wmOperatorType *ot)
ot->name = "Push Pose";
ot->idname = "POSE_OT_push";
ot->description = "Exaggerate the current pose";
-
+
/* callbacks */
ot->exec = pose_slide_push_exec;
ot->invoke = pose_slide_push_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1111,7 +1111,7 @@ void POSE_OT_push(wmOperatorType *ot)
static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
@@ -1119,10 +1119,10 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1131,7 +1131,7 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e
static int pose_slide_relax_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) {
pose_slide_exit(op);
@@ -1139,7 +1139,7 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1150,17 +1150,17 @@ void POSE_OT_relax(wmOperatorType *ot)
ot->name = "Relax Pose";
ot->idname = "POSE_OT_relax";
ot->description = "Make the current pose more similar to its surrounding ones";
-
+
/* callbacks */
ot->exec = pose_slide_relax_exec;
ot->invoke = pose_slide_relax_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1171,7 +1171,7 @@ void POSE_OT_relax(wmOperatorType *ot)
static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
tPoseSlideOp *pso;
-
+
/* initialize data */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
@@ -1179,10 +1179,10 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
}
else
pso = op->customdata;
-
+
/* initialise percentage so that it won't pop on first mouse move */
pose_slide_mouse_update_percentage(pso, op, event);
-
+
/* do common setup work */
return pose_slide_invoke_common(C, op, pso);
}
@@ -1191,7 +1191,7 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven
static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
{
tPoseSlideOp *pso;
-
+
/* initialize data (from RNA-props) */
if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) {
pose_slide_exit(op);
@@ -1199,7 +1199,7 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
}
else
pso = op->customdata;
-
+
/* do common exec work */
return pose_slide_exec_common(C, op, pso);
}
@@ -1210,17 +1210,17 @@ void POSE_OT_breakdown(wmOperatorType *ot)
ot->name = "Pose Breakdowner";
ot->idname = "POSE_OT_breakdown";
ot->description = "Create a suitable breakdown pose on the current frame";
-
+
/* callbacks */
ot->exec = pose_slide_breakdown_exec;
ot->invoke = pose_slide_breakdown_invoke;
ot->modal = pose_slide_modal;
ot->cancel = pose_slide_cancel;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
-
+
/* Properties */
pose_slide_opdef_properties(ot);
}
@@ -1240,7 +1240,7 @@ typedef enum ePosePropagate_Termination {
POSE_PROPAGATE_BEFORE_FRAME,
/* stop when we run out of keyframes */
POSE_PROPAGATE_BEFORE_END,
-
+
/* only do on keyframes that are selected */
POSE_PROPAGATE_SELECTED_KEYS,
/* only do on the frames where markers are selected */
@@ -1251,14 +1251,14 @@ typedef enum ePosePropagate_Termination {
typedef union tPosePropagate_ModeData {
/* smart holds + before frame: frame number to stop on */
float end_frame;
-
+
/* selected markers: listbase for CfraElem's marking these frames */
ListBase sel_markers;
} tPosePropagate_ModeData;
/* --------------------------------- */
-/* get frame on which the "hold" for the bone ends
+/* get frame on which the "hold" for the bone ends
* XXX: this may not really work that well if a bone moves on some channels and not others
* if this happens to be a major issue, scrap this, and just make this happen
* independently per F-Curve
@@ -1267,47 +1267,47 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
{
DLRBT_Tree keys, blocks;
ActKeyBlock *ab;
-
+
AnimData *adt = ob->adt;
LinkData *ld;
float endFrame = startFrame;
-
+
/* set up optimized data-structures for searching for relevant keyframes + holds */
BLI_dlrbTree_init(&keys);
BLI_dlrbTree_init(&blocks);
-
+
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
fcurve_to_keylist(adt, fcu, &keys, &blocks);
}
-
+
BLI_dlrbTree_linkedlist_sync(&keys);
BLI_dlrbTree_linkedlist_sync(&blocks);
-
- /* find the long keyframe (i.e. hold), and hence obtain the endFrame value
+
+ /* find the long keyframe (i.e. hold), and hence obtain the endFrame value
* - the best case would be one that starts on the frame itself
*/
ab = (ActKeyBlock *)BLI_dlrbTree_search_exact(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
if (actkeyblock_is_valid(ab, &keys) == 0) {
/* There are only two cases for no-exact match:
* 1) the current frame is just before another key but not on a key itself
* 2) the current frame is on a key, but that key doesn't link to the next
*
- * If we've got the first case, then we can search for another block,
+ * If we've got the first case, then we can search for another block,
* otherwise forget it, as we'd be overwriting some valid data.
*/
if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &startFrame) == NULL) {
/* we've got case 1, so try the one after */
ab = (ActKeyBlock *)BLI_dlrbTree_search_next(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
if (actkeyblock_is_valid(ab, &keys) == 0) {
/* try the block before this frame then as last resort */
ab = (ActKeyBlock *)BLI_dlrbTree_search_prev(&blocks, compare_ab_cfraPtr, &startFrame);
-
+
/* whatever happens, stop searching now... */
if (actkeyblock_is_valid(ab, &keys) == 0) {
- /* restrict range to just the frame itself
+ /* restrict range to just the frame itself
* i.e. everything is in motion, so no holds to safely overwrite
*/
ab = NULL;
@@ -1319,13 +1319,13 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
ab = NULL;
}
}
-
+
/* check if we can go any further than we've already gone */
if (ab) {
/* go to next if it is also valid and meets "extension" criteria */
while (ab->next) {
ActKeyBlock *abn = (ActKeyBlock *)ab->next;
-
+
/* must be valid */
if (actkeyblock_is_valid(abn, &keys) == 0)
break;
@@ -1335,24 +1335,24 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p
/* should have the same number of curves */
if (ab->totcurve != abn->totcurve)
break;
- /* should have the same value
+ /* should have the same value
* XXX: this may be a bit fuzzy on larger data sets, so be careful
*/
if (ab->val != abn->val)
break;
-
+
/* we can extend the bounds to the end of this "next" block now */
ab = abn;
}
-
+
/* end frame can now take the value of the end of the block */
endFrame = ab->end;
}
-
+
/* free temp memory */
BLI_dlrbTree_free(&keys);
BLI_dlrbTree_free(&blocks);
-
+
/* return the end frame we've found */
return endFrame;
}
@@ -1363,10 +1363,10 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
bool found = false;
-
+
/* base pointer is always the object -> id_ptr */
RNA_id_pointer_create(&ob->id, &id_ptr);
-
+
/* resolve the property... */
if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) {
if (RNA_property_array_check(prop)) {
@@ -1411,7 +1411,7 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
}
}
}
-
+
return found;
}
@@ -1420,25 +1420,25 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
float startFrame, tPosePropagate_ModeData modeData)
{
const int mode = RNA_enum_get(op->ptr, "mode");
-
+
BezTriple *bezt;
float refVal = 0.0f;
bool keyExists;
int i, match;
short first = 1;
-
+
/* skip if no keyframes to edit */
if ((fcu->bezt == NULL) || (fcu->totvert < 2))
return;
-
+
/* find the reference value from bones directly, which means that the user
- * doesn't need to firstly keyframe the pose (though this doesn't mean that
+ * doesn't need to firstly keyframe the pose (though this doesn't mean that
* they can't either)
*/
if (!pose_propagate_get_refVal(ob, fcu, &refVal))
return;
-
- /* find the first keyframe to start propagating from
+
+ /* find the first keyframe to start propagating from
* - if there's a keyframe on the current frame, we probably want to save this value there too
* since it may be as of yet unkeyed
* - if starting before the starting frame, don't touch the key, as it may have had some valid
@@ -1447,7 +1447,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
*/
if (mode != POSE_PROPAGATE_SELECTED_KEYS) {
match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
-
+
if (fcu->bezt[match].vec[1][0] < startFrame)
i = match + 1;
else
@@ -1457,13 +1457,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
/* selected - start from first keyframe */
i = 0;
}
-
+
for (bezt = &fcu->bezt[i]; i < fcu->totvert; i++, bezt++) {
/* additional termination conditions based on the operator 'mode' property go here... */
if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) {
/* stop if keyframe is outside the accepted range */
if (bezt->vec[1][0] > modeData.end_frame)
- break;
+ break;
}
else if (mode == POSE_PROPAGATE_NEXT_KEY) {
/* stop after the first keyframe has been processed */
@@ -1478,13 +1478,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* only allow if there's a marker on this frame */
CfraElem *ce = NULL;
-
+
/* stop on matching marker if there is one */
for (ce = modeData.sel_markers.first; ce; ce = ce->next) {
if (ce->cfra == round_fl_to_int(bezt->vec[1][0]))
break;
}
-
+
/* skip this keyframe if no marker */
if (ce == NULL)
continue;
@@ -1494,11 +1494,11 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
if (BEZT_ISSEL_ANY(bezt) == 0)
continue;
}
-
+
/* just flatten handles, since values will now be the same either side... */
/* TODO: perhaps a fade-out modulation of the value is required here (optional once again)? */
bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal;
-
+
/* select keyframe to indicate that it's been changed */
bezt->f2 |= SELECT;
first = 0;
@@ -1512,13 +1512,13 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bAction *act = (ob && ob->adt) ? ob->adt->action : NULL;
-
+
ListBase pflinks = {NULL, NULL};
tPChanFCurveLink *pfl;
-
+
tPosePropagate_ModeData modeData;
const int mode = RNA_enum_get(op->ptr, "mode");
-
+
/* sanity checks */
if (ob == NULL) {
BKE_report(op->reports, RPT_ERROR, "No object to propagate poses for");
@@ -1528,10 +1528,10 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No keyframed poses to propagate to");
return OPERATOR_CANCELLED;
}
-
+
/* isolate F-Curves related to the selected bones */
poseAnim_mapping_get(C, &pflinks, ob, act);
-
+
/* mode-specific data preprocessing (requiring no access to curves) */
if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
/* get a list of selected markers */
@@ -1541,11 +1541,11 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
/* assume everything else wants endFrame */
modeData.end_frame = RNA_float_get(op->ptr, "end_frame");
}
-
+
/* for each bone, perform the copying required */
for (pfl = pflinks.first; pfl; pfl = pfl->next) {
LinkData *ld;
-
+
/* mode-specific data preprocessing (requiring access to all curves) */
if (mode == POSE_PROPAGATE_SMART_HOLDS) {
/* we store in endFrame the end frame of the "long keyframe" (i.e. a held value) starting
@@ -1553,21 +1553,21 @@ static int pose_propagate_exec(bContext *C, wmOperator *op)
*/
modeData.end_frame = pose_propagate_get_boneHoldEndFrame(ob, pfl, (float)CFRA);
}
-
+
/* go through propagating pose to keyframes, curve by curve */
for (ld = pfl->fcurves.first; ld; ld = ld->next)
pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData);
}
-
+
/* free temp data */
poseAnim_mapping_free(&pflinks);
-
+
if (mode == POSE_PROPAGATE_SELECTED_MARKERS)
BLI_freelistN(&modeData.sel_markers);
-
+
/* updates + notifiers */
poseAnim_mapping_refresh(C, scene, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -1591,19 +1591,19 @@ void POSE_OT_propagate(wmOperatorType *ot)
{POSE_PROPAGATE_SELECTED_MARKERS, "SELECTED_MARKERS", 0, "On Selected Markers",
"Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"},
{0, NULL, 0, NULL, NULL}};
-
+
/* identifiers */
ot->name = "Propagate Pose";
ot->idname = "POSE_OT_propagate";
ot->description = "Copy selected aspects of the current pose to subsequent poses already keyframed";
-
+
/* callbacks */
ot->exec = pose_propagate_exec;
ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
/* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
ot->prop = RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes");
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 446bab00b70..1fc623eb6af 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -73,16 +73,16 @@
static void applyarmature_fix_boneparents(Scene *scene, Object *armob)
{
Object workob, *ob;
-
+
/* go through all objects in database */
for (ob = G.main->object.first; ob; ob = ob->id.next) {
/* if parent is bone in this armature, apply corrections */
if ((ob->parent == armob) && (ob->partype == PARBONE)) {
- /* apply current transform from parent (not yet destroyed),
+ /* apply current transform from parent (not yet destroyed),
* then calculate new parent inverse matrix
*/
BKE_object_apply_mat4(ob, ob->obmat, false, false);
-
+
BKE_object_workob_calc_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
@@ -98,7 +98,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
bPose *pose;
bPoseChannel *pchan;
EditBone *curbone;
-
+
/* don't check if editmode (should be done by caller) */
if (ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
@@ -116,17 +116,17 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
/* Get editbones of active armature to alter */
ED_armature_to_edit(arm);
-
+
/* get pose of active object and move it out of posemode */
pose = ob->pose;
-
+
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name);
-
+
/* simply copy the head/tail values from pchan over to curbone */
copy_v3_v3(curbone->head, pchan->pose_head);
copy_v3_v3(curbone->tail, pchan->pose_tail);
-
+
/* fix roll:
* 1. find auto-calculated roll value for this bone now
* 2. remove this from the 'visual' y-rotation
@@ -134,23 +134,23 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
float premat[3][3], imat[3][3], pmat[3][3], tmat[3][3];
float delta[3], eul[3];
-
+
/* obtain new auto y-rotation */
sub_v3_v3v3(delta, curbone->tail, curbone->head);
vec_roll_to_mat3(delta, 0.0f, premat);
invert_m3_m3(imat, premat);
-
+
/* get pchan 'visual' matrix */
copy_m3_m4(pmat, pchan->pose_mat);
-
+
/* remove auto from visual and get euler rotation */
mul_m3_m3m3(tmat, imat, pmat);
mat3_to_eul(eul, tmat);
-
+
/* just use this euler-y as new roll value */
curbone->roll = eul[1];
}
-
+
/* combine pose and rest values for bendy bone settings,
* then clear the pchan values (so we don't get a double-up)
*/
@@ -165,38 +165,38 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
curbone->ease2 += pchan->ease2;
curbone->scaleIn += pchan->scaleIn;
curbone->scaleOut += pchan->scaleOut;
-
+
pchan->curveInX = pchan->curveOutX = 0.0f;
pchan->curveInY = pchan->curveOutY = 0.0f;
pchan->roll1 = pchan->roll2 = 0.0f;
pchan->ease1 = pchan->ease2 = 0.0f;
pchan->scaleIn = pchan->scaleOut = 1.0f;
}
-
+
/* clear transform values for pchan */
zero_v3(pchan->loc);
zero_v3(pchan->eul);
unit_qt(pchan->quat);
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
-
+
/* set anim lock */
curbone->flag |= BONE_UNKEYED;
}
-
+
/* convert editbones back to bones, and then free the edit-data */
ED_armature_from_edit(arm);
ED_armature_edit_free(arm);
-
+
/* flush positions of posebones */
BKE_pose_where_is(scene, ob);
-
+
/* fix parenting of objects which are bone-parented */
applyarmature_fix_boneparents(scene, ob);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -206,11 +206,11 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
ot->name = "Apply Pose as Rest Pose";
ot->idname = "POSE_OT_armature_apply";
ot->description = "Apply the current pose as the new rest pose";
-
+
/* callbacks */
ot->exec = apply_armature_pose2bones_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -232,21 +232,21 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
{
float delta_mat[4][4];
-
+
/* chan_mat already contains the delta transform from rest pose to pose-mode pose
* as that is baked into there so that B-Bones will work. Once we've set this as the
- * new raw-transform components, don't recalc the poses yet, otherwise IK result will
+ * new raw-transform components, don't recalc the poses yet, otherwise IK result will
* change, thus changing the result we may be trying to record.
*/
/* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251).
* Using pchan->pose_mat and bringing it back in bone space seems to work as expected!
*/
BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, delta_mat);
-
+
BKE_pchan_apply_mat4(pchan, delta_mat, true);
}
CTX_DATA_END;
-
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
@@ -261,11 +261,11 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
ot->name = "Apply Visual Transform to Pose";
ot->idname = "POSE_OT_visual_transform_apply";
ot->description = "Apply final constrained position of pose bones to their transform";
-
+
/* callbacks */
ot->exec = pose_visual_transform_apply_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -273,7 +273,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
/* ********************************************** */
/* Copy/Paste */
-/* This function is used to indicate that a bone is selected
+/* This function is used to indicate that a bone is selected
* and needs to be included in copy buffer (used to be for inserting keys)
*/
static void set_pose_keys(Object *ob)
@@ -306,33 +306,33 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
bPoseChannel *pchan;
char name[MAXBONENAME];
short paste_ok;
-
+
/* get the name - if flipping, we must flip this first */
if (flip)
BLI_string_flip_side_name(name, chan->name, false, sizeof(name));
else
BLI_strncpy(name, chan->name, sizeof(name));
-
+
/* only copy when:
* 1) channel exists - poses are not meant to add random channels to anymore
* 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
*/
pchan = BKE_pose_channel_find_name(ob->pose, name);
-
+
if (selOnly)
paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED));
else
paste_ok = (pchan != NULL);
-
+
/* continue? */
if (paste_ok) {
- /* only loc rot size
- * - only copies transform info for the pose
+ /* only loc rot size
+ * - only copies transform info for the pose
*/
copy_v3_v3(pchan->loc, chan->loc);
copy_v3_v3(pchan->size, chan->size);
pchan->flag = chan->flag;
-
+
/* check if rotation modes are compatible (i.e. do they need any conversions) */
if (pchan->rotmode == chan->rotmode) {
/* copy the type of rotation in use */
@@ -368,29 +368,29 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
else
axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle);
}
-
+
/* B-Bone posing options should also be included... */
pchan->curveInX = chan->curveInX;
pchan->curveInY = chan->curveInY;
pchan->curveOutX = chan->curveOutX;
pchan->curveOutY = chan->curveOutY;
-
+
pchan->roll1 = chan->roll1;
pchan->roll2 = chan->roll2;
pchan->ease1 = chan->ease1;
pchan->ease2 = chan->ease2;
pchan->scaleIn = chan->scaleIn;
pchan->scaleOut = chan->scaleOut;
-
+
/* paste flipped pose? */
if (flip) {
pchan->loc[0] *= -1;
-
+
pchan->curveInX *= -1;
pchan->curveOutX *= -1;
pchan->roll1 *= -1; // XXX?
pchan->roll2 *= -1; // XXX?
-
+
/* has to be done as eulers... */
if (pchan->rotmode > 0) {
pchan->eul[1] *= -1;
@@ -398,7 +398,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
float eul[3];
-
+
axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle);
eul[1] *= -1;
eul[2] *= -1;
@@ -406,7 +406,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
}
else {
float eul[3];
-
+
normalize_qt(pchan->quat);
quat_to_eul(eul, pchan->quat);
eul[1] *= -1;
@@ -414,12 +414,12 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
eul_to_quat(pchan->quat, eul);
}
}
-
+
/* ID properties */
if (chan->prop) {
if (pchan->prop) {
- /* if we have existing properties on a bone, just copy over the values of
- * matching properties (i.e. ones which will have some impact) on to the
+ /* if we have existing properties on a bone, just copy over the values of
+ * matching properties (i.e. ones which will have some impact) on to the
* target instead of just blinding replacing all [
*/
IDP_SyncGroupValues(pchan->prop, chan->prop);
@@ -430,7 +430,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo
}
}
}
-
+
/* return whether paste went ahead */
return pchan;
}
@@ -488,11 +488,11 @@ void POSE_OT_copy(wmOperatorType *ot)
ot->name = "Copy Pose";
ot->idname = "POSE_OT_copy";
ot->description = "Copies the current pose of the selected bones to copy/paste buffer";
-
+
/* api callbacks */
ot->exec = pose_copy_exec;
ot->poll = ED_operator_posemode;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER;
}
@@ -506,15 +506,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
bPoseChannel *chan;
const bool flip = RNA_boolean_get(op->ptr, "flipped");
bool selOnly = RNA_boolean_get(op->ptr, "selected_mask");
-
+
/* Get KeyingSet to use. */
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
-
+
/* Sanity checks. */
if (ELEM(NULL, ob, ob->pose)) {
return OPERATOR_CANCELLED;
}
-
+
/* Read copy buffer .blend file. */
char str[FILE_MAX];
Main *tmp_bmain = BKE_main_new();
@@ -530,7 +530,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED;
}
-
+
Object *object_from = tmp_bmain->object.first;
bPose *pose_from = object_from->pose;
if (pose_from == NULL) {
@@ -538,7 +538,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
BKE_main_free(tmp_bmain);
return OPERATOR_CANCELLED;
}
-
+
/* If selOnly option is enabled, if user hasn't selected any bones,
* just go back to default behavior to be more in line with other
* pose tools.
@@ -548,7 +548,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
selOnly = false;
}
}
-
+
/* Safely merge all of the channels in the buffer pose into any
* existing pose.
*/
@@ -563,15 +563,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
}
}
BKE_main_free(tmp_bmain);
-
+
/* Update event for pose and deformation children. */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
-
+
/* Recalculate paths if any of the bones have paths... */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) {
ED_pose_recalculate_paths(scene, ob);
}
-
+
/* Notifiers for updates, */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
@@ -586,14 +586,14 @@ void POSE_OT_paste(wmOperatorType *ot)
ot->name = "Paste Pose";
ot->idname = "POSE_OT_paste";
ot->description = "Paste the stored pose on to the current pose";
-
+
/* api callbacks */
ot->exec = pose_paste_exec;
ot->poll = ED_operator_posemode;
-
+
/* flag */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-
+
/* properties */
prop = RNA_def_boolean(ot->srna, "flipped", false, "Flipped on X-Axis", "Paste the stored pose flipped on to current pose");
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
@@ -613,9 +613,9 @@ static void pchan_clear_scale(bPoseChannel *pchan)
pchan->size[1] = 1.0f;
if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
pchan->size[2] = 1.0f;
-
+
pchan->ease1 = 0.0f;
- pchan->ease2 = 0.0f;
+ pchan->ease2 = 0.0f;
pchan->scaleIn = 1.0f;
pchan->scaleOut = 1.0f;
}
@@ -647,7 +647,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
pchan->rotAxis[1] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
pchan->rotAxis[2] = 0.0f;
-
+
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
pchan->rotAxis[1] = 1.0f;
@@ -676,7 +676,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
/* perform clamping using euler form (3-components) */
float eul[3], oldeul[3], quat1[4] = {0};
float qlen = 0.0f;
-
+
if (pchan->rotmode == ROT_MODE_QUAT) {
qlen = normalize_qt_qt(quat1, pchan->quat);
quat_to_eul(oldeul, quat1);
@@ -687,22 +687,22 @@ static void pchan_clear_rot(bPoseChannel *pchan)
else {
copy_v3_v3(oldeul, pchan->eul);
}
-
+
eul[0] = eul[1] = eul[2] = 0.0f;
-
+
if (pchan->protectflag & OB_LOCK_ROTX)
eul[0] = oldeul[0];
if (pchan->protectflag & OB_LOCK_ROTY)
eul[1] = oldeul[1];
if (pchan->protectflag & OB_LOCK_ROTZ)
eul[2] = oldeul[2];
-
+
if (pchan->rotmode == ROT_MODE_QUAT) {
eul_to_quat(pchan->quat, eul);
-
+
/* restore original quat size */
mul_qt_fl(pchan->quat, qlen);
-
+
/* quaternions flip w sign to accumulate rotations correctly */
if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) {
mul_qt_fl(pchan->quat, -1.0f);
@@ -728,11 +728,11 @@ static void pchan_clear_rot(bPoseChannel *pchan)
zero_v3(pchan->eul);
}
}
-
+
/* Clear also Bendy Bone stuff - Roll is obvious, but Curve X/Y stuff is also kindof rotational in nature... */
pchan->roll1 = 0.0f;
pchan->roll2 = 0.0f;
-
+
pchan->curveInX = 0.0f;
pchan->curveInY = 0.0f;
pchan->curveOutX = 0.0f;
@@ -750,25 +750,25 @@ static void pchan_clear_transforms(bPoseChannel *pchan)
/* --------------- */
/* generic exec for clear-pose operators */
-static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
+static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
void (*clear_func)(bPoseChannel *), const char default_ksName[])
{
Scene *scene = CTX_data_scene(C);
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
short autokey = 0;
-
+
/* sanity checks */
if (ELEM(NULL, clear_func, default_ksName)) {
BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name");
return OPERATOR_CANCELLED;
}
-
+
/* only clear relevant transforms for selected bones */
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones)
{
/* run provided clearing function */
clear_func(pchan);
-
+
/* do auto-keyframing as appropriate */
if (autokeyframe_cfra_can_key(scene, &ob->id)) {
/* clear any unkeyed tags */
@@ -785,31 +785,31 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
}
}
CTX_DATA_END;
-
+
/* perform autokeying on the bones if needed */
if (autokey) {
/* get KeyingSet to use */
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName);
-
+
/* insert keyframes */
ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
-
+
/* now recalculate paths */
if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS))
ED_pose_recalculate_paths(scene, ob);
}
-
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
+
return OPERATOR_FINISHED;
}
/* --------------- */
-static int pose_clear_scale_exec(bContext *C, wmOperator *op)
+static int pose_clear_scale_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_scale, ANIM_KS_SCALING_ID);
}
@@ -820,17 +820,17 @@ void POSE_OT_scale_clear(wmOperatorType *ot)
ot->name = "Clear Pose Scale";
ot->idname = "POSE_OT_scale_clear";
ot->description = "Reset scaling of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_scale_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int pose_clear_rot_exec(bContext *C, wmOperator *op)
+static int pose_clear_rot_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_rot, ANIM_KS_ROTATION_ID);
}
@@ -841,17 +841,17 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
ot->name = "Clear Pose Rotation";
ot->idname = "POSE_OT_rot_clear";
ot->description = "Reset rotations of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_rot_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int pose_clear_loc_exec(bContext *C, wmOperator *op)
+static int pose_clear_loc_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_loc, ANIM_KS_LOCATION_ID);
}
@@ -862,17 +862,17 @@ void POSE_OT_loc_clear(wmOperatorType *ot)
ot->name = "Clear Pose Location";
ot->idname = "POSE_OT_loc_clear";
ot->description = "Reset locations of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_loc_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int pose_clear_transforms_exec(bContext *C, wmOperator *op)
+static int pose_clear_transforms_exec(bContext *C, wmOperator *op)
{
return pose_clear_transform_generic_exec(C, op, pchan_clear_transforms, ANIM_KS_LOC_ROT_SCALE_ID);
}
@@ -883,11 +883,11 @@ void POSE_OT_transforms_clear(wmOperatorType *ot)
ot->name = "Clear Pose Transforms";
ot->idname = "POSE_OT_transforms_clear";
ot->description = "Reset location, rotation, and scaling of selected bones to their default values";
-
+
/* api callbacks */
ot->exec = pose_clear_transforms_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -901,31 +901,31 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
float cframe = (float)CFRA;
const bool only_select = RNA_boolean_get(op->ptr, "only_selected");
-
+
if ((ob->adt) && (ob->adt->action)) {
- /* XXX: this is just like this to avoid contaminating anything else;
- * just pose values should change, so this should be fine
+ /* XXX: this is just like this to avoid contaminating anything else;
+ * just pose values should change, so this should be fine
*/
bPose *dummyPose = NULL;
Object workob = {{NULL}};
bPoseChannel *pchan;
-
+
/* execute animation step for current frame using a dummy copy of the pose */
BKE_pose_copy_data(&dummyPose, ob->pose, 0);
-
+
BLI_strncpy(workob.id.name, "OB<ClearTfmWorkOb>", sizeof(workob.id.name));
workob.type = OB_ARMATURE;
workob.data = ob->data;
workob.adt = ob->adt;
workob.pose = dummyPose;
-
+
BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM);
-
+
/* copy back values, but on selected bones only */
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
pose_bone_do_paste(ob, pchan, only_select, 0);
}
-
+
/* free temp data - free manually as was copied without constraints */
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->prop) {
@@ -933,22 +933,22 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
MEM_freeN(pchan->prop);
}
}
-
+
/* was copied without constraints */
BLI_freelistN(&dummyPose->chanbase);
MEM_freeN(dummyPose);
}
else {
- /* no animation, so just reset whole pose to rest pose
+ /* no animation, so just reset whole pose to rest pose
* (cannot just restore for selected though)
*/
BKE_pose_rest(ob->pose);
}
-
+
/* notifiers and updates */
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
-
+
return OPERATOR_FINISHED;
}
@@ -958,11 +958,11 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot)
ot->name = "Clear User Transforms";
ot->idname = "POSE_OT_user_transforms_clear";
ot->description = "Reset pose on selected bones to keyframed state";
-
+
/* callbacks */
ot->exec = pose_clear_user_transforms_exec;
ot->poll = ED_operator_posemode;
-
+
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 93d00addd02..84eaa5b02bd 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -62,7 +62,7 @@
* convenience functions, such as applying/getting pose values
* and/or inserting keyframes for these.
*/
-/* *********************************************** */
+/* *********************************************** */
/* FCurves <-> PoseChannels Links */
/* helper for poseAnim_mapping_get() -> get the relevant F-Curves per PoseChannel */
@@ -70,25 +70,25 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
{
ListBase curves = {NULL, NULL};
int transFlags = action_get_item_transforms(act, ob, pchan, &curves);
-
+
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
-
+
/* check if any transforms found... */
if (transFlags) {
/* make new linkage data */
tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink");
PointerRNA ptr;
-
+
pfl->fcurves = curves;
pfl->pchan = pchan;
-
+
/* get the RNA path to this pchan - this needs to be freed! */
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
pfl->pchan_path = RNA_path_from_ID_to_struct(&ptr);
-
+
/* add linkage data to operator data */
BLI_addtail(pfLinks, pfl);
-
+
/* set pchan's transform flags */
if (transFlags & ACT_TRANS_LOC)
pchan->flag |= POSE_LOC;
@@ -98,7 +98,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
pchan->flag |= POSE_SIZE;
if (transFlags & ACT_TRANS_BBONE)
pchan->flag |= POSE_BBONE_SHAPE;
-
+
/* store current transforms */
copy_v3_v3(pfl->oldloc, pchan->loc);
copy_v3_v3(pfl->oldrot, pchan->eul);
@@ -106,7 +106,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
copy_qt_qt(pfl->oldquat, pchan->quat);
copy_v3_v3(pfl->oldaxis, pchan->rotAxis);
pfl->oldangle = pchan->rotAngle;
-
+
/* store current bbone values */
pfl->roll1 = pchan->roll1;
pfl->roll2 = pchan->roll2;
@@ -118,18 +118,18 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a
pfl->ease2 = pchan->ease2;
pfl->scaleIn = pchan->scaleIn;
pfl->scaleOut = pchan->scaleOut;
-
+
/* make copy of custom properties */
if (pchan->prop && (transFlags & ACT_TRANS_PROP))
pfl->oldprops = IDP_CopyProperty(pchan->prop);
}
-}
+}
/* get sets of F-Curves providing transforms for the bones in the Pose */
void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *act)
-{
- /* for each Pose-Channel which gets affected, get the F-Curves for that channel
+{
+ /* for each Pose-Channel which gets affected, get the F-Curves for that channel
* and set the relevant transform flags...
*/
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
@@ -137,7 +137,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
}
CTX_DATA_END;
-
+
/* if no PoseChannels were found, try a second pass, doing visible ones instead
* i.e. if nothing selected, do whole pose
*/
@@ -147,7 +147,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
}
CTX_DATA_END;
-
+
}
}
@@ -155,23 +155,23 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
void poseAnim_mapping_free(ListBase *pfLinks)
{
tPChanFCurveLink *pfl, *pfln = NULL;
-
+
/* free the temp pchan links and their data */
for (pfl = pfLinks->first; pfl; pfl = pfln) {
pfln = pfl->next;
-
+
/* free custom properties */
if (pfl->oldprops) {
IDP_FreeProperty(pfl->oldprops);
MEM_freeN(pfl->oldprops);
}
-
+
/* free list of F-Curve reference links */
BLI_freelistN(&pfl->fcurves);
-
+
/* free pchan RNA Path */
MEM_freeN(pfl->pchan_path);
-
+
/* free link itself */
BLI_freelinkN(pfLinks, pfl);
}
@@ -183,8 +183,8 @@ void poseAnim_mapping_free(ListBase *pfLinks)
void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
{
bArmature *arm = (bArmature *)ob->data;
-
- /* old optimize trick... this enforces to bypass the depgraph
+
+ /* old optimize trick... this enforces to bypass the depgraph
* - note: code copied from transform_generics.c -> recalcData()
*/
/* FIXME: shouldn't this use the builtin stuff? */
@@ -192,7 +192,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
else
BKE_pose_where_is(scene, ob);
-
+
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
}
@@ -201,11 +201,11 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
void poseAnim_mapping_reset(ListBase *pfLinks)
{
tPChanFCurveLink *pfl;
-
+
/* iterate over each pose-channel affected, restoring all channels to their original values */
for (pfl = pfLinks->first; pfl; pfl = pfl->next) {
bPoseChannel *pchan = pfl->pchan;
-
+
/* just copy all the values over regardless of whether they changed or not */
copy_v3_v3(pchan->loc, pfl->oldloc);
copy_v3_v3(pchan->eul, pfl->oldrot);
@@ -213,7 +213,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
copy_qt_qt(pchan->quat, pfl->oldquat);
copy_v3_v3(pchan->rotAxis, pfl->oldaxis);
pchan->rotAngle = pfl->oldangle;
-
+
/* store current bbone values */
pchan->roll1 = pfl->roll1;
pchan->roll2 = pfl->roll2;
@@ -225,7 +225,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
pchan->ease2 = pfl->ease2;
pchan->scaleIn = pfl->scaleIn;
pchan->scaleOut = pfl->scaleOut;
-
+
/* just overwrite values of properties from the stored copies (there should be some) */
if (pfl->oldprops)
IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops);
@@ -240,26 +240,26 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
ListBase dsources = {NULL, NULL};
tPChanFCurveLink *pfl;
-
+
/* iterate over each pose-channel affected, tagging bones to be keyed */
- /* XXX: here we already have the information about what transforms exist, though
+ /* XXX: here we already have the information about what transforms exist, though
* it might be easier to just overwrite all using normal mechanisms
*/
for (pfl = pfLinks->first; pfl; pfl = pfl->next) {
bPoseChannel *pchan = pfl->pchan;
-
+
/* add datasource override for the PoseChannel, to be used later */
- ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
-
+ ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
+
/* clear any unkeyed tags */
if (pchan->bone)
pchan->bone->flag &= ~BONE_UNKEYED;
}
-
+
/* insert keyframes for all relevant bones in one go */
ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cframe);
BLI_freelistN(&dsources);
-
+
/* do the bone paths
* - only do this if keyframes should have been added
* - do not calculate unless there are paths already to update...
@@ -273,25 +273,25 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
/* ------------------------- */
-/* find the next F-Curve for a PoseChannel with matching path...
+/* find the next F-Curve for a PoseChannel with matching path...
* - path is not just the pfl rna_path, since that path doesn't have property info yet
*/
LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path)
{
LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL;
LinkData *ld;
-
+
/* check each link to see if the linked F-Curve has a matching path */
for (ld = first; ld; ld = ld->next) {
FCurve *fcu = (FCurve *)ld->data;
-
+
/* check if paths match */
if (STREQ(path, fcu->rna_path))
return ld;
}
-
+
/* none found */
return NULL;
}
-/* *********************************************** */
+/* *********************************************** */
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index 938e840a451..d837c702cb7 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -106,9 +106,9 @@ static VertexData *allocVertexData(EditMesh *em)
VertexData *data;
EditVert *eve;
int totvert, index;
-
+
totvert = BLI_listbase_count(&em->verts);
-
+
data = MEM_callocN(sizeof(VertexData) * totvert, "VertexData");
for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next)
@@ -117,7 +117,7 @@ static VertexData *allocVertexData(EditMesh *em)
data[index].w = 0;
eve->tmp.p = data + index;
}
-
+
return data;
}
@@ -152,13 +152,13 @@ void REEB_freeArc(BArc *barc)
{
ReebArc *arc = (ReebArc *)barc;
BLI_freelistN(&arc->edges);
-
+
if (arc->buckets)
MEM_freeN(arc->buckets);
-
+
if (arc->faces)
BLI_ghash_free(arc->faces, NULL, NULL);
-
+
MEM_freeN(arc);
}
@@ -166,13 +166,13 @@ void REEB_freeGraph(ReebGraph *rg)
{
ReebArc *arc;
ReebNode *node;
-
+
// free nodes
for (node = rg->nodes.first; node; node = node->next) {
BLI_freeNode((BGraph *)rg, (BNode *)node);
}
BLI_freelistN(&rg->nodes);
-
+
// free arcs
arc = rg->arcs.first;
while (arc) {
@@ -180,15 +180,15 @@ void REEB_freeGraph(ReebGraph *rg)
REEB_freeArc((BArc *)arc);
arc = next;
}
-
+
// free edge map
BLI_edgehash_free(rg->emap, NULL);
-
+
/* free linked graph */
if (rg->link_up) {
REEB_freeGraph(rg->link_up);
}
-
+
MEM_freeN(rg);
}
@@ -196,16 +196,16 @@ ReebGraph *newReebGraph(void)
{
ReebGraph *rg;
rg = MEM_callocN(sizeof(ReebGraph), "reeb graph");
-
+
rg->totnodes = 0;
rg->emap = BLI_edgehash_new(__func__);
-
-
+
+
rg->free_arc = REEB_freeArc;
rg->free_node = NULL;
rg->radial_symmetry = REEB_RadialSymmetry;
rg->axial_symmetry = REEB_AxialSymmetry;
-
+
return rg;
}
@@ -221,11 +221,11 @@ static ReebNode *addNode(ReebGraph *rg, EditVert *eve)
{
float weight;
ReebNode *node = NULL;
-
+
weight = weightData(eve);
-
+
node = MEM_callocN(sizeof(ReebNode), "reeb node");
-
+
node->flag = 0; // clear flag on init
node->symmetry_level = 0;
node->arcs = NULL;
@@ -233,45 +233,45 @@ static ReebNode *addNode(ReebGraph *rg, EditVert *eve)
node->weight = weight;
node->index = rg->totnodes;
copy_v3_v3(node->p, eve->co);
-
+
BLI_addtail(&rg->nodes, node);
rg->totnodes++;
-
+
nodeSetData(eve, node);
-
+
return node;
}
static ReebNode *copyNode(ReebGraph *rg, ReebNode *node)
{
ReebNode *cp_node = NULL;
-
+
cp_node = MEM_callocN(sizeof(ReebNode), "reeb node copy");
-
+
memcpy(cp_node, node, sizeof(ReebNode));
-
+
cp_node->prev = NULL;
cp_node->next = NULL;
cp_node->arcs = NULL;
-
+
cp_node->link_up = NULL;
cp_node->link_down = NULL;
-
+
BLI_addtail(&rg->nodes, cp_node);
rg->totnodes++;
-
- return cp_node;
+
+ return cp_node;
}
static void relinkNodes(ReebGraph *low_rg, ReebGraph *high_rg)
{
ReebNode *low_node, *high_node;
-
+
if (low_rg == NULL || high_rg == NULL)
{
return;
}
-
+
for (low_node = low_rg->nodes.first; low_node; low_node = low_node->next)
{
for (high_node = high_rg->nodes.first; high_node; high_node = high_node->next)
@@ -285,7 +285,7 @@ static void relinkNodes(ReebGraph *low_rg, ReebGraph *high_rg)
}
}
}
-#endif
+#endif
ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node)
{
@@ -302,7 +302,7 @@ ReebNode *BIF_lowestLevelNode(ReebNode *node)
while (node->link_down) {
node = node->link_down;
}
-
+
return node;
}
@@ -311,13 +311,13 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
{
ReebArc *cp_arc;
ReebNode *node;
-
+
cp_arc = MEM_callocN(sizeof(ReebArc), "reeb arc copy");
memcpy(cp_arc, arc, sizeof(ReebArc));
-
+
cp_arc->link_up = arc;
-
+
cp_arc->head = NULL;
cp_arc->tail = NULL;
@@ -330,11 +330,11 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
/* copy buckets */
cp_arc->buckets = MEM_callocN(sizeof(EmbedBucket) * cp_arc->bcount, "embed bucket");
memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount);
-
+
/* copy faces map */
cp_arc->faces = BLI_ghash_ptr_new("copyArc gh");
mergeArcFaces(rg, cp_arc, arc);
-
+
/* find corresponding head and tail */
for (node = rg->nodes.first; node && (cp_arc->head == NULL || cp_arc->tail == NULL); node = node->next)
{
@@ -347,9 +347,9 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
cp_arc->tail = node;
}
}
-
+
BLI_addtail(&rg->arcs, cp_arc);
-
+
return cp_arc;
}
@@ -358,7 +358,7 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level)
ReebNode *node;
ReebArc *arc;
ReebGraph *cp_rg = newReebGraph();
-
+
cp_rg->resolution = rg->resolution;
cp_rg->length = rg->length;
cp_rg->link_up = rg;
@@ -370,15 +370,15 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level)
ReebNode *cp_node = copyNode(cp_rg, node);
cp_node->multi_level = level;
}
-
+
/* Copy arcs */
for (arc = rg->arcs.first; arc; arc = arc->next)
{
copyArc(cp_rg, arc);
}
-
+
BLI_buildAdjacencyList((BGraph *)cp_rg);
-
+
return cp_rg;
}
#endif
@@ -386,11 +386,11 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level)
ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node)
{
ReebGraph *multi_rg = rg;
-
+
while (multi_rg && multi_rg->multi_level != node->multi_level) {
multi_rg = multi_rg->link_up;
}
-
+
return multi_rg;
}
@@ -398,13 +398,13 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node)
static ReebEdge *copyEdge(ReebEdge *edge)
{
ReebEdge *newEdge = NULL;
-
+
newEdge = MEM_callocN(sizeof(ReebEdge), "reeb edge");
memcpy(newEdge, edge, sizeof(ReebEdge));
-
+
newEdge->next = NULL;
newEdge->prev = NULL;
-
+
return newEdge;
}
@@ -414,7 +414,7 @@ static void printArc(ReebArc *arc)
ReebNode *head = (ReebNode *)arc->head;
ReebNode *tail = (ReebNode *)arc->tail;
printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight);
-
+
for (edge = arc->edges.first; edge; edge = edge->next)
{
printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index);
@@ -427,7 +427,7 @@ static void flipArc(ReebArc *arc)
tmp = arc->head;
arc->head = arc->tail;
arc->tail = tmp;
-
+
flipArcBuckets(arc);
}
@@ -461,20 +461,20 @@ void repositionNodes(ReebGraph *rg)
{
BArc *arc = NULL;
BNode *node = NULL;
-
+
// Reset node positions
for (node = rg->nodes.first; node; node = node->next) {
node->p[0] = node->p[1] = node->p[2] = 0;
}
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
if (((ReebArc *)arc)->bcount > 0) {
float p[3];
-
+
copy_v3_v3(p, ((ReebArc *)arc)->buckets[0].p);
mul_v3_fl(p, 1.0f / arc->head->degree);
add_v3_v3(arc->head->p, p);
-
+
copy_v3_v3(p, ((ReebArc *)arc)->buckets[((ReebArc *)arc)->bcount - 1].p);
mul_v3_fl(p, 1.0f / arc->tail->degree);
add_v3_v3(arc->tail->p, p);
@@ -518,7 +518,7 @@ static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc)
printf("count error in bucket %i/%i\n", i + 1, arc->bcount);
}
}
-
+
if (ceilf(head->weight) != arc->buckets[0].val) {
printArc(arc);
printf("alloc error in first bucket: %f should be %f\n", arc->buckets[0].val, ceil(head->weight));
@@ -548,14 +548,14 @@ void verifyFaces(ReebGraph *rg)
for (arc = rg->arcs.first; arc; arc = arc->next) {
total += BLI_ghash_len(arc->faces);
}
-
+
#endif
}
void verifyArcs(ReebGraph *rg)
{
ReebArc *arc;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
if (arc->head->weight > arc->tail->weight) {
printf("FLIPPED ARC!\n");
@@ -567,10 +567,10 @@ static void verifyMultiResolutionLinks(ReebGraph *rg, int level)
{
#ifdef DEBUG_REEB
ReebGraph *lower_rg = rg->link_up;
-
+
if (lower_rg) {
ReebArc *arc;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
if (BLI_findindex(&lower_rg->arcs, arc->link_up) == -1) {
printf("missing arc %p for level %i\n", (void *)arc->link_up, level);
@@ -580,8 +580,8 @@ static void verifyMultiResolutionLinks(ReebGraph *rg, int level)
arc->link_up = NULL;
}
}
-
-
+
+
verifyMultiResolutionLinks(lower_rg, level + 1);
}
#endif
@@ -620,9 +620,9 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end
{
if (aDst->bcount > 0 && aSrc->bcount > 0) {
int indexDst = 0, indexSrc = 0;
-
+
start = max_fff(start, aDst->buckets[0].val, aSrc->buckets[0].val);
-
+
while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) {
indexDst++;
}
@@ -630,12 +630,12 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end
while (indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start) {
indexSrc++;
}
-
+
for (; indexDst < aDst->bcount &&
indexSrc < aSrc->bcount &&
aDst->buckets[indexDst].val <= end &&
aSrc->buckets[indexSrc].val <= end
-
+
; indexDst++, indexSrc++)
{
mergeBuckets(aDst->buckets + indexDst, aSrc->buckets + indexSrc);
@@ -646,10 +646,10 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end
void flipArcBuckets(ReebArc *arc)
{
int i, j;
-
+
for (i = 0, j = arc->bcount - 1; i < j; i++, j--) {
EmbedBucket tmp;
-
+
tmp = arc->buckets[i];
arc->buckets[i] = arc->buckets[j];
arc->buckets[j] = tmp;
@@ -666,10 +666,10 @@ static void allocArcBuckets(ReebArc *arc)
int i;
float start = ceil(arc->head->weight);
arc->bcount = countArcBuckets(arc);
-
+
if (arc->bcount > 0) {
arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "embed bucket");
-
+
for (i = 0; i < arc->bcount; i++) {
arc->buckets[i].val = start + i;
}
@@ -683,13 +683,13 @@ static void resizeArcBuckets(ReebArc *arc)
{
EmbedBucket *oldBuckets = arc->buckets;
int oldBCount = arc->bcount;
-
+
if (countArcBuckets(arc) == oldBCount) {
return;
}
-
+
allocArcBuckets(arc);
-
+
if (oldBCount != 0 && arc->bcount != 0) {
int oldStart = (int)oldBuckets[0].val;
int oldEnd = (int)oldBuckets[oldBCount - 1].val;
@@ -698,17 +698,17 @@ static void resizeArcBuckets(ReebArc *arc)
int oldOffset = 0;
int newOffset = 0;
int len;
-
+
if (oldStart < newStart) {
oldOffset = newStart - oldStart;
}
else {
newOffset = oldStart - newStart;
}
-
+
len = MIN2(oldEnd - (oldStart + oldOffset) + 1, newEnd - (newStart - newOffset) + 1);
-
- memcpy(arc->buckets + newOffset, oldBuckets + oldOffset, len * sizeof(EmbedBucket));
+
+ memcpy(arc->buckets + newOffset, oldBuckets + oldOffset, len * sizeof(EmbedBucket));
}
if (oldBuckets != NULL) {
@@ -720,7 +720,7 @@ static void reweightBuckets(ReebArc *arc)
{
int i;
float start = ceil((arc->head)->weight);
-
+
if (arc->bcount > 0) {
for (i = 0; i < arc->bcount; i++) {
arc->buckets[i].val = start + i;
@@ -732,9 +732,9 @@ static void interpolateBuckets(ReebArc *arc, float *start_p, float *end_p, int s
{
int total;
int j;
-
+
total = end_index - start_index + 2;
-
+
for (j = start_index; j <= end_index; j++) {
EmbedBucket *empty = arc->buckets + j;
empty->nv = 1;
@@ -748,26 +748,26 @@ static void fillArcEmptyBuckets(ReebArc *arc)
int start_index = 0, end_index = 0;
int missing = 0;
int i;
-
+
start_p = arc->head->p;
-
+
for (i = 0; i < arc->bcount; i++) {
EmbedBucket *bucket = arc->buckets + i;
-
+
if (missing) {
if (bucket->nv > 0) {
missing = 0;
-
+
end_p = bucket->p;
end_index = i - 1;
-
+
interpolateBuckets(arc, start_p, end_p, start_index, end_index);
}
}
else {
if (bucket->nv == 0) {
missing = 1;
-
+
if (i > 0) {
start_p = arc->buckets[i - 1].p;
}
@@ -775,11 +775,11 @@ static void fillArcEmptyBuckets(ReebArc *arc)
}
}
}
-
+
if (missing) {
end_p = arc->tail->p;
end_index = arc->bcount - 1;
-
+
interpolateBuckets(arc, start_p, end_p, start_index, end_index);
}
}
@@ -792,15 +792,15 @@ static void ExtendArcBuckets(ReebArc *arc)
float *previous = NULL;
float average_length = 0, length;
int padding_head = 0, padding_tail = 0;
-
+
if (arc->bcount == 0) {
return; /* failsafe, shouldn't happen */
}
-
+
initArcIterator(iter, arc, arc->head);
IT_next(iter);
previous = iter->p;
-
+
for (IT_next(iter);
IT_stopped(iter) == 0;
previous = iter->p, IT_next(iter)
@@ -809,10 +809,10 @@ static void ExtendArcBuckets(ReebArc *arc)
average_length += len_v3v3(previous, iter->p);
}
average_length /= (arc->bcount - 1);
-
+
first_bucket = arc->buckets;
last_bucket = arc->buckets + (arc->bcount - 1);
-
+
length = len_v3v3(first_bucket->p, arc->head->p);
if (length > 2 * average_length) {
padding_head = (int)floor(length / average_length);
@@ -822,22 +822,22 @@ static void ExtendArcBuckets(ReebArc *arc)
if (length > 2 * average_length) {
padding_tail = (int)floor(length / average_length);
}
-
+
if (padding_head + padding_tail > 0) {
EmbedBucket *old_buckets = arc->buckets;
-
+
arc->buckets = MEM_callocN(sizeof(EmbedBucket) * (padding_head + arc->bcount + padding_tail), "embed bucket");
memcpy(arc->buckets + padding_head, old_buckets, arc->bcount * sizeof(EmbedBucket));
-
+
arc->bcount = padding_head + arc->bcount + padding_tail;
-
+
MEM_freeN(old_buckets);
}
-
+
if (padding_head > 0) {
interpolateBuckets(arc, arc->head->p, first_bucket->p, 0, padding_head);
}
-
+
if (padding_tail > 0) {
interpolateBuckets(arc, last_bucket->p, arc->tail->p, arc->bcount - padding_tail, arc->bcount - 1);
}
@@ -847,7 +847,7 @@ static void ExtendArcBuckets(ReebArc *arc)
static void extendGraphBuckets(ReebGraph *rg)
{
ReebArc *arc;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
ExtendArcBuckets(arc);
}
@@ -862,7 +862,7 @@ static void calculateArcLength(ReebArc *arc)
float *vec0, *vec1;
arc->length = 0;
-
+
initArcIterator(iter, arc, arc->head);
vec0 = arc->head->p;
@@ -870,19 +870,19 @@ static void calculateArcLength(ReebArc *arc)
while (IT_next(iter)) {
vec1 = iter->p;
-
+
arc->length += len_v3v3(vec0, vec1);
-
+
vec0 = vec1;
}
-
+
arc->length += len_v3v3(arc->tail->p, vec1);
}
static void calculateGraphLength(ReebGraph *rg)
{
ReebArc *arc;
-
+
for (arc = rg->arcs.first; arc; arc = arc->next) {
calculateArcLength(arc);
}
@@ -896,9 +896,9 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
ReebNode *node = (ReebNode *)root_node;
float axis[3];
int i;
-
+
copy_v3_v3(axis, root_node->symmetry_axis);
-
+
/* first pass, merge incrementally */
for (i = 0; i < count - 1; i++) {
ReebNode *node1, *node2;
@@ -909,45 +909,45 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
add_v3_v3v3(tangent, ring[i].n, ring[j].n);
cross_v3_v3v3(normal, tangent, axis);
-
+
node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node);
node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node);
-
+
arc1 = (ReebArc *)ring[i].arc;
arc2 = (ReebArc *)ring[j].arc;
/* mirror first node and mix with the second */
BLI_mirrorAlongAxis(node1->p, root_node->p, normal);
interp_v3_v3v3(node2->p, node2->p, node1->p, 1.0f / (j + 1));
-
+
/* Merge buckets
- * there shouldn't be any null arcs here, but just to be safe
+ * there shouldn't be any null arcs here, but just to be safe
* */
if (arc1->bcount > 0 && arc2->bcount > 0) {
ReebArcIterator arc_iter1, arc_iter2;
BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
-
+
initArcIterator(iter1, arc1, (ReebNode *)root_node);
initArcIterator(iter2, arc2, (ReebNode *)root_node);
-
+
bucket1 = IT_next(iter1);
bucket2 = IT_next(iter2);
-
+
/* Make sure they both start at the same value */
while (bucket1 && bucket2 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
-
+
while (bucket1 && bucket2 && bucket2->val < bucket1->val) {
bucket2 = IT_next(iter2);
}
-
-
+
+
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
bucket2->nv += bucket1->nv; /* add counts */
-
+
/* mirror on axis */
BLI_mirrorAlongAxis(bucket1->p, root_node->p, normal);
/* add bucket2 in bucket1 */
@@ -955,7 +955,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
}
}
}
-
+
/* second pass, mirror back on previous arcs */
for (i = count - 1; i > 0; i--) {
ReebNode *node1, *node2;
@@ -966,42 +966,42 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
add_v3_v3v3(tangent, ring[i].n, ring[j].n);
cross_v3_v3v3(normal, tangent, axis);
-
+
node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node);
node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node);
-
+
arc1 = (ReebArc *)ring[i].arc;
arc2 = (ReebArc *)ring[j].arc;
/* copy first node than mirror */
copy_v3_v3(node2->p, node1->p);
BLI_mirrorAlongAxis(node2->p, root_node->p, normal);
-
+
/* Copy buckets
- * there shouldn't be any null arcs here, but just to be safe
+ * there shouldn't be any null arcs here, but just to be safe
* */
if (arc1->bcount > 0 && arc2->bcount > 0) {
ReebArcIterator arc_iter1, arc_iter2;
BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
-
+
initArcIterator(iter1, arc1, node);
initArcIterator(iter2, arc2, node);
-
+
bucket1 = IT_next(iter1);
bucket2 = IT_next(iter2);
-
+
/* Make sure they both start at the same value */
while (bucket1 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
-
+
while (bucket2 && bucket2->val < bucket1->val) {
bucket2 = IT_next(iter2);
}
-
-
+
+
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
/* copy and mirror back to bucket2 */
bucket2->nv = bucket1->nv;
@@ -1021,7 +1021,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr
arc2 = (ReebArc *)barc2;
copy_v3_v3(nor, root_node->symmetry_axis);
-
+
/* mirror node2 along axis */
copy_v3_v3(p, node2->p);
BLI_mirrorAlongAxis(p, root_node->p, nor);
@@ -1029,31 +1029,31 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr
/* average with node1 */
add_v3_v3(node1->p, p);
mul_v3_fl(node1->p, 0.5f);
-
+
/* mirror back on node2 */
copy_v3_v3(node2->p, node1->p);
BLI_mirrorAlongAxis(node2->p, root_node->p, nor);
-
+
/* Merge buckets
- * there shouldn't be any null arcs here, but just to be safe
+ * there shouldn't be any null arcs here, but just to be safe
* */
if (arc1->bcount > 0 && arc2->bcount > 0) {
ReebArcIterator arc_iter1, arc_iter2;
BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
-
+
initArcIterator(iter1, arc1, (ReebNode *)root_node);
initArcIterator(iter2, arc2, (ReebNode *)root_node);
-
+
bucket1 = IT_next(iter1);
bucket2 = IT_next(iter2);
-
+
/* Make sure they both start at the same value */
while (bucket1 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
-
+
while (bucket2 && bucket2->val < bucket1->val) {
bucket2 = IT_next(iter2);
}
@@ -1061,7 +1061,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
bucket1->nv += bucket2->nv; /* add counts */
-
+
/* mirror on axis */
BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor);
/* add bucket2 in bucket1 */
@@ -1104,7 +1104,7 @@ void postprocessGraph(ReebGraph *rg, char mode)
// error("Unknown post processing mode");
return;
}
-
+
for (arc = rg->arcs.first; arc; arc = arc->next)
{
EmbedBucket *buckets = arc->buckets;
@@ -1125,7 +1125,7 @@ static int compareNodesWeight(void *vnode1, void *vnode2)
{
ReebNode *node1 = (ReebNode *)vnode1;
ReebNode *node2 = (ReebNode *)vnode2;
-
+
if (node1->weight < node2->weight)
{
return -1;
@@ -1150,7 +1150,7 @@ static int compareArcsWeight(void *varc1, void *varc2)
ReebArc *arc2 = (ReebArc *)varc2;
ReebNode *node1 = (ReebNode *)arc1->head;
ReebNode *node2 = (ReebNode *)arc2->head;
-
+
if (node1->weight < node2->weight)
{
return -1;
@@ -1176,9 +1176,9 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float
float old_weight;
float end_weight = start_weight + ABS(arc->tail->weight - arc->head->weight);
int i;
-
+
node = (ReebNode *)BLI_otherNode((BArc *)arc, (BNode *)start_node);
-
+
/* prevent backtracking */
if (node->flag == 1)
{
@@ -1189,13 +1189,13 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float
{
flipArc(arc);
}
-
+
start_node->flag = 1;
-
+
for (i = 0; i < node->degree; i++)
{
ReebArc *next_arc = node->arcs[i];
-
+
reweightArc(rg, next_arc, node, end_weight);
}
@@ -1203,28 +1203,28 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float
if (arc->head->weight != start_weight || arc->tail->weight != end_weight)
{
old_weight = arc->head->weight; /* backup head weight, other arcs need it intact, it will be fixed by the source arc */
-
+
arc->head->weight = start_weight;
arc->tail->weight = end_weight;
-
+
reweightBuckets(arc);
resizeArcBuckets(arc);
fillArcEmptyBuckets(arc);
-
+
arc->head->weight = old_weight;
}
-}
+}
static void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_weight)
{
int i;
-
+
BLI_flagNodes((BGraph *)rg, 0);
for (i = 0; i < start_node->degree; i++)
{
ReebArc *next_arc = start_node->arcs[i];
-
+
reweightArc(rg, next_arc, start_node, start_weight);
}
start_node->weight = start_weight;
@@ -1234,24 +1234,24 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
{
int joined = 0;
int subgraph;
-
+
for (subgraph = 1; subgraph <= nb_subgraphs; subgraph++)
{
ReebNode *start_node, *end_node;
ReebNode *min_node_start = NULL, *min_node_end = NULL;
float min_distance = FLT_MAX;
-
+
for (start_node = rg->nodes.first; start_node; start_node = start_node->next)
{
if (start_node->subgraph_index == subgraph && start_node->degree == 1)
{
-
+
for (end_node = rg->nodes.first; end_node; end_node = end_node->next)
{
if (end_node->subgraph_index != subgraph)
{
float distance = len_v3v3(start_node->p, end_node->p);
-
+
if (distance < threshold && distance < min_distance)
{
min_distance = distance;
@@ -1262,24 +1262,24 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
}
}
}
-
+
end_node = min_node_end;
start_node = min_node_start;
-
+
if (end_node && start_node)
{
ReebArc *start_arc /* , *end_arc */ /* UNUSED */;
int merging = 0;
-
+
start_arc = start_node->arcs[0];
/* end_arc = end_node->arcs[0]; */ /* UNUSED */
-
+
if (start_arc->tail == start_node)
{
reweightSubgraph(rg, end_node, start_node->weight);
-
+
start_arc->tail = end_node;
-
+
merging = 1;
}
else if (start_arc->head == start_node)
@@ -1290,24 +1290,24 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
merging = 2;
}
-
+
if (merging)
{
BLI_ReflagSubgraph((BGraph *)rg, end_node->flag, subgraph);
-
+
resizeArcBuckets(start_arc);
fillArcEmptyBuckets(start_arc);
-
+
NodeDegreeIncrement(rg, end_node);
BLI_rebuildAdjacencyListForNode((BGraph *)rg, (BNode *)end_node);
-
+
BLI_removeNode((BGraph *)rg, (BNode *)start_node);
}
-
+
joined = 1;
}
}
-
+
return joined;
}
@@ -1315,12 +1315,12 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
static void fixSubgraphsOrientation(ReebGraph *rg, int nb_subgraphs)
{
int subgraph;
-
+
for (subgraph = 1; subgraph <= nb_subgraphs; subgraph++)
{
ReebNode *node;
ReebNode *start_node = NULL;
-
+
for (node = rg->nodes.first; node; node = node->next)
{
if (node->subgraph_index == subgraph)
@@ -1331,7 +1331,7 @@ static void fixSubgraphsOrientation(ReebGraph *rg, int nb_subgraphs)
}
}
}
-
+
if (start_node)
{
reweightSubgraph(rg, start_node, start_node->weight);
@@ -1343,19 +1343,19 @@ static int joinSubgraphs(ReebGraph *rg, float threshold)
{
int nb_subgraphs;
int joined = 0;
-
+
BLI_buildAdjacencyList((BGraph *)rg);
-
+
if (BLI_isGraphCyclic((BGraph *)rg)) {
/* don't deal with cyclic graphs YET */
return 0;
}
-
+
/* sort nodes before flagging subgraphs to make sure root node is subgraph 0 */
sortNodes(rg);
-
+
nb_subgraphs = BLI_FlagSubgraphs((BGraph *)rg);
-
+
/* Harmonic function can create flipped arcs, take the occasion to fix them */
// XXX
// if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC)
@@ -1366,14 +1366,14 @@ static int joinSubgraphs(ReebGraph *rg, float threshold)
if (nb_subgraphs > 1)
{
joined |= joinSubgraphsEnds(rg, threshold, nb_subgraphs);
-
+
if (joined)
{
removeNormalNodes(rg);
BLI_buildAdjacencyList((BGraph *)rg);
}
}
-
+
return joined;
}
@@ -1384,7 +1384,7 @@ static float lengthArc(ReebArc *arc)
#if 0
ReebNode *head = (ReebNode *)arc->head;
ReebNode *tail = (ReebNode *)arc->tail;
-
+
return tail->weight - head->weight;
#else
return arc->length;
@@ -1397,7 +1397,7 @@ static int compareArcs(void *varc1, void *varc2)
ReebArc *arc2 = (ReebArc *)varc2;
float len1 = lengthArc(arc1);
float len2 = lengthArc(arc2);
-
+
if (len1 < len2) {
return -1;
}
@@ -1428,7 +1428,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
arc = rg->arcs.first;
while (arc) {
nextArc = arc->next;
-
+
if (arc->head == removedNode || arc->tail == removedNode) {
if (arc->head == removedNode) {
arc->head = newNode;
@@ -1441,7 +1441,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
if (arc->head == arc->tail) {
// v1 or v2 was already newNode, since we're removing an arc, decrement degree
NodeDegreeDecrement(rg, newNode);
-
+
// If it's srcArc, it'll be removed later, so keep it for now
if (arc != srcArc) {
BLI_remlink(&rg->arcs, arc);
@@ -1464,13 +1464,13 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
// resize bucket list
resizeArcBuckets(arc);
mergeArcBuckets(arc, srcArc, head->weight, tail->weight);
-
+
/* update length */
arc->length += srcArc->length;
}
}
}
-
+
arc = nextArc;
}
}
@@ -1478,7 +1478,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
void filterNullReebGraph(ReebGraph *rg)
{
ReebArc *arc = NULL, *nextArc = NULL;
-
+
arc = rg->arcs.first;
while (arc) {
nextArc = arc->next;
@@ -1487,22 +1487,22 @@ void filterNullReebGraph(ReebGraph *rg)
ReebNode *newNode = (ReebNode *)arc->head;
ReebNode *removedNode = (ReebNode *)arc->tail;
float blend;
-
+
blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors
-
+
interp_v3_v3v3(newNode->p, removedNode->p, newNode->p, blend);
-
+
filterArc(rg, newNode, removedNode, arc, 0);
// Reset nextArc, it might have changed
nextArc = arc->next;
-
+
BLI_remlink(&rg->arcs, arc);
REEB_freeArc((BArc *)arc);
-
+
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
}
-
+
arc = nextArc;
}
}
@@ -1511,9 +1511,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
{
ReebArc *arc = NULL, *nextArc = NULL;
int value = 0;
-
+
BLI_listbase_sort(&rg->arcs, compareArcs);
-
+
for (arc = rg->arcs.first; arc; arc = nextArc) {
nextArc = arc->next;
@@ -1525,7 +1525,7 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
{
ReebNode *newNode = NULL;
ReebNode *removedNode = NULL;
-
+
/* Always remove lower node, so arcs don't flip */
newNode = arc->head;
removedNode = arc->tail;
@@ -1534,14 +1534,14 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
// Reset nextArc, it might have changed
nextArc = arc->next;
-
+
BLI_remlink(&rg->arcs, arc);
REEB_freeArc((BArc *)arc);
-
+
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
value = 1;
}
-
+
// Only collapse terminal arcs that are shorter than threshold
else if ((threshold_external > 0) &&
(arc->head->degree == 1 || arc->tail->degree == 1) &&
@@ -1550,7 +1550,7 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
ReebNode *terminalNode = NULL;
ReebNode *middleNode = NULL;
ReebNode *removedNode = NULL;
-
+
// Assign terminal and middle nodes
if (arc->head->degree == 1) {
terminalNode = arc->head;
@@ -1560,13 +1560,13 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
terminalNode = arc->tail;
middleNode = arc->head;
}
-
+
if (middleNode->degree == 2 && middleNode != rg->nodes.first) {
#if 1
// If middle node is a normal node, it will be removed later
// Only if middle node is not the root node
/* USE THIS IF YOU WANT TO PROLONG ARCS TO THEIR TERMINAL NODES
- * FOR HANDS, THIS IS NOT THE BEST RESULT
+ * FOR HANDS, THIS IS NOT THE BEST RESULT
* */
continue;
#else
@@ -1586,15 +1586,15 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
// Reset nextArc, it might have changed
nextArc = arc->next;
-
+
BLI_remlink(&rg->arcs, arc);
REEB_freeArc((BArc *)arc);
-
+
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
value = 1;
}
}
-
+
return value;
}
@@ -1603,7 +1603,7 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold)
ReebArc *arc1, *arc2;
ReebArc *next2;
int filtered = 0;
-
+
for (arc1 = rg->arcs.first; arc1; arc1 = arc1->next) {
for (arc2 = arc1->next; arc2; arc2 = next2) {
next2 = arc2->next;
@@ -1617,12 +1617,12 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold)
BLI_remlink(&rg->arcs, arc2);
REEB_freeArc((BArc *)arc2);
-
+
filtered = 1;
}
}
}
-
+
return filtered;
}
@@ -1631,7 +1631,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
int value = 0;
#if 0 //XXX
ReebArc *arc = NULL, *nextArc = NULL;
-
+
BLI_listbase_sort(&rg->arcs, compareArcs);
#ifdef DEBUG_REEB
@@ -1647,7 +1647,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
while (arc)
{
nextArc = arc->next;
-
+
/* need correct normals and center */
recalc_editnormals();
@@ -1659,7 +1659,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
int total = BLI_ghash_len(arc->faces);
float avg_angle = 0;
float avg_vec[3] = {0, 0, 0};
-
+
for (BLI_ghashIterator_init(&ghi, arc->faces);
BLI_ghashIterator_done(&ghi) == false;
BLI_ghashIterator_step(&ghi))
@@ -1673,18 +1673,18 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
EmbedBucket *previous = NULL;
float min_distance = -1;
float angle = 0;
-
+
initArcIterator(iter, arc, arc->head);
-
+
bucket = nextBucket(iter);
-
+
while (bucket != NULL)
{
float *vec0 = NULL;
float *vec1 = bucket->p;
float midpoint[3], tangent[3];
float distance;
-
+
/* first bucket. Previous is head */
if (previous == NULL)
{
@@ -1694,25 +1694,25 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
else {
vec0 = previous->p;
}
-
+
copy_v3_v3(midpoint, vec1);
-
+
distance = len_v3v3(midpoint, efa->cent);
-
+
if (min_distance == -1 || distance < min_distance)
{
min_distance = distance;
-
+
sub_v3_v3v3(tangent, vec1, vec0);
normalize_v3(tangent);
-
+
angle = dot_v3v3(tangent, efa->n);
}
-
+
previous = bucket;
bucket = nextBucket(iter);
}
-
+
avg_angle += saacos(fabs(angle));
#ifdef DEBUG_REEB
efa->tmp.fp = saacos(fabs(angle));
@@ -1723,13 +1723,13 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
}
-#if 0
+#if 0
avg_angle /= total;
#else
mul_v3_fl(avg_vec, 1.0 / total);
avg_angle = dot_v3v3(avg_vec, avg_vec);
#endif
-
+
arc->angle = avg_angle;
if (avg_angle > threshold)
@@ -1777,27 +1777,27 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
/* Reset nextArc, it might have changed */
nextArc = arc->next;
-
+
BLI_remlink(&rg->arcs, arc);
REEB_freeArc((BArc *)arc);
-
+
BLI_freelinkN(&rg->nodes, removedNode);
value = 1;
}
}
-
+
arc = nextArc;
}
-
+
#endif
-
+
return value;
}
static void filterGraph(ReebGraph *rg, short options, float threshold_internal, float threshold_external)
{
bool done = true;
-
+
calculateGraphLength(rg);
if ((options & SKGEN_FILTER_EXTERNAL) == 0) {
@@ -1812,7 +1812,7 @@ static void filterGraph(ReebGraph *rg, short options, float threshold_internal,
/* filter until there's nothing more to do */
while (done == true) {
done = false; /* no work done yet */
-
+
done = filterInternalExternalReebGraph(rg, threshold_internal, threshold_external);
}
}
@@ -1831,17 +1831,17 @@ static void filterGraph(ReebGraph *rg, short options, float threshold_internal,
static void finalizeGraph(ReebGraph *rg, char passes, char method)
{
int i;
-
+
BLI_buildAdjacencyList((BGraph *)rg);
sortNodes(rg);
-
+
sortArcs(rg);
-
+
for (i = 0; i < passes; i++) {
postprocessGraph(rg, method);
}
-
+
extendGraphBuckets(rg);
}
@@ -1852,7 +1852,7 @@ static int compareVerts(const void *a, const void *b)
EditVert *va = *(EditVert **)a;
EditVert *vb = *(EditVert **)b;
int value = 0;
-
+
if (weightData(va) < weightData(vb)) {
value = -1;
}
@@ -1870,20 +1870,20 @@ static void spreadWeight(EditMesh *em)
int totvert = BLI_listbase_count(&em->verts);
int i;
int work_needed = 1;
-
+
verts = MEM_callocN(sizeof(EditVert *) * totvert, "verts array");
-
+
for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) {
verts[i] = eve;
}
-
+
while (work_needed == 1) {
work_needed = 0;
qsort(verts, totvert, sizeof(EditVert *), compareVerts);
-
+
for (i = 0; i < totvert; i++) {
eve = verts[i];
-
+
if (i == 0 || (weightData(eve) - lastWeight) > FLT_EPSILON) {
lastWeight = weightData(eve);
}
@@ -1894,7 +1894,7 @@ static void spreadWeight(EditMesh *em)
}
}
}
-
+
MEM_freeN(verts);
}
@@ -1910,7 +1910,7 @@ void REEB_exportGraph(ReebGraph *rg, int count)
ReebArc *arc;
char filename[128];
FILE *f;
-
+
if (count == -1) {
strcpy(filename, "test.txt");
}
@@ -1922,20 +1922,20 @@ void REEB_exportGraph(ReebGraph *rg, int count)
for (arc = rg->arcs.first; arc; arc = arc->next) {
int i;
float p[3];
-
+
exportNode(f, "v1", arc->head);
-
+
for (i = 0; i < arc->bcount; i++) {
fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]);
}
-
+
add_v3_v3v3(p, arc->tail->p, arc->head->p);
mul_v3_fl(p, 0.5f);
-
+
fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_len(arc->faces));
exportNode(f, "v2", arc->tail);
}
-
+
fclose(f);
}
@@ -1945,10 +1945,10 @@ void REEB_exportGraph(ReebGraph *rg, int count)
static void removeZeroNodes(ReebGraph *rg)
{
ReebNode *node, *next_node;
-
+
for (node = rg->nodes.first; node; node = next_node) {
next_node = node->next;
-
+
if (node->degree == 0) {
BLI_removeNode((BGraph *)rg, (BNode *)node);
}
@@ -1958,11 +1958,11 @@ static void removeZeroNodes(ReebGraph *rg)
void removeNormalNodes(ReebGraph *rg)
{
ReebArc *arc, *nextArc;
-
+
// Merge degree 2 nodes
for (arc = rg->arcs.first; arc; arc = nextArc) {
nextArc = arc->next;
-
+
while (arc->head->degree == 2 || arc->tail->degree == 2) {
// merge at v1
if (arc->head->degree == 2) {
@@ -1986,11 +1986,11 @@ void removeNormalNodes(ReebGraph *rg)
break;
}
}
-
+
/* merge at v2 */
if (arc->tail->degree == 2) {
ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->tail);
-
+
/* If arcs are one after the other */
if (arc->tail == connectedArc->head) {
/* remove furthest arc */
@@ -2011,7 +2011,7 @@ void removeNormalNodes(ReebGraph *rg)
}
}
}
-
+
}
static int edgeEquals(ReebEdge *e1, ReebEdge *e2)
@@ -2027,9 +2027,9 @@ static ReebArc *nextArcMappedToEdge(ReebArc *arc, ReebEdge *e)
/* Find the ReebEdge in the edge list */
for (edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next) { }
-
+
nextEdge = edge->nextEdge;
-
+
if (nextEdge != NULL) {
result = nextEdge->arc;
}
@@ -2045,7 +2045,7 @@ void addFacetoArc(ReebArc *arc, EditFace *efa)
void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc)
{
GHashIterator ghi;
-
+
for (BLI_ghashIterator_init(&ghi, aSrc->faces);
BLI_ghashIterator_done(&ghi) == false;
BLI_ghashIterator_step(&ghi))
@@ -2053,17 +2053,17 @@ void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc)
EditFace *efa = BLI_ghashIterator_getValue(&ghi);
BLI_ghash_insert(aDst->faces, efa, efa);
}
-}
+}
void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction)
{
ReebEdge *e = NULL;
-
+
if (direction == MERGE_APPEND) {
for (e = aSrc->edges.first; e; e = e->next) {
e->arc = aDst; // Edge is stolen by new arc
}
-
+
BLI_movelisttolist(&aDst->edges, &aSrc->edges);
}
else {
@@ -2071,12 +2071,12 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d
ReebEdge *newEdge = copyEdge(e);
newEdge->arc = aDst;
-
+
BLI_addtail(&aDst->edges, newEdge);
-
+
if (direction == MERGE_LOWER) {
void **p = BLI_edgehash_lookup_p(rg->emap, e->v1->index, e->v2->index);
-
+
newEdge->nextEdge = e;
// if edge was the first in the list, point the edit edge to the new reeb edge instead.
@@ -2086,11 +2086,11 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d
// otherwise, advance in the list until the predecessor is found then insert it there
else {
ReebEdge *previous = (ReebEdge *)*p;
-
+
while (previous->nextEdge != e) {
previous = previous->nextEdge;
}
-
+
previous->nextEdge = newEdge;
}
}
@@ -2100,19 +2100,19 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d
}
}
}
-}
+}
// return 1 on full merge
int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
{
int result = 0;
ReebNode *removedNode = NULL;
-
+
a0->length += a1->length;
-
+
mergeArcEdges(rg, a0, a1, MERGE_APPEND);
mergeArcFaces(rg, a0, a1);
-
+
// Bring a0 to the combine length of both arcs
if (a0->tail == a1->head) {
removedNode = a0->tail;
@@ -2122,18 +2122,18 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
removedNode = a0->head;
a0->head = a1->head;
}
-
+
resizeArcBuckets(a0);
// Merge a1 in a0
mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
-
+
// remove a1 from graph
BLI_remlink(&rg->arcs, a1);
REEB_freeArc((BArc *)a1);
-
+
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
result = 1;
-
+
return result;
}
// return 1 on full merge
@@ -2145,18 +2145,18 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
if (a0->tail->weight == a1->tail->weight) { /* tails also the same, arcs can be totally merge together */
mergeArcEdges(rg, a0, a1, MERGE_APPEND);
mergeArcFaces(rg, a0, a1);
-
+
mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
-
+
// Adjust node degree
//a1->head->degree--;
NodeDegreeDecrement(rg, a1->head);
//a1->tail->degree--;
NodeDegreeDecrement(rg, a1->tail);
-
+
// remove a1 from graph
BLI_remlink(&rg->arcs, a1);
-
+
REEB_freeArc((BArc *)a1);
result = 1;
}
@@ -2169,7 +2169,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
NodeDegreeDecrement(rg, a0->head);
//a1->tail->degree++;
NodeDegreeIncrement(rg, a1->tail);
-
+
mergeArcBuckets(a1, a0, a1->head->weight, a1->tail->weight);
a0->head = a1->tail;
resizeArcBuckets(a0);
@@ -2177,13 +2177,13 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
else { /* a0>n2 is in the middle */
mergeArcEdges(rg, a0, a1, MERGE_LOWER);
mergeArcFaces(rg, a0, a1);
-
+
// Adjust node degree
//a1->head->degree--;
NodeDegreeDecrement(rg, a1->head);
//a0->tail->degree++;
NodeDegreeIncrement(rg, a0->tail);
-
+
mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
a1->head = a0->tail;
resizeArcBuckets(a1);
@@ -2194,13 +2194,13 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
if (a0->head->weight > a1->head->weight) { /* a0->head->weight is in the middle */
mergeArcEdges(rg, a0, a1, MERGE_HIGHER);
mergeArcFaces(rg, a0, a1);
-
+
// Adjust node degree
//a1->tail->degree--;
NodeDegreeDecrement(rg, a1->tail);
//a0->head->degree++;
NodeDegreeIncrement(rg, a0->head);
-
+
mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight);
a1->tail = a0->head;
resizeArcBuckets(a1);
@@ -2223,7 +2223,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
else {
/* Need something here (OR NOT) */
}
-
+
return result;
}
@@ -2232,7 +2232,7 @@ static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e
int total = 0;
while (total == 0 && a0 != a1 && a0 != NULL && a1 != NULL) {
total = mergeArcs(rg, a0, a1);
-
+
if (total == 0) // if it wasn't a total merge, go forward {
if (a0->tail->weight < a1->tail->weight) {
a0 = nextArcMappedToEdge(a0, e0);
@@ -2250,31 +2250,31 @@ static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2)
a0 = e0->arc;
a1 = e1->arc;
a2 = e2->arc;
-
+
glueByMergeSort(rg, a0, a1, e0, e1);
glueByMergeSort(rg, a0, a2, e0, e2);
-}
+}
static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
{
ReebEdge *edge;
-
+
edge = BLI_edgehash_lookup(rg->emap, node1->index, node2->index);
-
+
// Only add existing edges that haven't been added yet
if (edge == NULL) {
ReebArc *arc;
ReebNode *v1, *v2;
float len, offset;
int i;
-
+
arc = MEM_callocN(sizeof(ReebArc), "reeb arc");
edge = MEM_callocN(sizeof(ReebEdge), "reeb edge");
-
+
arc->flag = 0; // clear flag on init
arc->symmetry_level = 0;
arc->faces = BLI_ghash_ptr_new("createArc gh");
-
+
if (node1->weight <= node2->weight) {
v1 = node1;
v2 = node2;
@@ -2283,10 +2283,10 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
v1 = node2;
v2 = node1;
}
-
+
arc->head = v1;
arc->tail = v2;
-
+
// increase node degree
//v1->degree++;
NodeDegreeIncrement(rg, v1);
@@ -2294,18 +2294,18 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
NodeDegreeIncrement(rg, v2);
BLI_edgehash_insert(rg->emap, node1->index, node2->index, edge);
-
+
edge->arc = arc;
edge->nextEdge = NULL;
edge->v1 = v1;
edge->v2 = v2;
-
+
BLI_addtail(&rg->arcs, arc);
BLI_addtail(&arc->edges, edge);
-
+
/* adding buckets for embedding */
allocArcBuckets(arc);
-
+
offset = arc->head->weight;
len = arc->tail->weight - arc->head->weight;
@@ -2322,14 +2322,14 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
for (i = 0; i < arc->bcount; i++) {
float co[3];
float f = (arc->buckets[i].val - offset) / len;
-
+
interp_v3_v3v3(co, v1->p, v2->p, f);
addVertToBucket(&(arc->buckets[i]), co);
}
#endif
}
-
+
return edge;
}
@@ -2338,21 +2338,21 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNo
ReebEdge *re1, *re2, *re3;
ReebEdge *e1, *e2, *e3;
float len1, len2, len3;
-
+
re1 = createArc(rg, n1, n2);
re2 = createArc(rg, n2, n3);
re3 = createArc(rg, n3, n1);
-
+
addFacetoArc(re1->arc, efa);
addFacetoArc(re2->arc, efa);
addFacetoArc(re3->arc, efa);
-
+
len1 = (float)fabs(n1->weight - n2->weight);
len2 = (float)fabs(n2->weight - n3->weight);
len3 = (float)fabs(n3->weight - n1->weight);
-
+
/* The rest of the algorithm assumes that e1 is the longest edge */
-
+
if (len1 >= len2 && len1 >= len3) {
e1 = re1;
e2 = re2;
@@ -2368,7 +2368,7 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNo
e2 = re2;
e3 = re1;
}
-
+
/* And e2 is the lowest edge
* If e3 is lower than e2, swap them
*/
@@ -2377,8 +2377,8 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNo
e2 = e3;
e3 = etmp;
}
-
-
+
+
mergePaths(rg, e1, e2, e3);
}
@@ -2389,23 +2389,23 @@ ReebGraph *generateReebGraph(EditMesh *em, int subdivisions)
EditFace *efa;
int index;
/*int totvert;*/
-
+
#ifdef DEBUG_REEB
int totfaces;
int countfaces = 0;
#endif
rg = newReebGraph();
-
+
rg->resolution = subdivisions;
-
+
/*totvert = BLI_listbase_count(&em->verts);*/ /*UNUSED*/
#ifdef DEBUG_REEB
totfaces = BLI_listbase_count(&em->faces);
#endif
-
+
renormalizeWeight(em, 1.0f);
-
+
/* Spread weight to minimize errors */
spreadWeight(em);
@@ -2419,18 +2419,18 @@ ReebGraph *generateReebGraph(EditMesh *em, int subdivisions)
index++;
}
}
-
+
/* Adding face, edge per edge */
for (efa = em->faces.first; efa; efa = efa->next) {
if (efa->h == 0) {
ReebNode *n1, *n2, *n3;
-
+
n1 = nodeData(efa->v1);
n2 = nodeData(efa->v2);
n3 = nodeData(efa->v3);
-
+
addTriangleToGraph(rg, n1, n2, n3, efa);
-
+
if (efa->v4) {
ReebNode *n4 = nodeData(efa->v4);
addTriangleToGraph(rg, n1, n3, n4, efa);
@@ -2443,13 +2443,13 @@ ReebGraph *generateReebGraph(EditMesh *em, int subdivisions)
#endif
}
}
-
+
printf("\n");
-
+
removeZeroNodes(rg);
-
+
removeNormalNodes(rg);
-
+
return rg;
}
@@ -2459,7 +2459,7 @@ void renormalizeWeight(EditMesh *em, float newmax)
{
EditVert *eve;
float minimum, maximum, range;
-
+
if (em == NULL || BLI_listbase_is_empty(&em->verts))
return;
@@ -2471,7 +2471,7 @@ void renormalizeWeight(EditMesh *em, float newmax)
maximum = MAX2(maximum, weightData(eve));
minimum = MIN2(minimum, weightData(eve));
}
-
+
range = maximum - minimum;
/* Normalize weights */
@@ -2485,7 +2485,7 @@ void renormalizeWeight(EditMesh *em, float newmax)
int weightFromLoc(EditMesh *em, int axis)
{
EditVert *eve;
-
+
if (em == NULL || BLI_listbase_is_empty(&em->verts) || axis < 0 || axis > 2)
return 0;
@@ -2501,17 +2501,17 @@ static void addTriangle(LinearSolver *context, EditVert *v1, EditVert *v2, EditV
{
/* Angle opposite e1 */
float t1 = cotangent_tri_weight_v3(v1->co, v2->co, v3->co) / e2;
-
+
/* Angle opposite e2 */
float t2 = cotangent_tri_weight_v3(v2->co, v3->co, v1->co) / e3;
/* Angle opposite e3 */
float t3 = cotangent_tri_weight_v3(v3->co, v1->co, v2->co) / e1;
-
+
int i1 = indexData(v1);
int i2 = indexData(v2);
int i3 = indexData(v3);
-
+
EIG_linear_solver_matrix_add(context, i1, i1, t2 + t3);
EIG_linear_solver_matrix_add(context, i2, i2, t1 + t3);
EIG_linear_solver_matrix_add(context, i3, i3, t1 + t2);
@@ -2536,14 +2536,14 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
int totvert = 0;
int index;
int rval;
-
+
/* Find local extrema */
for (eve = em->verts.first; eve; eve = eve->next) {
totvert++;
}
/* Solve */
-
+
context = EIG_linear_solver_new(, 0, totvert, 1);
/* Find local extrema */
@@ -2552,18 +2552,18 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
EditEdge *eed;
int maximum = 1;
int minimum = 1;
-
+
NextEdgeForVert(indexed_edges, -1); /* Reset next edge */
for (eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index)) {
EditVert *eve2;
-
+
if (eed->v1 == eve) {
eve2 = eed->v2;
}
else {
eve2 = eed->v1;
}
-
+
if (eve2->h == 0) {
/* Adjacent vertex is bigger, not a local maximum */
if (weightData(eve2) > weightData(eve)) {
@@ -2575,7 +2575,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
}
}
}
-
+
if (maximum || minimum) {
float w = weightData(eve);
eve->f1 = 0;
@@ -2587,19 +2587,19 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
}
}
}
-
+
/* Zero edge weight */
for (eed = em->edges.first; eed; eed = eed->next) {
eed->tmp.l = 0;
}
-
+
/* Add faces count to the edge weight */
for (efa = em->faces.first; efa; efa = efa->next) {
if (efa->h == 0) {
efa->e1->tmp.l++;
efa->e2->tmp.l++;
efa->e3->tmp.l++;
-
+
if (efa->e4) {
efa->e4->tmp.l++;
}
@@ -2618,7 +2618,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
}
}
}
-
+
success = EIG_linear_solver_solve(context);
if (success) {
@@ -2640,13 +2640,13 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index)
{
static int offset = -1;
-
+
/* Reset method, call with NULL mesh pointer */
if (index == -1) {
offset = -1;
return NULL;
}
-
+
/* first pass, start at the head of the list */
if (offset == -1) {
offset = indexed_edges->offset[index];
@@ -2655,7 +2655,7 @@ EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index)
else {
offset++;
}
-
+
return indexed_edges->edges[offset];
}
@@ -2665,11 +2665,11 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd
EditVert *current_eve = NULL;
EditEdge *eed = NULL;
EditEdge *select_eed = NULL;
-
+
edge_heap = BLI_heap_new();
-
+
current_eve = starting_vert;
-
+
/* insert guard in heap, when that is returned, no more edges */
BLI_heap_insert(edge_heap, FLT_MAX, NULL);
@@ -2677,12 +2677,12 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd
for (eed = em->edges.first; eed; eed = eed->next) {
eed->f1 = 0;
}
-
+
while (BLI_heap_len(edge_heap) > 0) {
float current_weight;
-
+
current_eve->f1 = 1; /* mark vertex as selected */
-
+
/* Add all new edges connected to current_eve to the list */
NextEdgeForVert(indexed_edges, -1); // Reset next edge
for (eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve))) {
@@ -2691,27 +2691,27 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd
eed->f1 = 1;
}
}
-
+
/* Find next shortest edge with unselected verts */
do {
current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap));
select_eed = BLI_heap_pop_min(edge_heap);
} while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1);
-
+
if (select_eed != NULL) {
select_eed->f1 = 2;
-
+
if (select_eed->v1->f1 == 0) /* v1 is the new vertex */ {
current_eve = select_eed->v1;
}
else { /* otherwise, it's v2 */
current_eve = select_eed->v2;
}
-
+
weightSetData(current_eve, current_weight);
}
}
-
+
BLI_heap_free(edge_heap, NULL);
}
@@ -2740,7 +2740,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
indexed_edges->offset[indexData(eed->v2)]++;
}
}
-
+
tot_indexed += totvert;
indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge *), "EdgeIndex edges");
@@ -2764,7 +2764,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
break;
}
}
-
+
for (i = indexed_edges->offset[indexData(eed->v2)]; i < tot_indexed; i++) {
if (indexed_edges->edges[i] == NULL) {
indexed_edges->edges[i] = eed;
@@ -2781,19 +2781,19 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
int totedge = 0;
int totvert = 0;
int vCount = 0;
-
+
totvert = BLI_listbase_count(&em->verts);
-
+
if (em == NULL || totvert == 0) {
return 0;
}
-
+
totedge = BLI_listbase_count(&em->edges);
-
+
if (totedge == 0) {
return 0;
}
-
+
/* Initialize vertice flag and find at least one selected vertex */
for (eve = em->verts.first; eve; eve = eve->next) {
eve->f1 = 0;
@@ -2801,7 +2801,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
vCount = 1;
}
}
-
+
if (vCount == 0) {
return 0; /* no selected vert, failure */
}
@@ -2822,20 +2822,20 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
shortestPathsFromVert(em, eve, indexed_edges);
}
}
-
+
/* connect unselected islands */
while (allDone == 0) {
EditVert *selected_eve = NULL;
float selected_weight = 0;
float min_distance = FLT_MAX;
-
+
allDone = 1;
-
+
for (eve = em->verts.first; eve; eve = eve->next) {
/* for every vertex visible that hasn't been processed yet */
if (eve->h == 0 && eve->f1 != 1) {
EditVert *closest_eve;
-
+
/* find the closest processed vertex */
for (closest_eve = em->verts.first; closest_eve; closest_eve = closest_eve->next) {
/* vertex is already processed and distance is smaller than current minimum */
@@ -2850,7 +2850,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
}
}
}
-
+
if (selected_eve) {
allDone = 0;
@@ -2866,7 +2866,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
break;
}
}
-
+
return 1;
}
#endif
@@ -2911,7 +2911,7 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head)
initIteratorFct(iter);
iter->arc = arc;
-
+
if (head == arc->head) {
iter->start = 0;
iter->end = arc->bcount - 1;
@@ -2922,9 +2922,9 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head)
iter->end = 0;
iter->stride = -1;
}
-
+
iter->length = arc->bcount;
-
+
iter->index = -1;
}
@@ -2934,7 +2934,7 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod
initIteratorFct(iter);
iter->arc = arc;
-
+
if (head == arc->head) {
iter->start = start;
iter->end = arc->bcount - 1;
@@ -2945,9 +2945,9 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod
iter->end = 0;
iter->stride = -1;
}
-
+
iter->index = -1;
-
+
iter->length = arc->bcount - start;
if (start >= arc->bcount) {
@@ -2961,10 +2961,10 @@ void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end)
initIteratorFct(iter);
iter->arc = arc;
-
+
iter->start = start;
iter->end = end;
-
+
if (end > start) {
iter->stride = 1;
}
@@ -2981,18 +2981,18 @@ static void *headNode(void *arg)
{
ReebArcIterator *iter = (ReebArcIterator *)arg;
ReebNode *node;
-
+
if (iter->start < iter->end) {
node = iter->arc->head;
}
else {
node = iter->arc->tail;
}
-
+
iter->p = node->p;
iter->no = node->no;
iter->size = 0;
-
+
return node;
}
@@ -3000,18 +3000,18 @@ static void *tailNode(void *arg)
{
ReebArcIterator *iter = (ReebArcIterator *)arg;
ReebNode *node;
-
+
if (iter->start < iter->end) {
node = iter->arc->tail;
}
else {
node = iter->arc->head;
}
-
+
iter->p = node->p;
iter->no = node->no;
iter->size = 0;
-
+
return node;
}
@@ -3019,13 +3019,13 @@ static void *nextBucket(void *arg)
{
ReebArcIterator *iter = (ReebArcIterator *)arg;
EmbedBucket *result = NULL;
-
+
iter->index++;
-
+
if (iter->index < iter->length) {
result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
}
-
+
setIteratorValues(iter, result);
return result;
}
@@ -3034,14 +3034,14 @@ static void *nextNBucket(void *arg, int n)
{
ReebArcIterator *iter = (ReebArcIterator *)arg;
EmbedBucket *result = NULL;
-
+
iter->index += n;
/* check if passed end */
if (iter->index < iter->length) {
result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
}
-
+
setIteratorValues(iter, result);
return result;
}
@@ -3065,7 +3065,7 @@ static void *previousBucket(void *arg)
{
ReebArcIterator *iter = (ReebArcIterator *)arg;
EmbedBucket *result = NULL;
-
+
if (iter->index > 0) {
iter->index--;
result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
@@ -3105,7 +3105,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
if (em == NULL)
return NULL;
-
+
data = allocVertexData(em);
buildIndexedEdges(em, &indexed_edges);
@@ -3116,16 +3116,16 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
freeEdgeIndex(&indexed_edges);
return NULL;
}
-
+
renormalizeWeight(em, 1.0f);
if (scene->toolsettings->skgen_options & SKGEN_HARMONIC)
{
weightToHarmonic(em, &indexed_edges);
}
-
+
freeEdgeIndex(&indexed_edges);
-
+
rg = generateReebGraph(em, scene->toolsettings->skgen_resolution);
/* Remove arcs without embedding */
@@ -3138,11 +3138,11 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
/* Filtering might have created degree 2 nodes, so remove them */
removeNormalNodes(rg);
-
+
joinSubgraphs(rg, 1.0);
BLI_buildAdjacencyList((BGraph *)rg);
-
+
/* calc length before copy, so we have same length on all levels */
BLI_calcGraphLength((BGraph *)rg);
@@ -3150,7 +3150,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
for (i = 0; i <= nb_levels; i++)
{
rgi = rg;
-
+
/* don't filter last level */
if (i > 0)
{
@@ -3165,7 +3165,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
else {
internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal * (2 * i / (float)nb_levels);
}
-
+
external_threshold = rg->length * scene->toolsettings->skgen_threshold_external * (i / (float)nb_levels);
filterGraph(rgi, scene->toolsettings->skgen_options, internal_threshold, external_threshold);
@@ -3179,23 +3179,23 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
finalizeGraph(rgi, scene->toolsettings->skgen_postpro_passes, scene->toolsettings->skgen_postpro);
BLI_markdownSymmetry((BGraph *)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit);
-
+
if (previous != NULL)
{
relinkNodes(rgi, previous);
}
previous = rgi;
}
-
+
verifyMultiResolutionLinks(rg, 0);
-
+
MEM_freeN(data);
/* no need to load the editmesh back into the object, just
* free it (avoids ngon conversion issues too going back the other way) */
free_editMesh(em);
MEM_freeN(em);
-
+
return rg;
#endif
}
@@ -3208,14 +3208,14 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void)
EdgeIndex indexed_edges;
VertexData *data;
ReebGraph *rg = NULL;
-
+
if (em == NULL)
return NULL;
data = allocVertexData(em);
buildIndexedEdges(em, &indexed_edges);
-
+
if (weightFromDistance(em, &indexed_edges) == 0)
{
error("No selected vertex\n");
@@ -3223,20 +3223,20 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void)
freeEdgeIndex(&indexed_edges);
return NULL;
}
-
+
renormalizeWeight(em, 1.0f);
if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC)
{
weightToHarmonic(em, &indexed_edges);
}
-
+
freeEdgeIndex(&indexed_edges);
-
+
#ifdef DEBUG_REEB
// weightToVCol(em, 1);
#endif
-
+
rg = generateReebGraph(em, G.scene->toolsettings->skgen_resolution);
@@ -3250,28 +3250,28 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void)
/* Filtering might have created degree 2 nodes, so remove them */
removeNormalNodes(rg);
-
+
joinSubgraphs(rg, 1.0);
BLI_buildAdjacencyList((BGraph *)rg);
-
+
/* calc length before copy, so we have same length on all levels */
BLI_calcGraphLength((BGraph *)rg);
-
+
filterGraph(rg, G.scene->toolsettings->skgen_options, G.scene->toolsettings->skgen_threshold_internal, G.scene->toolsettings->skgen_threshold_external);
finalizeGraph(rg, G.scene->toolsettings->skgen_postpro_passes, G.scene->toolsettings->skgen_postpro);
#ifdef DEBUG_REEB
REEB_exportGraph(rg, -1);
-
+
arcToVCol(rg, em, 0);
//angleToVCol(em, 1);
#endif
printf("DONE\n");
printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph *)rg));
-
+
MEM_freeN(data);
return rg;
@@ -3289,9 +3289,9 @@ void BIF_GlobalReebFree()
void BIF_GlobalReebGraphFromEditMesh(void)
{
ReebGraph *rg;
-
+
BIF_GlobalReebFree();
-
+
rg = BIF_ReebGraphMultiFromEditMesh();
GLOBAL_RG = rg;
@@ -3302,24 +3302,24 @@ void REEB_draw()
ReebGraph *rg;
ReebArc *arc;
int i = 0;
-
+
if (GLOBAL_RG == NULL)
{
return;
}
-
+
if (GLOBAL_RG->link_up && G.scene->toolsettings->skgen_options & SKGEN_DISP_ORIG)
{
for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up) ;
}
else {
i = G.scene->toolsettings->skgen_multi_level;
-
+
for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up) ;
}
-
+
glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
-
+
glDisable(GL_DEPTH_TEST);
for (arc = rg->arcs.first; arc; arc = arc->next, i++)
{
@@ -3328,12 +3328,12 @@ void REEB_draw()
float vec[3];
char text[128];
char *s = text;
-
+
glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2);
glColor3f(0, 0, 0);
glBegin(GL_LINE_STRIP);
glVertex3fv(arc->head->p);
-
+
if (arc->bcount)
{
initArcIterator(iter, arc, arc->head);
@@ -3342,7 +3342,7 @@ void REEB_draw()
glVertex3fv(iter->p);
}
}
-
+
glVertex3fv(arc->tail->p);
glEnd();
@@ -3365,7 +3365,7 @@ void REEB_draw()
}
glBegin(GL_LINE_STRIP);
glVertex3fv(arc->head->p);
-
+
if (arc->bcount)
{
initArcIterator(iter, arc, arc->head);
@@ -3374,18 +3374,18 @@ void REEB_draw()
glVertex3fv(iter->p);
}
}
-
+
glVertex3fv(arc->tail->p);
glEnd();
-
+
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED)
{
glColor3f(1, 1, 1);
glBegin(GL_POINTS);
glVertex3fv(arc->head->p);
glVertex3fv(arc->tail->p);
-
+
glColor3f(0.5f, 0.5f, 1);
if (arc->bcount)
{
@@ -3397,22 +3397,22 @@ void REEB_draw()
}
glEnd();
}
-
+
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_INDEX)
{
mid_v3_v3v3(vec, arc->head->p, arc->tail->p);
s += sprintf(s, "%i (%i-%i-%i) ", i, arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group);
-
+
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_WEIGHT)
{
s += sprintf(s, "w:%0.3f ", arc->tail->weight - arc->head->weight);
}
-
+
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_LENGTH)
{
s += sprintf(s, "l:%0.3f", arc->length);
}
-
+
glColor3f(0, 1, 0);
glRasterPos3fv(vec);
BMF_DrawString(G.fonts, text);
@@ -3423,7 +3423,7 @@ void REEB_draw()
sprintf(text, " %i", arc->head->index);
glRasterPos3fv(arc->head->p);
BMF_DrawString(G.fonts, text);
-
+
sprintf(text, " %i", arc->tail->index);
glRasterPos3fv(arc->tail->p);
BMF_DrawString(G.fonts, text);
diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h
index 7297f25c980..9eed343f18a 100644
--- a/source/blender/editors/armature/reeb.h
+++ b/source/blender/editors/armature/reeb.h
@@ -24,7 +24,7 @@
* \ingroup edarmature
*/
-
+
#ifndef __REEB_H__
#define __REEB_H__
@@ -43,15 +43,15 @@ struct ReebNode;
typedef struct ReebGraph {
ListBase arcs;
ListBase nodes;
-
+
float length;
-
+
FreeArc free_arc;
FreeNode free_node;
RadialSymmetry radial_symmetry;
AxialSymmetry axial_symmetry;
/*********************************/
-
+
int resolution;
int totnodes;
struct EdgeHash *emap;
@@ -80,7 +80,7 @@ typedef struct ReebNode {
int symmetry_flag;
float symmetry_axis[3];
/*********************************/
-
+
float no[3];
int index;
@@ -127,10 +127,10 @@ typedef struct ReebArcIterator {
NextNFct nextN;
PreviousFct previous;
StoppedFct stopped;
-
+
float *p, *no;
float size;
-
+
int length;
int index;
/*********************************/