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:
authorAlexander Gavrilov <angavrilov@gmail.com>2018-08-05 18:48:05 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2018-10-04 19:55:44 +0300
commit61a24c799b2882c22a43591138a113d7f09be0ed (patch)
treeea85047e68ff64bf7e25329a7e7048f1b9dbfeb1 /source/blender/editors
parent6932eaa2bcaff0649c82f6b31a205319c966bd15 (diff)
Move B-Bone custom handle settings to Edit mode.
Custom handle settings actually affect the B-Bone rest shape, so they should be changed in Edit mode rather than Pose mode. This is necessary to be able to display the correct rest shape of the bone in Edit Mode. Also, instead of flags, introduce an enum to specify the handle operation modes, so that new ones could be added later. Differential Revision: https://developer.blender.org/D3588
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/armature_add.c16
-rw-r--r--source/blender/editors/armature/armature_intern.h2
-rw-r--r--source/blender/editors/armature/armature_utils.c60
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c4
-rw-r--r--source/blender/editors/include/ED_armature.h5
5 files changed, 81 insertions, 6 deletions
diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c
index cf0b2457eca..a636e19faa2 100644
--- a/source/blender/editors/armature/armature_add.c
+++ b/source/blender/editors/armature/armature_add.c
@@ -561,6 +561,14 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op)
ebone->flag &= ~BONE_CONNECTED;
}
+ /* Update custom handle links. */
+ if (ebone_iter->bbone_prev && ebone_iter->bbone_prev->temp.ebone) {
+ ebone_iter->bbone_prev = ebone_iter->bbone_prev->temp.ebone;
+ }
+ if (ebone_iter->bbone_next && ebone_iter->bbone_next->temp.ebone) {
+ ebone_iter->bbone_next = ebone_iter->bbone_next->temp.ebone;
+ }
+
/* Lets try to fix any constraint subtargets that might
* have been duplicated
*/
@@ -751,6 +759,14 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op)
ebone->parent = ebone_parent;
}
+ /* Update custom handle links. */
+ if (ebone_iter->bbone_prev && ebone_iter->bbone_prev->temp.ebone) {
+ ebone_iter->bbone_prev = ebone_iter->bbone_prev->temp.ebone;
+ }
+ if (ebone_iter->bbone_next && ebone_iter->bbone_next->temp.ebone) {
+ ebone_iter->bbone_next = ebone_iter->bbone_next->temp.ebone;
+ }
+
/* Lets try to fix any constraint subtargets that might
* have been duplicated
*/
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index e28e9877eba..e5efb3315d0 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -213,7 +213,7 @@ void POSE_OT_propagate(struct wmOperatorType *ot);
* within each file, but some tools still have a bit of overlap which makes things messy -- Feb 2013
*/
-EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct EditBone *parent, struct Bone *actBone);
+EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct Bone *actBone);
/* duplicate method */
void preEditBoneDuplicate(struct ListBase *editbones);
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 2b28b76bcf6..339f0306779 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -131,6 +131,16 @@ void bone_free(bArmature *arm, EditBone *bone)
MEM_freeN(bone->prop);
}
+ /* Clear references from other edit bones. */
+ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ if (ebone->bbone_next == bone) {
+ ebone->bbone_next = NULL;
+ }
+ if (ebone->bbone_prev == bone) {
+ ebone->bbone_prev = NULL;
+ }
+ }
+
BLI_freelinkN(arm->edbo, bone);
}
@@ -426,7 +436,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit)
/* Armature EditMode Conversions */
/* converts Bones to EditBone list, used for tools as well */
-EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone)
+static EditBone *make_boneList_rec(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone)
{
EditBone *eBone;
EditBone *eBoneAct = NULL;
@@ -435,6 +445,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
for (curBone = bones->first; curBone; curBone = curBone->next) {
eBone = MEM_callocN(sizeof(EditBone), "make_editbone");
+ eBone->temp.bone = curBone;
/* Copy relevant data from bone to eBone
* Keep selection logic in sync with ED_armature_edit_sync_selection.
@@ -490,6 +501,9 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->scaleIn = curBone->scaleIn;
eBone->scaleOut = curBone->scaleOut;
+ eBone->bbone_prev_type = curBone->bbone_prev_type;
+ eBone->bbone_next_type = curBone->bbone_next_type;
+
if (curBone->prop)
eBone->prop = IDP_CopyProperty(curBone->prop);
@@ -497,7 +511,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
/* Add children if necessary */
if (curBone->childbase.first) {
- eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone);
+ eBoneTest = make_boneList_rec(edbo, &curBone->childbase, eBone, actBone);
if (eBoneTest)
eBoneAct = eBoneTest;
}
@@ -509,6 +523,36 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
return eBoneAct;
}
+static EditBone *find_ebone_link(ListBase *edbo, Bone *link)
+{
+ if (link != NULL) {
+ for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) {
+ if (ebone->temp.bone == link) {
+ return ebone;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+EditBone *make_boneList(ListBase *edbo, ListBase *bones, struct Bone *actBone)
+{
+ BLI_assert(!edbo->first && !edbo->last);
+
+ EditBone *active = make_boneList_rec(edbo, bones, NULL, actBone);
+
+ for (EditBone *ebone = edbo->first; ebone; ebone = ebone->next) {
+ Bone *bone = ebone->temp.bone;
+
+ /* Convert custom B-Bone handle links. */
+ ebone->bbone_prev = find_ebone_link(edbo, bone->bbone_prev);
+ ebone->bbone_next = find_ebone_link(edbo, bone->bbone_next);
+ }
+
+ return active;
+}
+
/* This function:
* - sets local head/tail rest locations using parent bone's arm_mat.
* - calls BKE_armature_where_is_bone() which uses parent's transform (arm_mat) to define this bone's transform.
@@ -655,6 +699,8 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
newBone->scaleIn = eBone->scaleIn;
newBone->scaleOut = eBone->scaleOut;
+ newBone->bbone_prev_type = eBone->bbone_prev_type;
+ newBone->bbone_next_type = eBone->bbone_next_type;
if (eBone->prop)
newBone->prop = IDP_CopyProperty(eBone->prop);
@@ -673,6 +719,14 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm)
else {
BLI_addtail(&arm->bonebase, newBone);
}
+
+ /* Also transfer B-Bone custom handles. */
+ if (eBone->bbone_prev) {
+ newBone->bbone_prev = eBone->bbone_prev->temp.bone;
+ }
+ if (eBone->bbone_next) {
+ newBone->bbone_next = eBone->bbone_next->temp.bone;
+ }
}
/* Finalize definition of restpose data (roll, bone_mat, arm_mat, head/tail...). */
@@ -715,7 +769,7 @@ void ED_armature_to_edit(bArmature *arm)
{
ED_armature_edit_free(arm);
arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
- arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
+ arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, arm->act_bone);
}
/* *************************************************************** */
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index 89e510e6f3e..0c770bcbcc4 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -1348,7 +1348,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
}
else {
rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
- make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
+ make_boneList(rg->editbones, &arm->bonebase, NULL);
rg->flag |= RIG_FREE_BONELIST;
}
@@ -1396,7 +1396,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
}
else {
rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
- make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
+ make_boneList(rg->editbones, &arm->bonebase, NULL);
rg->flag |= RIG_FREE_BONELIST;
}
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 3044543795c..9347d2037b0 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -90,6 +90,11 @@ typedef struct EditBone {
short segments;
+ char bbone_prev_type; /* Type of next/prev bone handles */
+ char bbone_next_type;
+ struct EditBone *bbone_prev; /* Next/prev bones to use as handle references when calculating bbones (optional) */
+ struct EditBone *bbone_next;
+
/* Used for display */
float disp_mat[4][4]; /* in Armature space, rest pos matrix */
float disp_tail_mat[4][4]; /* in Armature space, rest pos matrix */