Bug #4348
authorTon Roosendaal <ton@blender.org>
Sat, 17 Jun 2006 15:14:43 +0000 (15:14 +0000)
committerTon Roosendaal <ton@blender.org>
Sat, 17 Jun 2006 15:14:43 +0000 (15:14 +0000)
Animated groups, being linked and dupli-grouped in other file, didn't
correctly calculate particles inside the group.

source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/effect.c

index dbe0ce140407e7c6a944be594033b0ff2b9460b4..2a177207a878dfe35f10ac51f60b723b4e516f9d 100644 (file)
@@ -65,6 +65,7 @@
 #include "BKE_action.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
+#include "BKE_group.h"
 #include "BKE_key.h"
 #include "BKE_main.h"
 #include "BKE_mball.h"
@@ -1209,7 +1210,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest      *dag, void *ob)
        
        time = 1;
        
-       node = dag_find_node(dag,ob);   // could be done in loop above (ton)
+       node = dag_find_node(dag, ob);   // could be done in loop above (ton)
        if(node) { // can be null for newly added objects
                
                node->color = DAG_GRAY;
@@ -1253,7 +1254,7 @@ short     are_obs_related(struct DagForest        *dag, void *ob1, void *ob2) {
        DagNode * node;
        DagAdjList *itA;
        
-       node = dag_find_node(dag,ob1);
+       node = dag_find_node(dag, ob1);
        
        itA = node->child;
        while(itA != NULL) {
@@ -1881,24 +1882,38 @@ void DAG_object_update_flags(Scene *sce, Object *ob, unsigned int lay)
        for(node = sce->theDag->DagNode.first; node; node= node->next) 
                node->color = DAG_WHITE;
        
-       node = dag_get_node(sce->theDag, ob);
-       node->color = DAG_GRAY;
+       node= dag_find_node(sce->theDag, ob);
        
-       sce->theDag->time++;
-       node= sce->theDag->DagNode.first;
-       for(itA = node->child; itA; itA= itA->next) {
-               if(itA->node->type==ID_OB && itA->node->lasttime!=sce->theDag->time)
-                       itA->node->color= parent_check_node(itA->node, sce->theDag->time);
+       /* object not in scene? then handle group exception. needs to be dagged once too */
+       if(node==NULL) {
+               Group *group= find_group(ob);
+               if(group) {
+                       GroupObject *go;
+                       /* primitive; tag all... this call helps building groups for particles */
+                       for(go= group->gobject.first; go; go= go->next)
+                               go->ob->recalc= OB_RECALC;
+               }
        }
-       
-       /* set recalcs and flushes */
-       DAG_scene_update_flags(sce, lay);
-       
-       /* now we clear recalcs, unless color is set */
-       for(node = sce->theDag->DagNode.first; node; node= node->next) {
-               if(node->type==ID_OB && node->color==DAG_WHITE) {
-                       Object *ob= node->ob;
-                       ob->recalc= 0;
+       else {
+               
+               node->color = DAG_GRAY;
+               
+               sce->theDag->time++;
+               node= sce->theDag->DagNode.first;
+               for(itA = node->child; itA; itA= itA->next) {
+                       if(itA->node->type==ID_OB && itA->node->lasttime!=sce->theDag->time)
+                               itA->node->color= parent_check_node(itA->node, sce->theDag->time);
+               }
+               
+               /* set recalcs and flushes */
+               DAG_scene_update_flags(sce, lay);
+               
+               /* now we clear recalcs, unless color is set */
+               for(node = sce->theDag->DagNode.first; node; node= node->next) {
+                       if(node->type==ID_OB && node->color==DAG_WHITE) {
+                               Object *ob= node->ob;
+                               ob->recalc= 0;
+                       }
                }
        }
 }
index 853e7ba6eac2cd9ee312e0bda7826e66e3f7f0fd..0dc7a5d5c2a1590787360dbfc1d20fac7fe76a35 100644 (file)
@@ -74,6 +74,7 @@
 #include "BKE_DerivedMesh.h"
 #include "BKE_effect.h"
 #include "BKE_global.h"
+#include "BKE_group.h"
 #include "BKE_ipo.h"
 #include "BKE_key.h"
 #include "BKE_lattice.h"
@@ -81,6 +82,7 @@
 #include "BKE_material.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
+#include "BKE_scene.h"
 #include "BKE_screen.h"
 #include "BKE_utildefines.h"
 
@@ -1528,10 +1530,15 @@ typedef struct pMatrixCache {
 static pMatrixCache *cache_object_matrices(Object *ob, int start, int end)
 {
        pMatrixCache *mcache, *mc;
+       Group *group= NULL;
        Object *obcopy;
        Base *base;
        float framelenold, cfrao;
        
+       /* object can be linked in group... stupid exception */
+       if(NULL==object_in_scene(ob, G.scene))
+               group= find_group(ob);
+       
        mcache= mc= MEM_mallocN( (end-start+1)*sizeof(pMatrixCache), "ob matrix cache");
        
        framelenold= G.scene->r.framelen;
@@ -1543,25 +1550,42 @@ static pMatrixCache *cache_object_matrices(Object *ob, int start, int end)
        for(obcopy= G.main->object.first; obcopy; obcopy= obcopy->id.next) 
                obcopy->id.newid= NULL;
        
-       /* all objects get tagged recalc that influence this object */
+       /* all objects get tagged recalc that influence this object (does group too) */
        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++) {
-               for(base= G.scene->base.first; base; base= base->next) {
-                       if(base->object->recalc) {
-                               if(base->object->id.newid==NULL)
-                                       base->object->id.newid= MEM_dupallocN(base->object);
-                               
-                               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);
+               
+               if(group) {
+                       GroupObject *go;
+
+                       for(go= group->gobject.first; go; go= go->next) {
+                               if(go->ob->recalc) {
+                                       where_is_object(go->ob);
+                                       
+                                       do_ob_key(go->ob);
+                                       if(go->ob->type==OB_ARMATURE) {
+                                               do_all_pose_actions(go->ob);    // only does this object actions
+                                               where_is_pose(go->ob);
+                                       }
                                }
                        }
                }
-               
+               else {
+                       for(base= G.scene->base.first; base; base= base->next) {
+                               if(base->object->recalc) {
+                                       if(base->object->id.newid==NULL)
+                                               base->object->id.newid= MEM_dupallocN(base->object);
+                                       
+                                       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);
+                                       }
+                               }
+                       }
+               }               
                Mat4CpyMat4(mc->obmat, ob->obmat);
                Mat4Invert(ob->imat, ob->obmat);
                Mat3CpyMat4(mc->imat, ob->imat);
@@ -1572,24 +1596,40 @@ static pMatrixCache *cache_object_matrices(Object *ob, int start, int end)
        G.scene->r.cfra= cfrao;
        G.scene->r.framelen= framelenold;
 
-       for(base= G.scene->base.first; base; base= base->next) {
-               if(base->object->recalc) {
-                       
-                       if(base->object->id.newid) {
-                               obcopy= (Object *)base->object->id.newid;
-                               *(base->object) = *(obcopy); 
-                               MEM_freeN(obcopy);
-                               base->object->id.newid= NULL;
-                       }
-                       
-                       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);
+       if(group) {
+               GroupObject *go;
+               
+               for(go= group->gobject.first; go; go= go->next) {
+                       if(go->ob->recalc) {
+                               where_is_object(go->ob);
+                               
+                               do_ob_key(go->ob);
+                               if(go->ob->type==OB_ARMATURE) {
+                                       do_all_pose_actions(go->ob);    // only does this object actions
+                                       where_is_pose(go->ob);
+                               }
                        }
                }
        }
-       
+       else {
+               for(base= G.scene->base.first; base; base= base->next) {
+                       if(base->object->recalc) {
+                               
+                               if(base->object->id.newid) {
+                                       obcopy= (Object *)base->object->id.newid;
+                                       *(base->object) = *(obcopy); 
+                                       MEM_freeN(obcopy);
+                                       base->object->id.newid= NULL;
+                               }
+                               
+                               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);
+                               }
+                       }
+               }
+       }       
        return mcache;
 }