From 958ab951c6cfe626a42aa9bc821de183dde8042c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 8 Apr 2006 18:13:47 +0000 Subject: [PATCH] Hrms... the fix for bug #4010 didn't work as expected. The issue was that particle emittors were still transformed by the object matrix itself. That was solved in the previous commit, but there was still an error in correctly evaluating dependencies for the object... Current commit uses depsgraph to recalculate all objects that influence the emittor. The depsgraph code doesn't like particles much (because it uses baking). Current construct is still weak, is on the list to solve nice. --- source/blender/blenkernel/intern/effect.c | 71 ++++++++++++++++------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index e0c7509afc2..46777921859 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -69,6 +69,7 @@ #include "BKE_blender.h" #include "BKE_constraint.h" #include "BKE_deform.h" +#include "BKE_depsgraph.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_effect.h" @@ -1525,7 +1526,8 @@ typedef struct pMatrixCache { static pMatrixCache *cache_object_matrices(Object *ob, int start, int end) { pMatrixCache *mcache, *mc; - Object *par, ob_store; + Object ob_store; + Base *base; float framelenold, cfrao; mcache= mc= MEM_mallocN( (end-start+1)*sizeof(pMatrixCache), "ob matrix cache"); @@ -1536,20 +1538,35 @@ static pMatrixCache *cache_object_matrices(Object *ob, int start, int end) ob_store= *ob; /* quick copy of all settings */ ob->sf= 0.0f; + /* all objects get tagged recalc that influence this object */ + DAG_object_update_flags(G.scene, ob, G.scene->lay); + for(G.scene->r.cfra= start; G.scene->r.cfra<=end; G.scene->r.cfra++, mc++) { - - par= ob; - while(par) { - par->ctime= -1234567.0; /* hrms? */ - do_ob_key(par); - if(par->type==OB_ARMATURE) { - do_all_pose_actions(par); // only does this object actions - where_is_pose(par); + for(base= G.scene->base.first; base; base= base->next) { + if(base->object->recalc) { + where_is_object(base->object); + + do_ob_key(base->object); + if(base->object->type==OB_ARMATURE) { + do_all_pose_actions(base->object); // only does this object actions + where_is_pose(base->object); + } } - par= par->parent; } - - where_is_object(ob); + +// par= ob; +// while(par) { +// par->ctime= -1234567.0; /* hrms? */ +// do_ob_key(par); +// if(par->type==OB_ARMATURE) { +// do_all_pose_actions(par); // only does this object actions +// where_is_pose(par); +// } +// par= par->parent; +// } + +// where_is_object(ob); + Mat4CpyMat4(mc->obmat, ob->obmat); Mat4Invert(ob->imat, ob->obmat); Mat3CpyMat4(mc->imat, ob->imat); @@ -1561,19 +1578,31 @@ static pMatrixCache *cache_object_matrices(Object *ob, int start, int end) G.scene->r.cfra= cfrao; G.scene->r.framelen= framelenold; *ob= ob_store; + + for(base= G.scene->base.first; base; base= base->next) { + where_is_object(base->object); + if(base->object->recalc) { + do_ob_key(base->object); + if(base->object->type==OB_ARMATURE) { + do_all_pose_actions(base->object); // only does this object actions + where_is_pose(base->object); + } + } + } + /* restore hierarchy, weak code destroying potential depgraph stuff... */ - par= ob; - while(par) { +// par= ob; +// while(par) { /* do not do ob->ipo: keep insertkey */ - do_ob_key(par); +// do_ob_key(par); - if(par->type==OB_ARMATURE) { - do_all_pose_actions(par); // only does this object actions - where_is_pose(par); - } - par= par->parent; - } +// if(par->type==OB_ARMATURE) { +// do_all_pose_actions(par); // only does this object actions +// where_is_pose(par); +// } +// par= par->parent; +// } return mcache; }