diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2013-09-06 12:35:00 +0400 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2013-09-06 12:35:00 +0400 |
commit | 36e6bddb5c155b4ae27a9cd17b4af26bbcdc8dae (patch) | |
tree | 025a56b2e71adc77d53a4a33ac17a6cf55d360c2 /source/blender/editors/physics | |
parent | df3974b6d1c6469ca1a0b8a1c505b09385198780 (diff) | |
parent | 63ade11564798e68943ad5d8c82d45771df67677 (diff) |
svn merge -r59229:59868 ^/trunk/blender
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index d6bb394ff79..1a561efd217 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" @@ -2452,7 +2453,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) copy_v3_v3(co, point->keys->co); mul_m4_v3(mat, co); - totn= BLI_kdtree_find_n_nearest(tree, 10, co, NULL, nearest); + totn = BLI_kdtree_find_nearest_n(tree, co, NULL, nearest, 10); for (n=0; n<totn; n++) { /* this needs a custom threshold still */ @@ -3458,7 +3459,7 @@ static int brush_add(PEData *data, short number) float maxd, totw=0.0, weight[3]; psys_particle_on_dm(psmd->dm, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, 0, 0); - maxw= BLI_kdtree_find_n_nearest(tree, 3, co1, NULL, ptn); + maxw = BLI_kdtree_find_nearest_n(tree, co1, NULL, ptn, 3); maxd= ptn[maxw-1].dist; @@ -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); } |