Fix for [#24319] Removing a cloth or softbody simulation in paticle mode problem
authorJanne Karhu <jhkarh@gmail.com>
Tue, 19 Oct 2010 10:17:19 +0000 (10:17 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Tue, 19 Oct 2010 10:17:19 +0000 (10:17 +0000)
source/blender/editors/object/object_modifier.c

index c273b37..3d36ed9 100644 (file)
@@ -196,6 +196,11 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob
                CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface);
        }
 
+       if(ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
+               ob->particlesystem.first == NULL) {
+               ob->mode &= ~OB_MODE_PARTICLE_EDIT;
+       }
+
        BLI_remlink(&ob->modifiers, md);
        modifier_free(md);
 
@@ -658,11 +663,18 @@ static int modifier_remove_exec(bContext *C, wmOperator *op)
        Scene *scene= CTX_data_scene(C);
        Object *ob = ED_object_active_context(C);
        ModifierData *md = edit_modifier_property_get(op, ob, 0);
+       int mode_orig = ob->mode;
        
        if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md))
                return OPERATOR_CANCELLED;
 
        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
+
+       /* if cloth/softbody was removed, particle mode could be cleared */
+       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);
        
        return OPERATOR_FINISHED;
 }