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:
-rw-r--r--source/blender/blenkernel/BKE_material.h3
-rw-r--r--source/blender/blenkernel/intern/material.c23
-rw-r--r--source/blender/editors/render/render_shading.c9
3 files changed, 27 insertions, 8 deletions
diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h
index e2f5fb23465..b5d2323c59a 100644
--- a/source/blender/blenkernel/BKE_material.h
+++ b/source/blender/blenkernel/BKE_material.h
@@ -78,7 +78,8 @@ enum {
BKE_MAT_ASSIGN_OBJECT
};
-struct Material *give_current_material(struct Object *ob, short act);
+struct Material **give_current_material_p(struct Object *ob, short act);
+struct Material *give_current_material(struct Object *ob, short act);
void assign_material_id(struct Main *bmain, struct ID *id, struct Material *ma, short act);
void assign_material(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type);
void assign_matarar(struct Main *bmain, struct Object *ob, struct Material ***matar, short totcol);
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 5c8ac0a81ce..5e14a520bf6 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -543,9 +543,9 @@ void BKE_material_clear_id(Main *bmain, ID *id, bool update_data)
}
}
-Material *give_current_material(Object *ob, short act)
+Material **give_current_material_p(Object *ob, short act)
{
- Material ***matarar, *ma;
+ Material ***matarar, **ma_p;
const short *totcolp;
if (ob == NULL) return NULL;
@@ -565,7 +565,7 @@ Material *give_current_material(Object *ob, short act)
}
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
- ma = ob->mat[act - 1];
+ ma_p = &ob->mat[act - 1];
}
else { /* in data */
@@ -576,12 +576,21 @@ Material *give_current_material(Object *ob, short act)
matarar = give_matarar(ob);
- if (matarar && *matarar) ma = (*matarar)[act - 1];
- else ma = NULL;
-
+ if (matarar && *matarar) {
+ ma_p = &(*matarar)[act - 1];
+ }
+ else {
+ ma_p = NULL;
+ }
}
- return ma;
+ return ma_p;
+}
+
+Material *give_current_material(Object *ob, short act)
+{
+ Material **ma_p = give_current_material_p(ob, act);
+ return ma_p ? *ma_p : NULL;
}
Material *give_node_material(Material *ma)
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 5b198774b71..8aa345dfa10 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -483,6 +483,15 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
if (prop) {
+ if (RNA_struct_is_a(ptr.type, &RNA_Object)) {
+ /* Add slot follows user-preferences for creating new slots,
+ * RNA pointer assignment doesn't, see: T60014. */
+ Object *ob = ptr.data;
+ if (give_current_material_p(ob, ob->actcol) == NULL) {
+ BKE_object_material_slot_add(bmain, ob);
+ }
+ }
+
/* when creating new ID blocks, use is already 1, but RNA
* pointer use also increases user, so this compensates it */
id_us_min(&ma->id);