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:
authorAntony Riakiotakis <kalast@gmail.com>2014-07-24 13:39:04 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-07-24 13:39:04 +0400
commitcc40925c360fe031a623311045e1b74b4618629f (patch)
treeccb4deb03740d0cedb12cf279562c9964c8327c8 /source/blender/editors
parent6e41b008e3fadf76e5a9e2f29005f192c2ed33ec (diff)
UI cleanup:
New layer in texture painting will now allow entering image parameters, similar to new image.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c14
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c66
-rw-r--r--source/blender/editors/sculpt_paint/paint_intern.h2
3 files changed, 48 insertions, 34 deletions
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);