[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50186] trunk/blender/source/blender/ editors/mask/mask_add.c: use the zoom level to set the size for new mask point handle sizes ( artist request - handles were annoyingly bug when zoomed in)
Campbell Barton
ideasman42 at gmail.com
Fri Aug 24 16:00:39 CEST 2012
Revision: 50186
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50186
Author: campbellbarton
Date: 2012-08-24 14:00:39 +0000 (Fri, 24 Aug 2012)
Log Message:
-----------
use the zoom level to set the size for new mask point handle sizes (artist request - handles were annoyingly bug when zoomed in)
Modified Paths:
--------------
trunk/blender/source/blender/editors/mask/mask_add.c
Modified: trunk/blender/source/blender/editors/mask/mask_add.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_add.c 2012-08-24 13:29:48 UTC (rev 50185)
+++ trunk/blender/source/blender/editors/mask/mask_add.c 2012-08-24 14:00:39 UTC (rev 50186)
@@ -182,7 +182,8 @@
static void setup_vertex_point(const bContext *C, 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)
+ MaskSplinePoint *reference_point, const short reference_adjacent,
+ const float view_zoom)
{
ScrArea *sa = CTX_wm_area(C);
@@ -225,8 +226,8 @@
/* initial offset for handles */
if (spline->tot_point == 1) {
/* first point of splien is aligned horizontally */
- bezt->vec[0][0] -= len / width;
- bezt->vec[2][0] += len / width;
+ bezt->vec[0][0] -= len / maxi(width, height) * view_zoom;
+ bezt->vec[2][0] += len / maxi(width, height) * view_zoom;
}
else if (tangent) {
float vec[2];
@@ -391,7 +392,7 @@
new_point = &spline->points[point_index + 1];
- setup_vertex_point(C, mask, spline, new_point, co, tangent, u, NULL, TRUE);
+ setup_vertex_point(C, 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);
@@ -490,7 +491,7 @@
masklay->act_point = new_point;
- setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE);
+ setup_vertex_point(C, 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);
@@ -512,6 +513,7 @@
MaskSpline *spline;
MaskSplinePoint *point;
MaskSplinePoint *new_point = NULL, *ref_point = NULL;
+ float view_zoom;
if (!masklay) {
/* if there's no masklay currently operationg on, create new one */
@@ -536,8 +538,27 @@
masklay->act_point = new_point;
- setup_vertex_point(C, mask, spline, new_point, co, NULL, 0.5f, ref_point, FALSE);
+ {
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = CTX_wm_region(C);
+ /* 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_mouse_pos(sa, ar, mval_a, co_a);
+ ED_mask_mouse_pos(sa, ar, mval_b, co_b);
+
+ 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;
+ }
+
+ setup_vertex_point(C, 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);
BKE_mask_layer_shape_changed_add(masklay, BKE_mask_layer_shape_spline_to_index(masklay, spline) + point_index, TRUE, TRUE);
More information about the Bf-blender-cvs
mailing list