- removing the last particle system now exits particle edit mode.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 6 Nov 2009 12:27:28 +0000 (12:27 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 6 Nov 2009 12:27:28 +0000 (12:27 +0000)
- py UI script used an undeclared variable

release/scripts/ui/space_view3d_toolbar.py
source/blender/blenkernel/intern/particle.c
source/blender/editors/physics/particle_object.c

index 53dbef20020c1d4f05ef18aa27e9b59c6ed19991..49c284277244d19161a9c1e7a2f6c11eb26fdfa2 100644 (file)
@@ -830,6 +830,8 @@ class VIEW3D_PT_tools_particlemode(View3DPanel):
 
         layout.itemR(pe, "type", text="")
 
+        ptcache = None
+
         if pe.type == 'PARTICLES':
             if ob.particle_systems:
                 if len(ob.particle_systems) > 1:
index 43a624b30138760e6ea0903c75bd0b2152ae0fd3..24d6b229297c28a8969486124919f3600e106c40 100644 (file)
@@ -2276,7 +2276,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c
 /*     Object *ob= ctx->sim.ob; */
        ParticleSystem *psys= ctx->sim.psys;
        ParticleSettings *part = psys->part;
-       ParticleEditSettings *pset = &scene->toolsettings->particle;
+/*     ParticleEditSettings *pset = &scene->toolsettings->particle; */
        int totparent=0, between=0;
        int steps = (int)pow(2.0, (double)part->draw_step);
        int totchild = psys->totchild;
@@ -3334,6 +3334,8 @@ void object_remove_particle_system(Scene *scene, Object *ob)
 
        if(ob->particlesystem.first)
                ((ParticleSystem *) ob->particlesystem.first)->flag |= PSYS_CURRENT;
+       else
+               ob->mode &= ~OB_MODE_PARTICLE_EDIT;
 
        DAG_scene_sort(scene);
        DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
index d227591739b17269741105055481aba8e1fa5a86..d763c0500d2902daa9d7735f8dcfd99f7af459bd 100644 (file)
@@ -93,11 +93,20 @@ static int particle_system_remove_exec(bContext *C, wmOperator *op)
 {
        Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
        Scene *scene = CTX_data_scene(C);
-
+       int mode_orig = ob->mode;
        if(!scene || !ob)
                return OPERATOR_CANCELLED;
 
        object_remove_particle_system(scene, ob);
+
+       /* possible this isn't the active object
+        * object_remove_particle_system() clears the mode on the last psys
+        * */
+       if(mode_orig & OB_MODE_PARTICLE_EDIT)
+               if((ob->mode & OB_MODE_PARTICLE_EDIT)==0)
+                       if(scene->basact && scene->basact->object==ob)
+                               WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
+
        WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob);
        
        return OPERATOR_FINISHED;