[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30861] branches/soc-2010-nicolasbishop/ source/blender/editors/sculpt_paint: == VPaint ==
Nicholas Bishop
nicholasbishop at gmail.com
Thu Jul 29 05:20:38 CEST 2010
Revision: 30861
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30861
Author: nicholasbishop
Date: 2010-07-29 05:20:37 +0200 (Thu, 29 Jul 2010)
Log Message:
-----------
== VPaint ==
More fixes and cleanups
* Removed unused parameters in vpaint
* Use more of paint stroke in vpaint
* Partial fix of anchored brush in vpaint, doesn't restore colors yet though
* Fixed smooth stroke
TODO:
* Color restore for vpaint
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-29 02:29:32 UTC (rev 30860)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-29 03:20:37 UTC (rev 30861)
@@ -1061,7 +1061,7 @@
}
}
else
- copy_v3_v3(stroke->mouse, mouse_in);
+ copy_v2_v2(stroke->mouse, mouse_in);
if(stroke->first_dab ||
!((stroke->brush->flag & BRUSH_ANCHORED) ||
@@ -1154,7 +1154,7 @@
pressure = brush_use_size_pressure(stroke->brush) ? wmtab->Pressure : 1;
}
- scale = (stroke->pixel_radius * pressure * stroke->brush->spacing/50.0f) / length;
+ scale = (brush_size(stroke->brush) * pressure * stroke->brush->spacing/50.0f) / length;
mul_v2_fl(vec, scale);
steps = (int)(1.0f / scale);
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c 2010-07-29 02:29:32 UTC (rev 30860)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c 2010-07-29 03:20:37 UTC (rev 30861)
@@ -1586,48 +1586,17 @@
IMB_blend_color_float(col, col, brush->rgb, alpha, tool);
}
-static float tex_strength(Brush *brush, PaintStroke *stroke,
- float co[3], float mask, float dist,
- float radius3d)
-{
- return paint_stroke_combined_strength(stroke, dist, co, mask);
-}
-
-/* apply paint at specified coordinate
- returns 1 if paint was applied, 0 otherwise */
-static int vpaint_paint_coord(Brush *brush, PaintStroke *stroke,
- float co[3], float col[4],
- float center[3], float radius,
- float radius_squared, float mask)
-{
- float strength, dist, dist_squared;
-
- dist_squared = len_squared_v3v3(center, co);
-
- if(dist_squared < radius_squared) {
- dist = sqrtf(dist_squared);
-
- strength = brush->alpha *
- tex_strength(brush, stroke, co, mask, dist, radius);
-
- vpaint_blend(brush, col, strength);
-
- return 1;
- }
-
- return 0;
-}
-
static void vpaint_nodes_grids(Brush *brush, PaintStroke *stroke,
DMGridData **grids, CustomData *vdata,
GridKey *gridkey,
int *grid_indices, int totgrid,
- int gridsize, int active, float center[3],
- float radius)
+ int gridsize, int active)
{
- float radius_squared = radius*radius;
+ PaintStrokeTest test;
int i, x, y;
+ paint_stroke_test_init(&test, stroke);
+
for(i = 0; i < totgrid; ++i) {
DMGridData *grid = grids[grid_indices[i]];
@@ -1642,11 +1611,14 @@
gridkey,
vdata);
- vpaint_paint_coord(brush, stroke, co,
- gridcol,
- center, radius,
- radius_squared,
- mask);
+ if(paint_stroke_test(&test, co)) {
+ float strength;
+
+ strength = brush->alpha *
+ paint_stroke_combined_strength(stroke, test.dist, co, mask);
+
+ vpaint_blend(brush, gridcol, strength);
+ }
}
}
}
@@ -1655,10 +1627,9 @@
static void vpaint_nodes_faces(Brush *brush, PaintStroke *stroke,
MFace *mface, MVert *mvert,
CustomData *vdata, CustomData *fdata,
- int *face_indices, int totface, float center[3],
- float radius)
+ int *face_indices, int totface)
{
- float radius_squared = radius*radius;
+ PaintStrokeTest test;
MCol *mcol;
int pmask_totlayer, pmask_first_layer;
int i, j;
@@ -1667,6 +1638,8 @@
pmask_totlayer = CustomData_number_of_layers(vdata, CD_PAINTMASK);
pmask_first_layer = CustomData_get_layer_index(vdata, CD_PAINTMASK);
+ paint_stroke_test_init(&test, stroke);
+
for(i = 0; i < totface; ++i) {
int face_index = face_indices[i];
MFace *f = mface + face_index;
@@ -1687,10 +1660,15 @@
mask = paint_mask_from_vertex(vdata, vndx,
pmask_totlayer,
pmask_first_layer);
+ if(paint_stroke_test(&test, co)) {
+ float strength;
+
+ strength = brush->alpha *
+ paint_stroke_combined_strength(stroke, test.dist, co, mask);
+
+ vpaint_blend(brush, fcol, strength);
+ }
- vpaint_paint_coord(brush, stroke, co, fcol, center,
- radius, radius_squared, mask);
-
mcol[cndx].b = fcol[0] * 255.0f;
mcol[cndx].g = fcol[1] * 255.0f;
mcol[cndx].r = fcol[2] * 255.0f;
@@ -1703,11 +1681,13 @@
DMGridData **grids, CustomData *vdata,
GridKey *gridkey,
int *grid_indices, int totgrid,
- int gridsize, int active, float center[3],
- float radius, float radius_squared)
+ int gridsize, int active)
{
+ PaintStrokeTest test;
int i, j, x, y, x2, y2;
+ paint_stroke_test_init(&test, stroke);
+
/* TODO: this could be better optimized like sculpt,
just doing the simplest smooth for now */
@@ -1718,19 +1698,16 @@
for(x = 0; x < gridsize; ++x) {
float avg_col[4] = {0, 0, 0, 0};
float *act_col, strength, mask;
- float *co, dist_squared, dist;
+ float *co;
int totcol = 0;
act_elem = GRIDELEM_AT(grid, y*gridsize + x, gridkey);
co = GRIDELEM_CO(act_elem, gridkey);
- dist_squared = len_squared_v3v3(center, co);
- if(dist_squared > radius_squared)
+ if(!paint_stroke_test(&test, co))
continue;
- dist = sqrtf(dist_squared);
-
for(y2 = -1; y2 <= 1; y2+=2) {
if(y + y2 < 0 || y + y2 >= gridsize)
continue;
@@ -1751,9 +1728,7 @@
gridkey,
vdata);
strength = brush->alpha *
- tex_strength(brush, stroke,
- co, mask,
- dist, radius);
+ paint_stroke_combined_strength(stroke, test.dist, co, mask);
act_col = GRIDELEM_COLOR(act_elem, gridkey)[active];
for(j = 0; j < 4; ++j)
act_col[j] = interpf(avg_col[j] / totcol, act_col[j], strength);
@@ -1767,9 +1742,7 @@
static void vpaint_nodes_faces_smooth(Brush *brush, PaintStroke *stroke,
PBVH *pbvh, PBVHNode *node,
MFace *mface,
- CustomData *fdata, ListBase *fmap,
- float center[3],
- float radius, float radius_squared)
+ CustomData *fdata, ListBase *fmap)
{
PBVHVertexIter vd;
PaintStrokeTest test;
@@ -1820,10 +1793,10 @@
continue;
strength = brush->alpha *
- tex_strength(brush, stroke,
- vd.co,
- vd.mask_combined,
- test.dist, radius);
+ paint_stroke_combined_strength(stroke,
+ test.dist,
+ vd.co,
+ vd.mask_combined);
for(j = 0; j < 4; ++j) {
unsigned char *c;
@@ -1862,8 +1835,7 @@
static void vpaint_nodes(VPaint *vp, PaintStroke *stroke,
Scene *scene, Object *ob,
- PBVHNode **nodes, int totnode,
- float center[3], float radius)
+ PBVHNode **nodes, int totnode)
{
PBVH *pbvh = ob->paint->pbvh;
Brush *brush = paint_brush(&vp->paint);
@@ -1897,8 +1869,7 @@
grid_indices,
totgrid,
gridsize,
- active, center,
- radius, radius*radius);
+ active);
BLI_pbvh_node_set_flags(nodes[n],
SET_INT_IN_POINTER(PBVH_NeedsColorStitch));
}
@@ -1909,8 +1880,7 @@
grid_indices,
totgrid,
gridsize,
- active, center,
- radius);
+ active);
}
}
}
@@ -1933,15 +1903,14 @@
vpaint_nodes_faces_smooth(brush, stroke,
pbvh, nodes[n],
mface, fdata,
- fmap, center,
- radius, radius*radius);
+ fmap);
}
else {
vpaint_nodes_faces(brush, stroke,
mface, mvert,
vdata, fdata,
- face_indices, totface,
- center, radius);
+ face_indices,
+ totface);
}
}
@@ -2128,8 +2097,7 @@
brush->alpha);
}
else {
- vpaint_nodes(vp, stroke, scene, ob, nodes, totnode,
- center, radius);
+ vpaint_nodes(vp, stroke, scene, ob, nodes, totnode);
}
if(nodes)
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c 2010-07-29 02:29:32 UTC (rev 30860)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c 2010-07-29 03:20:37 UTC (rev 30861)
@@ -177,7 +177,6 @@
Brush *brush;
float (*face_norms)[3]; /* Copy of the mesh faces' normals */
- float special_rotation; /* Texture rotation (radians) for anchored and rake modes */
float grab_delta[3], grab_delta_symmetry[3];
float old_grab_location[3], orig_grab_location[3];
@@ -2385,7 +2384,6 @@
if(!(brush->flag & BRUSH_ACCUMULATE))
cache->original = 1;
- cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0;
//cache->last_rake[0] = sd->last_x;
//cache->last_rake[1] = sd->last_y;
More information about the Bf-blender-cvs
mailing list