diff options
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index d4de04a9e98..e878a894b27 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -955,18 +955,26 @@ void BKE_object_material_remap_calc(Object *ob_dst, Object *ob_src, short *remap void BKE_object_material_array_assign(Main *bmain, struct Object *ob, struct Material ***matar, - short totcol) + int totcol, + const bool to_object_only) { int actcol_orig = ob->actcol; - short i; while ((ob->totcol > totcol) && BKE_object_material_slot_remove(bmain, ob)) { /* pass */ } /* now we have the right number of slots */ - for (i = 0; i < totcol; i++) { - BKE_object_material_assign(bmain, ob, (*matar)[i], i + 1, BKE_MAT_ASSIGN_USERPREF); + for (int i = 0; i < totcol; i++) { + if (to_object_only && ob->matbits[i] == 0) { + /* If we only assign to object, and that slot uses obdata material, do nothing. */ + continue; + } + BKE_object_material_assign(bmain, + ob, + (*matar)[i], + i + 1, + to_object_only ? BKE_MAT_ASSIGN_OBJECT : BKE_MAT_ASSIGN_USERPREF); } if (actcol_orig > ob->totcol) { @@ -1272,8 +1280,6 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma) if (ma->paint_clone_slot >= count) { ma->paint_clone_slot = count - 1; } - - return; } void BKE_texpaint_slots_refresh_object(Scene *scene, struct Object *ob) @@ -1712,6 +1718,29 @@ static void material_default_volume_init(Material *ma) nodeSetActive(ntree, output); } +static void material_default_holdout_init(Material *ma) +{ + bNodeTree *ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname); + ma->nodetree = ntree; + ma->use_nodes = true; + + bNode *holdout = nodeAddStaticNode(NULL, ntree, SH_NODE_HOLDOUT); + bNode *output = nodeAddStaticNode(NULL, ntree, SH_NODE_OUTPUT_MATERIAL); + + nodeAddLink(ntree, + holdout, + nodeFindSocket(holdout, SOCK_OUT, "Holdout"), + output, + nodeFindSocket(output, SOCK_IN, "Surface")); + + holdout->locx = 10.0f; + holdout->locy = 300.0f; + output->locx = 300.0f; + output->locy = 300.0f; + + nodeSetActive(ntree, output); +} + Material *BKE_material_default_empty(void) { return &default_material_empty; @@ -1757,6 +1786,7 @@ void BKE_materials_init(void) material_default_surface_init(&default_material_surface); material_default_volume_init(&default_material_volume); + material_default_holdout_init(&default_material_holdout); material_default_gpencil_init(&default_material_gpencil); } |