Revision: 50202
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50202
Author:   campbellbarton
Date:     2012-08-25 14:18:54 +0000 (Sat, 25 Aug 2012)
Log Message:
-----------
better handle sizes by default for mask mode, now ignore image width/height

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy/utils.py
    trunk/blender/source/blender/editors/mask/mask_add.c

Modified: trunk/blender/release/scripts/modules/bpy/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy/utils.py  2012-08-25 14:07:51 UTC 
(rev 50201)
+++ trunk/blender/release/scripts/modules/bpy/utils.py  2012-08-25 14:18:54 UTC 
(rev 50202)
@@ -34,6 +34,8 @@
     "register_class",
     "register_module",
     "register_manual_map",
+    "unregister_manual_map",
+    "manual_map",
     "resource_path",
     "script_path_user",
     "script_path_pref",

Modified: trunk/blender/source/blender/editors/mask/mask_add.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_add.c        2012-08-25 
14:07:51 UTC (rev 50201)
+++ trunk/blender/source/blender/editors/mask/mask_add.c        2012-08-25 
14:18:54 UTC (rev 50202)
@@ -180,25 +180,20 @@
 
 /******************** add vertex *********************/
 
-static void setup_vertex_point(const bContext *C, Mask *mask, MaskSpline 
*spline, MaskSplinePoint *new_point,
+static void setup_vertex_point(Mask *mask, MaskSpline *spline, MaskSplinePoint 
*new_point,
                                const float point_co[2], const float 
tangent[2], const float u,
                                MaskSplinePoint *reference_point, const short 
reference_adjacent,
                                const float view_zoom)
 {
-       ScrArea *sa = CTX_wm_area(C);
-
        MaskSplinePoint *prev_point = NULL;
        MaskSplinePoint *next_point = NULL;
        BezTriple *bezt;
-       int width, height;
        float co[3];
-       const float len = 20.0; /* default length of handle in pixel space */
+       const float len = 10.0; /* default length of handle in pixel space */
 
        copy_v2_v2(co, point_co);
        co[2] = 0.0f;
 
-       ED_mask_get_size(sa, &width, &height);
-
        /* point coordinate */
        bezt = &new_point->bezt;
 
@@ -226,22 +221,16 @@
        /* initial offset for handles */
        if (spline->tot_point == 1) {
                /* first point of splien is aligned horizontally */
-               bezt->vec[0][0] -= len / maxi(width, height) * view_zoom;
-               bezt->vec[2][0] += len / maxi(width, height) * view_zoom;
+               bezt->vec[0][0] -= len * view_zoom;
+               bezt->vec[2][0] += len * view_zoom;
        }
        else if (tangent) {
                float vec[2];
 
                copy_v2_v2(vec, tangent);
 
-               vec[0] *= width;
-               vec[1] *= height;
+               mul_v2_fl(vec, len);
 
-               mul_v2_fl(vec, len / len_v2(vec));
-
-               vec[0] /= width;
-               vec[1] /= height;
-
                sub_v2_v2(bezt->vec[0], vec);
                add_v2_v2(bezt->vec[2], vec);
 
@@ -392,7 +381,7 @@
 
                new_point = &spline->points[point_index + 1];
 
-               setup_vertex_point(C, mask, spline, new_point, co, tangent, u, 
NULL, TRUE, 1.0f);
+               setup_vertex_point(mask, spline, new_point, co, tangent, u, 
NULL, TRUE, 1.0f);
 
                /* TODO - we could pass the spline! */
                BKE_mask_layer_shape_changed_add(masklay, 
BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index + 1, TRUE, 
TRUE);
@@ -491,7 +480,7 @@
 
        masklay->act_point = new_point;
 
-       setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, 
ref_point, FALSE, 1.0f);
+       setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, 
FALSE, 1.0f);
 
        if (masklay->splines_shapes.first) {
                point_index = (((int)(new_point - spline->points) + 0) % 
spline->tot_point);
@@ -542,22 +531,18 @@
                ScrArea *sa = CTX_wm_area(C);
                ARegion *ar = CTX_wm_region(C);
 
+               float zoom_x, zoom_y;
                /* calc view zoom in a simplistic way */
-               float co_a[2];
-               float co_b[2];
-               int mval_a[2] = {0, 0};
-               int mval_b[2] = {1, 1};
+               ED_mask_zoom(sa, ar, &zoom_x, &zoom_y);
 
-               ED_mask_mouse_pos(sa, ar, mval_a, co_a);
-               ED_mask_mouse_pos(sa, ar, mval_b, co_b);
+               view_zoom = zoom_x + zoom_y / 2.0f;
+               view_zoom = 1.0f / view_zoom;
 
-               view_zoom = ((co_b[0] - co_a[0]) + (co_b[1] - co_a[1])) / 2.0f;
-
-               /* scale up - arbitrarty but works well in the view */
-               view_zoom *= 200.0f;
+               /* arbitrary but gives good results */
+               view_zoom /= 500.0f;
        }
 
-       setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, 
ref_point, FALSE, view_zoom);
+       setup_vertex_point(mask, spline, new_point, co, NULL, 0.5f, ref_point, 
FALSE, view_zoom);
 
        {
                int point_index = (((int)(new_point - spline->points) + 0) % 
spline->tot_point);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to