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:
authorJoshua Leung <aligorith@gmail.com>2012-06-07 09:39:28 +0400
committerJoshua Leung <aligorith@gmail.com>2012-06-07 09:39:28 +0400
commitffd75901f32e2270406e43855c7b2dee065f948e (patch)
tree29b7fc0b18f475e111a750f61b5021f9462b982e
parente69ec8be5554a774612b8eeb15a2f00a327cc795 (diff)
Code cleanup - Shuffled solve_parenting() function around to remove need for
forward def/local prototype
-rw-r--r--source/blender/blenkernel/intern/object.c169
1 files changed, 82 insertions, 87 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 16b699f16f9..a01024acfd3 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -115,8 +115,6 @@
#include "GPU_material.h"
/* Local function protos */
-static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul);
-
float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */
void BKE_object_workob_clear(Object *workob)
@@ -1904,6 +1902,84 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
}
}
+static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
+{
+ float totmat[4][4];
+ float tmat[4][4];
+ float locmat[4][4];
+ float vec[3];
+ int ok;
+
+ BKE_object_to_mat4(ob, locmat);
+
+ if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
+
+ switch (ob->partype & PARTYPE) {
+ case PAROBJECT:
+ ok = 0;
+ if (par->type == OB_CURVE) {
+ if (((Curve *)par->data)->flag & CU_PATH) {
+ ob_parcurve(scene, ob, par, tmat);
+ ok = 1;
+ }
+ }
+
+ if (ok) mul_serie_m4(totmat, par->obmat, tmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ else copy_m4_m4(totmat, par->obmat);
+
+ break;
+ case PARBONE:
+ ob_parbone(ob, par, tmat);
+ mul_serie_m4(totmat, par->obmat, tmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ break;
+
+ case PARVERT1:
+ unit_m4(totmat);
+ if (simul) {
+ copy_v3_v3(totmat[3], par->obmat[3]);
+ }
+ else {
+ give_parvert(par, ob->par1, vec);
+ mul_v3_m4v3(totmat[3], par->obmat, vec);
+ }
+ break;
+ case PARVERT3:
+ ob_parvert3(ob, par, tmat);
+
+ mul_serie_m4(totmat, par->obmat, tmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ break;
+
+ case PARSKEL:
+ copy_m4_m4(totmat, par->obmat);
+ break;
+ }
+
+ // total
+ mul_serie_m4(tmat, totmat, ob->parentinv,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ mul_serie_m4(obmat, tmat, locmat,
+ NULL, NULL, NULL, NULL, NULL, NULL);
+
+ if (simul) {
+
+ }
+ else {
+ // external usable originmat
+ copy_m3_m4(originmat, tmat);
+
+ // origin, voor help line
+ if ((ob->partype & PARTYPE) == PARSKEL) {
+ copy_v3_v3(ob->orig, par->obmat[3]);
+ }
+ else {
+ copy_v3_v3(ob->orig, totmat[3]);
+ }
+ }
+}
+
static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4])
{
float *fp1, *fp2;
@@ -1926,8 +2002,6 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[
void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
{
- float slowmat[4][4] = MAT4_UNITY;
-
if (ob == NULL) return;
/* execute drivers only, as animation has already been done */
@@ -1935,6 +2009,7 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
if (ob->parent) {
Object *par = ob->parent;
+ float slowmat[4][4] = MAT4_UNITY;
/* calculate parent matrix */
solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
@@ -1950,7 +2025,7 @@ void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
else {
BKE_object_to_mat4(ob, ob->obmat);
}
-
+
/* solve constraints */
if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
bConstraintOb *cob;
@@ -1975,9 +2050,9 @@ 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);
-
+
if (ob->partype & PARSLOW)
where_is_object_parslow(ob, obmat, slowmat);
}
@@ -1986,91 +2061,11 @@ void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
}
}
-static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
-{
- float totmat[4][4];
- float tmat[4][4];
- float locmat[4][4];
- float vec[3];
- int ok;
-
- BKE_object_to_mat4(ob, locmat);
-
- if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat);
-
- switch (ob->partype & PARTYPE) {
- case PAROBJECT:
- ok = 0;
- if (par->type == OB_CURVE) {
- if (((Curve *)par->data)->flag & CU_PATH) {
- ob_parcurve(scene, ob, par, tmat);
- ok = 1;
- }
- }
-
- if (ok) mul_serie_m4(totmat, par->obmat, tmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
- else copy_m4_m4(totmat, par->obmat);
-
- break;
- case PARBONE:
- ob_parbone(ob, par, tmat);
- mul_serie_m4(totmat, par->obmat, tmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
- break;
-
- case PARVERT1:
- unit_m4(totmat);
- if (simul) {
- copy_v3_v3(totmat[3], par->obmat[3]);
- }
- else {
- give_parvert(par, ob->par1, vec);
- mul_v3_m4v3(totmat[3], par->obmat, vec);
- }
- break;
- case PARVERT3:
- ob_parvert3(ob, par, tmat);
-
- mul_serie_m4(totmat, par->obmat, tmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
- break;
-
- case PARSKEL:
- copy_m4_m4(totmat, par->obmat);
- break;
- }
-
- // total
- mul_serie_m4(tmat, totmat, ob->parentinv,
- NULL, NULL, NULL, NULL, NULL, NULL);
- mul_serie_m4(obmat, tmat, locmat,
- NULL, NULL, NULL, NULL, NULL, NULL);
-
- if (simul) {
-
- }
- else {
- // external usable originmat
- copy_m3_m4(originmat, tmat);
-
- // origin, voor help line
- if ((ob->partype & PARTYPE) == PARSKEL) {
- copy_v3_v3(ob->orig, par->obmat[3]);
- }
- else {
- copy_v3_v3(ob->orig, totmat[3]);
- }
- }
-
-}
-
void BKE_object_where_is_calc(struct Scene *scene, Object *ob)
{
BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra);
}
-
void BKE_object_where_is_calc_simul(Scene *scene, Object *ob)
/* was written for the old game engine (until 2.04) */
/* It seems that this function is only called