diff options
author | Falk David <falkdavid@gmx.de> | 2021-01-19 05:20:02 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-01-19 05:20:02 +0300 |
commit | d31dd1da805b28660c85145300957ba8028acaad (patch) | |
tree | 4f4ffb1cba45b777bb722f714a8b9c671cb39238 /source/blender/editors/space_view3d/view3d_placement.c | |
parent | 58e554a55c66bbb8f83351d4e50d2a86908cb0dd (diff) |
Fix T84824: Incorrect height using interactive add tool
When using the interactive add tool for primitives with a fixed
height and base aspect ratio, the height of the created primitive
would be incorrect (two times too small or two times too big).
When the base origin was centered, the `fixed_aspect_dimension`
was not changed even though the base length was doubled.
Additionally, when the height origin was centered but the height
aspect ratio was fixed, the height was doubled leading to an
incorrect size.
The fix doubles `fixed_aspect_dimension` when the base origin is
centered and correctly calculates the height of the primitive when
the aspect ratio is set to fixed.
Ref D10140
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_placement.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_placement.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index 31032eab547..0700b47dbde 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -610,11 +610,12 @@ static bool calc_bbox(struct InteractivePlaceData *ipd, BoundBox *bounds) /* Use a copy in case aspect was applied to the quad. */ float base_co_dst[3]; copy_v3_v3(base_co_dst, quad_base[2]); - for (int i = 0; i < 4; i++) { + for (int i = 0; i < ARRAY_SIZE(quad_base); i++) { sub_v3_v3(quad_base[i], base_co_dst); mul_v3_fl(quad_base[i], 2.0f); add_v3_v3(quad_base[i], base_co_dst); } + fixed_aspect_dimension *= 2.0f; } /* *** Secondary *** */ @@ -634,10 +635,18 @@ static bool calc_bbox(struct InteractivePlaceData *ipd, BoundBox *bounds) } if (ipd->step[1].is_centered) { + float temp_delta[3]; + if (ipd->step[1].is_fixed_aspect) { + mul_v3_v3fl(temp_delta, delta_local, 0.5f); + } + else { + copy_v3_v3(temp_delta, delta_local); + mul_v3_fl(delta_local, 2.0f); + } + for (int i = 0; i < ARRAY_SIZE(quad_base); i++) { - sub_v3_v3(quad_base[i], delta_local); + sub_v3_v3(quad_base[i], temp_delta); } - mul_v3_fl(delta_local, 2.0f); } if ((ipd->step_index == STEP_DEPTH) && |