Moved code for calculating local_matrix to BKE funtion for reuse

This commit is contained in:
Gaia Clary
2013-07-12 12:58:01 +00:00
parent 1d205f4446
commit 24c77647d2
3 changed files with 15 additions and 10 deletions

View File

@@ -95,6 +95,7 @@ void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat)
void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
void BKE_object_apply_mat4(struct Object *ob, float mat[4][4], const bool use_compat, const bool use_parent);
void BKE_object_matrix_local_get(struct Object *ob, float mat[4][4]);
bool BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);

View File

@@ -1736,6 +1736,18 @@ void BKE_object_to_mat4(Object *ob, float mat[4][4])
add_v3_v3v3(mat[3], ob->loc, ob->dloc);
}
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);
}
else {
copy_m4_m4(mat, ob->obmat);
}
}
/* extern */
int enable_cu_speed = 1;

View File

@@ -44,7 +44,7 @@
#include "BKE_paint.h"
#include "BKE_editmesh.h"
#include "BKE_group.h" /* needed for BKE_group_object_exists() */
#include "BKE_object.h" /* Needed for BKE_object_matrix_local_get() */
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@@ -216,15 +216,7 @@ static void rna_Object_hide_update(Main *bmain, Scene *UNUSED(scene), PointerRNA
static void rna_Object_matrix_local_get(PointerRNA *ptr, float values[16])
{
Object *ob = ptr->id.data;
if (ob->parent) {
float invmat[4][4]; /* for inverse of parent's matrix */
invert_m4_m4(invmat, ob->parent->obmat);
mul_m4_m4m4((float(*)[4])values, invmat, ob->obmat);
}
else {
copy_m4_m4((float(*)[4])values, ob->obmat);
}
BKE_object_matrix_local_get(ob, (float(*)[4])values);
}
static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16])