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:
Diffstat (limited to 'source/blender/blenkernel/intern/object.c')
-rw-r--r--source/blender/blenkernel/intern/object.c192
1 files changed, 83 insertions, 109 deletions
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 3304ccc73cf..b656cb6d8de 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -117,8 +117,6 @@
#include "FRS_freestyle.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)
@@ -1914,109 +1912,6 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4])
}
}
-static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[4][4])
-{
- float *fp1, *fp2;
- float fac1, fac2;
- int a;
-
- // include framerate
- fac1 = (1.0f / (1.0f + fabsf(ob->sf)) );
- if (fac1 >= 1.0f) return 0;
- fac2 = 1.0f - fac1;
-
- fp1 = obmat[0];
- fp2 = slowmat[0];
- for (a = 0; a < 16; a++, fp1++, fp2++) {
- fp1[0] = fac1 * fp1[0] + fac2 * fp2[0];
- }
-
- return 1;
-}
-
-void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
-{
- float slowmat[4][4] = MAT4_UNITY;
- float stime = ctime;
-
- /* new version: correct parent+vertexparent and track+parent */
- /* this one only calculates direct attached parent and track */
- /* is faster, but should keep track of timeoffs */
-
- if (ob == NULL) return;
-
- /* execute drivers only, as animation has already been done */
- BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
-
- if (ob->parent) {
- Object *par = ob->parent;
-
- /* hurms, code below conflicts with depgraph... (ton) */
- /* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */
- if (stime != par->ctime) {
- // only for ipo systems?
- Object tmp = *par;
-
- if (par->proxy_from) ; // was a copied matrix, no where_is! bad...
- else BKE_object_where_is_calc_time(scene, par, ctime);
-
- solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
-
- *par = tmp;
- }
- else
- solve_parenting(scene, ob, par, ob->obmat, slowmat, 0);
-
- /* "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
- */
- if (ob->partype & PARSLOW) {
- if (!where_is_object_parslow(ob, ob->obmat, slowmat))
- return;
- }
- }
- else {
- BKE_object_to_mat4(ob, ob->obmat);
- }
-
- /* solve constraints */
- if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
- bConstraintOb *cob;
-
- cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
-
- /* constraints need ctime, not stime. Some call BKE_object_where_is_calc_time and bsystem_time */
- solve_constraints(&ob->constraints, cob, ctime);
-
- constraints_clear_evalob(cob);
- }
-
- /* set negative scale flag in object */
- if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
- else ob->transflag &= ~OB_NEG_SCALE;
-}
-
-/* get object transformation matrix without recalculating dependencies and
- * constraints -- assume dependencies are already solved by depsgraph.
- * no changes to object and it's parent would be done.
- * used for bundles orientation in 3d space relative to parented blender camera */
-void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
-{
- float slowmat[4][4] = MAT4_UNITY;
-
- 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);
- }
- else {
- BKE_object_to_mat4(ob, obmat);
- }
-}
-
static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul)
{
float totmat[4][4];
@@ -2038,11 +1933,11 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[]
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);
@@ -2062,7 +1957,7 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[]
break;
case PARVERT3:
ob_parvert3(ob, par, tmat);
-
+
mul_serie_m4(totmat, par->obmat, tmat,
NULL, NULL, NULL, NULL, NULL, NULL);
break;
@@ -2093,7 +1988,87 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[]
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;
+ float fac1, fac2;
+ int a;
+
+ // include framerate
+ fac1 = (1.0f / (1.0f + fabsf(ob->sf)) );
+ if (fac1 >= 1.0f) return 0;
+ fac2 = 1.0f - fac1;
+
+ fp1 = obmat[0];
+ fp2 = slowmat[0];
+ for (a = 0; a < 16; a++, fp1++, fp2++) {
+ fp1[0] = fac1 * fp1[0] + fac2 * fp2[0];
+ }
+
+ return 1;
+}
+
+void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime)
+{
+ if (ob == NULL) return;
+
+ /* execute drivers only, as animation has already been done */
+ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS);
+
+ 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);
+
+ /* "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
+ */
+ if (ob->partype & PARSLOW) {
+ if (!where_is_object_parslow(ob, ob->obmat, slowmat))
+ return;
+ }
+ }
+ else {
+ BKE_object_to_mat4(ob, ob->obmat);
+ }
+
+ /* solve constraints */
+ if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) {
+ bConstraintOb *cob;
+
+ cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT);
+ solve_constraints(&ob->constraints, cob, ctime);
+ constraints_clear_evalob(cob);
+ }
+
+ /* set negative scale flag in object */
+ if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE;
+ else ob->transflag &= ~OB_NEG_SCALE;
+}
+/* get object transformation matrix without recalculating dependencies and
+ * constraints -- assume dependencies are already solved by depsgraph.
+ * no changes to object and it's parent would be done.
+ * used for bundles orientation in 3d space relative to parented blender camera */
+void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4])
+{
+ float slowmat[4][4] = MAT4_UNITY;
+
+ 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);
+ }
+ else {
+ BKE_object_to_mat4(ob, obmat);
+ }
}
void BKE_object_where_is_calc(struct Scene *scene, Object *ob)
@@ -2101,7 +2076,6 @@ 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