Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_convert_sequencer_image.c
| Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | SEQ_ITERATOR_FOREACH (seq, strips) { | ||||
| SeqToTransData(t->scene, seq, td++, td2d++, tdseq++, 0); | SeqToTransData(t->scene, seq, td++, td2d++, tdseq++, 0); | ||||
| SeqToTransData(t->scene, seq, td++, td2d++, tdseq++, 1); | SeqToTransData(t->scene, seq, td++, td2d++, tdseq++, 1); | ||||
| SeqToTransData(t->scene, seq, td++, td2d++, tdseq++, 2); | SeqToTransData(t->scene, seq, td++, td2d++, tdseq++, 2); | ||||
| } | } | ||||
| SEQ_collection_free(strips); | SEQ_collection_free(strips); | ||||
| } | } | ||||
| static bool autokeyframe_sequencer_image(bContext *C, | |||||
| Scene *scene, | |||||
| StripTransform *transform, | |||||
| int tmode) | |||||
sybren: `const` | |||||
| { | |||||
| PointerRNA ptr; | |||||
| PropertyRNA *prop; | |||||
| RNA_pointer_create(&scene->id, &RNA_SequenceTransform, transform, &ptr); | |||||
| bool do_loc = false, do_rot = false, do_scale = false; | |||||
| const bool around_cursor = scene->toolsettings->sequencer_tool_settings->pivot_point == | |||||
| V3D_AROUND_CURSOR; | |||||
| if (tmode == TFM_ROTATION) { | |||||
| do_rot = true; | |||||
| if (around_cursor) { | |||||
| do_loc = true; | |||||
| } | |||||
| } | |||||
| if (tmode == TFM_TRANSLATION) { | |||||
| do_loc = true; | |||||
| } | |||||
| if (tmode == TFM_RESIZE) { | |||||
| do_scale = true; | |||||
| if (around_cursor) { | |||||
| do_loc = true; | |||||
| } | |||||
| } | |||||
sybrenUnsubmitted Not Done Inline ActionsI think this is expressed in a clearer way like this: const bool around_cursor = scene->toolsettings->sequencer_tool_settings->pivot_point == V3D_AROUND_CURSOR; const bool do_loc = tmode == TFM_TRANSLATION || around_cursor; const bool do_rot = tmode == TFM_ROTATION; const bool do_scale = tmode == TFM_RESIZE; That way you can use const bool instead of bool, and it's much simpler to see when a certain do_xxx is set or not. sybren: I think this is expressed in a clearer way like this:
```lang=c
const bool around_cursor =… | |||||
| bool changed = false; | |||||
| if (do_rot) { | |||||
| prop = RNA_struct_find_property(&ptr, "rotation"); | |||||
| changed |= ED_autokeyframe_property(C, scene, &ptr, prop, -1, CFRA, false); | |||||
| } | |||||
| if (do_loc) { | |||||
| prop = RNA_struct_find_property(&ptr, "offset_x"); | |||||
| changed |= ED_autokeyframe_property(C, scene, &ptr, prop, -1, CFRA, false); | |||||
| prop = RNA_struct_find_property(&ptr, "offset_y"); | |||||
| changed |= ED_autokeyframe_property(C, scene, &ptr, prop, -1, CFRA, false); | |||||
| } | |||||
| if (do_scale) { | |||||
| prop = RNA_struct_find_property(&ptr, "scale_x"); | |||||
| changed |= ED_autokeyframe_property(C, scene, &ptr, prop, -1, CFRA, false); | |||||
| prop = RNA_struct_find_property(&ptr, "scale_y"); | |||||
| changed |= ED_autokeyframe_property(C, scene, &ptr, prop, -1, CFRA, false); | |||||
| } | |||||
| return changed; | |||||
| } | |||||
| void recalcData_sequencer_image(TransInfo *t) | void recalcData_sequencer_image(TransInfo *t) | ||||
| { | { | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | ||||
| TransData *td = NULL; | TransData *td = NULL; | ||||
| TransData2D *td2d = NULL; | TransData2D *td2d = NULL; | ||||
| int i; | int i; | ||||
| for (i = 0, td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) { | for (i = 0, td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) { | ||||
| Show All 29 Lines | for (i = 0, td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) { | ||||
| /* Scale. */ | /* Scale. */ | ||||
| transform->scale_x = tdseq->orig_scale[0] * fabs(len_v2(handle_x)); | transform->scale_x = tdseq->orig_scale[0] * fabs(len_v2(handle_x)); | ||||
| transform->scale_y = tdseq->orig_scale[1] * fabs(len_v2(handle_y)); | transform->scale_y = tdseq->orig_scale[1] * fabs(len_v2(handle_y)); | ||||
| /* Rotation. Scaling can cause negative rotation. */ | /* Rotation. Scaling can cause negative rotation. */ | ||||
| if (t->mode == TFM_ROTATION) { | if (t->mode == TFM_ROTATION) { | ||||
| transform->rotation = tdseq->orig_rotation - t->values_final[0]; | transform->rotation = tdseq->orig_rotation - t->values_final[0]; | ||||
| } | } | ||||
| if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { | |||||
| animrecord_check_state(t, &t->scene->id); | |||||
| autokeyframe_sequencer_image(t->context, t->scene, transform, t->mode); | |||||
| } | |||||
| SEQ_relations_invalidate_cache_preprocessed(t->scene, seq); | SEQ_relations_invalidate_cache_preprocessed(t->scene, seq); | ||||
| } | } | ||||
| } | } | ||||
| void special_aftertrans_update__sequencer_image(bContext *UNUSED(C), TransInfo *t) | void special_aftertrans_update__sequencer_image(bContext *UNUSED(C), TransInfo *t) | ||||
| { | { | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | ||||
| TransData *td = NULL; | TransData *td = NULL; | ||||
| TransData2D *td2d = NULL; | TransData2D *td2d = NULL; | ||||
| int i; | int i; | ||||
| PointerRNA ptr; | |||||
| PropertyRNA *prop; | |||||
| for (i = 0, td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) { | for (i = 0, td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) { | ||||
| TransDataSeq *tdseq = td->extra; | TransDataSeq *tdseq = td->extra; | ||||
| Sequence *seq = tdseq->seq; | Sequence *seq = tdseq->seq; | ||||
| StripTransform *transform = seq->strip->transform; | StripTransform *transform = seq->strip->transform; | ||||
| if (t->state == TRANS_CANCEL) { | if (t->state == TRANS_CANCEL) { | ||||
| if (t->mode == TFM_ROTATION) { | if (t->mode == TFM_ROTATION) { | ||||
| transform->rotation = tdseq->orig_rotation; | transform->rotation = tdseq->orig_rotation; | ||||
| } | } | ||||
| continue; | continue; | ||||
| } | } | ||||
| Scene *scene = t->scene; | if (IS_AUTOKEY_ON(t->scene)) { | ||||
| RNA_pointer_create(&scene->id, &RNA_SequenceTransform, transform, &ptr); | autokeyframe_sequencer_image(t->context, t->scene, transform, t->mode); | ||||
| if (t->mode == TFM_ROTATION) { | |||||
| prop = RNA_struct_find_property(&ptr, "rotation"); | |||||
| ED_autokeyframe_property(t->context, scene, &ptr, prop, -1, CFRA); | |||||
| } | |||||
| if (t->mode == TFM_TRANSLATION) { | |||||
| prop = RNA_struct_find_property(&ptr, "offset_x"); | |||||
| ED_autokeyframe_property(t->context, scene, &ptr, prop, -1, CFRA); | |||||
| prop = RNA_struct_find_property(&ptr, "offset_y"); | |||||
| ED_autokeyframe_property(t->context, scene, &ptr, prop, -1, CFRA); | |||||
| } | |||||
| if (t->mode == TFM_RESIZE) { | |||||
| prop = RNA_struct_find_property(&ptr, "scale_x"); | |||||
| ED_autokeyframe_property(t->context, scene, &ptr, prop, -1, CFRA); | |||||
| prop = RNA_struct_find_property(&ptr, "scale_y"); | |||||
| ED_autokeyframe_property(t->context, scene, &ptr, prop, -1, CFRA); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
const