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_object.h4
-rw-r--r--source/blender/blenkernel/intern/object.c33
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c8
3 files changed, 24 insertions, 21 deletions
diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h
index 463720fb8cf..abc216033ff 100644
--- a/source/blender/blenkernel/BKE_object.h
+++ b/source/blender/blenkernel/BKE_object.h
@@ -100,10 +100,10 @@ bool BKE_object_pose_context_check(struct Object *ob);
struct Object *BKE_object_pose_armature_get(struct Object *ob);
void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob);
-void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob);
+void BKE_object_where_is_calc_ex(struct Scene *scene, struct RigidBodyWorld *rbw, struct Object *ob, float r_originmat[3][3]);
void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime);
void BKE_object_where_is_calc_time_ex(struct Scene *scene, struct Object *ob, float ctime,
- struct RigidBodyWorld *rbw);
+ struct RigidBodyWorld *rbw, float r_originmat[3][3]);
void BKE_object_where_is_calc_simul(struct Scene *scene, struct Object *ob);
void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f1183868e8b..957bd84cd90 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));
@@ -1991,7 +1988,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 +2057,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 +2094,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 +2106,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 +2141,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 +2155,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 +2165,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 +2189,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 +2661,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) {
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 1678487d8bf..e9aca8d4640 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -74,8 +74,6 @@
#include "view3d_intern.h"
-extern float originmat[3][3]; /* XXX object.c */
-
/* ************************************************** */
/* ********************* old transform stuff ******** */
/* *********** will get replaced with new transform * */
@@ -628,7 +626,8 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
vec[2] = -ob->obmat[3][2] + gridf * floorf(0.5f + ob->obmat[3][2] / gridf);
if (ob->parent) {
- BKE_object_where_is_calc(scene, ob);
+ float originmat[3][3];
+ BKE_object_where_is_calc_ex(scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);
@@ -751,7 +750,8 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op))
vec[2] = -ob->obmat[3][2] + curs[2];
if (ob->parent) {
- BKE_object_where_is_calc(scene, ob);
+ float originmat[3][3];
+ BKE_object_where_is_calc_ex(scene, NULL, ob, originmat);
invert_m3_m3(imat, originmat);
mul_m3_v3(imat, vec);