Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-08-29 14:34:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-08-29 14:34:09 +0400
commit291ad172a1aacea96a460387cc420d96c8d63e63 (patch)
tree896aa3412487d6167bf6374e2ccc0eb91c692958 /source/blender/editors/physics/particle_edit.c
parent1b8da326ba36caeb79fd5ebdc9e93283ab0cc648 (diff)
follow up on r59628, setting modes now ensures that other modes exit first,
this was only done in some cases before and it was possible to enable weightpaint+sculpt at the same time when enabling sculpt by directly running the mode switching operator. add generic function to ensure a compatible mode before entering the new mode (added to each operators exec function)
Diffstat (limited to 'source/blender/editors/physics/particle_edit.c')
-rw-r--r--source/blender/editors/physics/particle_edit.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index d6bb394ff79..dc7ec16d7c1 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -69,6 +69,7 @@
#include "BIF_gl.h"
#include "BIF_glutil.h"
+#include "ED_object.h"
#include "ED_physics.h"
#include "ED_mesh.h"
#include "ED_particle.h"
@@ -4345,23 +4346,36 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
static int particle_edit_toggle_poll(bContext *C)
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= CTX_data_active_object(C);
+ Object *ob = CTX_data_active_object(C);
- if (!scene || !ob || ob->id.lib)
+ if (ob == NULL || ob->type != OB_MESH)
return 0;
-
- return (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody));
+ if (!ob->data || ((ID *)ob->data)->lib)
+ return 0;
+ if (CTX_data_edit_object(C))
+ return 0;
+
+ return (ob->particlesystem.first ||
+ modifiers_findByType(ob, eModifierType_Cloth) ||
+ modifiers_findByType(ob, eModifierType_Softbody));
}
-static int particle_edit_toggle_exec(bContext *C, wmOperator *UNUSED(op))
+static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= CTX_data_active_object(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ const int mode_flag = OB_MODE_PARTICLE_EDIT;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
+
+ if (!is_mode_set) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
+ return OPERATOR_CANCELLED;
+ }
+ }
- if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
+ if (!is_mode_set) {
PTCacheEdit *edit;
- ob->mode |= OB_MODE_PARTICLE_EDIT;
+ ob->mode |= mode_flag;
edit= PE_create_current(scene, ob);
/* mesh may have changed since last entering editmode.
@@ -4373,7 +4387,7 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *UNUSED(op))
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL);
}
else {
- ob->mode &= ~OB_MODE_PARTICLE_EDIT;
+ ob->mode &= ~mode_flag;
toggle_particle_cursor(C, 0);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
}