[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47555] trunk/blender/source/blender/ blenkernel/intern/object.c: Code cleanup - Shuffled solve_parenting() function around to remove need for
Joshua Leung
aligorith at gmail.com
Thu Jun 7 07:39:39 CEST 2012
Revision: 47555
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47555
Author: aligorith
Date: 2012-06-07 05:39:28 +0000 (Thu, 07 Jun 2012)
Log Message:
-----------
Code cleanup - Shuffled solve_parenting() function around to remove need for
forward def/local prototype
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/object.c
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2012-06-07 05:29:10 UTC (rev 47554)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2012-06-07 05:39:28 UTC (rev 47555)
@@ -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 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 @@
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 @@
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 @@
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 @@
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 @@
}
}
-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
More information about the Bf-blender-cvs
mailing list