Merge branch 'blender-v4.2-release'

This commit is contained in:
Richard Antalik
2024-06-28 21:03:23 +02:00

View File

@@ -475,38 +475,22 @@ static void sequencer_image_crop_transform_matrix(const Sequence *seq,
const float preview_scale_factor,
float r_transform_matrix[4][4])
{
/* Center the image and scale it to expected size (downscale original media if needed). */
const StripTransform *transform = seq->strip->transform;
const float scale_x = transform->scale_x * image_scale_factor;
const float scale_y = transform->scale_y * 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;
float image_prescale_matrix[4][4];
float rotation_matrix[3][3];
unit_m3(rotation_matrix);
loc_rot_size_to_mat4(image_prescale_matrix,
float3{image_center_offs_x, image_center_offs_y, 0.0f},
rotation_matrix,
float3{image_scale_factor, image_scale_factor, 1.0f});
const float3 preview_scale_pivot{in->x * 0.5f, in->y * 0.5f, 0.0f};
transform_pivot_set_m4(image_prescale_matrix, preview_scale_pivot);
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[3] = {in->x * transform->origin[0], in->y * transform->origin[1], 0.0f};
/* Apply rest of transformations. */
float transform_matrix[4][4];
const StripTransform *transform = seq->strip->transform;
const float translate_x = transform->xofs * preview_scale_factor;
const float translate_y = transform->yofs * preview_scale_factor;
float rotation_matrix[3][3];
axis_angle_to_mat3_single(rotation_matrix, 'Z', transform->rotation);
loc_rot_size_to_mat4(transform_matrix,
loc_rot_size_to_mat4(r_transform_matrix,
float3{translate_x, translate_y, 0.0f},
rotation_matrix,
float3{transform->scale_x, transform->scale_y, 1.0f});
/* Calculate pivot point: Center of output buffer +/- half of prescaled input image. */
const float2 image_size{in->x * image_scale_factor, in->y * image_scale_factor};
const float2 origin_fac{transform->origin[0] - 0.5f, transform->origin[1] - 0.5f};
const float2 origin_rel = image_size * origin_fac;
const float3 pivot{out->x / 2 + origin_rel.x, out->y / 2 + origin_rel.y, 0.0f};
transform_pivot_set_m4(transform_matrix, pivot);
mul_m4_m4m4_aligned_scale(r_transform_matrix, transform_matrix, image_prescale_matrix);
float3{scale_x, scale_y, 1.0f});
transform_pivot_set_m4(r_transform_matrix, pivot);
invert_m4(r_transform_matrix);
}