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:
authorRichard Antalik <richardantalik@gmail.com>2021-10-16 00:02:08 +0300
committerRichard Antalik <richardantalik@gmail.com>2021-10-16 00:20:45 +0300
commite11b33fec33392640e74b9f180572fc0a504287e (patch)
treefc5528eeac6e5239b6f48e01ec7db2ba07665db0 /source/blender/sequencer/intern
parent81514b0e913b03ab7fb6aa779d23a1d651ad82b7 (diff)
Remove math for 2D affine transform
Commit e1665c3d3190 added math to do 2D affine transformations with 3x3 matrices, but these matrices are also used for 3D transformations. Remove added functions and use 4x4 matrices for 2D transformation. Reviewed By: campbellbarton Differential Revision: https://developer.blender.org/D12510
Diffstat (limited to 'source/blender/sequencer/intern')
-rw-r--r--source/blender/sequencer/intern/render.c40
-rw-r--r--source/blender/sequencer/intern/strip_transform.c55
2 files changed, 53 insertions, 42 deletions
diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c
index 6b233cd20fb..4405253586b 100644
--- a/source/blender/sequencer/intern/render.c
+++ b/source/blender/sequencer/intern/render.c
@@ -403,7 +403,7 @@ static void sequencer_image_crop_transform_matrix(const Sequence *seq,
const ImBuf *out,
const float image_scale_factor,
const float preview_scale_factor,
- float r_transform_matrix[3][3])
+ float r_transform_matrix[4][4])
{
const StripTransform *transform = seq->strip->transform;
const float scale_x = transform->scale_x * image_scale_factor;
@@ -412,13 +412,16 @@ static void sequencer_image_crop_transform_matrix(const Sequence *seq,
const float image_center_offs_y = (out->y - in->y) / 2;
const float translate_x = transform->xofs * preview_scale_factor + image_center_offs_x;
const float translate_y = transform->yofs * preview_scale_factor + image_center_offs_y;
- const float pivot[2] = {in->x * transform->origin[0], in->y * transform->origin[1]};
- loc_rot_size_to_mat3(r_transform_matrix,
- (const float[]){translate_x, translate_y},
- transform->rotation,
- (const float[]){scale_x, scale_y});
- transform_pivot_set_m3(r_transform_matrix, pivot);
- invert_m3(r_transform_matrix);
+ const float pivot[3] = {in->x * transform->origin[0], in->y * transform->origin[1], 0.0f};
+
+ float rotation_matrix[3][3];
+ axis_angle_to_mat3_single(rotation_matrix, 'Z', transform->rotation);
+ loc_rot_size_to_mat4(r_transform_matrix,
+ (const float[]){translate_x, translate_y, 0.0f},
+ rotation_matrix,
+ (const float[]){scale_x, scale_y, 1.0f});
+ transform_pivot_set_m4(r_transform_matrix, pivot);
+ invert_m4(r_transform_matrix);
}
static void sequencer_image_crop_init(const Sequence *seq,
@@ -438,20 +441,23 @@ static void sequencer_image_crop_init(const Sequence *seq,
static void sequencer_thumbnail_transform(ImBuf *in, ImBuf *out)
{
float image_scale_factor = (float)out->x / in->x;
- float transform_matrix[3][3];
+ float transform_matrix[4][4];
/* Set to keep same loc,scale,rot but change scale to thumb size limit. */
const float scale_x = 1 * image_scale_factor;
const float scale_y = 1 * image_scale_factor;
const float image_center_offs_x = (out->x - in->x) / 2;
const float image_center_offs_y = (out->y - in->y) / 2;
- const float pivot[2] = {in->x / 2, in->y / 2};
- loc_rot_size_to_mat3(transform_matrix,
- (const float[]){image_center_offs_x, image_center_offs_y},
- 0,
- (const float[]){scale_x, scale_y});
- transform_pivot_set_m3(transform_matrix, pivot);
- invert_m3(transform_matrix);
+ const float pivot[3] = {in->x / 2, in->y / 2, 0.0f};
+
+ float rotation_matrix[3][3];
+ unit_m3(rotation_matrix);
+ loc_rot_size_to_mat4(transform_matrix,
+ (const float[]){image_center_offs_x, image_center_offs_y, 0.0f},
+ rotation_matrix,
+ (const float[]){scale_x, scale_y, 1.0f});
+ transform_pivot_set_m4(transform_matrix, pivot);
+ invert_m4(transform_matrix);
/* No crop. */
rctf source_crop;
@@ -471,7 +477,7 @@ static void sequencer_preprocess_transform_crop(
const bool do_scale_to_render_size = seq_need_scale_to_render_size(seq, is_proxy_image);
const float image_scale_factor = do_scale_to_render_size ? 1.0f : preview_scale_factor;
- float transform_matrix[3][3];
+ float transform_matrix[4][4];
sequencer_image_crop_transform_matrix(
seq, in, out, image_scale_factor, preview_scale_factor, transform_matrix);
diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c
index ec504c0c9b6..c70f8d646af 100644
--- a/source/blender/sequencer/intern/strip_transform.c
+++ b/source/blender/sequencer/intern/strip_transform.c
@@ -490,36 +490,41 @@ static void seq_image_transform_quad_get_ex(const Scene *scene,
image_size[1] = seq->strip->stripdata->orig_height;
}
- float transform_matrix[3][3];
- loc_rot_size_to_mat3(transform_matrix,
- (const float[]){transform->xofs, transform->yofs},
- apply_rotation ? transform->rotation : 0.0f,
- (const float[]){transform->scale_x, transform->scale_y});
+ float transform_matrix[4][4];
+
+ float rotation_matrix[3][3];
+ axis_angle_to_mat3_single(rotation_matrix, 'Z', apply_rotation ? transform->rotation : 0.0f);
+ loc_rot_size_to_mat4(transform_matrix,
+ (const float[]){transform->xofs, transform->yofs, 0.0f},
+ rotation_matrix,
+ (const float[]){transform->scale_x, transform->scale_y, 1.0f});
const float origin[2] = {image_size[0] * transform->origin[0],
image_size[1] * transform->origin[1]};
- const float pivot[2] = {origin[0] - (image_size[0] / 2), origin[1] - (image_size[1] / 2)};
- transform_pivot_set_m3(transform_matrix, pivot);
-
- r_quad[0][0] = (image_size[0] / 2) - crop->right;
- r_quad[0][1] = (image_size[1] / 2) - crop->top;
- r_quad[1][0] = (image_size[0] / 2) - crop->right;
- r_quad[1][1] = (-image_size[1] / 2) + crop->bottom;
- r_quad[2][0] = (-image_size[0] / 2) + crop->left;
- r_quad[2][1] = (-image_size[1] / 2) + crop->bottom;
- r_quad[3][0] = (-image_size[0] / 2) + crop->left;
- r_quad[3][1] = (image_size[1] / 2) - crop->top;
-
- mul_m3_v2(transform_matrix, r_quad[0]);
- mul_m3_v2(transform_matrix, r_quad[1]);
- mul_m3_v2(transform_matrix, r_quad[2]);
- mul_m3_v2(transform_matrix, r_quad[3]);
+ const float pivot[3] = {origin[0] - (image_size[0] / 2), origin[1] - (image_size[1] / 2), 0.0f};
+ transform_pivot_set_m4(transform_matrix, pivot);
+
+ float quad_temp[4][3];
+ for (int i = 0; i < 4; i++) {
+ zero_v2(quad_temp[i]);
+ }
+
+ quad_temp[0][0] = (image_size[0] / 2) - crop->right;
+ quad_temp[0][1] = (image_size[1] / 2) - crop->top;
+ quad_temp[1][0] = (image_size[0] / 2) - crop->right;
+ quad_temp[1][1] = (-image_size[1] / 2) + crop->bottom;
+ quad_temp[2][0] = (-image_size[0] / 2) + crop->left;
+ quad_temp[2][1] = (-image_size[1] / 2) + crop->bottom;
+ quad_temp[3][0] = (-image_size[0] / 2) + crop->left;
+ quad_temp[3][1] = (image_size[1] / 2) - crop->top;
float mirror[2];
SEQ_image_transform_mirror_factor_get(seq, mirror);
- mul_v2_v2(r_quad[0], mirror);
- mul_v2_v2(r_quad[1], mirror);
- mul_v2_v2(r_quad[2], mirror);
- mul_v2_v2(r_quad[3], mirror);
+
+ for (int i = 0; i < 4; i++) {
+ mul_m4_v3(transform_matrix, quad_temp[i]);
+ mul_v2_v2(quad_temp[i], mirror);
+ copy_v2_v2(r_quad[i], quad_temp[i]);
+ }
}
void SEQ_image_transform_quad_get(const Scene *scene,