diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_brush.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_brush.c | 181 |
1 files changed, 106 insertions, 75 deletions
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 90617d01833..15125795e01 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - * Contributor(s): Blender Foundation (2008), Juho Vepsäläinen + * Contributor(s): Blender Foundation (2008), Juho Veps�l�inen * * ***** END GPL LICENSE BLOCK ***** */ @@ -32,65 +32,84 @@ #include "DNA_brush_types.h" #include "DNA_texture_types.h" +#include "IMB_imbuf.h" + +EnumPropertyItem brush_sculpt_tool_items[] = { + {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, + {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, + {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, + {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, + {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, + {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, + {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "BKE_texture.h" + static void rna_Brush_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Brush *brush= (Brush*)ptr->data; - rna_iterator_array_begin(iter, (void*)brush->mtex, sizeof(MTex*), MAX_MTEX, NULL); + rna_iterator_array_begin(iter, (void*)brush->mtex, sizeof(MTex*), MAX_MTEX, 0, NULL); } static PointerRNA rna_Brush_active_texture_get(PointerRNA *ptr) { - Brush *brush= (Brush*)ptr->data; - return rna_pointer_inherit_refine(ptr, &RNA_TextureSlot, brush->mtex[(int)brush->texact]); -} + Brush *br= (Brush*)ptr->data; + Tex *tex; -static float rna_Brush_rotation_get(PointerRNA *ptr) -{ - Brush *brush= (Brush*)ptr->data; - const float conv = 57.295779506; - return brush->rot * conv; + tex= (br->mtex[(int)br->texact])? br->mtex[(int)br->texact]->tex: NULL; + return rna_pointer_inherit_refine(ptr, &RNA_Texture, tex); } -static void rna_Brush_rotation_set(PointerRNA *ptr, float v) +static void rna_Brush_active_texture_set(PointerRNA *ptr, PointerRNA value) { - Brush *brush= (Brush*)ptr->data; - const float conv = 0.017453293; - brush->rot = v * conv; + Brush *br= (Brush*)ptr->data; + int act= br->texact; + + if(br->mtex[act] && br->mtex[act]->tex) + id_us_min(&br->mtex[act]->tex->id); + + if(value.data) { + if(!br->mtex[act]) + br->mtex[act]= add_mtex(); + + br->mtex[act]->tex= value.data; + id_us_plus(&br->mtex[act]->tex->id); + } + else if(br->mtex[act]) { + MEM_freeN(br->mtex[act]); + br->mtex[act]= NULL; + } } #else -void rna_def_brush(BlenderRNA *brna) +static void rna_def_brush(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + static EnumPropertyItem prop_blend_items[] = { - {BRUSH_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."}, - {BRUSH_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."}, - {BRUSH_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting."}, - {BRUSH_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting."}, - {BRUSH_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."}, - {BRUSH_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, - {BRUSH_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."}, - {BRUSH_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_texture_mode_items[] = { - {BRUSH_TEX_DRAG, "TEX_DRAG", 0, "Drag", ""}, - {BRUSH_TEX_TILE, "TEX_TILE", 0, "Tile", ""}, - {BRUSH_TEX_3D, "TEX_3D", 0, "3D", ""}, + {IMB_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting."}, + {IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting."}, + {IMB_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting."}, + {IMB_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting."}, + {IMB_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting."}, + {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting."}, + {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting."}, + {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting."}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem prop_sculpt_tool_items[] = { - {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, - {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, - {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, - {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, - {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, - {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, - {0, NULL, 0, NULL, NULL}}; + static const EnumPropertyItem prop_flip_direction_items[]= { + {0, "ADD", 0, "Add", "Add effect of brush"}, + {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting."); RNA_def_struct_ui_icon(srna, ICON_BRUSH_DATA); @@ -100,29 +119,37 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, prop_blend_items); RNA_def_property_ui_text(prop, "Blending mode", "Brush blending mode."); - prop= RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "tex_mode"); - RNA_def_property_enum_items(prop, prop_texture_mode_items); - RNA_def_property_ui_text(prop, "Texture Mode", ""); - prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_sculpt_tool_items); + RNA_def_property_enum_items(prop, brush_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); + + prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, prop_flip_direction_items); + RNA_def_property_ui_text(prop, "Direction", "Mapping type to use for this image in the game engine."); /* number values */ prop= RNA_def_property(srna, "size", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 1, 200); RNA_def_property_ui_text(prop, "Size", "Diameter of the brush."); - prop= RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "innerradius"); + prop= RNA_def_property(srna, "jitter", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "jitter"); RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Falloff", "Falloff radius of the brush."); - + RNA_def_property_ui_text(prop, "Jitter", "Jitter the position of the brush while painting."); + prop= RNA_def_property(srna, "spacing", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spacing"); RNA_def_property_range(prop, 1.0f, 100.0f); RNA_def_property_ui_text(prop, "Spacing", "Spacing between brush stamps."); + + prop= RNA_def_property(srna, "smooth_stroke_radius", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 10, 200); + RNA_def_property_ui_text(prop, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues."); + + prop= RNA_def_property(srna, "smooth_stroke_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.5, 0.99); + RNA_def_property_ui_text(prop, "Smooth Stroke Factor", "Higher values give a smoother stroke."); prop= RNA_def_property(srna, "rate", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rate"); @@ -138,63 +165,67 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Strength", "The amount of pressure on the brush."); - prop= RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "rot"); - RNA_def_property_range(prop, 0, 360); - RNA_def_property_float_funcs(prop, "rna_Brush_rotation_get", "rna_Brush_rotation_set", NULL); - RNA_def_property_ui_text(prop, "Rotation", "Angle of the brush texture."); - /* flag */ - prop= RNA_def_property(srna, "airbrush", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_airbrush", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_AIRBRUSH); RNA_def_property_ui_text(prop, "Airbrush", "Keep applying paint effect while holding mouse (spray)."); - prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_TORUS); RNA_def_property_ui_text(prop, "Wrap", "Enable torus wrapping while painting."); - prop= RNA_def_property(srna, "alpha_pressure", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_strength_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ALPHA_PRESSURE); - RNA_def_property_ui_text(prop, "Opacity Pressure", "Enable tablet pressure sensitivity for opacity."); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Strength Pressure", "Enable tablet pressure sensitivity for strength."); - prop= RNA_def_property(srna, "size_pressure", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_size_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SIZE_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); RNA_def_property_ui_text(prop, "Size Pressure", "Enable tablet pressure sensitivity for size."); - prop= RNA_def_property(srna, "falloff_pressure", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RAD_PRESSURE); - RNA_def_property_ui_text(prop, "Falloff Pressure", "Enable tablet pressure sensitivity for falloff."); - - prop= RNA_def_property(srna, "spacing_pressure", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_jitter_pressure", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_JITTER_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); + RNA_def_property_ui_text(prop, "Jitter Pressure", "Enable tablet pressure sensitivity for jitter."); + + prop= RNA_def_property(srna, "use_spacing_pressure", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACING_PRESSURE); + RNA_def_property_ui_icon(prop, ICON_STYLUS_PRESSURE, 0); RNA_def_property_ui_text(prop, "Spacing Pressure", "Enable tablet pressure sensitivity for spacing."); - prop= RNA_def_property(srna, "rake", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_rake", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_RAKE); RNA_def_property_ui_text(prop, "Rake", "Rotate the brush texture to match the stroke direction."); - prop= RNA_def_property(srna, "anchored", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_anchor", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_ANCHORED); RNA_def_property_ui_text(prop, "Anchored", "Keep the brush anchored to the initial location."); - prop= RNA_def_property(srna, "flip_direction", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_DIR_IN); - RNA_def_property_ui_text(prop, "Flip Direction", "Move vertices in the opposite direction."); - - prop= RNA_def_property(srna, "space", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "use_space", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SPACE); RNA_def_property_ui_text(prop, "Space", "Limit brush application to the distance specified by spacing."); + + prop= RNA_def_property(srna, "use_smooth_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_SMOOTH_STROKE); + RNA_def_property_ui_text(prop, "Smooth Stroke", "Brush lags behind mouse and follows a smoother path."); + + prop= RNA_def_property(srna, "use_persistent", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_PERSISTENT); + RNA_def_property_ui_text(prop, "Persistent", "Sculpts on a persistent layer of the mesh."); /* not exposed in the interface yet prop= RNA_def_property(srna, "fixed_tex", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_FIXED_TEX); RNA_def_property_ui_text(prop, "Fixed Texture", "Keep texture origin in fixed position.");*/ - prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NEVER_NULL); + prop= RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "Curve", "Editable falloff curve."); /* texture */ - rna_def_mtex_common(srna, "rna_Brush_mtex_begin", "rna_Brush_active_texture_get", "TextureSlot"); + rna_def_mtex_common(srna, "rna_Brush_mtex_begin", "rna_Brush_active_texture_get", + "rna_Brush_active_texture_set", "TextureSlot"); /* clone tool */ prop= RNA_def_property(srna, "clone_image", PROP_POINTER, PROP_NONE); @@ -207,7 +238,7 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clone Opacity", "Opacity of clone image display."); - prop= RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "clone.offset"); RNA_def_property_ui_text(prop, "Clone Offset", ""); RNA_def_property_ui_range(prop, -1.0f , 1.0f, 10.0f, 3); @@ -232,12 +263,12 @@ static void rna_def_operator_stroke_element(BlenderRNA *brna) srna= RNA_def_struct(brna, "OperatorStrokeElement", "IDPropertyGroup"); RNA_def_struct_ui_text(srna, "Operator Stroke Element", ""); - prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); + prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Location", ""); - prop= RNA_def_property(srna, "mouse", PROP_INT, PROP_VECTOR); + prop= RNA_def_property(srna, "mouse", PROP_FLOAT, PROP_XYZ); RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_array(prop, 2); RNA_def_property_ui_text(prop, "Mouse", ""); |