[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37357] branches/soc-2011-onion: Revision: 30702
Jason Wilkins
Jason.A.Wilkins at gmail.com
Fri Jun 10 07:10:18 CEST 2011
Revision: 37357
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37357
Author: jwilkins
Date: 2011-06-10 05:10:17 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
Revision: 30702
Author: nicholasbishop
Date: 8:36:47 PM, Saturday, July 24, 2010
Message:
== VPaint ==
* Updated non VP_AREA painting for both regular and multires meshes. Still looks bad because of drawing issues though.
Modified Paths:
--------------
branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
Property Changed:
----------------
branches/soc-2011-onion/
Property changes on: branches/soc-2011-onion
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693,30696,30699-30701,30742
/trunk/blender:36833-37206
+ /branches/soc-2010-jwilkins:28499-37009
/branches/soc-2010-nicolasbishop:28448-30676,30692-30693,30696,30699-30702,30742
/trunk/blender:36833-37206
Modified: branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-10 04:36:51 UTC (rev 37356)
+++ branches/soc-2011-onion/source/blender/blenlib/intern/pbvh.c 2011-06-10 05:10:17 UTC (rev 37357)
@@ -1568,13 +1568,16 @@
for(i = 0; i < totgrid; ++i) {
DMGridData *grid= bvh->grids[node->prim_indices[i]];
+
if (!grid)
continue;
for(y = 0; y < gridsize-1; ++y) {
for(x = 0; x < gridsize-1; ++x) {
+ int lhit = 0;
+
if(origco) {
- hit |= ray_face_intersection(ray_start, ray_normal,
+ lhit |= ray_face_intersection(ray_start, ray_normal,
origco[y*gridsize + x],
origco[y*gridsize + x+1],
origco[(y+1)*gridsize + x+1],
@@ -1582,13 +1585,20 @@
dist);
}
else {
- hit |= ray_face_intersection(ray_start, ray_normal,
+ lhit |= ray_face_intersection(ray_start, ray_normal,
GRIDELEM_CO_AT(grid, y*gridsize + x, bvh->gridkey),
GRIDELEM_CO_AT(grid, y*gridsize + x+1, bvh->gridkey),
GRIDELEM_CO_AT(grid, (y+1)*gridsize + x+1, bvh->gridkey),
GRIDELEM_CO_AT(grid, (y+1)*gridsize + x, bvh->gridkey),
dist);
}
+
+ if(lhit && hit_index) {
+ *hit_index = i;
+ *grid_hit_index = y*gridsize + x;
+ }
+
+ hit |= lhit;
}
}
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-10 04:36:51 UTC (rev 37356)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c 2011-06-10 05:10:17 UTC (rev 37357)
@@ -1583,7 +1583,6 @@
*/
typedef struct VPaintData {
- unsigned int paintcol;
int *indexar;
float *vertexcosnos;
float vpimat[3][3];
@@ -1637,7 +1636,6 @@
paint_stroke_set_mode_data(stroke, vpd);
vpd->vertexcosnos= mesh_get_mapped_verts_nors(vc->scene, ob);
- vpd->paintcol= vpaint_get_current_col(vp);
/* for filtering */
copy_vpaint_prev(vp, (unsigned int *)me->mcol, me->totface);
@@ -1653,6 +1651,14 @@
return 1;
}
+static void vpaint_blend(Brush *brush, float col[4], float alpha)
+{
+ if(brush->vertexpaint_tool != VERTEX_PAINT_BLUR) {
+ IMB_blend_color_float(col, col, brush->rgb, alpha,
+ brush->vertexpaint_tool);
+ }
+}
+
/* apply paint at specified coordinate
returns 1 if paint was applied, 0 otherwise */
static int vpaint_paint_coord(VPaint *vp, VPaintData *vpd, float co[3],
@@ -1662,13 +1668,7 @@
{
Brush *brush = paint_brush(&vp->paint);
float strength, dist, dist_squared;
- float paint_col[4];
- paint_col[0] = ((MCol*)&vpd->paintcol)->b / 255.0f;
- paint_col[1] = ((MCol*)&vpd->paintcol)->g / 255.0f;
- paint_col[2] = ((MCol*)&vpd->paintcol)->r / 255.0f;
- paint_col[3] = ((MCol*)&vpd->paintcol)->a / 255.0f;
-
dist_squared = len_squared_v3v3(center, co);
if(dist_squared < radius_squared) {
@@ -1678,10 +1678,7 @@
brush_curve_strength(brush, dist,
radius);
- if(brush->vertexpaint_tool != VERTEX_PAINT_BLUR) {
- IMB_blend_color_float(col, col, paint_col, strength,
- brush->vertexpaint_tool);
- }
+ vpaint_blend(brush, col, strength);
return 1;
}
@@ -1853,11 +1850,54 @@
}
}
-static void vpaint_color_one_face(bContext *C, PaintStroke *stroke,
+/* applies brush color to a single point in a multires grid */
+static void vpaint_color_single_gridelem(Brush *brush, DMGridData **grids,
+ GridKey *gridkey, int *grid_indices,
+ int gridsize, int active,
+ int hit_index, int grid_hit_index)
+{
+ float *gridcol;
+
+ gridcol = GRIDELEM_COLOR_AT(grids[grid_indices[hit_index]],
+ grid_hit_index, gridkey)[active];
+
+ vpaint_blend(brush, gridcol, brush->alpha);
+}
+
+/* applies brush color to a single face */
+static void vpaint_color_single_face(Brush *brush, MFace *mface,
+ CustomData *fdata, int *face_indices,
+ int hit_index)
+{
+ MCol *mcol;
+ int i, S;
+
+ mcol = CustomData_get_layer(fdata, CD_MCOL);
+ mface += face_indices[hit_index];
+ S = mface->v4 ? 4 : 3;
+
+ for(i = 0; i < S; ++i) {
+ int cndx = face_indices[hit_index]*4 + i;
+ float fcol[4];
+
+ fcol[0] = mcol[cndx].b / 255.0f;
+ fcol[1] = mcol[cndx].g / 255.0f;
+ fcol[2] = mcol[cndx].r / 255.0f;
+ fcol[3] = mcol[cndx].a / 255.0f;
+
+ vpaint_blend(brush, fcol, brush->alpha);
+
+ mcol[cndx].b = fcol[0] * 255.0f;
+ mcol[cndx].g = fcol[1] * 255.0f;
+ mcol[cndx].r = fcol[2] * 255.0f;
+ mcol[cndx].a = fcol[3] * 255.0f;
+ }
+}
+
+static void vpaint_color_single_element(bContext *C, PaintStroke *stroke,
PointerRNA *itemptr)
{
- VPaint *vp= CTX_data_tool_settings(C)->vpaint
-; VPaintData *vpd = paint_stroke_mode_data(stroke);
+ VPaint *vp= CTX_data_tool_settings(C)->vpaint;
ViewContext *vc = paint_stroke_view_context(stroke);
Brush *brush = paint_brush(&vp->paint);
float mouse[2], hit_loc[3];
@@ -1868,33 +1908,43 @@
if(paint_stroke_get_location(C, stroke,
vpaint_color_one_face_raycast_cb,
&hit_data, hit_loc, mouse, 0)) {
+ DMGridData **grids;
+ GridKey *gridkey;
MFace *mface;
CustomData *fdata;
- MCol *mcol;
- unsigned int *orig= (unsigned int*)vp->vpaint_prev;
- int *face_indices;
- int i, S;
+ int *face_indices, *grid_indices, gridsize;
BLI_pbvh_node_get_faces(vc->obact->paint->pbvh, hit_data.node,
&mface, &fdata, &face_indices,
NULL, NULL);
+ BLI_pbvh_node_get_grids(vc->obact->paint->pbvh, hit_data.node,
+ &grid_indices,
+ NULL, NULL, &gridsize, &grids,
+ NULL, &gridkey);
- mcol = CustomData_get_layer(fdata, CD_MCOL);
- mface += face_indices[hit_data.hit_index];
- S = mface->v4 ? 4 : 3;
+ if(grids) {
+ int active = vpaint_find_gridkey_active_layer(fdata,
+ gridkey);
- for(i = 0; i < S; ++i) {
- int cndx = face_indices[hit_data.hit_index]*4 + i;
- unsigned int *col = (unsigned int*)(mcol + cndx);
- unsigned int *orig_col = (unsigned int*)(orig + cndx);
-
- /*vpaint_blend(vp, col, orig_col,
- vpd->paintcol,
- brush->alpha * 255);*/
+ if(active != -1) {
+ vpaint_color_single_gridelem(brush,
+ grids,
+ gridkey,
+ grid_indices,
+ gridsize, active,
+ hit_data.hit_index,
+ hit_data.grid_hit_index);
+ }
}
+ else {
+ vpaint_color_single_face(brush, mface, fdata,
+ face_indices,
+ hit_data.hit_index);
+ }
BLI_pbvh_node_set_flags(hit_data.node,
- SET_INT_IN_POINTER(PBVH_UpdateColorBuffers|PBVH_UpdateRedraw));
+ SET_INT_IN_POINTER(PBVH_UpdateColorBuffers|
+ PBVH_UpdateRedraw));
}
}
@@ -1925,15 +1975,15 @@
vpaint_nodes(vp, vpd, ob->paint->pbvh, nodes, totnode,
center, radius);
- multires_mark_as_modified(ob);
-
if(nodes)
MEM_freeN(nodes);
}
else {
- vpaint_color_one_face(C, stroke, itemptr);
+ vpaint_color_single_element(C, stroke, itemptr);
}
+ multires_mark_as_modified(ob);
+
/* XXX
if(brush->vertexpaint_tool == VP_BLUR)
do_shared_vertexcol(ob->data);*/
More information about the Bf-blender-cvs
mailing list