[Bf-blender-cvs] [cc40925] master: UI cleanup:
Antony Riakiotakis
noreply at git.blender.org
Thu Jul 24 11:39:11 CEST 2014
Commit: cc40925c360fe031a623311045e1b74b4618629f
Author: Antony Riakiotakis
Date: Thu Jul 24 11:39:04 2014 +0200
Branches: master
https://developer.blender.org/rBcc40925c360fe031a623311045e1b74b4618629f
UI cleanup:
New layer in texture painting will now allow entering image parameters,
similar to new image.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenloader/intern/versioning_270.c
M source/blender/editors/sculpt_paint/paint_image.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
M source/blender/editors/sculpt_paint/paint_intern.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 4caf25c..39e6e2d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1082,11 +1082,6 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
if not mat.use_nodes:
col.operator_menu_enum("paint.add_texture_paint_slot", "type")
- row = col.row(align=True)
- row.prop(settings, "slot_xresolution_default")
- row.prop(settings, "slot_yresolution_default")
- col.prop(settings, "slot_color_default")
-
slot = mat.texture_paint_slots[mat.paint_active_slot]
col.separator()
col.label("UV Layer")
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index be6f985..2e4d38e 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 0e76506..21def9f 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 5c1af41..08cc964 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 f49699f..921992e 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 5e27fff..d7bc8e5 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 f335ce0..af6cf49 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list