Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bishop <nicholasbishop@gmail.com>2010-07-27 20:09:02 +0400
committerNicholas Bishop <nicholasbishop@gmail.com>2010-07-27 20:09:02 +0400
commit88dcfbaee9be4a08104efc2f4edd20dd8e7957fe (patch)
tree22670033fd0118e29e4293911ac231b34b784321 /source/blender/blenkernel/intern/brush.c
parent78e5a299900233aa8779f87947edb9f37f9336bf (diff)
== Sculpt ==
Added a brush reset operator so that a user won't need to reload the default blend to get back default brush settings * New brush.reset operator, resets a brush based on the currently-selected tool * Added UI button in the tools panel TODO: * Only resets sculpt brushes right now, other paint modes should be added * Sculpt polish tool exists only as a Brush, not as a tool; I'd suggest we make it a tool so it can be reset to defaults too
Diffstat (limited to 'source/blender/blenkernel/intern/brush.c')
-rw-r--r--source/blender/blenkernel/intern/brush.c196
1 files changed, 188 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index a8a53e3fbe6..1e4fb13d1df 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -62,25 +62,22 @@
#include "RE_render_ext.h" /* externtex */
#include "RE_shader_ext.h"
-/* Datablock add/copy/free/make_local */
-
-Brush *add_brush(const char *name)
+static void brush_set_defaults(Brush *brush)
{
- Brush *brush;
-
- brush= alloc_libblock(&G.main->brush, ID_BR, name);
+ brush->blend = 0;
+ brush->flag = 0;
/* BRUSH SCULPT TOOL SETTINGS */
- brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
brush->size= 35; /* radius of the brush in pixels */
brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */
brush->autosmooth_factor= 0.0f;
brush->crease_pinch_factor= 0.5f;
- brush->sculpt_plane = SCULPT_DISP_DIR_VIEW;
+ brush->sculpt_plane = SCULPT_DISP_DIR_AREA;
brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */
brush->plane_trim= 0.5f;
brush->clone.alpha= 0.5f;
brush->normal_weight= 0.0f;
+ brush->flag |= BRUSH_ALPHA_PRESSURE;
/* BRUSH PAINT TOOL SETTINGS */
brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */
@@ -102,6 +99,7 @@ Brush *add_brush(const char *name)
default_mtex(&brush->mtex);
brush->texture_sample_bias= 0; /* value to added to texture samples */
+ brush->texture_overlay_alpha= 33;
/* brush appearance */
@@ -112,6 +110,19 @@ Brush *add_brush(const char *name)
brush->sub_col[0]= 0.39; /* subtract mode color is light blue */
brush->sub_col[1]= 0.39;
brush->sub_col[2]= 1.00;
+}
+
+/* Datablock add/copy/free/make_local */
+
+Brush *add_brush(const char *name)
+{
+ Brush *brush;
+
+ brush= alloc_libblock(&G.main->brush, ID_BR, name);
+
+ brush_set_defaults(brush);
+
+ brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
/* the default alpha falloff curve */
brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
@@ -212,6 +223,175 @@ void make_local_brush(Brush *brush)
}
}
+void brush_debug_print_state(Brush *br)
+{
+ Brush def;
+
+ /* create a fake brush and set it to the defaults */
+ memset(&def, 0, sizeof(Brush));
+ brush_set_defaults(&def);
+
+#define BR_TEST(field, t) \
+ if(br->field != def.field) \
+ printf("br->" #field " = %" #t ";\n", br->field)
+
+#define BR_TEST_FLAG(_f) \
+ if((br->flag & _f) && !(def.flag & _f)) \
+ printf("br->flag |= " #_f ";\n"); \
+ else if(!(br->flag & _f) && (def.flag & _f)) \
+ printf("br->flag &= ~" #_f ";\n")
+
+
+ /* print out any non-default brush state */
+ BR_TEST(normal_weight, f);
+
+ BR_TEST(blend, d);
+ BR_TEST(size, d);
+
+ /* br->flag */
+ BR_TEST_FLAG(BRUSH_AIRBRUSH);
+ BR_TEST_FLAG(BRUSH_TORUS);
+ BR_TEST_FLAG(BRUSH_ALPHA_PRESSURE);
+ BR_TEST_FLAG(BRUSH_SIZE_PRESSURE);
+ BR_TEST_FLAG(BRUSH_JITTER_PRESSURE);
+ BR_TEST_FLAG(BRUSH_SPACING_PRESSURE);
+ BR_TEST_FLAG(BRUSH_FIXED_TEX);
+ BR_TEST_FLAG(BRUSH_RAKE);
+ BR_TEST_FLAG(BRUSH_ANCHORED);
+ BR_TEST_FLAG(BRUSH_DIR_IN);
+ BR_TEST_FLAG(BRUSH_SPACE);
+ BR_TEST_FLAG(BRUSH_SMOOTH_STROKE);
+ BR_TEST_FLAG(BRUSH_PERSISTENT);
+ BR_TEST_FLAG(BRUSH_ACCUMULATE);
+ BR_TEST_FLAG(BRUSH_LOCK_ALPHA);
+ BR_TEST_FLAG(BRUSH_ORIGINAL_NORMAL);
+ BR_TEST_FLAG(BRUSH_OFFSET_PRESSURE);
+ BR_TEST_FLAG(BRUSH_SPACE_ATTEN);
+ BR_TEST_FLAG(BRUSH_ADAPTIVE_SPACE);
+ BR_TEST_FLAG(BRUSH_LOCK_SIZE);
+ BR_TEST_FLAG(BRUSH_TEXTURE_OVERLAY);
+ BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE);
+ BR_TEST_FLAG(BRUSH_RESTORE_MESH);
+ BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE);
+ BR_TEST_FLAG(BRUSH_RANDOM_ROTATION);
+ BR_TEST_FLAG(BRUSH_PLANE_TRIM);
+ BR_TEST_FLAG(BRUSH_FRONTFACE);
+ BR_TEST_FLAG(BRUSH_CUSTOM_ICON);
+
+ BR_TEST(jitter, f);
+ BR_TEST(spacing, d);
+ BR_TEST(smooth_stroke_radius, d);
+ BR_TEST(smooth_stroke_factor, f);
+ BR_TEST(rate, f);
+
+ BR_TEST(alpha, f);
+
+ BR_TEST(sculpt_plane, d);
+
+ BR_TEST(plane_offset, f);
+
+ BR_TEST(autosmooth_factor, f);
+
+ BR_TEST(crease_pinch_factor, f);
+
+ BR_TEST(plane_trim, f);
+
+ BR_TEST(texture_sample_bias, f);
+ BR_TEST(texture_overlay_alpha, d);
+
+ BR_TEST(add_col[0], f);
+ BR_TEST(add_col[1], f);
+ BR_TEST(add_col[2], f);
+ BR_TEST(sub_col[0], f);
+ BR_TEST(sub_col[1], f);
+ BR_TEST(sub_col[2], f);
+
+ printf("\n");
+
+#undef BR_TEST
+#undef BR_TEST_FLAG
+}
+
+void brush_reset_sculpt(Brush *br)
+{
+ /* enable this to see any non-default
+ settings used by a brush:
+
+ brush_debug_print_state(br);
+ */
+
+ brush_set_defaults(br);
+ brush_curve_preset(br, CURVE_PRESET_SMOOTH);
+
+ switch(br->sculpt_tool) {
+ case SCULPT_TOOL_CLAY:
+ br->flag |= BRUSH_FRONTFACE;
+ break;
+ case SCULPT_TOOL_CREASE:
+ br->flag |= BRUSH_DIR_IN;
+ br->alpha = 0.25;
+ break;
+ case SCULPT_TOOL_FILL:
+ br->add_col[1] = 1;
+ br->sub_col[0] = 0.25;
+ br->sub_col[1] = 1;
+ break;
+ case SCULPT_TOOL_FLATTEN:
+ br->add_col[1] = 1;
+ br->sub_col[0] = 0.25;
+ br->sub_col[1] = 1;
+ break;
+ case SCULPT_TOOL_INFLATE:
+ br->add_col[0] = 0.750000;
+ br->add_col[1] = 0.750000;
+ br->add_col[2] = 0.750000;
+ br->sub_col[0] = 0.250000;
+ br->sub_col[1] = 0.250000;
+ br->sub_col[2] = 0.250000;
+ break;
+ case SCULPT_TOOL_NUDGE:
+ br->add_col[0] = 0.250000;
+ br->add_col[1] = 1.000000;
+ br->add_col[2] = 0.250000;
+ break;
+ case SCULPT_TOOL_PINCH:
+ br->add_col[0] = 0.750000;
+ br->add_col[1] = 0.750000;
+ br->add_col[2] = 0.750000;
+ br->sub_col[0] = 0.250000;
+ br->sub_col[1] = 0.250000;
+ br->sub_col[2] = 0.250000;
+ break;
+ case SCULPT_TOOL_SCRAPE:
+ br->add_col[1] = 1.000000;
+ br->sub_col[0] = 0.250000;
+ br->sub_col[1] = 1.000000;
+ break;
+ case SCULPT_TOOL_ROTATE:
+ break;
+ case SCULPT_TOOL_SMOOTH:
+ br->flag &= ~BRUSH_SPACE_ATTEN;
+ br->spacing = 5;
+ br->add_col[0] = 0.750000;
+ br->add_col[1] = 0.750000;
+ br->add_col[2] = 0.750000;
+ break;
+ case SCULPT_TOOL_GRAB:
+ case SCULPT_TOOL_SNAKE_HOOK:
+ case SCULPT_TOOL_THUMB:
+ br->size = 75;
+ br->flag &= ~BRUSH_ALPHA_PRESSURE;
+ br->flag &= ~BRUSH_SPACE;
+ br->flag &= ~BRUSH_SPACE_ATTEN;
+ br->add_col[0] = 0.250000;
+ br->add_col[1] = 1.000000;
+ br->add_col[2] = 0.250000;
+ break;
+ default:
+ break;
+ }
+}
+
/* Library Operations */
int brush_set_nr(Brush **current_brush, int nr, const char *name)