diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-08-06 11:04:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-08-06 11:07:44 +0300 |
commit | be1a684755905fd022be5ceecf9a7b2687475793 (patch) | |
tree | 5bcc3a62904a75e67980ea0e73dedd3a713c5e89 /source/blender/blenkernel/intern/material.c | |
parent | fa4172c28cfee1cd8c4b91481b6377eae48fdf93 (diff) |
Fix T45695: Assigning material reverts MaterialSlot.link
Setting the material was resetting the link bit, this is OK from the UI,
confusing for scripts.
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 283c7a6fc88..dd69de4877f 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -879,8 +879,20 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type) *totcolp = act; } + if (act > ob->totcol) { + /* Need more space in the material arrays */ + ob->mat = MEM_recallocN_id(ob->mat, sizeof(void *) * act, "matarray2"); + ob->matbits = MEM_recallocN_id(ob->matbits, sizeof(char) * act, "matbits1"); + ob->totcol = act; + } + /* Determine the object/mesh linking */ - if (assign_type == BKE_MAT_ASSIGN_USERPREF && ob->totcol && ob->actcol) { + if (assign_type == BKE_MAT_ASSIGN_EXISTING) { + /* keep existing option (avoid confusion in scripts), + * intentionally ignore userpref (default to obdata). */ + bit = ob->matbits[act - 1]; + } + else if (assign_type == BKE_MAT_ASSIGN_USERPREF && ob->totcol && ob->actcol) { /* copy from previous material */ bit = ob->matbits[ob->actcol - 1]; } @@ -898,13 +910,6 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type) break; } } - - if (act > ob->totcol) { - /* Need more space in the material arrays */ - ob->mat = MEM_recallocN_id(ob->mat, sizeof(void *) * act, "matarray2"); - ob->matbits = MEM_recallocN_id(ob->matbits, sizeof(char) * act, "matbits1"); - ob->totcol = act; - } /* do it */ |