diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-07-17 05:40:26 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-07-17 05:40:26 +0400 |
commit | eb21bdd249427465a093a078cda7864309a8f735 (patch) | |
tree | 1da7dc7f6fd3670bf28b2bf00dfe7ec356344105 /source/blender/blenkernel/intern/object.c | |
parent | 5ba2f4367d6cebc415c4e20572a8cea4e52fb0c3 (diff) | |
parent | 20d6cd008b8a7b110fff3ca211651693916d9946 (diff) |
Merging changes from trunk r58091-58323.
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f1183868e8b..e79a759407b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -121,9 +121,6 @@ #include "GPU_material.h" -/* Local function protos */ -float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */ - void BKE_object_workob_clear(Object *workob) { memset(workob, 0, sizeof(Object)); @@ -1739,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; @@ -1991,7 +2000,11 @@ static void ob_parvert3(Object *ob, Object *par, float mat[4][4]) } } -static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4], int simul) +/** + * \param r_originmat Optional matrix that stores the space the object is in (without its own matrix applied) + */ +static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4][4], float slowmat[4][4], + float r_originmat[3][3], const bool simul) { float totmat[4][4]; float tmat[4][4]; @@ -2056,8 +2069,10 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[4 } else { - /* external usable originmat */ - copy_m3_m4(originmat, tmat); + if (r_originmat) { + /* usable originmat */ + copy_m3_m4(r_originmat, tmat); + } /* origin, for help line */ if ((ob->partype & PARTYPE) == PARSKEL) { @@ -2091,7 +2106,7 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ /* note, scene is the active scene while actual_scene is the scene the object resides in */ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, - RigidBodyWorld *rbw) + RigidBodyWorld *rbw, float r_originmat[3][3]) { if (ob == NULL) return; @@ -2103,7 +2118,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, float slowmat[4][4] = MAT4_UNITY; /* calculate parent matrix */ - solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); + solve_parenting(scene, ob, par, ob->obmat, slowmat, r_originmat, false); /* "slow parent" is definitely not threadsafe, and may also give bad results jumping around * An old-fashioned hack which probably doesn't really cut it anymore @@ -2138,7 +2153,7 @@ void BKE_object_where_is_calc_time_ex(Scene *scene, Object *ob, float ctime, void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) { - BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL); + BKE_object_where_is_calc_time_ex(scene, ob, ctime, NULL, NULL); } /* get object transformation matrix without recalculating dependencies and @@ -2152,7 +2167,7 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) if (ob->parent) { Object *par = ob->parent; - solve_parenting(scene, ob, par, obmat, slowmat, 1); + solve_parenting(scene, ob, par, obmat, slowmat, NULL, true); if (ob->partype & PARSLOW) where_is_object_parslow(ob, obmat, slowmat); @@ -2162,13 +2177,13 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) } } -void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob) +void BKE_object_where_is_calc_ex(Scene *scene, RigidBodyWorld *rbw, Object *ob, float r_originmat[3][3]) { - BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw); + BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), rbw, r_originmat); } void BKE_object_where_is_calc(Scene *scene, Object *ob) { - BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL); + BKE_object_where_is_calc_time_ex(scene, ob, BKE_scene_frame_get(scene), NULL, NULL); } /* was written for the old game engine (until 2.04) */ @@ -2186,7 +2201,7 @@ void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) if (ob->parent) { par = ob->parent; - solve_parenting(scene, ob, par, ob->obmat, slowmat, 1); + solve_parenting(scene, ob, par, ob->obmat, slowmat, NULL, true); if (ob->partype & PARSLOW) { fac1 = (float)(1.0 / (1.0 + fabs(ob->sf))); @@ -2658,7 +2673,7 @@ void BKE_object_handle_update_ex(Scene *scene, Object *ob, copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } else - BKE_object_where_is_calc_ex(scene, rbw, ob); + BKE_object_where_is_calc_ex(scene, rbw, ob, NULL); } if (ob->recalc & OB_RECALC_DATA) { |