Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2021-10-08 13:09:27 +0300
committerSebastian Parborg <darkdefende@gmail.com>2021-10-08 13:14:45 +0300
commit482806c81678e351ff171c68a757386a5b2d4676 (patch)
tree7f9b1dfccb0683584af937ec77b440cb6ccaa413 /source/blender/editors/transform/transform_convert_sequencer_image.c
parenta3e2cc0bb7fe47fa1122cd19c4fa8a5aa59f761c (diff)
VSE: Implement the bounding box (xform) tool in the seq preview window
Make the "xform" tool/gizmo available for strip transformations in the sequencer preview window. Because of the amount of hacks needed to make the gizmo work nicely with multiple strips at the same time, it was decided to only show the translate gizmo when multiple strips are selected. This is because the transforms with multiple strips would appear buggy because of our lack of shearing support in the transform system. There is also currently no way to properly sync the gizmo drawing with the transform when using multiple strips. Reviewed By: Richard Antalik, Campbell Barton Differential Revision: http://developer.blender.org/D12729
Diffstat (limited to 'source/blender/editors/transform/transform_convert_sequencer_image.c')
-rw-r--r--source/blender/editors/transform/transform_convert_sequencer_image.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/source/blender/editors/transform/transform_convert_sequencer_image.c b/source/blender/editors/transform/transform_convert_sequencer_image.c
index 6e3f12de472..2b5ed268504 100644
--- a/source/blender/editors/transform/transform_convert_sequencer_image.c
+++ b/source/blender/editors/transform/transform_convert_sequencer_image.c
@@ -64,12 +64,16 @@ static TransData *SeqToTransData(const Scene *scene,
SEQ_image_transform_origin_offset_pixelspace_get(scene, seq, origin);
float vertex[2] = {origin[0], origin[1]};
- /* Add control vertex, so rotation and scale can be calculated. */
+ /* Add control vertex, so rotation and scale can be calculated.
+ * All three vertices will form a "L" shape that is aligned to the local strip axis.
+ */
if (vert_index == 1) {
- vertex[0] += 1.0f;
+ vertex[0] += cosf(transform->rotation);
+ vertex[1] += sinf(transform->rotation);
}
else if (vert_index == 2) {
- vertex[1] += 1.0f;
+ vertex[0] -= sinf(transform->rotation);
+ vertex[1] += cosf(transform->rotation);
}
td2d->loc[0] = vertex[0];
@@ -81,10 +85,12 @@ static TransData *SeqToTransData(const Scene *scene,
td->center[0] = origin[0];
td->center[1] = origin[1];
- memset(td->axismtx, 0, sizeof(td->axismtx));
- td->axismtx[2][2] = 1.0f;
unit_m3(td->mtx);
unit_m3(td->smtx);
+ unit_m3(td->axismtx);
+
+ rotate_m3(td->axismtx, transform->rotation);
+ normalize_m3(td->axismtx);
tdseq->seq = seq;
copy_v2_v2(tdseq->orig_origin_position, origin);
@@ -159,18 +165,18 @@ void recalcData_sequencer_image(TransInfo *t)
for (i = 0, td = tc->data, td2d = tc->data_2d; i < tc->data_len; i++, td++, td2d++) {
/* Origin. */
- float loc[2];
- copy_v2_v2(loc, td2d->loc);
+ float origin[2];
+ copy_v2_v2(origin, td2d->loc);
i++, td++, td2d++;
/* X and Y control points used to read scale and rotation. */
float handle_x[2];
copy_v2_v2(handle_x, td2d->loc);
- sub_v2_v2(handle_x, loc);
+ sub_v2_v2(handle_x, origin);
i++, td++, td2d++;
float handle_y[2];
copy_v2_v2(handle_y, td2d->loc);
- sub_v2_v2(handle_y, loc);
+ sub_v2_v2(handle_y, origin);
TransDataSeq *tdseq = td->extra;
Sequence *seq = tdseq->seq;
@@ -181,8 +187,9 @@ void recalcData_sequencer_image(TransInfo *t)
/* Calculate translation. */
float translation[2];
copy_v2_v2(translation, tdseq->orig_origin_position);
- sub_v2_v2(translation, loc);
+ sub_v2_v2(translation, origin);
mul_v2_v2(translation, mirror);
+
transform->xofs = tdseq->orig_translation[0] - translation[0];
transform->yofs = tdseq->orig_translation[1] - translation[1];
@@ -192,7 +199,8 @@ void recalcData_sequencer_image(TransInfo *t)
/* Rotation. Scaling can cause negative rotation. */
if (t->mode == TFM_ROTATION) {
- float rotation = angle_signed_v2v2(handle_x, (float[]){1, 0}) * mirror[0] * mirror[1];
+ const float orig_dir[2] = {cosf(tdseq->orig_rotation), sinf(tdseq->orig_rotation)};
+ float rotation = angle_signed_v2v2(handle_x, orig_dir) * mirror[0] * mirror[1];
transform->rotation = tdseq->orig_rotation + rotation;
transform->rotation += DEG2RAD(360.0);
transform->rotation = fmod(transform->rotation, DEG2RAD(360.0));