From afa0fa5e29de94b093f4eda2f8105faa59ba5573 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 16 Aug 2009 19:50:00 +0000 Subject: 2.5 Sculpt: * Added a new Paint type in scene DNA. This is now the base struct for Sculpt. * The Paint type contains a list of Brushes, you can add or remove these much like material and texture slots. * Modified the UI for the new Paint type, now shows the list of brushes active for this mode * Added a New Brush operator, shows in the UI as a list of brush tool types to add * Made the sculpt tool property UI smaller and not expanded, expectation is that we will have a number of preset brushes that will cover the basic sculpt brush types TODO: * Vertex paint, weight paint, texture paint need to be converted to this system next * Add brush presets to the default blend --- source/blender/makesrna/RNA_enum_types.h | 2 + source/blender/makesrna/intern/rna_brush.c | 24 ++++----- source/blender/makesrna/intern/rna_sculpt_paint.c | 60 +++++++++++++++++++++-- 3 files changed, 69 insertions(+), 17 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index a7488ed437b..46d8c50caa6 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -49,6 +49,8 @@ extern EnumPropertyItem nla_mode_blend_items[]; extern EnumPropertyItem event_value_items[]; extern EnumPropertyItem event_type_items[]; +extern EnumPropertyItem brush_sculpt_tool_items[]; + #endif /* RNA_ENUM_TYPES */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index b58df16dc62..65c66800f41 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -32,6 +32,17 @@ #include "DNA_brush_types.h" #include "DNA_texture_types.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" @@ -92,17 +103,6 @@ void rna_def_brush(BlenderRNA *brna) {BRUSH_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", ""}, - {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, - {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); @@ -113,7 +113,7 @@ void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Blending mode", "Brush blending 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", ""); /* number values */ diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 1e512d8f9bb..9b0e679e3b6 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -31,6 +31,8 @@ #include "DNA_scene_types.h" +#include "BKE_paint.h" + #ifdef RNA_RUNTIME static PointerRNA rna_ParticleEdit_brush_get(PointerRNA *ptr) @@ -49,20 +51,67 @@ static PointerRNA rna_ParticleBrush_curve_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, &RNA_CurveMapping, NULL); } +static void rna_Paint_brushes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Paint *p= (Paint*)ptr->data; + rna_iterator_array_begin(iter, (void*)p->brushes, sizeof(Brush*), p->brush_count, 0, NULL); +} + +static int rna_Paint_brushes_length(PointerRNA *ptr) +{ + Paint *p= (Paint*)ptr->data; + + return p->brush_count; +} + +static PointerRNA rna_Paint_active_brush_get(PointerRNA *ptr) +{ + return rna_pointer_inherit_refine(ptr, &RNA_Brush, paint_brush(ptr->data)); +} + +static void rna_Paint_active_brush_set(PointerRNA *ptr, PointerRNA value) +{ + paint_brush_set(ptr->data, value.data); +} + #else -static void rna_def_sculpt(BlenderRNA *brna) +static void rna_def_paint(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna= RNA_def_struct(brna, "Sculpt", NULL); - RNA_def_struct_ui_text(srna, "Sculpt", ""); - + srna= RNA_def_struct(brna, "Paint", NULL); + RNA_def_struct_ui_text(srna, "Paint", ""); + + prop= RNA_def_property(srna, "brushes", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "Brush"); + RNA_def_property_collection_funcs(prop, "rna_Paint_brushes_begin", + "rna_iterator_array_next", + "rna_iterator_array_end", + "rna_iterator_array_dereference_get", + "rna_Paint_brushes_length", 0, 0, 0, 0); + RNA_def_property_ui_text(prop, "Brushes", "Brushes selected for this paint mode."); + + prop= RNA_def_property(srna, "active_brush_index", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, INT_MAX); + + /* Fake property to get active brush directly, rather than integer index */ prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Brush"); - RNA_def_property_ui_text(prop, "Brush", ""); + RNA_def_property_pointer_funcs(prop, "rna_Paint_active_brush_get", "rna_Paint_active_brush_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Brush", "Active paint brush."); +} +static void rna_def_sculpt(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "Sculpt", "Paint"); + RNA_def_struct_ui_text(srna, "Sculpt", ""); + prop= RNA_def_property(srna, "symmetry_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SYMM_X); RNA_def_property_ui_text(prop, "Symmetry X", "Mirror brush across the X axis."); @@ -353,6 +402,7 @@ static void rna_def_particle_edit(BlenderRNA *brna) void RNA_def_sculpt_paint(BlenderRNA *brna) { + rna_def_paint(brna); rna_def_sculpt(brna); rna_def_vertex_paint(brna); rna_def_image_paint(brna); -- cgit v1.2.3