Merge branch 'blender2.7'
This commit is contained in:
@@ -79,6 +79,7 @@ enum {
|
|||||||
BKE_MAT_ASSIGN_OBJECT
|
BKE_MAT_ASSIGN_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Material **give_current_material_p(struct Object *ob, short act);
|
||||||
struct Material *give_current_material(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_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_material(struct Main *bmain, struct Object *ob, struct Material *ma, short act, int assign_type);
|
||||||
|
@@ -512,9 +512,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;
|
const short *totcolp;
|
||||||
|
|
||||||
if (ob == NULL) return NULL;
|
if (ob == NULL) return NULL;
|
||||||
@@ -534,7 +534,7 @@ Material *give_current_material(Object *ob, short act)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
|
if (ob->matbits && ob->matbits[act - 1]) { /* in object */
|
||||||
ma = ob->mat[act - 1];
|
ma_p = &ob->mat[act - 1];
|
||||||
}
|
}
|
||||||
else { /* in data */
|
else { /* in data */
|
||||||
|
|
||||||
@@ -545,12 +545,21 @@ Material *give_current_material(Object *ob, short act)
|
|||||||
|
|
||||||
matarar = give_matarar(ob);
|
matarar = give_matarar(ob);
|
||||||
|
|
||||||
if (matarar && *matarar) ma = (*matarar)[act - 1];
|
if (matarar && *matarar) {
|
||||||
else ma = NULL;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaterialGPencilStyle *BKE_material_gpencil_settings_get(Object *ob, short act)
|
MaterialGPencilStyle *BKE_material_gpencil_settings_get(Object *ob, short act)
|
||||||
|
@@ -523,7 +523,6 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
{
|
{
|
||||||
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
|
||||||
Main *bmain = CTX_data_main(C);
|
Main *bmain = CTX_data_main(C);
|
||||||
Object *ob = CTX_data_active_object(C);
|
|
||||||
PointerRNA ptr, idptr;
|
PointerRNA ptr, idptr;
|
||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
@@ -532,6 +531,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
ma = BKE_material_copy(bmain, ma);
|
ma = BKE_material_copy(bmain, ma);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Object *ob = CTX_data_active_object(C);
|
||||||
if ((!ob) || (ob->type != OB_GPENCIL)) {
|
if ((!ob) || (ob->type != OB_GPENCIL)) {
|
||||||
ma = BKE_material_add(bmain, DATA_("Material"));
|
ma = BKE_material_add(bmain, DATA_("Material"));
|
||||||
}
|
}
|
||||||
@@ -546,6 +546,15 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
|
|||||||
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
UI_context_active_but_prop_get_templateID(C, &ptr, &prop);
|
||||||
|
|
||||||
if (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
|
/* when creating new ID blocks, use is already 1, but RNA
|
||||||
* pointer use also increases user, so this compensates it */
|
* pointer use also increases user, so this compensates it */
|
||||||
id_us_min(&ma->id);
|
id_us_min(&ma->id);
|
||||||
|
Reference in New Issue
Block a user