Bugfix: particle settings didn't automatically link in associated
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 18 Jan 2008 14:30:26 +0000 (14:30 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 18 Jan 2008 14:30:26 +0000 (14:30 +0000)
objects or groups.

source/blender/blenkernel/intern/object.c
source/blender/blenloader/intern/readfile.c
source/blender/render/intern/source/convertblender.c

index bfe2b56b289ad121ed72dfcfb59c05e0c45cc9b0..3ac4a572b960657484bf2e5eca2865dcbfe02c41 100644 (file)
@@ -2223,6 +2223,9 @@ void object_handle_update(Object *ob)
                                         * since object_duplilist does dupliparticles before that */
                                        dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
                                        dm->release(dm);
+
+                                       for(psys=ob->particlesystem.first; psys; psys=psys->next)
+                                               psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
                                }
                        }
                }
index 61f6f6bfb53db45b1c57abc06d577dca03764da8..88bbcca3a9419c87f6bf84f25ac7e6c443240184 100644 (file)
@@ -7529,6 +7529,14 @@ static void expand_doit(FileData *fd, Main *mainvar, void *old)
        }
 }
 
+static void expand_particlesettings(FileData *fd, Main *mainvar, ParticleSettings *part)
+{
+       expand_doit(fd, mainvar, part->dup_ob);
+       expand_doit(fd, mainvar, part->dup_group);
+       expand_doit(fd, mainvar, part->eff_group);
+       expand_doit(fd, mainvar, part->bb_ob);
+}
+
 static void expand_ipo(FileData *fd, Main *mainvar, Ipo *ipo)
 {
        IpoCurve *icu;
@@ -8121,6 +8129,8 @@ static void expand_main(FileData *fd, Main *mainvar)
                                        case ID_IP:
                                                expand_ipo(fd, mainvar, (Ipo *)id);
                                                break;
+                                       case ID_PA:
+                                               expand_particlesettings(fd, mainvar, (ParticleSettings *)id);
                                        }
 
                                        doit= 1;
index 8117a85d0158cf36d5c4768d78d510ee71479f5e..7675747d18fd3384559d58dd8100d1a216076df0 100644 (file)
@@ -4147,16 +4147,31 @@ static void dupli_render_particle_set(Render *re, Object *ob, int level, int ena
        Group *group;
        GroupObject *go;
        ParticleSystem *psys;
+       DerivedMesh *dm;
 
        if(level >= MAX_DUPLI_RECUR)
                return;
        
        if(ob->transflag & OB_DUPLIPARTS) {
-               for(psys=ob->particlesystem.first; psys; psys=psys->next)
-                       if(enable)
-                               psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy);
-                       else
-                               psys_render_restore(ob, psys);
+               for(psys=ob->particlesystem.first; psys; psys=psys->next) {
+                       if(ELEM(psys->part->draw_as, PART_DRAW_OB, PART_DRAW_GR)) {
+                               if(enable)
+                                       psys_render_set(ob, psys, re->viewmat, re->winmat, re->winx, re->winy);
+                               else
+                                       psys_render_restore(ob, psys);
+                       }
+               }
+
+               if(level == 0 && enable) {
+                       /* this is to make sure we get render level duplis in groups:
+                       * the derivedmesh must be created before init_render_mesh,
+                       * since object_duplilist does dupliparticles before that */
+                       dm = mesh_create_derived_render(ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL);
+                       dm->release(dm);
+
+                       for(psys=ob->particlesystem.first; psys; psys=psys->next)
+                               psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated;
+               }
        }
 
        if(ob->dup_group==NULL) return;
@@ -4186,7 +4201,7 @@ static void database_init_objects(Render *re, unsigned int lay, int nolamps, int
 
        for(SETLOOPER(re->scene, base)) {
                ob= base->object;
-               
+
                /* if the object has been restricted from rendering in the outliner, ignore it */
                if(ob->restrictflag & OB_RESTRICT_RENDER) continue;
 
@@ -4216,7 +4231,7 @@ static void database_init_objects(Render *re, unsigned int lay, int nolamps, int
 
                                        if(obd->restrictflag & OB_RESTRICT_RENDER)
                                                continue;
-                                       
+
                                        if(obd->type==OB_MBALL)
                                                continue;