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
path: root/source
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-08-27 15:54:02 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-08-27 15:54:02 +0400
commit2a15ecdb5d3a8b56851e587bbdf0c562bfd2252e (patch)
tree67ca75d90db17419e4ce5274d84016238502eb98 /source
parent4f4997cb0386de5d3d2b2d8f41c9d6f9078e5910 (diff)
Do not allow empty material slots in texture painting.
Any mfaces using those materials will cause a crash.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 82f918b8cd8..5a4fda033d8 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1349,38 +1349,34 @@ void paint_proj_mesh_data_ensure(bContext *C, Object *ob, wmOperator *op)
{
Mesh *me;
int layernum;
- bool add_material = false;
ImagePaintSettings *imapaint = &(CTX_data_tool_settings(C)->imapaint);
Brush *br = BKE_paint_brush(&imapaint->paint);
/* no material, add one */
if (ob->totcol == 0) {
- add_material = true;
+ 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, ma, NULL);
}
else {
/* there may be material slots but they may be empty, check */
- bool has_material = false;
int i;
for (i = 1; i < ob->totcol + 1; i++) {
Material *ma = give_current_material(ob, i);
if (ma) {
- has_material = true;
if (!ma->texpaintslot) {
proj_paint_add_slot(C, ma, NULL);
}
}
+ else {
+ Material *ma = BKE_material_add(CTX_data_main(C), "Material");
+ /* no material found, just assign to first slot */
+ assign_material(ob, ma, i, BKE_MAT_ASSIGN_USERPREF);
+ proj_paint_add_slot(C, ma, NULL);
+ }
}
-
- if (!has_material)
- add_material = true;
- }
-
- if (add_material) {
- 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, ma, NULL);
}
me = BKE_mesh_from_object(ob);
@@ -1460,7 +1456,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
}
}
}
-
+
ob->mode |= mode_flag;
BKE_paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT);