[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30202] branches/soc-2010-jwilkins: == Clay Tubes Tool ==
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sun Jul 11 13:51:45 CEST 2010
Revision: 30202
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30202
Author: jwilkins
Date: 2010-07-11 13:51:44 +0200 (Sun, 11 Jul 2010)
Log Message:
-----------
== Clay Tubes Tool ==
Clay Tubes uses a cube brush test and distance calculation instead of a sphere.
Will try to generalize sphere/cube/cylinder tests later if it doesn't effect performance too much.
* Bug Fix: 'special' rotation (rotation as the result of random, anchored, or rake) wasn't being considered when drawing the texture overlay.
* Known problem: clay tubes does not play nicely with anchored stroke method. This is a genearal problem with different tools and strokes and needs to be worked out.
Modified Paths:
--------------
branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
branches/soc-2010-jwilkins/source/blender/makesdna/DNA_brush_types.h
branches/soc-2010-jwilkins/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-07-11 09:50:23 UTC (rev 30201)
+++ branches/soc-2010-jwilkins/release/scripts/ui/space_view3d_toolbar.py 2010-07-11 11:51:44 UTC (rev 30202)
@@ -641,14 +641,14 @@
row.prop(brush, "sculpt_plane", text="")
- if brush.sculpt_tool in ('CLAY', 'WAX', 'FLATTEN', 'FILL', 'SCRAPE'):
+ if brush.sculpt_tool in ('CLAY', 'CLAY_TUBES', 'WAX', 'FLATTEN', 'FILL', 'SCRAPE'):
row = col.row(align=True)
row.prop(brush, "plane_offset", slider=True)
row.prop(brush, "use_offset_pressure", text="")
- if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY', 'WAX'):
+ if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY', 'CLAY_TUBES', 'WAX'):
col.separator()
col.row().prop(brush, "direction", expand=True)
elif brush.sculpt_tool in ('FLATTEN'):
@@ -669,7 +669,7 @@
- if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY', 'WAX'):
+ if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY', 'CLAY_TUBES', 'WAX'):
col.separator()
col.prop(brush, "use_accumulate")
@@ -1104,7 +1104,7 @@
col = layout.column();
if context.sculpt_object and context.tool_settings.sculpt:
- if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'WAX', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN'):
+ if brush.sculpt_tool in ('DRAW', 'INFLATE', 'CLAY', 'CLAY_TUBES', 'WAX', 'PINCH', 'CREASE', 'BLOB', 'FLATTEN'):
col.prop(brush, "add_col", text="Add Color")
col.prop(brush, "sub_col", text="Substract Color")
else:
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-11 09:50:23 UTC (rev 30201)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/paint_stroke.c 2010-07-11 11:51:44 UTC (rev 30202)
@@ -734,7 +734,7 @@
if (brush->draw_anchored) {
glTranslatef(brush->anchored_initial_mouse[0] - vc.ar->winrct.xmin, brush->anchored_initial_mouse[1] - vc.ar->winrct.ymin, 0.0f);
glutil_draw_lined_arc(0.0, M_PI*2.0, brush->anchored_size, 40);
- glTranslatef(-brush->anchored_initial_mouse[0], -brush->anchored_initial_mouse[1], 0.0f);
+ glTranslatef(-brush->anchored_initial_mouse[0] + vc.ar->winrct.xmin, -brush->anchored_initial_mouse[1] + vc.ar->winrct.xmin, 0.0f);
}
else {
glTranslatef((float)x, (float)y, 0.0f);
@@ -770,12 +770,17 @@
glLoadIdentity();
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
+ glTranslatef(0.5f, 0.5f, 0);
+
if (brush->flag & BRUSH_RAKE) {
- glTranslatef(0.5f, 0.5f, 0);
glRotatef(brush->last_angle*(float)(180.0/M_PI), 0, 0, 1);
- glTranslatef(-0.5f, -0.5f, 0);
}
+ else {
+ glRotatef(brush->special_rotation*(float)(180.0/M_PI), 0, 0, 1);
+ }
+ glTranslatef(-0.5f, -0.5f, 0);
+
if (brush->draw_pressure && (brush->flag & BRUSH_SIZE_PRESSURE)) {
glTranslatef(0.5f, 0.5f, 0);
glScalef(1.0f/brush->pressure_value, 1.0f/brush->pressure_value, 1);
@@ -793,16 +798,16 @@
if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) {
if (brush->draw_anchored) {
glTexCoord2f(0, 0);
- glVertex2f(brush->anchored_initial_mouse[0]-brush->anchored_size, brush->anchored_initial_mouse[1]-brush->anchored_size);
+ glVertex2f(brush->anchored_initial_mouse[0]-brush->anchored_size - vc.ar->winrct.xmin, brush->anchored_initial_mouse[1]-brush->anchored_size - vc.ar->winrct.ymin);
glTexCoord2f(1, 0);
- glVertex2f(brush->anchored_initial_mouse[0]+brush->anchored_size, brush->anchored_initial_mouse[1]-brush->anchored_size);
+ glVertex2f(brush->anchored_initial_mouse[0]+brush->anchored_size - vc.ar->winrct.xmin, brush->anchored_initial_mouse[1]-brush->anchored_size - vc.ar->winrct.ymin);
glTexCoord2f(1, 1);
- glVertex2f(brush->anchored_initial_mouse[0]+brush->anchored_size, brush->anchored_initial_mouse[1]+brush->anchored_size);
+ glVertex2f(brush->anchored_initial_mouse[0]+brush->anchored_size - vc.ar->winrct.xmin, brush->anchored_initial_mouse[1]+brush->anchored_size - vc.ar->winrct.ymin);
glTexCoord2f(0, 1);
- glVertex2f(brush->anchored_initial_mouse[0]-brush->anchored_size, brush->anchored_initial_mouse[1]+brush->anchored_size);
+ glVertex2f(brush->anchored_initial_mouse[0]-brush->anchored_size - vc.ar->winrct.xmin, brush->anchored_initial_mouse[1]+brush->anchored_size - vc.ar->winrct.ymin);
}
else {
glTexCoord2f(0, 0);
Modified: branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-07-11 09:50:23 UTC (rev 30201)
+++ branches/soc-2010-jwilkins/source/blender/editors/sculpt_paint/sculpt.c 2010-07-11 11:51:44 UTC (rev 30202)
@@ -212,9 +212,9 @@
int symmetry; /* Symmetry index between 0 and 7 bit combo 0 is Brush only;
1 is X mirror; 2 is Y mirror; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */
int mirror_symmetry_pass; /* the symmetry pass we are currently on between 0 and 7*/
+ float true_view_normal[3];
float view_normal[3];
float last_area_normal[3];
- float last_view_normal_symmetry[3];
float last_center[3];
int radial_symmetry_pass;
float symm_rot_mat[4][4];
@@ -444,6 +444,29 @@
//}
}
+static int sculpt_brush_test_cube(SculptBrushTest *test, float co[3], float local[4][4])
+{
+ const static float side = 0.70710678118654752440084436210485; // sqrt(.5);
+ //float corner = 0.80*side;
+
+ float local_co[3];
+
+ mul_v3_m4v3(local_co, local, co);
+
+ local_co[0] = fabs(local_co[0]);
+ local_co[1] = fabs(local_co[1]);
+ local_co[2] = fabs(local_co[2]);
+
+ if (local_co[0] <= side && local_co[1] <= side && local_co[2] <= side) {
+ test->dist = MAX3(local_co[0], local_co[1], local_co[2]) / side;
+
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
static int sculpt_brush_test_fast(SculptBrushTest *test, float co[3])
{
//if (sculpt_brush_test_clip(test, co)) {
@@ -622,6 +645,7 @@
switch(brush->sculpt_tool){
case SCULPT_TOOL_CLAY:
+ case SCULPT_TOOL_CLAY_TUBES:
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_WAX:
case SCULPT_TOOL_LAYER:
@@ -2116,6 +2140,83 @@
}
}
+static void do_clay_tubes_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
+{
+ Brush *brush = paint_brush(&sd->paint);
+
+ float bstrength = ss->cache->bstrength;
+ float radius = ss->cache->radius;
+ float offset = get_offset(sd, ss);
+
+ float displace;
+
+ float an[3]; // area normal
+ float fc[3]; // flatten center
+
+ int n;
+
+ float temp[3];
+ float mat[4][4];
+ float scale[4][4];
+ float tmat[4][4];
+
+ int flip;
+
+ calc_area_normal_and_flatten_center(sd, ss, nodes, totnode, an, fc);
+
+ flip = bstrength < 0;
+
+ if (flip) {
+ bstrength = -bstrength;
+ radius = -radius;
+ }
+
+ displace = radius * (0.25f+offset);
+
+ mul_v3_v3v3(temp, an, ss->cache->scale);
+ mul_v3_fl(temp, displace);
+ add_v3_v3(fc, temp);
+
+ cross_v3_v3v3(mat[0], an, ss->cache->grab_delta_symmetry); mat[0][3] = 0;
+ cross_v3_v3v3(mat[1], an, mat[0]); mat[1][3] = 0;
+ copy_v3_v3(mat[2], an); mat[2][3] = 0;
+ copy_v3_v3(mat[3], ss->cache->location); mat[3][3] = 1;
+ normalize_m4(mat);
+ scale_m4_fl(scale, ss->cache->radius);
+ mul_m4_m4m4(tmat, scale, mat);
+ invert_m4_m4(mat, tmat);
+
+ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP)
+ for (n = 0; n < totnode; n++) {
+ PBVHVertexIter vd;
+ SculptBrushTest test;
+ float (*proxy)[3];
+
+ proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co;
+
+ sculpt_brush_test_init(ss, &test);
+
+ BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) {
+ if (sculpt_brush_test_cube(&test, vd.co, mat)) {
+ if (plane_point_side_flip(vd.co, an, fc, flip)) {
+ float intr[3];
+ float val[3];
+
+ const float fade = bstrength*tex_strength(ss, brush, vd.co, ss->cache->radius*test.dist);
+
+ point_plane_project(intr, vd.co, an, fc);
+ sub_v3_v3v3(val, intr, vd.co);
+ mul_v3_v3fl(proxy[vd.i], val, fade);
+
+ if(vd.mvert)
+ vd.mvert->flag |= ME_VERT_PBVH_UPDATE;
+ }
+ }
+ }
+ BLI_pbvh_vertex_iter_end;
+ }
+}
+
static void do_fill_brush(Sculpt *sd, SculptSession *ss, PBVHNode **nodes, int totnode)
{
Brush *brush = paint_brush(&sd->paint);
@@ -2356,6 +2457,10 @@
case SCULPT_TOOL_CLAY:
do_clay_brush(sd, ss, nodes, totnode);
break;
+ case SCULPT_TOOL_CLAY_TUBES:
+ if (!ss->cache->first_time)
+ do_clay_tubes_brush(sd, ss, nodes, totnode);
+ break;
case SCULPT_TOOL_FILL:
do_fill_brush(sd, ss, nodes, totnode);
break;
@@ -2432,6 +2537,7 @@
case SCULPT_TOOL_DRAW:
case SCULPT_TOOL_CLAY:
+ case SCULPT_TOOL_CLAY_TUBES:
case SCULPT_TOOL_CREASE:
case SCULPT_TOOL_BLOB:
case SCULPT_TOOL_FILL:
@@ -2485,6 +2591,7 @@
{
flip_coord(cache->location, cache->true_location, symm);
flip_coord(cache->grab_delta_symmetry, cache->grab_delta, symm);
+ flip_coord(cache->view_normal, cache->true_view_normal, symm);
unit_m4(cache->symm_rot_mat);
unit_m4(cache->symm_rot_mat_inv);
@@ -2640,6 +2747,8 @@
return "Flatten Brush"; break;
case SCULPT_TOOL_CLAY:
return "Clay Brush"; break;
+ case SCULPT_TOOL_CLAY_TUBES:
+ return "Clay Tubes Brush"; break;
case SCULPT_TOOL_WAX:
return "Wax Brush"; break;
case SCULPT_TOOL_FILL:
@@ -2847,7 +2956,7 @@
cache->mats = MEM_callocN(sizeof(bglMats), "sculpt bglMats");
view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, cache->mats);
- viewvector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->view_normal);
+ viewvector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal);
/* Initialize layer brush displacements and persistent coords */
if(brush->sculpt_tool == SCULPT_TOOL_LAYER) {
/* not supported yet for multires */
@@ -2873,7 +2982,7 @@
cache->original = 1;
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list