[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25461] trunk/blender/source/blender/ editors/sculpt_paint/sculpt.c: Bugfix: sculpt brush size was computed wrong in perspective view with
Brecht Van Lommel
brecht at blender.org
Fri Dec 18 12:26:28 CET 2009
Revision: 25461
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25461
Author: blendix
Date: 2009-12-18 12:26:26 +0100 (Fri, 18 Dec 2009)
Log Message:
-----------
Bugfix: sculpt brush size was computed wrong in perspective view with
scaled/translated objects.
Modified Paths:
--------------
trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2009-12-18 09:50:14 UTC (rev 25460)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c 2009-12-18 11:26:26 UTC (rev 25461)
@@ -1633,13 +1633,19 @@
/**** Operator for applying a stroke (various attributes including mouse path)
using the current brush. ****/
-static float unproject_brush_radius(ViewContext *vc, float center[3], float offset)
+static float unproject_brush_radius(Object *ob, ViewContext *vc, float center[3], float offset)
{
- float delta[3];
+ float delta[3], scale, loc[3];
- initgrabz(vc->rv3d, center[0], center[1], center[2]);
+ mul_v3_m4v3(loc, ob->obmat, center);
+
+ initgrabz(vc->rv3d, loc[0], loc[1], loc[2]);
window_to_3d_delta(vc->ar, delta, offset, 0);
- return len_v3(delta);
+
+ scale= fabsf(mat4_to_scale(ob->obmat));
+ scale= (scale == 0.0f)? 1.0f: scale;
+
+ return len_v3(delta)/scale;
}
static void sculpt_cache_free(StrokeCache *cache)
@@ -1738,7 +1744,7 @@
cache->pixel_radius = brush->size;
if(cache->first_time)
- cache->initial_radius = unproject_brush_radius(cache->vc, cache->true_location, brush->size);
+ cache->initial_radius = unproject_brush_radius(ss->ob, cache->vc, cache->true_location, brush->size);
if(brush->flag & BRUSH_SIZE_PRESSURE) {
cache->pixel_radius *= cache->pressure;
@@ -1754,7 +1760,7 @@
dx = cache->mouse[0] - cache->initial_mouse[0];
dy = cache->mouse[1] - cache->initial_mouse[1];
cache->pixel_radius = sqrt(dx*dx + dy*dy);
- cache->radius = unproject_brush_radius(paint_stroke_view_context(stroke),
+ cache->radius = unproject_brush_radius(ss->ob, paint_stroke_view_context(stroke),
cache->true_location, cache->pixel_radius);
cache->rotation = atan2(dy, dx);
}
More information about the Bf-blender-cvs
mailing list