- fix for eternal loop with metaballs in set scenes.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 13 Jul 2010 16:06:51 +0000 (16:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 13 Jul 2010 16:06:51 +0000 (16:06 +0000)
- next_object() now loops through all set scenes, not just the first one.
- removed F_SET, rather them having a mode for looping on a set, just use the set when the first scene ends.
- metaballs can now glob between scenes however there are still some depsgraph issues that existed before.

source/blender/blenkernel/BKE_scene.h
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/scene.c
source/blender/makesdna/DNA_scene_types.h

index b5b0a72..f0fb2a6 100644 (file)
@@ -63,7 +63,7 @@ struct Scene *set_scene_name(char *name);
 struct Scene *copy_scene(struct Main *bmain, struct Scene *sce, int type);
 void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce);
 
-int next_object(struct Scene *scene, int val, struct Base **base, struct Object **ob);
+int next_object(struct Scene **scene, int val, struct Base **base, struct Object **ob);
 struct Object *scene_find_camera(struct Scene *sc);
 struct Object *scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH
 int scene_camera_switch_update(struct Scene *scene);
index c41dcfa..e35d8bc 100644 (file)
@@ -296,6 +296,7 @@ int is_mball_basis_for(Object *ob1, Object *ob2)
  * because this metaball influence polygonisation of metaballs. */
 void copy_mball_properties(Scene *scene, Object *active_object)
 {
+       Scene *sce_iter= scene;
        Base *base;
        Object *ob;
        MetaBall *active_mball = (MetaBall*)active_object->data;
@@ -305,10 +306,10 @@ void copy_mball_properties(Scene *scene, Object *active_object)
        splitIDname(active_object->id.name+2, basisname, &basisnr);
 
        /* XXX recursion check, see scene.c, just too simple code this next_object() */
-       if(F_ERROR==next_object(scene, 0, 0, 0))
+       if(F_ERROR==next_object(&sce_iter, 0, 0, 0))
                return;
        
-       while(next_object(scene, 1, &base, &ob)) {
+       while(next_object(&sce_iter, 1, &base, &ob)) {
                if (ob->type==OB_MBALL) {
                        if(ob!=active_object){
                                splitIDname(ob->id.name+2, obname, &obnr);
@@ -338,6 +339,7 @@ void copy_mball_properties(Scene *scene, Object *active_object)
  */
 Object *find_basis_mball(Scene *scene, Object *basis)
 {
+       Scene *sce_iter= scene;
        Base *base;
        Object *ob,*bob= basis;
        MetaElem *ml=NULL;
@@ -348,10 +350,10 @@ Object *find_basis_mball(Scene *scene, Object *basis)
        totelem= 0;
 
        /* XXX recursion check, see scene.c, just too simple code this next_object() */
-       if(F_ERROR==next_object(scene, 0, 0, 0))
+       if(F_ERROR==next_object(&sce_iter, 0, 0, 0))
                return NULL;
        
-       while(next_object(scene, 1, &base, &ob)) {
+       while(next_object(&sce_iter, 1, &base, &ob)) {
                
                if (ob->type==OB_MBALL) {
                        if(ob==bob){
@@ -1507,6 +1509,7 @@ void polygonize(PROCESS *mbproc, MetaBall *mb)
 
 float init_meta(Scene *scene, Object *ob)      /* return totsize */
 {
+       Scene *sce_iter= scene;
        Base *base;
        Object *bob;
        MetaBall *mb;
@@ -1523,9 +1526,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */
        splitIDname(ob->id.name+2, obname, &obnr);
        
        /* make main array */
-       
-       next_object(scene, 0, 0, 0);
-       while(next_object(scene, 1, &base, &bob)) {
+       next_object(&sce_iter, 0, 0, 0);
+       while(next_object(&sce_iter, 1, &base, &bob)) {
 
                if(bob->type==OB_MBALL) {
                        zero_size= 0;
index 2896ac6..fe52375 100644 (file)
@@ -593,7 +593,7 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce)
 /* used by metaballs
  * doesnt return the original duplicated object, only dupli's
  */
-int next_object(Scene *scene, int val, Base **base, Object **ob)
+int next_object(Scene **scene, int val, Base **base, Object **ob)
 {
        static ListBase *duplilist= NULL;
        static DupliObject *dupob;
@@ -622,17 +622,21 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
 
                        /* the first base */
                        if(fase==F_START) {
-                               *base= scene->base.first;
+                               *base= (*scene)->base.first;
                                if(*base) {
                                        *ob= (*base)->object;
                                        fase= F_SCENE;
                                }
                                else {
                                        /* exception: empty scene */
-                                       if(scene->set && scene->set->base.first) {
-                                               *base= scene->set->base.first;
-                                               *ob= (*base)->object;
-                                               fase= F_SET;
+                                       while((*scene)->set) {
+                                               (*scene)= (*scene)->set;
+                                               if((*scene)->base.first) {
+                                                       *base= (*scene)->base.first;
+                                                       *ob= (*base)->object;
+                                                       fase= F_SCENE;
+                                                       break;
+                                               }
                                        }
                                }
                        }
@@ -642,11 +646,14 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
                                        if(*base) *ob= (*base)->object;
                                        else {
                                                if(fase==F_SCENE) {
-                                                       /* scene is finished, now do the set */
-                                                       if(scene->set && scene->set->base.first) {
-                                                               *base= scene->set->base.first;
-                                                               *ob= (*base)->object;
-                                                               fase= F_SET;
+                                                       /* (*scene) is finished, now do the set */
+                                                       while((*scene)->set) {
+                                                               (*scene)= (*scene)->set;
+                                                               if((*scene)->base.first) {
+                                                                       *base= (*scene)->base.first;
+                                                                       *ob= (*base)->object;
+                                                                       break;
+                                                               }
                                                        }
                                                }
                                        }
@@ -661,7 +668,7 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
                                                this enters eternal loop because of 
                                                makeDispListMBall getting called inside of group_duplilist */
                                                if((*base)->object->dup_group == NULL) {
-                                                       duplilist= object_duplilist(scene, (*base)->object);
+                                                       duplilist= object_duplilist((*scene), (*base)->object);
                                                        
                                                        dupob= duplilist->first;
 
@@ -697,6 +704,10 @@ int next_object(Scene *scene, int val, Base **base, Object **ob)
                }
        }
        
+       /* if(ob && *ob) {
+               printf("Scene: '%s', '%s'\n", (*scene)->id.name+2, (*ob)->id.name+2);
+       } */
+
        /* reset recursion test */
        in_next_object= 0;
        
index 1933798..a4e9dea 100644 (file)
@@ -1093,7 +1093,6 @@ typedef struct Scene {
 #define F_ERROR                        -1
 #define F_START                        0
 #define F_SCENE                        1
-#define F_SET                  2
 #define F_DUPLI                        3
 
 /* audio->flag */