Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/gpencil/gpencil_draw_data.c
| Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | |||||
| * Creates a linked list of material pool containing all materials assigned for a given object. | * Creates a linked list of material pool containing all materials assigned for a given object. | ||||
| * We merge the material pools together if object does not contain a huge amount of materials. | * We merge the material pools together if object does not contain a huge amount of materials. | ||||
| * Also return an offset to the first material of the object in the ubo. | * Also return an offset to the first material of the object in the ubo. | ||||
| */ | */ | ||||
| GPENCIL_MaterialPool *gpencil_material_pool_create(GPENCIL_PrivateData *pd, Object *ob, int *ofs) | GPENCIL_MaterialPool *gpencil_material_pool_create(GPENCIL_PrivateData *pd, Object *ob, int *ofs) | ||||
| { | { | ||||
| GPENCIL_MaterialPool *matpool = pd->last_material_pool; | GPENCIL_MaterialPool *matpool = pd->last_material_pool; | ||||
| int mat_len = max_ii(1, ob->totcol); | int mat_len = max_ii(1, BKE_object_material_count_eval(ob)); | ||||
| bool reuse_matpool = matpool && ((matpool->used_count + mat_len) <= GP_MATERIAL_BUFFER_LEN); | bool reuse_matpool = matpool && ((matpool->used_count + mat_len) <= GP_MATERIAL_BUFFER_LEN); | ||||
| if (reuse_matpool) { | if (reuse_matpool) { | ||||
| /* Share the matpool with other objects. Return offset to first material. */ | /* Share the matpool with other objects. Return offset to first material. */ | ||||
| *ofs = matpool->used_count; | *ofs = matpool->used_count; | ||||
| } | } | ||||
| else { | else { | ||||
| ▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines | |||||