diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-07-24 13:39:04 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-07-24 13:39:04 +0400 |
commit | cc40925c360fe031a623311045e1b74b4618629f (patch) | |
tree | ccb4deb03740d0cedb12cf279562c9964c8327c8 /source | |
parent | 6e41b008e3fadf76e5a9e2f29005f192c2ed33ec (diff) |
UI cleanup:
New layer in texture painting will now allow entering image parameters,
similar to new image.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 14 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 66 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 15 |
6 files changed, 48 insertions, 60 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index be6f985d701..2e4d38eebcc 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -343,14 +343,8 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } if (!MAIN_VERSION_ATLEAST(main, 271, 3)) { - Scene *sce; Brush *br; - for (sce = main->scene.first; sce; sce = sce->id.next) { - sce->toolsettings->imapaint.slot_xresolution_default = 1024; - sce->toolsettings->imapaint.slot_yresolution_default = 1024; - } - for (br = main->brush.first; br; br = br->id.next) { br->fill_threshold = 0.2f; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 0e765060967..21def9fe6d4 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1372,7 +1372,7 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op) if (ma) { has_material = true; if (!ma->texpaintslot) { - proj_paint_add_slot(C, MAP_COL, ma); + proj_paint_add_slot(C, MAP_COL, ma, NULL); } } } @@ -1385,7 +1385,7 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op) Material *ma = BKE_material_add(CTX_data_main(C), "Material"); /* no material found, just assign to first slot */ assign_material(ob, ma, 1, BKE_MAT_ASSIGN_USERPREF); - proj_paint_add_slot(C, MAP_COL, ma); + proj_paint_add_slot(C, MAP_COL, ma, NULL); } me = BKE_mesh_from_object(ob); @@ -1407,14 +1407,8 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op) Main *bmain = CTX_data_main(C); float color[4] = {0.0, 0.0, 0.0, 1.0}; - /* should not be allowed, but just in case */ - if (imapaint->slot_xresolution_default == 0) - imapaint->slot_xresolution_default = 1024; - if (imapaint->slot_yresolution_default == 0) - imapaint->slot_yresolution_default = 1024; - - width = imapaint->slot_xresolution_default; - height = imapaint->slot_yresolution_default; + width = 1024; + height = 1024; imapaint->stencil = BKE_image_add_generated(bmain, width, height, "Stencil", 32, false, IMA_GENTYPE_BLANK, color); } } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 5c1af41e05d..08cc964741e 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -4816,28 +4816,16 @@ static EnumPropertyItem layer_type_items[] = { {0, NULL, 0, NULL, NULL} }; -bool proj_paint_add_slot(bContext *C, int type, Material *ma) +bool proj_paint_add_slot(bContext *C, int type, Material *ma, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); int i; - ImagePaintSettings *imapaint = &CTX_data_tool_settings(C)->imapaint; bool use_nodes = BKE_scene_use_new_shading_nodes(scene); - int width; - int height; if (!ob) return false; - /* should not be allowed, but just in case */ - if (imapaint->slot_xresolution_default == 0) - imapaint->slot_xresolution_default = 1024; - if (imapaint->slot_yresolution_default == 0) - imapaint->slot_yresolution_default = 1024; - - width = imapaint->slot_xresolution_default; - height = imapaint->slot_yresolution_default; - if (!ma) ma = give_current_material(ob, ob->actcol); @@ -4866,13 +4854,22 @@ bool proj_paint_add_slot(bContext *C, int type, Material *ma) if (mtex->tex) { char imagename[FILE_MAX]; float color[4]; - bool use_float = type == MAP_NORM; - - copy_v4_v4(color, imapaint->slot_color_default); - if (use_float) { - mul_v3_fl(color, color[3]); + int width = 1024; + int height = 1024; + bool use_float = false; + short gen_type = IMA_GENTYPE_BLANK; + bool alpha = false; + + if (op) { + width = RNA_int_get(op->ptr, "width"); + height = RNA_int_get(op->ptr, "height"); + use_float = RNA_boolean_get(op->ptr, "float"); + gen_type = RNA_enum_get(op->ptr, "generated_type"); + RNA_float_get_array(op->ptr, "color", color); + alpha = RNA_boolean_get(op->ptr, "alpha"); } - else { + + if (!use_float) { /* crappy workaround because we only upload straight color to OpenGL and that makes * painting result on viewport too opaque */ color[3] = 1.0; @@ -4881,8 +4878,8 @@ bool proj_paint_add_slot(bContext *C, int type, Material *ma) /* take the second letter to avoid the ID identifier */ BLI_snprintf(imagename, FILE_MAX, "%s_%s", &ma->id.name[2], name); - ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, 32, use_float, - IMA_GENTYPE_BLANK, color); + ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float, + gen_type, color); BKE_texpaint_slot_refresh_cache(ma, false); BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE); @@ -4904,17 +4901,28 @@ static int texture_paint_add_texture_paint_slot_exec(bContext *C, wmOperator *op { int type = RNA_enum_get(op->ptr, "type"); - return proj_paint_add_slot(C, type, NULL) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + return proj_paint_add_slot(C, type, NULL, op); +} + + +static int texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +{ + return WM_operator_props_dialog_popup(C, op, 15 * UI_UNIT_X, 5 * UI_UNIT_Y); } + void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot) { + PropertyRNA *prop; + static float default_color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + /* identifiers */ ot->name = "Add Texture Paint Slot"; ot->description = "Add a texture paint slot"; ot->idname = "PAINT_OT_add_texture_paint_slot"; /* api callbacks */ + ot->invoke = texture_paint_add_texture_paint_slot_invoke; ot->exec = texture_paint_add_texture_paint_slot_exec; ot->poll = ED_operator_region_view3d_active; @@ -4922,5 +4930,17 @@ void PAINT_OT_add_texture_paint_slot(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", layer_type_items, 0, "Type", "Merge method to use"); + prop = RNA_def_enum(ot->srna, "type", layer_type_items, 0, "Type", "Merge method to use"); + RNA_def_property_flag(prop, PROP_HIDDEN); + prop = RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width", 1, 16384); + RNA_def_property_subtype(prop, PROP_PIXEL); + prop = RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height", 1, 16384); + RNA_def_property_subtype(prop, PROP_PIXEL); + prop = RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color", 0.0f, 1.0f); + RNA_def_property_subtype(prop, PROP_COLOR_GAMMA); + RNA_def_property_float_array_default(prop, default_color); + RNA_def_boolean(ot->srna, "alpha", 1, "Alpha", "Create an image with an alpha channel"); + RNA_def_enum(ot->srna, "generated_type", image_generated_type_items, IMA_GENTYPE_BLANK, + "Generated Type", "Fill the image with a grid for UV map testing"); + RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth"); } diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index f49699faad7..921992ed2f9 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -169,7 +169,7 @@ void paint_proj_stroke(const struct bContext *C, void *ps, const float prevmval_ void paint_proj_redraw(const struct bContext *C, void *pps, bool final); void paint_proj_stroke_done(void *ps); void paint_proj_mesh_data_ensure(bContext *C, struct Object *ob, struct wmOperator *op); -bool proj_paint_add_slot(bContext *C, int type, struct Material *ma); +bool proj_paint_add_slot(bContext *C, int type, struct Material *ma, struct wmOperator *op); void paint_brush_color_get(struct Scene *scene, struct Brush *br, bool color_correction, bool invert, float distance, float pressure, float color[3], struct ColorManagedDisplay *display); bool paint_use_opacity_masking(struct Brush *brush); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 5e27fffcc97..d7bc8e56e38 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -841,15 +841,10 @@ typedef struct ImagePaintSettings { short seam_bleed, normal_angle; short screen_grab_size[2]; /* capture size for re-projection */ - /* new layer default resolution */ - int slot_xresolution_default; - int slot_yresolution_default; - int pad1; void *paintcursor; /* wm handle */ struct Image *stencil; /* workaround until we support true layer masks */ - float slot_color_default[4]; float stencil_col[3]; float pad2; } ImagePaintSettings; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index f335ce04d96..af6cf493f1e 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -614,11 +614,6 @@ static void rna_def_image_paint(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "stencil_col"); RNA_def_property_ui_text(prop, "Stencil Color", "Stencil color in the viewport"); RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ImaPaint_stencil_update"); - - prop = RNA_def_property(srna, "slot_color_default", PROP_FLOAT, PROP_COLOR_GAMMA); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "New Layer Color", "Color/Alpha used for new"); - RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); prop = RNA_def_property(srna, "use_clone_layer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMAGEPAINT_PROJECT_LAYER_CLONE); @@ -639,16 +634,6 @@ static void rna_def_image_paint(BlenderRNA *brna) prop = RNA_def_int_array(srna, "screen_grab_size", 2, NULL, 0, 0, "screen_grab_size", "Size to capture the image for re-projecting", 0, 0); RNA_def_property_range(prop, 512, 16384); - - prop = RNA_def_property(srna, "slot_xresolution_default", PROP_INT, PROP_UNSIGNED); - RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_range(prop, 64, 4096, 0, -1); - RNA_def_property_ui_text(prop, "X resolution", "X Resolution of new image"); - - prop = RNA_def_property(srna, "slot_yresolution_default", PROP_INT, PROP_UNSIGNED); - RNA_def_property_range(prop, 1, SHRT_MAX); - RNA_def_property_ui_range(prop, 64, 4096, 0, -1); - RNA_def_property_ui_text(prop, "Y resolution", "Y Resolution of new image"); } static void rna_def_particle_edit(BlenderRNA *brna) |