diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-12-07 22:22:48 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-12-07 22:22:48 +0300 |
commit | 82ddfbf99fc0776a7fe439b81cf71bab87ceaaf9 (patch) | |
tree | fb1eda53eeeab12b093f5178693923b606708b05 /source/blender/editors/physics | |
parent | 4ca2581b77112c488938f0a2dc226042e0390b71 (diff) | |
parent | fc69c54c4ce810e6236eaa45017130f27ba3f1e2 (diff) |
Sculpt Branch:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r24889:25180
Diffstat (limited to 'source/blender/editors/physics')
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 82 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_object.c | 11 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 2 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_intern.h | 6 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_pointcache.c | 42 |
6 files changed, 113 insertions, 38 deletions
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index a1034eaf9f7..ac986ba7df6 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1174,8 +1174,11 @@ static void update_velocities(Object *ob, PTCacheEdit *edit) } } } + void PE_update_object(Scene *scene, Object *ob, int useflag) { + /* use this to do partial particle updates, not usable when adding or + removing, then a full redo is necessary and calling this may crash */ ParticleEditSettings *pset= PE_settings(scene); PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; @@ -1261,29 +1264,51 @@ static void toggle_key_select(PEData *data, int point_index, int key_index) /************************ de select all operator ************************/ -static int de_select_all_exec(bContext *C, wmOperator *op) +static int select_all_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - int sel= 0; - - LOOP_VISIBLE_POINTS { - LOOP_SELECTED_KEYS { - sel= 1; - key->flag &= ~PEK_SELECT; - point->flag |= PEP_EDIT_RECALC; + int action = RNA_enum_get(op->ptr, "action"); + + if (action == SEL_TOGGLE) { + action = SEL_SELECT; + LOOP_VISIBLE_POINTS { + LOOP_SELECTED_KEYS { + action = SEL_DESELECT; + break; + } + + if (action == SEL_DESELECT) + break; } } - if(sel==0) { - LOOP_VISIBLE_POINTS { - LOOP_KEYS { - if(!(key->flag & PEK_SELECT)) { + LOOP_VISIBLE_POINTS { + LOOP_VISIBLE_KEYS { + switch (action) { + case SEL_SELECT: + if ((key->flag & PEK_SELECT) == 0) { + key->flag |= PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; + } + break; + case SEL_DESELECT: + if (key->flag & PEK_SELECT) { + key->flag &= ~PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; + } + break; + case SEL_INVERT: + if ((key->flag & PEK_SELECT) == 0) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; + } else { + key->flag &= ~PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; } + break; } } } @@ -1294,18 +1319,20 @@ static int de_select_all_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PARTICLE_OT_select_all_toggle(wmOperatorType *ot) +void PARTICLE_OT_select_all(wmOperatorType *ot) { /* identifiers */ - ot->name= "Select or Deselect All"; - ot->idname= "PARTICLE_OT_select_all_toggle"; + ot->name= "Selection of all particles"; + ot->idname= "PARTICLE_OT_select_all"; /* api callbacks */ - ot->exec= de_select_all_exec; + ot->exec= select_all_exec; ot->poll= PE_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + WM_operator_properties_select_all(ot); } /************************ pick select operator ************************/ @@ -1472,7 +1499,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot) /************************ border select operator ************************/ -int PE_border_select(bContext *C, rcti *rect, int select) +int PE_border_select(bContext *C, rcti *rect, int select, int extend) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -1482,6 +1509,17 @@ int PE_border_select(bContext *C, rcti *rect, int select) if(!PE_start_edit(edit)) return OPERATOR_CANCELLED; + if (extend == 0 && select) { + POINT_P; KEY_K; + + LOOP_VISIBLE_POINTS { + LOOP_SELECTED_KEYS { + key->flag &= ~PEK_SELECT; + point->flag |= PEP_EDIT_RECALC; + } + } + } + PE_set_view3d_data(C, &data); data.rect= rect; data.select= select; @@ -2029,6 +2067,12 @@ static int remove_tagged_particles(Scene *scene, Object *ob, ParticleSystem *psy edit->mirror_cache= NULL; } + if(psys->child) { + MEM_freeN(psys->child); + psys->child= NULL; + psys->totchild=0; + } + edit->totpoint= psys->totpart= new_totpart; } @@ -2295,7 +2339,6 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "Remove %d double particles.", totremoved); - PE_update_object(scene, ob, 0); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob); @@ -2472,7 +2515,6 @@ static int delete_exec(bContext *C, wmOperator *op) recalc_lengths(data.edit); } - PE_update_object(data.scene, data.ob, 0); DAG_id_flush_update(&data.ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, data.ob); @@ -3698,7 +3740,6 @@ void PE_undo_step(Scene *scene, int step) } } - PE_update_object(scene, OBACT, 0); DAG_id_flush_update(&OBACT->id, OB_RECALC_DATA); } @@ -3983,6 +4024,7 @@ static int clear_edited_exec(bContext *C, wmOperator *op) psys->flag &= ~PSYS_EDITED; psys_reset(psys, PSYS_RESET_DEPSGRAPH); + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); } } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 1ef3ffa6c34..f94835593c5 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -56,6 +56,7 @@ #include "WM_types.h" #include "ED_particle.h" +#include "ED_screen.h" #include "physics_intern.h" @@ -69,7 +70,7 @@ static int particle_system_add_exec(bContext *C, wmOperator *op) if(!scene || !ob) return OPERATOR_CANCELLED; - object_add_particle_system(scene, ob); + object_add_particle_system(scene, ob, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); return OPERATOR_FINISHED; @@ -83,8 +84,9 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot) ot->description="Add a particle system."; /* api callbacks */ + ot->poll= ED_operator_object_active_editable; ot->exec= particle_system_add_exec; - + /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -120,6 +122,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) ot->description="Remove the selected particle system."; /* api callbacks */ + ot->poll= ED_operator_object_active_editable; ot->exec= particle_system_remove_exec; /* flags */ @@ -266,11 +269,11 @@ static int remove_particle_target_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PARTICLE_OT_remove_target(wmOperatorType *ot) +void PARTICLE_OT_target_remove(wmOperatorType *ot) { /* identifiers */ ot->name= "Remove Particle Target"; - ot->idname= "PARTICLE_OT_remove_target"; + ot->idname= "PARTICLE_OT_target_remove"; ot->description="Remove the selected particle target."; /* api callbacks */ diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index e5d553dacc7..7893b314e3e 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1200,6 +1200,6 @@ void FLUID_OT_bake(wmOperatorType *ot) /* api callbacks */ ot->exec= fluid_bake_exec; - ot->poll= ED_operator_object_active; + ot->poll= ED_operator_object_active_editable; } diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h index e8169adc8dc..085332b1788 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -36,7 +36,7 @@ struct wmOperatorType; /* particle_edit.c */ -void PARTICLE_OT_select_all_toggle(struct wmOperatorType *ot); +void PARTICLE_OT_select_all(struct wmOperatorType *ot); void PARTICLE_OT_select_first(struct wmOperatorType *ot); void PARTICLE_OT_select_last(struct wmOperatorType *ot); void PARTICLE_OT_select_linked(struct wmOperatorType *ot); @@ -68,7 +68,7 @@ void OBJECT_OT_particle_system_remove(struct wmOperatorType *ot); void PARTICLE_OT_new(struct wmOperatorType *ot); void PARTICLE_OT_new_target(struct wmOperatorType *ot); -void PARTICLE_OT_remove_target(struct wmOperatorType *ot); +void PARTICLE_OT_target_remove(struct wmOperatorType *ot); void PARTICLE_OT_target_move_up(struct wmOperatorType *ot); void PARTICLE_OT_target_move_down(struct wmOperatorType *ot); void PARTICLE_OT_connect_hair(struct wmOperatorType *ot); @@ -99,7 +99,7 @@ void PTCACHE_OT_free_bake_all(struct wmOperatorType *ot); void PTCACHE_OT_bake(struct wmOperatorType *ot); void PTCACHE_OT_free_bake(struct wmOperatorType *ot); void PTCACHE_OT_bake_from_cache(struct wmOperatorType *ot); -void PTCACHE_OT_add_new(struct wmOperatorType *ot); +void PTCACHE_OT_add(struct wmOperatorType *ot); void PTCACHE_OT_remove(struct wmOperatorType *ot); #endif /* ED_PHYSICS_INTERN_H */ diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index af269dc8ed0..09b4ebec7a2 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -43,7 +43,7 @@ static void operatortypes_particle(void) { - WM_operatortype_append(PARTICLE_OT_select_all_toggle); + WM_operatortype_append(PARTICLE_OT_select_all); WM_operatortype_append(PARTICLE_OT_select_first); WM_operatortype_append(PARTICLE_OT_select_last); WM_operatortype_append(PARTICLE_OT_select_linked); @@ -75,7 +75,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_new); WM_operatortype_append(PARTICLE_OT_new_target); - WM_operatortype_append(PARTICLE_OT_remove_target); + WM_operatortype_append(PARTICLE_OT_target_remove); WM_operatortype_append(PARTICLE_OT_target_move_up); WM_operatortype_append(PARTICLE_OT_target_move_down); WM_operatortype_append(PARTICLE_OT_connect_hair); @@ -94,7 +94,7 @@ static void keymap_particle(wmKeyConfig *keyconf) keymap= WM_keymap_find(keyconf, "Particle", 0, 0); keymap->poll= PE_poll; - WM_keymap_add_item(keymap, "PARTICLE_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "PARTICLE_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); 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); @@ -149,7 +149,7 @@ static void operatortypes_pointcache(void) WM_operatortype_append(PTCACHE_OT_bake); WM_operatortype_append(PTCACHE_OT_free_bake); WM_operatortype_append(PTCACHE_OT_bake_from_cache); - WM_operatortype_append(PTCACHE_OT_add_new); + WM_operatortype_append(PTCACHE_OT_add); WM_operatortype_append(PTCACHE_OT_remove); } diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 26099a18966..858ff3637b1 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -80,9 +80,21 @@ static int ptcache_poll(bContext *C) return (ptr.data && ptr.id.data); } +void bake_console_progress(void *arg, int nr) +{ + printf("\rbake: %3i%%", nr); + fflush(stdout); +} + +void bake_console_progress_end(void *arg, int nr) +{ + printf("\n"); +} + static int ptcache_bake_all_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); + wmWindow *win = CTX_wm_window(C); PTCacheBaker baker; @@ -94,8 +106,16 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op) baker.quick_step = 1; baker.break_test = cache_break_test; baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); + + if (win) { + baker.progressbar = (void (*)(void *, int))WM_timecursor; + baker.progressend = (void (*)(void *))WM_cursor_restore; + baker.progresscontext = win; + } else { + baker.progressbar = bake_console_progress; + baker.progressend = bake_console_progress_end; + baker.progresscontext = NULL; + } BKE_ptcache_make_cache(&baker); @@ -156,6 +176,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) static int ptcache_bake_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); + wmWindow *win = CTX_wm_window(C); PointerRNA ptr= CTX_data_pointer_get_type(C, "PointCache", &RNA_PointCache); Object *ob= ptr.id.data; PointCache *cache= ptr.data; @@ -178,8 +199,17 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op) baker.quick_step = 1; baker.break_test = cache_break_test; baker.break_data = NULL; - baker.progressbar = (void (*)(void *, int))WM_timecursor; - baker.progresscontext = CTX_wm_window(C); + + if (win) { + baker.progressbar = (void (*)(void *, int))WM_timecursor; + baker.progressend = (void (*)(void *))WM_cursor_restore; + baker.progresscontext = win; + } else { + printf("\n"); /* empty first line before console reports */ + baker.progressbar = bake_console_progress; + baker.progressend = bake_console_progress_end; + baker.progresscontext = NULL; + } BKE_ptcache_make_cache(&baker); @@ -308,11 +338,11 @@ static int ptcache_remove_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -void PTCACHE_OT_add_new(wmOperatorType *ot) +void PTCACHE_OT_add(wmOperatorType *ot) { /* identifiers */ ot->name= "Add new cache"; - ot->idname= "PTCACHE_OT_add_new"; + ot->idname= "PTCACHE_OT_add"; /* api callbacks */ ot->exec= ptcache_add_new_exec; |