[Bf-blender-cvs] [de7544202ab] blender2.8: Fix camera lens/ortho manipulator

Campbell Barton noreply at git.blender.org
Fri Oct 27 06:00:40 CEST 2017


Commit: de7544202ab968b1e9b6c529b09bc2616e0f4f00
Author: Campbell Barton
Date:   Fri Oct 27 14:57:02 2017 +1100
Branches: blender2.8
https://developer.blender.org/rBde7544202ab968b1e9b6c529b09bc2616e0f4f00

Fix camera lens/ortho manipulator

Update issues remain, require listening to notifiers.

===================================================================

M	source/blender/editors/space_view3d/view3d_manipulator_camera.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_manipulator_camera.c b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
index cac849bcb09..7d4a8820c9a 100644
--- a/source/blender/editors/space_view3d/view3d_manipulator_camera.c
+++ b/source/blender/editors/space_view3d/view3d_manipulator_camera.c
@@ -170,11 +170,6 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
 	/* TODO - make focal length/ortho scale widget optional */
 	if (true) {
 		const bool is_ortho = (ca->type == CAM_ORTHO);
-		const float scale[3] = {1.0f / len_v3(ob->obmat[0]), 1.0f / len_v3(ob->obmat[1]), 1.0f / len_v3(ob->obmat[2])};
-		const float scale_fac = ca->drawsize;
-		const float drawsize = is_ortho ?
-		        (0.5f * ca->ortho_scale) :
-		        (scale_fac / ((scale[0] + scale[1] + scale[2]) / 3.0f));
 		float offset[3];
 		float aspect[2];
 
@@ -196,13 +191,30 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmManipulatorGroup *mg
 		aspect[0] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? 1.0f : aspx / aspy;
 		aspect[1] = (sensor_fit == CAMERA_SENSOR_FIT_HOR) ? aspy / aspx : 1.0f;
 
+		unit_m4(widget->matrix_basis);
 		WM_manipulator_set_matrix_location(widget, ob->obmat[3]);
 		WM_manipulator_set_matrix_rotation_from_yz_axis(widget, ob->obmat[1], dir);
 
+		{
+			float scale_matrix;
+			if (is_ortho) {
+				scale_matrix = ca->ortho_scale * 0.5f;
+			}
+			else {
+				const float scale[3] = {
+					1.0f / len_v3(ob->obmat[0]),
+					1.0f / len_v3(ob->obmat[1]),
+					1.0f / len_v3(ob->obmat[2]),
+				};
+				scale_matrix = ca->drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
+			}
+			mul_v3_fl(widget->matrix_basis[0], scale_matrix);
+			mul_v3_fl(widget->matrix_basis[1], scale_matrix);
+		}
+
 		RNA_float_set_array(widget->ptr, "aspect", aspect);
 
 		WM_manipulator_set_matrix_offset_location(widget, offset);
-		WM_manipulator_set_scale(widget, drawsize);
 
 		/* need to set property here for undo. TODO would prefer to do this in _init */
 		WM_manipulator_target_property_def_rna(camgroup->focal_len, "offset", &camera_ptr, "lens", -1);
@@ -217,7 +229,6 @@ void VIEW3D_WGT_camera(wmManipulatorGroupType *wgt)
 
 	wgt->flag = (WM_MANIPULATORGROUPTYPE_PERSISTENT |
 	             WM_MANIPULATORGROUPTYPE_3D |
-	             WM_MANIPULATORGROUPTYPE_SCALE |
 	             WM_MANIPULATORGROUPTYPE_DEPTH_3D);
 
 	wgt->poll = WIDGETGROUP_camera_poll;



More information about the Bf-blender-cvs mailing list