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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-02-05 16:19:14 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-02-05 16:19:14 +0300
commit90cf78eb5409a77c912b90fb812a4391e31897ae (patch)
tree23594e3f54008f749cfeacc394134425316d860c /source/blender/blenloader
parentfe99f35210bfe932e8f1e8161dc9fe68cd09bf5d (diff)
Fix bones moving when changing between editmode and posemode.
Patch #25901 by Tobias Oelgarte. Bone transformations would be converted back and forth between different representations when changing modes, which due to numerical errors could lead to bone transformations slowly changing as you edit the armature. Now the editmode head, tail and roll values are stored in bones and used directly when entering edit mode. Head and tail were already there but now we ensure they are the exact same value, roll was not yet there, so we have a version patch for it. The sub version was incremented to 1 for the version patch.
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 069d85f9bda..085ec92e209 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5746,6 +5746,23 @@ static int map_223_keybd_code_to_224_keybd_code(int code)
}
}
+static void do_version_bone_head_tail_237(Bone *bone)
+{
+ Bone *child;
+ float vec[3];
+
+ /* head */
+ copy_v3_v3(bone->arm_head, bone->arm_mat[3]);
+
+ /* tail is in current local coord system */
+ copy_v3_v3(vec, bone->arm_mat[1]);
+ mul_v3_fl(vec, bone->length);
+ add_v3_v3v3(bone->arm_tail, bone->arm_head, vec);
+
+ for(child= bone->childbase.first; child; child= child->next)
+ do_version_bone_head_tail_237(child);
+}
+
static void bone_version_238(ListBase *lb)
{
Bone *bone;
@@ -6655,6 +6672,19 @@ static void do_versions_seq_unique_name_all_strips(
}
}
+
+static void do_version_bone_roll_256(Bone *bone)
+{
+ Bone *child;
+ float submat[3][3];
+
+ copy_m3_m4(submat, bone->arm_mat);
+ mat3_to_vec_roll(submat, 0, &bone->arm_roll);
+
+ for(child = bone->childbase.first; child; child = child->next)
+ do_version_bone_roll_256(child);
+}
+
static void do_versions(FileData *fd, Library *lib, Main *main)
{
/* WATCH IT!!!: pointers from libdata have not been converted */
@@ -7964,10 +7994,14 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
bArmature *arm;
bConstraint *con;
Object *ob;
+ Bone *bone;
// armature recode checks
for(arm= main->armature.first; arm; arm= arm->id.next) {
where_is_armature(arm);
+
+ for(bone= arm->bonebase.first; bone; bone= bone->next)
+ do_version_bone_head_tail_237(bone);
}
for(ob= main->object.first; ob; ob= ob->id.next) {
if(ob->parent) {
@@ -11285,6 +11319,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
+ if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) {
+ /* fix for bones that didn't have arm_roll before */
+ bArmature* arm;
+ Bone* bone;
+
+ for (arm = main->armature.first; arm; arm = arm->id.next)
+ for (bone = arm->bonebase.first; bone; bone = bone->next)
+ do_version_bone_roll_256(bone);
+ }
+
/* put compatibility code here until next subversion bump */
{