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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-12-29 17:23:12 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2014-12-29 17:26:38 +0300
commitfb7ff31315a1c9feefe993264178cb34ce443208 (patch)
treea2dd5f3ea023b2a6deb4c6b1978e94bf74f8920d /source
parentc5927cd97758baf3df30459d43dc7c6c488fc616 (diff)
Fix stupid handling of 'Object.matrix_local' in RNA.
The getter of this matrix (actually, `BKE_object_matrix_local_get()`) was only correct in case of pure-object parenting, bone parenting and such did not gave valid results. Also cleaned up a bit setter code, was using as temp storage ob->obmat itself, which is supposed to be a world matrix! Reviewers: campbellbarton Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D958
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/object.c10
-rw-r--r--source/blender/collada/TransformWriter.cpp2
-rw-r--r--source/blender/makesrna/intern/rna_object.c14
3 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 1676f22683a..f6b328eb8e8 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2019,12 +2019,16 @@ void BKE_object_to_mat4(Object *ob, float mat[4][4])
add_v3_v3v3(mat[3], ob->loc, ob->dloc);
}
+static void ob_get_parent_matrix(Scene *scene, Object *ob, Object *par, float parentmat[4][4]);
+
void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4])
{
if (ob->parent) {
- float invmat[4][4]; /* for inverse of parent's matrix */
- invert_m4_m4(invmat, ob->parent->obmat);
- mul_m4_m4m4(mat, invmat, ob->obmat);
+ float par_imat[4][4];
+
+ ob_get_parent_matrix(NULL, ob, ob->parent, par_imat);
+ invert_m4(par_imat);
+ mul_m4_m4m4(mat, par_imat, ob->obmat);
}
else {
copy_m4_m4(mat, ob->obmat);
diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp
index 595787b44ac..e205608a365 100644
--- a/source/blender/collada/TransformWriter.cpp
+++ b/source/blender/collada/TransformWriter.cpp
@@ -102,7 +102,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B
double d_obmat[4][4];
float f_obmat[4][4];
- /* Export the local Matrix (relative to the object parent) */
+ /* Export the local Matrix (relative to the object parent, be it an object, bone or vertex(-tices)) */
BKE_object_matrix_local_get(ob, f_obmat);
converter.mat4_to_dae_double(d_obmat, f_obmat);
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 9741c75d68f..6c421c82195 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -233,21 +233,21 @@ static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])
{
Object *ob = ptr->id.data;
+ float local_mat[4][4];
- /* localspace matrix is truly relative to the parent, but parameters
- * stored in object are relative to parentinv matrix. Undo the parent
- * inverse part before updating obmat and calling apply_obmat() */
+ /* localspace matrix is truly relative to the parent, but parameters stored in object are
+ * relative to parentinv matrix. Undo the parent inverse part before applying it as local matrix. */
if (ob->parent) {
float invmat[4][4];
invert_m4_m4(invmat, ob->parentinv);
- mul_m4_m4m4(ob->obmat, invmat, (float(*)[4])values);
+ mul_m4_m4m4(local_mat, invmat, (float(*)[4])values);
}
else {
- copy_m4_m4(ob->obmat, (float(*)[4])values);
+ copy_m4_m4(local_mat, (float(*)[4])values);
}
- /* don't use compat so we get predictable rotation */
- BKE_object_apply_mat4(ob, ob->obmat, false, false);
+ /* don't use compat so we get predictable rotation, and do not use parenting either, because it's a local matrix! */
+ BKE_object_apply_mat4(ob, local_mat, false, false);
}
static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16])