Fix #108591: Handle null material adding paint slot #108592

Merged
YimingWu merged 5 commits from ChengduLittleA/blender:fix-108591 into blender-v3.6-release 2023-06-06 04:13:08 +02:00
1 changed files with 6 additions and 4 deletions
Showing only changes of commit 7b6d4c66a1 - Show all commits

View File

@ -6631,6 +6631,10 @@ static const char *proj_paint_color_attribute_create(wmOperator *op, Object *ob)
*/
static void default_paint_slot_color_get(int layer_type, Material *ma, float color[4])
{
if ((!ma) || (!ma->nodetree)) {
color[0] = color[1] = color[2] = color[3] = 1.0f;
return;
}
switch (layer_type) {
case LAYER_BASE_COLOR:
case LAYER_SPECULAR:
@ -6872,10 +6876,8 @@ static int texture_paint_add_texture_paint_slot_invoke(bContext *C,
/* Set default color. Copy the color from nodes, so it matches the existing material.
* Material could be null so we should have a default color. */
float color[4]={1.0f, 1.0f, 1.0f, 1.0f};
if(ma) {
default_paint_slot_color_get(type, ma, color);
}
float color[4];
default_paint_slot_color_get(type, ma, color);
RNA_float_set_array(op->ptr, "color", color);
return WM_operator_props_dialog_popup(C, op, 300);