Fix T52051: Orthographic camera display size error
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Dec 2018 02:02:39 +0000 (13:02 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Dec 2018 02:05:32 +0000 (13:05 +1100)
It was impractical to create a small orthographic camera with a usable
size in the view-port.

No longer scale the draw-size by ortho-size.

source/blender/blenkernel/intern/camera.c
source/blender/makesrna/intern/rna_camera.c

index bda26c958157233ed842d1ba5f8f7fb72c1a70cc..3e6e88c5f444a891cd1728954de602aa9528de7e 100644 (file)
@@ -401,7 +401,7 @@ void BKE_camera_view_frame_ex(
                facy = 0.5f * camera->ortho_scale * r_asp[1] * scale[1];
                r_shift[0] = camera->shiftx * camera->ortho_scale * scale[0];
                r_shift[1] = camera->shifty * camera->ortho_scale * scale[1];
-               depth = do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : -drawsize * camera->ortho_scale * scale[2];
+               depth = do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : -(drawsize * 2.0f) * scale[2];
 
                *r_drawsize = 0.5f * camera->ortho_scale;
        }
index 981ae75e7c5c059b9a6f983cb892c64d901968fe..c1a76b1627a408bdfafdb55d9b2ca87cc887a717 100644 (file)
 
 #include "WM_api.h"
 
+static float rna_Camera_draw_size_get(PointerRNA *ptr)
+{
+       Camera *cam = ptr->id.data;
+       return cam->drawsize * 2.0f;
+}
+
+static void rna_Camera_draw_size_set(PointerRNA *ptr, float value)
+{
+       Camera *cam = ptr->id.data;
+       cam->drawsize = value / 2.0f;
+}
+
 static float rna_Camera_angle_get(PointerRNA *ptr)
 {
        Camera *cam = ptr->id.data;
@@ -309,7 +321,11 @@ void RNA_def_camera(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
 
        prop = RNA_def_property(srna, "draw_size", PROP_FLOAT, PROP_DISTANCE);
+#if 0
        RNA_def_property_float_sdna(prop, NULL, "drawsize");
+#else
+       RNA_def_property_float_funcs(prop, "rna_Camera_draw_size_get", "rna_Camera_draw_size_set", NULL);
+#endif
        RNA_def_property_range(prop, 0.01f, 1000.0f);
        RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);
        RNA_def_property_ui_text(prop, "Draw Size", "Apparent size of the Camera object in the 3D View");