diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-09 11:51:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-09 11:51:34 +0300 |
commit | 97e7e26babe9823ae78eaf7719e1f46d64169bc2 (patch) | |
tree | 4e4cf677d5e3ecc0177833559b18e56ac7e1730b | |
parent | ae91ca7217414038442487ec76f192fd1e5ac584 (diff) |
- added particle select_inverse
- added select root/tip to the select menu
- selection drawing updates for select more/less were not working
-rw-r--r-- | release/scripts/ui/space_view3d.py | 6 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 52 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_ops.c | 2 |
4 files changed, 60 insertions, 1 deletions
diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py index a3c2166d506..09043c3407c 100644 --- a/release/scripts/ui/space_view3d.py +++ b/release/scripts/ui/space_view3d.py @@ -306,12 +306,18 @@ class VIEW3D_MT_select_particle(bpy.types.Menu): layout.itemO("particle.select_all_toggle", text="Select/Deselect All") layout.itemO("particle.select_linked") + layout.itemO("particle.select_inverse") layout.itemS() layout.itemO("particle.select_more") layout.itemO("particle.select_less") + layout.itemS() + + layout.itemO("particle.select_first", text="Roots") + layout.itemO("particle.select_last", text="Tips") + class VIEW3D_MT_select_edit_mesh(bpy.types.Menu): bl_label = "Select" diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 438150b25ac..75c56575474 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1347,6 +1347,7 @@ int PE_mouse_particles(bContext *C, short *mval, int extend) static void select_root(PEData *data, int point_index) { data->edit->points[point_index].keys->flag |= PEK_SELECT; + data->edit->points[point_index].flag |= PEP_EDIT_RECALC; /* redraw selection only */ } static int select_first_exec(bContext *C, wmOperator *op) @@ -1355,6 +1356,8 @@ static int select_first_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); foreach_point(&data, select_root); + + PE_update_selection(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob); return OPERATOR_FINISHED; @@ -1380,6 +1383,7 @@ static void select_tip(PEData *data, int point_index) { PTCacheEditPoint *point = data->edit->points + point_index; point->keys[point->totkey - 1].flag |= PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ } static int select_last_exec(bContext *C, wmOperator *op) @@ -1388,6 +1392,8 @@ static int select_last_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); foreach_point(&data, select_tip); + + PE_update_selection(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob); return OPERATOR_FINISHED; @@ -1693,8 +1699,10 @@ static void select_less_keys(PEData *data, int point_index) } LOOP_KEYS { - if(key->flag&PEK_TAG) + if(key->flag&PEK_TAG) { key->flag &= ~(PEK_TAG|PEK_SELECT); + point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ + } } } @@ -1704,6 +1712,8 @@ static int select_less_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); foreach_point(&data, select_less_keys); + + PE_update_selection(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob); return OPERATOR_FINISHED; @@ -1752,6 +1762,7 @@ static void select_more_keys(PEData *data, int point_index) if(key->flag&PEK_TAG) { key->flag &= ~PEK_TAG; key->flag |= PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ } } } @@ -1762,6 +1773,8 @@ static int select_more_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); foreach_point(&data, select_more_keys); + + PE_update_selection(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob); return OPERATOR_FINISHED; @@ -1781,6 +1794,43 @@ void PARTICLE_OT_select_more(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +static int select_inverse_exec(bContext *C, wmOperator *op) +{ + PEData data; + PTCacheEdit *edit; + POINT_P; KEY_K; + + PE_set_data(C, &data); + + edit= PE_get_current(data.scene, data.ob); + + LOOP_VISIBLE_POINTS { + LOOP_KEYS { + key->flag ^= PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ + } + } + + PE_update_selection(data.scene, data.ob, 1); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_SELECT, data.ob); + + return OPERATOR_FINISHED; +} + +void PARTICLE_OT_select_inverse(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Select Inverse"; + ot->idname= "PARTICLE_OT_select_inverse"; + + /* api callbacks */ + ot->exec= select_inverse_exec; + ot->poll= PE_poll; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + /************************ rekey operator ************************/ static void rekey_particle(PEData *data, int pa_index) diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index babaaefe155..e8169adc8dc 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -42,6 +42,7 @@ void PARTICLE_OT_select_last(struct wmOperatorType *ot); void PARTICLE_OT_select_linked(struct wmOperatorType *ot); void PARTICLE_OT_select_less(struct wmOperatorType *ot); void PARTICLE_OT_select_more(struct wmOperatorType *ot); +void PARTICLE_OT_select_inverse(struct wmOperatorType *ot); void PARTICLE_OT_hide(struct wmOperatorType *ot); void PARTICLE_OT_reveal(struct wmOperatorType *ot); diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 8fb91a6c296..1b9ebf27edc 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -49,6 +49,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_select_linked); WM_operatortype_append(PARTICLE_OT_select_less); WM_operatortype_append(PARTICLE_OT_select_more); + WM_operatortype_append(PARTICLE_OT_select_inverse); WM_operatortype_append(PARTICLE_OT_hide); WM_operatortype_append(PARTICLE_OT_reveal); @@ -98,6 +99,7 @@ static void keymap_particle(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "PARTICLE_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "PARTICLE_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1); + WM_keymap_add_item(keymap, "PARTICLE_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_delete", DELKEY, KM_PRESS, 0, 0); |