DNA: version patch Camera.drawsize to twice it's value
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Dec 2018 03:30:24 +0000 (14:30 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Dec 2018 03:42:50 +0000 (14:42 +1100)
Draw size represented half the actual size used.

source/blender/blenkernel/BKE_blender_version.h
source/blender/blenkernel/intern/camera.c
source/blender/blenloader/intern/versioning_280.c
source/blender/editors/space_view3d/view3d_gizmo_camera.c
source/blender/makesrna/intern/rna_camera.c

index 92ce2e6107ef54a1b7349b8887c0f9c59e63f8d8..a71987c20c514aa24e3e4267b23e9ffea881bad0 100644 (file)
@@ -28,7 +28,7 @@
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         280
-#define BLENDER_SUBVERSION      36
+#define BLENDER_SUBVERSION      37
 /* Several breakages with 280, e.g. collections vs layers */
 #define BLENDER_MINVERSION      280
 #define BLENDER_MINSUBVERSION   0
index 7457fc8b7ad0916ae97568973b1abf9ec08d2c17..ab9129e107a3348697463e5219fac8fe7dae64d7 100644 (file)
@@ -71,7 +71,7 @@ void BKE_camera_init(Camera *cam)
        cam->sensor_y = DEFAULT_SENSOR_HEIGHT;
        cam->clipsta = 0.1f;
        cam->clipend = 1000.0f;
-       cam->drawsize = 0.5f;
+       cam->drawsize = 1.0f;
        cam->ortho_scale = 6.0;
        cam->flag |= CAM_SHOWPASSEPARTOUT;
        cam->passepartalpha = 0.5f;
@@ -378,7 +378,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 * 2.0f) * scale[2];
+               depth = do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : -drawsize * scale[2];
 
                *r_drawsize = 0.5f * camera->ortho_scale;
        }
@@ -400,7 +400,7 @@ void BKE_camera_view_frame_ex(
                }
                else {
                        /* fixed size, variable depth (stays a reasonable size in the 3D view) */
-                       *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f);
+                       *r_drawsize = (drawsize / 2.0f) / ((scale[0] + scale[1] + scale[2]) / 3.0f);
                        depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2];
                        fac = *r_drawsize;
                        scale_x = scale[0];
index 188372ab4382cd0dc95472355a7bf0c5c13865aa..9e6f64586ae114ac4ee334d740a8cd20b9ae0af8 100644 (file)
@@ -2505,6 +2505,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 #endif
        }
 
+       if (!MAIN_VERSION_ATLEAST(bmain, 280, 37)) {
+               for (Camera *ca = bmain->camera.first; ca; ca = ca->id.next) {
+                       ca->drawsize *= 2.0f;
+               }
+       }
+
        {
                /* Versioning code until next subversion bump goes here. */
 
index 0dcffbbdcb0bfd6dbafecb78f7618a0ab99387b4..3c29d4c407ba8fe9645c76a4065f112f23d64ec7 100644 (file)
@@ -137,13 +137,6 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
        PointerRNA camera_ptr;
        float dir[3];
 
-       const float ob_scale_inv[3] = {
-               1.0f / len_v3(ob->obmat[0]),
-               1.0f / len_v3(ob->obmat[1]),
-               1.0f / len_v3(ob->obmat[2]),
-       };
-       const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f;
-
        RNA_pointer_create(&ca->id, &RNA_Camera, ca, &camera_ptr);
 
        negate_v3_v3(dir, ob->obmat[2]);
@@ -194,7 +187,13 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
                        scale_matrix = ca->ortho_scale * 0.5f;
                }
                else {
-                       scale_matrix = ca->drawsize / ob_scale_uniform_inv;
+                       const float ob_scale_inv[3] = {
+                               1.0f / len_v3(ob->obmat[0]),
+                               1.0f / len_v3(ob->obmat[1]),
+                               1.0f / len_v3(ob->obmat[2]),
+                       };
+                       const float ob_scale_uniform_inv = (ob_scale_inv[0] + ob_scale_inv[1] + ob_scale_inv[2]) / 3.0f;
+                       scale_matrix = (ca->drawsize * 0.5f) / ob_scale_uniform_inv;
                }
                mul_v3_fl(widget->matrix_basis[0], scale_matrix);
                mul_v3_fl(widget->matrix_basis[1], scale_matrix);
@@ -221,7 +220,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup)
 
                ED_gizmo_arrow3d_set_range_fac(
                        widget, is_ortho ?
-                       ((range / scale_matrix) * ca->drawsize) :
+                       ((range / ca->ortho_scale) * ca->drawsize) :
                        (scale_matrix * range /
                         /* Half sensor, intentionally use sensor from camera and not calculated above. */
                         (0.5f * ((sensor_fit == CAMERA_SENSOR_FIT_HOR) ? ca->sensor_x : ca->sensor_y))));
index aee14cd3185d4cce3a5f769750f62aa92e7d5181..1e68ab659655bcb48c2ba4f1448893f7aa31631a 100644 (file)
 #include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.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;
@@ -514,11 +502,7 @@ void RNA_def_camera(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update");
 
        prop = RNA_def_property(srna, "display_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_float_default(prop, 1.0f);
        RNA_def_property_range(prop, 0.01f, 1000.0f);
        RNA_def_property_ui_range(prop, 0.01, 100, 1, 2);