[Bf-blender-cvs] [eafe96a7185] blender2.8: Manipulator: empty image manipulator, use aspect
Campbell Barton
noreply at git.blender.org
Wed Aug 30 18:32:05 CEST 2017
Commit: eafe96a718529dc650888afc91cea14e35170953
Author: Campbell Barton
Date: Thu Aug 31 02:36:47 2017 +1000
Branches: blender2.8
https://developer.blender.org/rBeafe96a718529dc650888afc91cea14e35170953
Manipulator: empty image manipulator, use aspect
===================================================================
M source/blender/editors/space_view3d/view3d_manipulator_empty.c
===================================================================
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);
More information about the Bf-blender-cvs
mailing list