diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-27 00:34:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-27 00:34:13 +0400 |
commit | 879e4fd9be91b590a9c15fc68bdb9850f6f15bb1 (patch) | |
tree | dfb5294520eed1400aa02e7c96b12a2a2eb234c7 /source | |
parent | 166cdf8b5aaf5f36012f8d62a4882ec838bd5cb3 (diff) |
sequencer gaps
- remove unneeded checks (poll checks editor is non-null)
- use booleans
- rename operator SEQUENCER_OT_gap_remove, _gap_insert
also quiet shadow warning in rigidbody.c (shadowing 'loc')
Diffstat (limited to 'source')
4 files changed, 38 insertions, 43 deletions
diff --git a/source/blender/blenkernel/intern/rigidbody.c b/source/blender/blenkernel/intern/rigidbody.c index bccc6f9a93b..eaf385fbfcf 100644 --- a/source/blender/blenkernel/intern/rigidbody.c +++ b/source/blender/blenkernel/intern/rigidbody.c @@ -1001,26 +1001,26 @@ static void rigidbody_update_sim_ob(Scene *scene, RigidBodyWorld *rbw, Object *o /* get effectors present in the group specified by effector_weights */ effectors = pdInitEffectors(scene, ob, NULL, effector_weights); if (effectors) { - float force[3] = {0.0f, 0.0f, 0.0f}; - float loc[3], vel[3]; + float eff_force[3] = {0.0f, 0.0f, 0.0f}; + float eff_loc[3], eff_vel[3]; /* create dummy 'point' which represents last known position of object as result of sim */ // XXX: this can create some inaccuracies with sim position, but is probably better than using unsimulated vals? - RB_body_get_position(rbo->physics_object, loc); - RB_body_get_linear_velocity(rbo->physics_object, vel); + RB_body_get_position(rbo->physics_object, eff_loc); + RB_body_get_linear_velocity(rbo->physics_object, eff_vel); - pd_point_from_loc(scene, loc, vel, 0, &epoint); + pd_point_from_loc(scene, eff_loc, eff_vel, 0, &epoint); /* calculate net force of effectors, and apply to sim object * - we use 'central force' since apply force requires a "relative position" which we don't have... */ - pdDoEffectors(effectors, NULL, effector_weights, &epoint, force, NULL); + pdDoEffectors(effectors, NULL, effector_weights, &epoint, eff_force, NULL); if (G.f & G_DEBUG) - printf("\tapplying force (%f,%f,%f) to '%s'\n", force[0], force[1], force[2], ob->id.name + 2); + printf("\tapplying force (%f,%f,%f) to '%s'\n", eff_force[0], eff_force[1], eff_force[2], ob->id.name + 2); /* activate object in case it is deactivated */ - if (!is_zero_v3(force)) + if (!is_zero_v3(eff_force)) RB_body_activate(rbo->physics_object); - RB_body_apply_central_force(rbo->physics_object, force); + RB_body_apply_central_force(rbo->physics_object, eff_force); } else if (G.f & G_DEBUG) printf("\tno forces to apply to '%s'\n", ob->id.name + 2); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 516ec6f3a0d..fb372a7b838 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -866,11 +866,11 @@ static int cut_seq_list(Scene *scene, ListBase *slist, int cutframe, return (seq_first_new != NULL); } -static int insert_gap(Scene *scene, int gap, int cfra) +static bool insert_gap(Scene *scene, int gap, int cfra) { Sequence *seq; Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - int done = FALSE; + bool done = false; /* all strips >= cfra are shifted */ @@ -881,7 +881,7 @@ static int insert_gap(Scene *scene, int gap, int cfra) if (seq->startdisp >= cfra) { seq->start += gap; BKE_sequence_calc(scene, seq); - done = TRUE; + done = true; } } SEQ_END @@ -988,15 +988,13 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) } -static int sequencer_no_gap_exec(bContext *C, wmOperator *op) +static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = BKE_sequencer_editing_get(scene, FALSE); rctf rectf; - int cfra, efra, sfra, first = 0, done; - int do_all = RNA_boolean_get(op->ptr, "all"); - - if (ed == NULL) return OPERATOR_CANCELLED; + int cfra, efra, sfra; + bool first = false, done; + bool do_all = RNA_boolean_get(op->ptr, "all"); /* get first and last frame */ boundbox_seq(scene, &rectf); @@ -1006,23 +1004,23 @@ static int sequencer_no_gap_exec(bContext *C, wmOperator *op) /* first check if the current frame has a gap already */ for (cfra = CFRA; cfra >= sfra; cfra--) { if (BKE_sequencer_evaluate_frame(scene, cfra)) { - first = 1; + first = true; break; } } for ( ; cfra < efra; cfra++) { /* first == 0 means there's still no strip to remove a gap for */ - if (first == 0) { - if (BKE_sequencer_evaluate_frame(scene, cfra) ) first = 1; + if (first == false) { + if (BKE_sequencer_evaluate_frame(scene, cfra) ) first = true; } else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) { - done = TRUE; + done = true; while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) { done = insert_gap(scene, -1, cfra); - if (done == 0) break; + if (done == false) break; } - if (done == 0 || do_all == 0) break; + if (done == false || do_all == false) break; } } @@ -1033,16 +1031,16 @@ static int sequencer_no_gap_exec(bContext *C, wmOperator *op) } -void SEQUENCER_OT_no_gap(struct wmOperatorType *ot) +void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Remove Gap"; - ot->idname = "SEQUENCER_OT_no_gap"; + ot->name = "Remove Gaps"; + ot->idname = "SEQUENCER_OT_gap_remove"; ot->description = "Remove gap at current frame to first strip at the right"; /* api callbacks */ // ot->invoke = sequencer_snap_invoke; - ot->exec = sequencer_no_gap_exec; + ot->exec = sequencer_gap_remove_exec; ot->poll = sequencer_edit_poll; /* flags */ @@ -1051,14 +1049,11 @@ void SEQUENCER_OT_no_gap(struct wmOperatorType *ot) RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame"); } -static int sequencer_insert_gap_exec(bContext *C, wmOperator *op) +static int sequencer_gap_insert_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int frames = RNA_int_get(op->ptr, "frames"); - if (ed == NULL) return OPERATOR_CANCELLED; - insert_gap(scene, frames, CFRA); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1067,16 +1062,16 @@ static int sequencer_insert_gap_exec(bContext *C, wmOperator *op) } -void SEQUENCER_OT_insert_gap(struct wmOperatorType *ot) +void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot) { /* identifiers */ - ot->name = "Insert Gap"; - ot->idname = "SEQUENCER_OT_insert_gap"; + ot->name = "Insert Gaps"; + ot->idname = "SEQUENCER_OT_gap_insert"; ot->description = "Insert gap at current frame to first strips at the right"; /* api callbacks */ // ot->invoke = sequencer_snap_invoke; - ot->exec = sequencer_insert_gap_exec; + ot->exec = sequencer_gap_insert_exec; ot->poll = sequencer_edit_poll; /* flags */ diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 4eb71c9fb09..32a6c49da89 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -98,8 +98,8 @@ void SEQUENCER_OT_meta_toggle(struct wmOperatorType *ot); void SEQUENCER_OT_meta_make(struct wmOperatorType *ot); void SEQUENCER_OT_meta_separate(struct wmOperatorType *ot); -void SEQUENCER_OT_no_gap(struct wmOperatorType *ot); -void SEQUENCER_OT_insert_gap(struct wmOperatorType *ot); +void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot); +void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot); void SEQUENCER_OT_snap(struct wmOperatorType *ot); void SEQUENCER_OT_strip_jump(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index 7ddc5a77555..a236a97a803 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -73,8 +73,8 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_meta_make); WM_operatortype_append(SEQUENCER_OT_meta_separate); - WM_operatortype_append(SEQUENCER_OT_no_gap); - WM_operatortype_append(SEQUENCER_OT_insert_gap); + WM_operatortype_append(SEQUENCER_OT_gap_remove); + WM_operatortype_append(SEQUENCER_OT_gap_insert); WM_operatortype_append(SEQUENCER_OT_snap); WM_operatortype_append(SEQUENCER_OT_strip_jump); WM_operatortype_append(SEQUENCER_OT_swap); @@ -216,9 +216,9 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT); RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT); - RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_no_gap", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "all", FALSE); - RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_no_gap", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", TRUE); - WM_keymap_add_item(keymap, "SEQUENCER_OT_insert_gap", EQUALKEY, KM_PRESS, KM_SHIFT, 0); + RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_remove", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "all", FALSE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_remove", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", TRUE); + WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_insert", EQUALKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0); |