[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39098] branches/soc-2011-onion: re-enabled "Symmetry Feather" option
Jason Wilkins
Jason.A.Wilkins at gmail.com
Sat Aug 6 16:05:02 CEST 2011
Revision: 39098
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39098
Author: jwilkins
Date: 2011-08-06 14:05:02 +0000 (Sat, 06 Aug 2011)
Log Message:
-----------
re-enabled "Symmetry Feather" option
Modified Paths:
--------------
branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c
branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c
branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c
Modified: branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-08-06 12:53:58 UTC (rev 39097)
+++ branches/soc-2011-onion/release/scripts/startup/bl_ui/space_view3d_toolbar.py 2011-08-06 14:05:02 UTC (rev 39098)
@@ -644,6 +644,9 @@
row.operator("paint.set_persistent_base")
row.active = brush.use_layer
+ col.separator()
+ col.prop(brush, "use_symmetry_feather")
+
# Texture Paint Mode #
elif context.image_paint_object and brush:
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c 2011-08-06 12:53:58 UTC (rev 39097)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_bspace.c 2011-08-06 14:05:02 UTC (rev 39098)
@@ -103,6 +103,74 @@
+/* symmetry overlap */
+
+static float calc_mirror_symmetry_overlap(BrushSpace *bspace, const char symm, const char axis, const float angle)
+{
+ if (symm != 0) {
+ float mirror[3];
+ float distsq;
+
+ paint_flip_v3_v3(mirror, bspace->location, symm);
+
+ if (axis >= 'X' && axis <= 'Z' && angle != 0) {
+ float mat[4][4]= MAT4_UNITY;
+ rotate_m4(mat, axis, angle);
+ mul_m4_v3(mat, mirror);
+ }
+
+ distsq= len_squared_v3v3(mirror, bspace->location);
+
+ if (distsq <= 4.0f*(bspace->radius3d_sq))
+ return (2.0f*(bspace->radius3d) - sqrt(distsq)) / (2.0f*(bspace->radius3d));
+ else
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+static float calc_radial_symmetry_overlap(Paint *paint, BrushSpace *bspace, const char symm, const char axis)
+{
+ int i;
+ float overlap= 0;
+
+ for(i = 1; i < paint->radial_symm[axis-'X']; ++i) {
+ const float angle = 2*M_PI*i/(paint->radial_symm[axis-'X']);
+ overlap += calc_mirror_symmetry_overlap(bspace, symm, axis, angle);
+ }
+
+ return overlap;
+}
+
+static float calc_symmetry_overlap(
+ struct Paint *paint,
+ struct BrushSpace *bspace)
+{
+ Brush *brush= paint_brush(paint);
+ float overlap= 0;
+ int symm= paint->mirror_symm;
+ int i;
+
+ for (i= 0; i <= symm; i++) {
+ if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
+
+ overlap += calc_mirror_symmetry_overlap(bspace, i, 0, 0);
+
+ overlap += calc_radial_symmetry_overlap(paint, bspace, i, 'X');
+ overlap += calc_radial_symmetry_overlap(paint, bspace, i, 'Y');
+ overlap += calc_radial_symmetry_overlap(paint, bspace, i, 'Z');
+ }
+ }
+
+ //printf("overlap: %f\n", overlap);
+
+ return overlap;
+}
+
+
+
/* mirror symmetry */
static void calc_mirror_symmetry(struct BrushSpace *bspace, int mirror_pass)
{
@@ -368,6 +436,12 @@
/* mirror */
/* angle flip */
/* radial */
+
+ /* symmetry overlap */
+ if (paint_brush(paint)->flag & BRUSH_SYMMETRY_FEATHER)
+ out->symmetry_overlap= calc_symmetry_overlap(paint, out);
+ else
+ out->symmetry_overlap= 1;
}
void paint_bspace_init(
@@ -377,7 +451,8 @@
const float mouse[2],
float radius2d)
{
- struct PaintCache *cache= paint_get_active(CTX_data_scene(C))->cache;
+ struct Paint *paint= paint_get_active(CTX_data_scene(C));
+ struct PaintCache *cache= paint->cache;
struct BrushSpace *bspace_curr= cache->bspace_curr;
struct BrushSpace *bspace_prev= cache->bspace_prev;
struct BrushSpace *bspace_first= cache->bspace_first;
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c 2011-08-06 12:53:58 UTC (rev 39097)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_dab.c 2011-08-06 14:05:02 UTC (rev 39098)
@@ -181,70 +181,6 @@
return max;
}
-static float calc_overlap(BrushSpace *bspace, const char symm, const char axis, const float angle)
-{
- float mirror[3];
- float distsq;
-
- //flip_coord(mirror, bspace->traced_location, symm);
- paint_flip_coord(mirror, bspace->location, symm);
-
- if(axis >= 'X' && axis <= 'Z') {
- float mat[4][4]= MAT4_UNITY;
- rotate_m4(mat, axis, angle);
- mul_m4_v3(mat, mirror);
- }
-
- //distsq = len_squared_v3v3(mirror, bspace->traced_location);
- distsq = len_squared_v3v3(mirror, bspace->location);
-
- if (distsq <= 4.0f*(bspace->radius3d_sq))
- return (2.0f*(bspace->radius3d) - sqrt(distsq)) / (2.0f*(bspace->radius3d));
- else
- return 0;
-}
-
-static float calc_radial_symmetry_feather(Sculpt *sd, BrushSpace *bspace, const char symm, const char axis)
-{
- int i;
- float overlap;
-
- overlap = 0;
- for(i = 1; i < sd->paint.radial_symm[axis-'X']; ++i) {
- const float angle = 2*M_PI*i/sd->paint.radial_symm[axis-'X'];
- overlap += calc_overlap(bspace, symm, axis, angle);
- }
-
- return overlap;
-}
-
-static float calc_symmetry_feather(Sculpt *sd, BrushSpace *bspace)
-{
- Brush *brush= paint_brush(&(sd->paint));
-
- if (brush->flag & BRUSH_SYMMETRY_FEATHER) {
- float overlap;
- int symm = sd->paint.mirror_symm;
- int i;
-
- overlap = 0;
- for (i = 0; i <= symm; i++) {
- if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) {
-
- overlap += calc_overlap(bspace, i, 0, 0);
-
- overlap += calc_radial_symmetry_feather(sd, bspace, i, 'X');
- overlap += calc_radial_symmetry_feather(sd, bspace, i, 'Y');
- overlap += calc_radial_symmetry_feather(sd, bspace, i, 'Z');
- }
- }
-
- return 1/overlap;
- }
- else {
- return 1;
- }
-}
#if 0 //SNIP
/* Return modified brush strength. Includes the direction of the brush, positive
values pull vertices, negative values push. Uses tablet pressure and a
@@ -369,5 +305,3 @@
{
return (1.0f-mask)*brush_curve_strength(brush, dist, bspace->radius3d);
}
-
-void paint_flip_coord(float out[3], const float in[3], int mirror_symm){}
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h 2011-08-06 12:53:58 UTC (rev 39097)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h 2011-08-06 14:05:02 UTC (rev 39098)
@@ -146,6 +146,8 @@
float angle_flip;
+ float symmetry_overlap;
+
} BrushSpace;
#define TEMP_SWITCH_NAME_SIZE 24
@@ -285,8 +287,6 @@
struct MultiresModifierData *paint_mesh_get_active_multires(const struct bContext *C);
-void paint_flip_coord(float out[3], const float in[3], int mirror_symm);
-
float brush_tex_strength(const struct ViewContext *vc,
float pmat[4][4], float symm_brush_local_mat[4][4], int mirror_pass, struct Brush *br,
float co[3], float mask, const float len,
Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c 2011-08-06 12:53:58 UTC (rev 39097)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt_tools.c 2011-08-06 14:05:02 UTC (rev 39098)
@@ -1652,16 +1652,11 @@
float val[3];
int p;
- zero_v3(val);
+ copy_v3_v3(val, orig_co[vd.i]);
for (p= 0; p < proxy_count; p++)
add_v3_v3(val, proxies[p].co[vd.i]);
- if (brush->flag & BRUSH_SYMMETRY_FEATHER)
- mul_v3_fl(val, 1.0f/proxy_count);
-
- add_v3_v3(val, orig_co[vd.i]);
-
clip(sd, mode_data, vd.co, val);
if (ob->paint->modifiers_active)
@@ -1706,16 +1701,11 @@
float val[3];
int p;
- zero_v3(val);
+ copy_v3_v3(val, vd.co);
for (p= 0; p < proxy_count; p++)
add_v3_v3(val, proxies[p].co[vd.i]);
- if (brush->flag & BRUSH_SYMMETRY_FEATHER)
- mul_v3_fl(val, 1.0f/proxy_count);
-
- add_v3_v3(val, vd.co);
-
if (brush->sculpt_tool == SCULPT_TOOL_LAYER || brush->flag & BRUSH_LAYER) {
float disp[3];
float len;
@@ -1803,9 +1793,13 @@
paint_bspace_update(C, stroke, sculpt_stroke_get_location, paint_stroke_mouse(stroke), brush_size(brush));
if (paint_bspace_hit(C)) {
+ struct BrushSpace *bspace= sd->paint.cache->bspace_curr;
+
paint_stroke_update_params(C, stroke);
- mode_data->bstrength= tool_strength(brush, stroke, sd->paint.cache->bspace_curr);
+ mode_data->bstrength=
+ (1.0f / bspace->symmetry_overlap) *
+ tool_strength(brush, stroke, bspace);
paint_stroke_apply(C, stroke);
Modified: branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c 2011-08-06 12:53:58 UTC (rev 39097)
+++ branches/soc-2011-onion/source/blender/makesrna/intern/rna_brush.c 2011-08-06 14:05:02 UTC (rev 39098)
@@ -946,7 +946,7 @@
prop= RNA_def_property(srna, "use_symmetry_feather", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SYMMETRY_FEATHER);
- RNA_def_property_ui_text(prop, "Symmetry Feathering", "Reduce the strength of the brush where it overlaps symmetrical dabs");
+ RNA_def_property_ui_text(prop, "Symmetry Feather", "Reduce the strength of the brush where symmetrical dabs overlap");
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop= RNA_def_property(srna, "use_layer", PROP_BOOLEAN, PROP_NONE);
More information about the Bf-blender-cvs
mailing list