Particles
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 18 Dec 2007 16:55:09 +0000 (16:55 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 18 Dec 2007 16:55:09 +0000 (16:55 +0000)
=========

- The render and realtime button for the particle system modifier
  and the enabled button for particles now work seperate again,
  made a bad design decision to tie them together. Now with only
  the render button and not realtime enabled it renders.
- Fix for bug #7948: particle mode crash while constraining axis.
- Fix for bug #7945: crash loading effector groups from an old file.
- Fix for bug #7942: crash for reactor particles emitting from particles.

16 files changed:
source/blender/blenkernel/BKE_particle.h
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_particle_types.h
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/strand.c
source/blender/src/buttons_editing.c
source/blender/src/buttons_object.c
source/blender/src/drawobject.c
source/blender/src/editobject.c
source/blender/src/editparticle.c
source/blender/src/transform_conversions.c

index c45989a6b5bcd2e7e8b146c176a426a23921a015..1c69fe613c77676155cbc2306d64b94ae7065c6e 100644 (file)
@@ -169,6 +169,8 @@ typedef struct ParticleThreadContext {
 
        int from, cfrom, distr;
 
+       struct ParticleData *tpars;
+
        /* path caching */
        int editupdate, between, steps;
        int totchild, totparent;
@@ -203,15 +205,18 @@ void psys_disable_all(struct Object *ob);
 void psys_enable_all(struct Object *ob);
 int psys_ob_has_hair(struct Object *ob);
 int psys_in_edit_mode(struct ParticleSystem *psys);
+int psys_check_enabled(struct Object *ob, struct ParticleSystem *psys);
 
 void psys_free_settings(struct ParticleSettings *part);
 void free_child_path_cache(struct ParticleSystem *psys);
 void psys_free_path_cache(struct ParticleSystem *psys);
-void psys_free_render_memory(struct Object *ob, struct ParticleSystem *psys);
 void free_hair(struct ParticleSystem *psys);
 void free_keyed_keys(struct ParticleSystem *psys);
 void psys_free(struct Object * ob, struct ParticleSystem * psys);
 
+void psys_particles_to_render_backup(struct Object *ob, struct ParticleSystem *psys);
+void psys_render_backup_to_particles(struct Object *ob, struct ParticleSystem *psys);
+
 void clear_particles_from_cache(struct Object *ob, struct ParticleSystem *psys, int cfra);
 //void psys_remove_from_particle_list(struct Object *ob, short nbr, struct ParticleSystem *psys);
 
@@ -280,6 +285,7 @@ void psys_particle_on_dm(struct Object *ob, struct DerivedMesh *dm, int from, in
 void initialize_particle(struct ParticleData *pa, int p, struct Object *ob, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd);
 void reset_particle(struct ParticleData *pa, struct ParticleSystem *psys, struct ParticleSystemModifierData *psmd, struct Object *ob, float dtime, float cfra, float *vg_vel, float *vg_tan, float *vg_rot);
 
+void psys_calc_dmfaces(struct Object *ob, struct DerivedMesh *dm, struct ParticleSystem *psys);
 int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int index, float *fw, struct LinkNode *node);
 
 /* ParticleEffectorCache->type */
index 1076641b4c5b51f35697002b16b12a2ce9688c55..a963b877912e0de2d48477c3ab923a5ae3086898 100644 (file)
@@ -1900,7 +1900,7 @@ static void dag_object_time_update_flags(Object *ob)
                        ParticleSystem *psys= ob->particlesystem.first;
 
                        for(; psys; psys=psys->next) {
-                               if(psys->flag & PSYS_ENABLED) {
+                               if(psys_check_enabled(ob, psys)) {
                                        ob->recalc |= OB_RECALC_DATA;
                                        break;
                                }
index ad0092e17110460b4671dba06bc84acaae54dca5..fc8b14b8d4c5a77d324bb2f2f6493e545d41fbe6 100644 (file)
@@ -5097,7 +5097,7 @@ static void particleSystemModifier_deformVerts(
        else
                return;
        
-       if((psys->flag&PSYS_ENABLED)==0)
+       if(!psys_check_enabled(ob, psys))
                return;
 
        if(dm==0){
index 15c4943f6fb11a00e76cc5fec78f6096e62ebf10..d48be54fe10cc38c55ca09c16b013508eeeb12fd 100644 (file)
@@ -2201,7 +2201,7 @@ void object_handle_update(Object *ob)
                                
                                psys= ob->particlesystem.first;
                                while(psys) {
-                                       if(psys->flag & PSYS_ENABLED) {
+                                       if(psys_check_enabled(ob, psys)) {
                                                particle_system_update(ob, psys);
                                                psys= psys->next;
                                        }
index 08f269852e38cac0b81746d1193d2f0835d46332..85ac809bf700a77b2448a04971e6dfd3b1de8230 100644 (file)
@@ -77,6 +77,7 @@
 #include "BKE_bad_level_calls.h"
 #include "BKE_modifier.h"
 #include "BKE_mesh.h"
+#include "BKE_cdderivedmesh.h"
 
 #include "blendef.h"
 #include "RE_render_ext.h"
@@ -248,6 +249,23 @@ int psys_in_edit_mode(ParticleSystem *psys)
 {
        return ((G.f & G_PARTICLEEDIT) && psys==psys_get_current(OBACT) && psys->edit);
 }
+int psys_check_enabled(Object *ob, ParticleSystem *psys)
+{
+       ParticleSystemModifierData *psmd;
+
+       if(!(psys->flag & PSYS_ENABLED))
+               return 0;
+
+       psmd= psys_get_modifier(ob, psys);
+       if(G.rendering) {
+               if(!psys->renderdata || !(psmd->modifier.mode & eModifierMode_Render))
+                       return 0;
+       }
+       else if(!(psmd->modifier.mode & eModifierMode_Realtime))
+               return 0;
+       
+       return 1;
+}
 
 /************************************************/
 /*                     Freeing stuff                                           */
@@ -301,27 +319,6 @@ void psys_free_path_cache(ParticleSystem *psys)
        }
        free_child_path_cache(psys);
 }
-void psys_free_render_memory(Object *ob, ParticleSystem *psys)
-{
-       ParticleSystemModifierData *psmd;
-
-       /* this is a bad function, but saves a lot of memory rendering.
-        * particles should really be generated on the fly with render
-        * settings! */
-       psys_free_path_cache(psys);
-
-       if(psys->child){
-               MEM_freeN(psys->child);
-               psys->child=0;
-               psys->totchild=0;
-       }
-       
-       psmd= psys_get_modifier(ob, psys);
-       psmd->flag &= ~eParticleSystemFlag_psys_updated;
-
-       psys->recalc |= PSYS_ALLOC|PSYS_DISTR;
-       //DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
-}
 /* free everything */
 void psys_free(Object *ob, ParticleSystem * psys)
 {
@@ -366,6 +363,92 @@ void psys_free(Object *ob, ParticleSystem * psys)
        }
 }
 
+/* these two functions move away particle data and bring it back after
+ * rendering, to make different render settings possible without
+ * removing the previous data. this should be solved properly once */
+
+typedef struct ParticleRenderDataup {
+       ChildParticle *child;
+       ParticleCacheKey **pathcache;
+       ParticleCacheKey **childcache;
+       int totchild, totcached, totchildcache;
+       DerivedMesh *dm;
+       int totdmvert, totdmedge, totdmface;
+} ParticleRenderDataup;
+
+void psys_particles_to_render_backup(Object *ob, ParticleSystem *psys)
+{
+       ParticleRenderDataup *data;
+       ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
+
+       if(!G.rendering)
+               return;
+
+       data= MEM_callocN(sizeof(ParticleRenderDataup), "ParticleRenderDataup");
+
+       data->child= psys->child;
+       data->totchild= psys->totchild;
+       data->pathcache= psys->pathcache;
+       data->totcached= psys->totcached;
+       data->childcache= psys->childcache;
+       data->totchildcache= psys->totchildcache;
+
+       if(psmd->dm)
+               data->dm= CDDM_copy(psmd->dm);
+       data->totdmvert= psmd->totdmvert;
+       data->totdmedge= psmd->totdmedge;
+       data->totdmface= psmd->totdmface;
+
+       psys->child= NULL;
+       psys->pathcache= NULL;
+       psys->childcache= NULL;
+       psys->totchild= psys->totcached= psys->totchildcache= 0;
+
+       psys->renderdata= data;
+}
+
+void psys_render_backup_to_particles(Object *ob, ParticleSystem *psys)
+{
+       ParticleRenderDataup *data;
+       ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
+
+       data= psys->renderdata;
+       if(!data)
+               return;
+
+       if(psmd->dm) {
+               psmd->dm->needsFree= 1;
+               psmd->dm->release(psmd->dm);
+       }
+
+       psys_free_path_cache(psys);
+
+       if(psys->child){
+               MEM_freeN(psys->child);
+               psys->child= 0;
+               psys->totchild= 0;
+       }
+       
+       psys->child= data->child;
+       psys->totchild= data->totchild;
+       psys->pathcache= data->pathcache;
+       psys->totcached= data->totcached;
+       psys->childcache= data->childcache;
+       psys->totchildcache= data->totchildcache;
+
+       psmd->dm= data->dm;
+       psmd->totdmvert= data->totdmvert;
+       psmd->totdmedge= data->totdmedge;
+       psmd->totdmface= data->totdmface;
+       psmd->flag &= ~eParticleSystemFlag_psys_updated;
+
+       if(psys->part->from==PART_FROM_FACE && psmd->dm)
+               psys_calc_dmfaces(ob, psmd->dm, psys);
+
+       MEM_freeN(data);
+       psys->renderdata= NULL;
+}
+
 /************************************************/
 /*                     Interpolated Particles                          */
 /************************************************/
@@ -1407,7 +1490,7 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate)
 
        /*---start figuring out what is actually wanted---*/
        if(psys_in_edit_mode(psys))
-               if(G.rendering==0 && (psys->edit==NULL || pset->flag & PE_SHOW_CHILD)==0)
+               if(psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_SHOW_CHILD)==0)
                        totchild=0;
 
        if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){
@@ -1416,7 +1499,7 @@ int psys_threads_init_path(ParticleThread *threads, float cfra, int editupdate)
                between=1;
        }
 
-       if(G.rendering)
+       if(psys->renderdata)
                steps=(int)pow(2.0,(double)part->ren_step);
        else{
                totchild=(int)((float)totchild*(float)part->disp/100.0f);
@@ -1871,7 +1954,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
        if((psys->flag & PSYS_HAIR_DONE)==0 && (psys->flag & PSYS_KEYED)==0)
                return;
 
-       if(G.rendering)
+       if(psys->renderdata)
                steps = (int)pow(2.0, (double)psys->part->ren_step);
        else if(psys_in_edit_mode(psys)){
                edit=psys->edit;
index b7fa75916925253782630f5c1a98fcbbd94ff14e..af1db36b648a20b75ce60c46e8bc8e84b3e41a67 100644 (file)
@@ -92,7 +92,7 @@ static int get_current_display_percentage(ParticleSystem *psys)
 {
        ParticleSettings *part=psys->part;
 
-       if(G.rendering || (part->child_nbr && part->childtype)) 
+       if(psys->renderdata || (part->child_nbr && part->childtype)) 
                return 100;
 
        if(part->phystype==PART_PHYS_KEYED){
@@ -136,7 +136,7 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
        }
        psys->particles=newpars;
 
-       child_nbr= (G.rendering)? psys->part->ren_child_nbr: psys->part->child_nbr;
+       child_nbr= (psys->renderdata)? psys->part->ren_child_nbr: psys->part->child_nbr;
        if(child_nbr && psys->part->childtype){
                if(psys->child)
                        MEM_freeN(psys->child);
@@ -155,7 +155,7 @@ static void alloc_particles(ParticleSystem *psys, int new_totpart)
 }
 
 /* only run this if from == PART_FROM_FACE */
-static void psys_calc_dmfaces(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
+void psys_calc_dmfaces(Object *ob, DerivedMesh *dm, ParticleSystem *psys)
 {
        /* use for building derived mesh face-origin info,
        node - the allocated links - total derived mesh face count 
@@ -472,7 +472,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
        ParticleThreadContext *ctx= thread->ctx;
        Object *ob= ctx->ob;
        DerivedMesh *dm= ctx->dm;
-       ParticleData *tpars=0, *tpa;
+       ParticleData *tpa;
        ParticleSettings *part= ctx->psys->part;
        float *v1, *v2, *v3, *v4, nor[3], orco1[3], co1[3], co2[3], nor1[3], ornor1[3];
        float cur_d, min_d;
@@ -587,7 +587,7 @@ void psys_thread_distribute_particle(ParticleThread *thread, ParticleData *pa, C
                //pa->verts[1]=0;
                //pa->verts[2]=0;
 
-               tpa=tpars+ctx->index[p];
+               tpa=ctx->tpars+ctx->index[p];
                pa->num=ctx->index[p];
                pa->fuv[0]=tpa->fuv[0];
                pa->fuv[1]=tpa->fuv[1];
@@ -780,7 +780,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
        Object *ob= ctx->ob;
        ParticleSystem *psys= ctx->psys;
        Object *tob;
-       ParticleData *pa=0, *tpars;
+       ParticleData *pa=0, *tpars= 0;
        ParticleSettings *part;
        ParticleSystem *tpsys;
        ParticleSeam *seams= 0;
@@ -877,7 +877,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
                }
                else{
                        /* no need to figure out distribution */
-                       int child_nbr= (G.rendering)? part->ren_child_nbr: part->child_nbr;
+                       int child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
 
                        for(i=0; i<child_nbr; i++){
                                for(p=0; p<psys->totpart; p++,cpa++){
@@ -1173,6 +1173,7 @@ int psys_threads_init_distribution(ParticleThread *threads, DerivedMesh *finaldm
        ctx->cfrom= cfrom;
        ctx->distr= distr;
        ctx->dm= dm;
+       ctx->tpars= tpars;
 
        seed= 31415926 + ctx->psys->seed;
 
@@ -1450,9 +1451,6 @@ static void initialize_all_particles(Object *ob, ParticleSystem *psys, ParticleS
                initialize_particle(pa,p,ob,psys,psmd);
        
        /* store the derived mesh face index for each particle */
-       //if(psys->part->from==PART_FROM_FACE)
-       //      psys_calc_dmfaces(ob, psmd->dm, psys);
-       
        icu=find_ipocurve(psys->part->ipo,PART_EMIT_FREQ);
        if(icu){
                float time=psys->part->sta, end=psys->part->end;
@@ -1731,9 +1729,6 @@ static void reset_all_particles(Object *ob, ParticleSystem *psys, ParticleSystem
        float *vg_tan=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_TAN);
        float *vg_rot=psys_cache_vgroup(psmd->dm,psys,PSYS_VG_ROT);
        
-       //if (psys->part->from == PART_FROM_FACE)
-       //      psys_calc_dmfaces(ob, psmd->dm, psys);
-       
        for(p=from, pa=psys->particles+from; p<totpart; p++, pa++)
                reset_particle(pa, psys, psmd, ob, dtime, cfra, vg_vel, vg_tan, vg_rot);
 
@@ -4183,7 +4178,7 @@ static void psys_update_path_cache(Object *ob, ParticleSystemModifierData *psmd,
        ParticleSettings *part=psys->part;
        ParticleEditSettings *pset=&G.scene->toolsettings->particle;
        int distr=0,alloc=0;
-       int child_nbr= (G.rendering)? part->ren_child_nbr: part->child_nbr;
+       int child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
 
        if((psys->part->childtype && psys->totchild != psys->totpart*child_nbr) || psys->recalc&PSYS_ALLOC)
                alloc=1;
@@ -4221,11 +4216,10 @@ static void hair_step(Object *ob, ParticleSystemModifierData *psmd, ParticleSyst
 {
        ParticleSettings *part = psys->part;
 
-       if(psys->recalc & PSYS_DISTR) {
+       if(psys->recalc & PSYS_DISTR)
                /* need this for changing subsurf levels */
                psys_calc_dmfaces(ob, psmd->dm, psys);
-       }
-       
+
        if(psys->effectors.first)
                psys_end_effectors(psys);
 
@@ -4406,7 +4400,7 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
        else
                totpart = psys->part->totpart;
 
-       child_nbr= (G.rendering)? part->ren_child_nbr: part->child_nbr;
+       child_nbr= (psys->renderdata)? part->ren_child_nbr: part->child_nbr;
        if(oldtotpart != totpart || psys->recalc&PSYS_ALLOC || (psys->part->childtype && psys->totchild != psys->totpart*child_nbr))
                alloc = 1;
 
@@ -4456,12 +4450,9 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier
        }
 
        /* ok now we're all set so let's go */
-       if(psys->totpart) {
-               //if(psys->part->from==PART_FROM_FACE) {
-               //      psys_calc_dmfaces(ob, psmd->dm, psys);
-               //}
+       if(psys->totpart)
                dynamics_step(ob,psys,psmd,cfra,vg_vel,vg_tan,vg_rot,vg_size);
-       }
+
        psys->recalc = 0;
        psys->cfra=cfra;
 
@@ -4533,21 +4524,24 @@ void particle_system_update(Object *ob, ParticleSystem *psys){
 
        ParticleSystemModifierData *psmd=0;
        float cfra;
-       
-       if((psys->flag & PSYS_ENABLED)==0) return;
 
-       psmd=psys_get_modifier(ob,psys);
+       if(!psys_check_enabled(ob, psys))
+               return;
 
        cfra=bsystem_time(ob,(float)CFRA,0.0);
+       psmd= psys_get_modifier(ob, psys);
 
        /* system was already updated from modifier stack */
-       if(psmd->flag&eParticleSystemFlag_psys_updated){
+       if(psmd->flag&eParticleSystemFlag_psys_updated) {
                psmd->flag &= ~eParticleSystemFlag_psys_updated;
                /* make sure it really was updated to cfra */
                if(psys->cfra==cfra)
                        return;
        }
 
+       if(!psmd->dm)
+               return;
+
        /* baked path softbody */
        if(psys->part->type==PART_HAIR && psys->soft)
                psys_to_softbody(ob, psys, 0);
index 0763224b4ec561617eb9de9875ac2a59e5d90eba..cf71d9ab41e930d80f421d03ddbfd94011909384 100644 (file)
@@ -7087,6 +7087,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                oldnewmap_insert(fd->libmap, psys->part, psys->part, 0);
 
                                part->id.us--;
+                               part->id.flag |= (ob->id.flag & LIB_NEEDLINK);
                                
                                psys->totpart=0;
                                psys->flag=PSYS_ENABLED|PSYS_CURRENT;
index fc2fa7cab2019f2d6c3a812696435bcc60517bbc..a00d7d484d934f6b50351dc26ad45b1a7707fa5b 100644 (file)
@@ -198,6 +198,9 @@ typedef struct ParticleSystem{
 
        /* if you change these remember to update array lengths to PSYS_TOT_VG! */
        short vgroup[11], vg_neg, rt3[2];
+
+       /* temporary storage during render */
+       void *renderdata;
 }ParticleSystem;
 
 /* general particle maximums */
index c18409c1d008306d6980121fb187af8e941cc650..de3bd6079a427c0bfb53b514490dfdb6eddb81e3 100644 (file)
@@ -1508,9 +1508,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
        part=psys->part;
        pars=psys->particles;
 
-       if(part==NULL || pars==NULL || (psys->flag & PSYS_ENABLED)==0)
+       if(part==NULL || pars==NULL || !psys_check_enabled(ob, psys))
                return 0;
-
+       
        if(part->draw_as==PART_DRAW_OB || part->draw_as==PART_DRAW_GR || part->draw_as==PART_DRAW_NOT)
                return 1;
 
@@ -3854,7 +3854,6 @@ static void init_render_object_data(Render *re, ObjectRen *obr, int only_verts)
                        psys= psys->next;
 
                render_new_particle_system(re, obr, psys);
-               psys_free_render_memory(ob, psys);
        }
        else {
                if ELEM(ob->type, OB_FONT, OB_CURVE)
@@ -3885,8 +3884,10 @@ static void add_render_object(Render *re, Object *ob, Object *par, int index, in
        /* so here we only check if the emitter should be rendered */
        if(ob->particlesystem.first) {
                show_emitter= 0;
-               for(psys=ob->particlesystem.first; psys; psys=psys->next)
+               for(psys=ob->particlesystem.first; psys; psys=psys->next) {
                        show_emitter += psys->part->draw & PART_DRAW_EMITTER;
+                       psys_particles_to_render_backup(ob, psys);
+               }
 
                /* if no psys has "show emitter" selected don't render emitter */
                if(show_emitter == 0)
@@ -3909,6 +3910,7 @@ static void add_render_object(Render *re, Object *ob, Object *par, int index, in
                for(psys=ob->particlesystem.first; psys; psys=psys->next, psysindex++) {
                        obr= RE_addRenderObject(re, ob, par, index, psysindex);
                        init_render_object_data(re, obr, only_verts);
+                       psys_render_backup_to_particles(ob, psys);
 
                        /* only add instance for objects that have not been used for dupli */
                        if(!(ob->transflag & OB_RENDER_DUPLI))
index cadde9530ed5b9f93ce6961598cc23335391ef95..42c6d559f6545f9e85634ad5068cfa927cc6cc56 100644 (file)
@@ -648,6 +648,8 @@ static int strand_test_clip(float winmat[][4], ZSpan *zspan, float *bounds, floa
        else if(hoco[1] > bounds[3]*hoco[3]) clipflag |= 4;
        else if(hoco[1]< bounds[2]*hoco[3]) clipflag |= 8;
 
+       clipflag |= testclip(hoco);
+
        return clipflag;
 }
 
index 92ee7af26cc99889bb4bad885ff7714d097d5557..83139fcfb0af3a3ea9a2aa194c4919008ec367f9 100644 (file)
@@ -1639,19 +1639,6 @@ void modifiers_explodeFacepa(void *arg1, void *arg2)
        emd->flag |= eExplodeFlag_CalcFaces;
 }
 
-void modifiers_psysEnable(void *ob_v, void *md_v)
-{
-       ParticleSystemModifierData *psmd = (ParticleSystemModifierData*) md_v;
-
-       if(psmd->modifier.mode & eModifierMode_Realtime) {
-               psmd->psys->flag |= PSYS_ENABLED;
-       }
-       else {
-               psmd->psys->flag &= ~PSYS_ENABLED;
-               PE_free_particle_edit(psmd->psys);
-       }
-}
-
 static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco, int *yco, int index, int cageIndex, int lastCageIndex)
 {
        ModifierTypeInfo *mti = modifierType_getInfo(md->type);
@@ -1691,8 +1678,6 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
                if (md->type!=eModifierType_Softbody || !(ob->pd && ob->pd->deflect)) {
                        uiDefIconButBitI(block, TOG, eModifierMode_Render, B_MODIFIER_RECALC, ICON_SCENE, x+10+buttonWidth-60, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during rendering");
                        but= uiDefIconButBitI(block, TOG, eModifierMode_Realtime, B_MODIFIER_RECALC, VICON_VIEW3D, x+10+buttonWidth-40, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during interactive display");
-                       if (md->type==eModifierType_ParticleSystem)
-                               uiButSetFunc(but, modifiers_psysEnable, ob, md);
                        if (mti->flags&eModifierTypeFlag_SupportsEditmode) {
                                uiDefIconButBitI(block, TOG, eModifierMode_Editmode, B_MODIFIER_RECALC, VICON_EDIT, x+10+buttonWidth-20, y-1, 19, 19,&md->mode, 0, 0, 1, 0, "Enable modifier during Editmode (only if enabled for display)");
                        }
index 3c1a7680ed2c9b71efdc2e8a2d4faa1032880f5f..3c2969e77bfe057c732b2d41af2d862d6eef8917 100644 (file)
@@ -2855,15 +2855,6 @@ void do_effects_panels(unsigned short event)
                break;
        case B_PART_ENABLE:
                if(psys) {
-                       ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys);
-                       if(psys->flag & PSYS_ENABLED) {
-                               psmd->modifier.mode |= eModifierMode_Realtime;
-                       }
-                       else {
-                               psmd->modifier.mode &= ~eModifierMode_Realtime;
-                               PE_free_particle_edit(psys);
-                       }
-
                        DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
                        allqueue(REDRAWVIEW3D, 0);
                        allqueue(REDRAWBUTSOBJECT, 0);
index 397d411e4b0c77018941736a053e0f335f0d1f36..db2225f4823ef11247aa7247afd424a44513e86a 100644 (file)
@@ -3005,7 +3005,7 @@ static void draw_new_particle_system(Base *base, ParticleSystem *psys)
        part=psys->part;
        pars=psys->particles;
 
-       if(part==0 || (psys->flag & PSYS_ENABLED)==0)
+       if(part==0 || !psys_check_enabled(ob, psys))
                return;
 
        if(pars==0) return;
index 7e88c8278b5a5048cbb330743b88ca60c19f220a..bb3beb329f1ad93615a40e6b3a7bb54b89e8e9a3 100644 (file)
@@ -2841,7 +2841,6 @@ static void object_has_subdivision_particles(Object *ob, int *havesubdiv, int *h
 
 static void object_flip_subdivison_particles(Object *ob, int *set, int level, int mode, int particles, int depth)
 {
-       void modifiers_psysEnable(void *ob_v, void *md_v);
        ModifierData *md;
 
        if(ob->type==OB_MESH) {
@@ -2857,8 +2856,6 @@ static void object_flip_subdivison_particles(Object *ob, int *set, int level, in
                                                psmd->modifier.mode &= ~(mode);
                                        else
                                                psmd->modifier.mode |= (mode);
-
-                                       modifiers_psysEnable(ob, md);
                                }
                        }
                }
index cad5e4af5b514b7fff6dd50f4eaf34affd1ad14b..0475e91f2b7471161550042f26f5cc6a0136189c 100644 (file)
@@ -157,7 +157,7 @@ void PE_change_act(void *ob_v, void *act_v)
                if((psys=BLI_findlink(&ob->particlesystem,act))) {
                        psys->flag |= PSYS_CURRENT;
 
-                       if(psys->flag & PSYS_ENABLED) {
+                       if(psys_check_enabled(ob, psys)) {
                                if(G.f & G_PARTICLEEDIT && !psys->edit)
                                        PE_create_particle_edit(ob, psys);
                                PE_recalc_world_cos(ob, psys);
@@ -186,7 +186,7 @@ ParticleSystem *PE_get_current(Object *ob)
                psys->flag |= PSYS_CURRENT;
        }
 
-       if(psys && (psys->flag & PSYS_ENABLED) && ob == OBACT && (G.f & G_PARTICLEEDIT))
+       if(psys && psys_check_enabled(ob, psys) && ob == OBACT && (G.f & G_PARTICLEEDIT))
                if(psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED)
                        if(psys->edit == NULL)
                                PE_create_particle_edit(ob, psys);
@@ -1102,7 +1102,7 @@ void PE_set_particle_edit(void)
 
        if((G.f & G_PARTICLEEDIT)==0){
                if(psys && psys->part->type == PART_HAIR && psys->flag & PSYS_EDITED) {
-                       if(psys->flag & PSYS_ENABLED) {
+                       if(psys_check_enabled(ob, psys)) {
                                if(psys->edit==0)
                                        PE_create_particle_edit(ob, psys);
                                PE_recalc_world_cos(ob, psys);
index 9b2b563595d8c4a981cda60d96be4778d7130f7c..bde79b068dd4c5963538ca5b98d46709d704ab94 100644 (file)
@@ -1565,6 +1565,7 @@ static void createTransParticleVerts(TransInfo *t)
                        if(k==0 && pset->flag & PE_LOCK_FIRST)
                                td->protectflag |= OB_LOCK_LOC;
 
+                       td->ob = ob;
                        td->ext = tx;
                        td->tdi = NULL;
                        if(t->mode == TFM_BAKE_TIME) {