Bugfixes for:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 11 Dec 2007 15:03:45 +0000 (15:03 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 11 Dec 2007 15:03:45 +0000 (15:03 +0000)
- Disabled particle modifiers in particle mode.
- Particle col option without material.

source/blender/blenkernel/intern/particle.c
source/blender/include/butspace.h
source/blender/src/buttons_editing.c
source/blender/src/buttons_object.c
source/blender/src/editparticle.c

index c812c794682f78956ae9bf93883d6b2b4fbd70f7..639a982460062d2d0ce1dc7897e1d28eef68b339 100644 (file)
@@ -1730,7 +1730,7 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
                        VECSUB((state-1)->vel,state->co,(state-2)->co);
                        VecMulf((state-1)->vel,0.5);
 
-                       if(part->draw & PART_DRAW_MAT_COL)
+                       if(ctx->ma && (part->draw & PART_DRAW_MAT_COL))
                                get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel);
                }
 
@@ -1754,7 +1754,7 @@ void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa,
                        cur_length= 0.0f;
                }
 
-               if(part->draw & PART_DRAW_MAT_COL) {
+               if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) {
                        VECCOPY(state->col, &ctx->ma->r)
                        get_strand_normal(ctx->ma, ornor, cur_length, state->vel);
                }
@@ -1910,7 +1910,7 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda
        
        psys->lattice = psys_get_lattice(ob, psys);
        ma= give_current_material(ob, psys->part->omat);
-       if(psys->part->draw & PART_DRAW_MAT_COL)
+       if(ma && (psys->part->draw & PART_DRAW_MAT_COL))
                VECCOPY(col, &ma->r)
 
        /*---first main loop: create all actual particles' paths---*/
index 5029c88fba753162a167a6f85df750d678e9b69a..ec8ffb819f640bc3675be69ccb8aedf34bd50da3 100644 (file)
@@ -735,8 +735,8 @@ enum {
 #define B_PART_INIT_CHILD      3433
 #define B_PART_RECALC_CHILD    3434
 #define B_PART_EDITABLE                3435
-
 #define B_PART_REKEY           3436
+#define B_PART_ENABLE          3437
 
 #define B_MODIFIER_BUTS                3600
 
index ba648d3f4ad551c68a3bac397dc4295c9454a49d..2a14609dc4006f3b6536e7a40bc3cb301c357b78 100644 (file)
@@ -1643,10 +1643,13 @@ static void modifiers_psysEnable(void *ob_v, void *md_v)
 {
        ParticleSystemModifierData *psmd = (ParticleSystemModifierData*) md_v;
 
-       if(psmd->modifier.mode & eModifierMode_Realtime)
+       if(psmd->modifier.mode & eModifierMode_Realtime) {
                psmd->psys->flag |= PSYS_ENABLED;
-       else
+       }
+       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)
index e0190ab474f78fd12709d9cf8b830f5513ebe698..8d29e0441420b3d4aa1f0cd5288ca4cc6e2d6e93 100644 (file)
@@ -2853,6 +2853,23 @@ void do_effects_panels(unsigned short event)
                        allqueue(REDRAWOOPS, 0);
                }
                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);
+                       allqueue(REDRAWBUTSEDIT, 0);
+               }
+               break;
        case B_PART_RECALC:
        case B_PART_RECALC_CHILD:
                if(psys){
@@ -4200,7 +4217,7 @@ static void object_panel_particle_system(Object *ob)
        butx=0;
        buty-=5;
        
-       uiDefButBitI(block, TOG, PSYS_ENABLED, B_PART_REDRAW, "Enabled",         0,(buty-=buth),100,buth, &psys->flag, 0, 0, 0, 0, "Sets particle system to be calculated and shown");
+       uiDefButBitI(block, TOG, PSYS_ENABLED, B_PART_ENABLE, "Enabled",         0,(buty-=buth),100,buth, &psys->flag, 0, 0, 0, 0, "Sets particle system to be calculated and shown");
 
        if(part->type == PART_HAIR){
                if(psys->flag & PSYS_EDITED)
index bb88e9624bf7873698b398721faaed58f49735ba..3611efed995fbe1c77ec4a9c2c0da3013f91b160 100644 (file)
@@ -155,9 +155,12 @@ void PE_change_act(void *ob_v, void *act_v)
        if(act>=0){
                if((psys=BLI_findlink(&ob->particlesystem,act))) {
                        psys->flag |= PSYS_CURRENT;
-                       if(G.f & G_PARTICLEEDIT && !psys->edit)
-                               PE_create_particle_edit(ob, psys);
-                       PE_recalc_world_cos(ob, psys);
+
+                       if(psys->flag & PSYS_ENABLED) {
+                               if(G.f & G_PARTICLEEDIT && !psys->edit)
+                                       PE_create_particle_edit(ob, psys);
+                               PE_recalc_world_cos(ob, psys);
+                       }
                }
        }
 }
@@ -182,7 +185,7 @@ ParticleSystem *PE_get_current(Object *ob)
                psys->flag |= PSYS_CURRENT;
        }
 
-       if(psys && ob == OBACT && (G.f & G_PARTICLEEDIT))
+       if(psys && (psys->flag & PSYS_ENABLED) && 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);
@@ -1098,9 +1101,11 @@ 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->edit==0)
-                               PE_create_particle_edit(ob, psys);
-                       PE_recalc_world_cos(ob, psys);
+                       if(psys->flag & PSYS_ENABLED) {
+                               if(psys->edit==0)
+                                       PE_create_particle_edit(ob, psys);
+                               PE_recalc_world_cos(ob, psys);
+                       }
                }
 
                G.f |= G_PARTICLEEDIT;
@@ -2582,6 +2587,7 @@ int PE_brush_particles(void)
                                if(pset->brushtype == PE_BRUSH_ADD && (pset->flag & PE_X_MIRROR))
                                        PE_mirror_x(1);
                                PE_recalc_world_cos(ob,psys);
+                               psys_free_path_cache(psys);
                                DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
                        }
                        else