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:
-rw-r--r--source/blender/blenkernel/BKE_armature.h3
-rw-r--r--source/blender/blenkernel/intern/armature.c29
-rw-r--r--source/blender/editors/object/object_transform.c4
3 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 73e62f6a7b3..99c6bb405b5 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -75,6 +75,9 @@ void BKE_armature_copy_data(struct Main *bmain,
const int flag);
struct bArmature *BKE_armature_copy(struct Main *bmain, const struct bArmature *arm);
+void BKE_armature_copy_bone_transforms(struct bArmature *armature_dst,
+ const struct bArmature *armature_src);
+
/* Bounding box. */
struct BoundBox *BKE_armature_boundbox_get(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index c36acd1eae1..3621926e93b 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -239,6 +239,35 @@ bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
return arm_copy;
}
+static void copy_bone_transform(Bone *bone_dst, const Bone *bone_src)
+{
+ bone_dst->roll = bone_src->roll;
+
+ copy_v3_v3(bone_dst->head, bone_src->head);
+ copy_v3_v3(bone_dst->tail, bone_src->tail);
+
+ copy_m3_m3(bone_dst->bone_mat, bone_src->bone_mat);
+
+ copy_v3_v3(bone_dst->arm_head, bone_src->arm_head);
+ copy_v3_v3(bone_dst->arm_tail, bone_src->arm_tail);
+
+ copy_m4_m4(bone_dst->arm_mat, bone_src->arm_mat);
+
+ bone_dst->arm_roll = bone_src->arm_roll;
+}
+
+void BKE_armature_copy_bone_transforms(bArmature *armature_dst, const bArmature *armature_src)
+{
+ Bone *bone_dst = armature_dst->bonebase.first;
+ const Bone *bone_src = armature_src->bonebase.first;
+ while (bone_dst != NULL) {
+ BLI_assert(bone_src != NULL);
+ copy_bone_transform(bone_dst, bone_src);
+ bone_dst = bone_dst->next;
+ bone_src = bone_src->next;
+ }
+}
+
static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
{
Bone *curBone, *rbone;
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 9c98fdc2a2e..3f7d5dba149 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -856,6 +856,7 @@ static int apply_objects_internal(bContext *C,
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
if (ob->type == OB_ARMATURE) {
/* needed for bone parents */
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_pose_where_is(depsgraph, scene, ob_eval);
}
@@ -1229,6 +1230,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_transform_copy(ob_eval, ob);
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
BKE_pose_where_is(depsgraph, scene, ob_eval); /* needed for bone parents */
@@ -1370,6 +1372,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
if (ob->type == OB_ARMATURE) {
/* needed for bone parents */
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_pose_where_is(depsgraph, scene, ob_eval);
}
@@ -1398,6 +1401,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
BKE_object_where_is_calc(depsgraph, scene, ob_other_eval);
if (ob_other->type == OB_ARMATURE) {
/* needed for bone parents */
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_pose_where_is(depsgraph, scene, ob_other_eval);
}
ignore_parent_tx(bmain, depsgraph, scene, ob_other);