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:
authorCampbell Barton <ideasman42@gmail.com>2017-08-30 19:36:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-08-30 19:38:16 +0300
commiteafe96a718529dc650888afc91cea14e35170953 (patch)
tree1b02bd25ae5e16b16dd553beb629fbfc2a72b4c9 /source/blender/editors/space_view3d/view3d_manipulator_empty.c
parent00ba48a6997d5421a899101b696e5f86c0bdef0a (diff)
Manipulator: empty image manipulator, use aspect
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_manipulator_empty.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_manipulator_empty.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/source/blender/editors/space_view3d/view3d_manipulator_empty.c b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
index 4c5f3c259f7..1d56c5ee7f4 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_empty.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_empty.c
@@ -147,12 +147,22 @@ static void WIDGETGROUP_empty_image_refresh(const bContext *C, wmManipulatorGrou
/* Use dimensions for aspect. */
if (ob->data != NULL) {
+ const Image *image = ob->data;
ImageUser iuser = *ob->iuser;
- int w, h;
- BKE_image_get_size(ob->data, &iuser, &w, &h);
- const float dims_max = max_ff(w, h);
- imgroup->state.dims[0] = (float)w / dims_max;
- imgroup->state.dims[1] = (float)h / dims_max;
+ float size[2];
+ BKE_image_get_size_fl(ob->data, &iuser, size);
+
+ /* Get the image aspect even if the buffer is invalid */
+ if (image->aspx > image->aspy) {
+ size[1] *= image->aspy / image->aspx;
+ }
+ else if (image->aspx < image->aspy) {
+ size[0] *= image->aspx / image->aspy;
+ }
+
+ const float dims_max = max_ff(size[0], size[1]);
+ imgroup->state.dims[0] = size[0] / dims_max;
+ imgroup->state.dims[1] = size[1] / dims_max;
}
else {
copy_v2_fl(imgroup->state.dims, 1.0f);