From fde88ad9d2fc93caa6c3cc39d4c009a0c9bac7c5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 9 Jul 2019 20:07:08 -0300 Subject: Fix T66627: Multiobject Edit UV constraint to image bounds This was broken since the original commit to handle multi-object editing: rBbfc9d426bb95. --- .../editors/transform/transform_conversions.c | 76 +++++++++++----------- 1 file changed, 37 insertions(+), 39 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 1b5ac66644d..27a2ab85127 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3710,50 +3710,48 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize) for (a = 0, td = tc->data; a < tc->data_len; a++, td++) { minmax_v2v2_v2(min, max, td->loc); } + } - if (resize) { - if (min[0] < 0.0f && t->center_global[0] > 0.0f && - t->center_global[0] < t->aspect[0] * 0.5f) { - vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]); - } - else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) { - vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]); - } - else { - clipx = 0; - } + if (resize) { + if (min[0] < 0.0f && t->center_global[0] > 0.0f && t->center_global[0] < t->aspect[0] * 0.5f) { + vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]); + } + else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) { + vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]); + } + else { + clipx = 0; + } - if (min[1] < 0.0f && t->center_global[1] > 0.0f && - t->center_global[1] < t->aspect[1] * 0.5f) { - vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]); - } - else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) { - vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]); - } - else { - clipy = 0; - } + if (min[1] < 0.0f && t->center_global[1] > 0.0f && t->center_global[1] < t->aspect[1] * 0.5f) { + vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]); + } + else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) { + vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]); } else { - if (min[0] < 0.0f) { - vec[0] -= min[0]; - } - else if (max[0] > t->aspect[0]) { - vec[0] -= max[0] - t->aspect[0]; - } - else { - clipx = 0; - } + clipy = 0; + } + } + else { + if (min[0] < 0.0f) { + vec[0] -= min[0]; + } + else if (max[0] > t->aspect[0]) { + vec[0] -= max[0] - t->aspect[0]; + } + else { + clipx = 0; + } - if (min[1] < 0.0f) { - vec[1] -= min[1]; - } - else if (max[1] > t->aspect[1]) { - vec[1] -= max[1] - t->aspect[1]; - } - else { - clipy = 0; - } + if (min[1] < 0.0f) { + vec[1] -= min[1]; + } + else if (max[1] > t->aspect[1]) { + vec[1] -= max[1] - t->aspect[1]; + } + else { + clipy = 0; } } -- cgit v1.2.3