diff options
author | YimingWu <xp8110@outlook.com> | 2022-08-16 13:29:54 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2022-08-16 13:32:43 +0300 |
commit | accf38c1d1d9c2b34f8e30ee1f1cbbf3cdfb69f6 (patch) | |
tree | 8c1882966c672a181067cea9bdbe9141a7ca3ec7 /source/blender | |
parent | 2d19038c6c2817fff4d8278adfa9d14020c9eea6 (diff) |
Fix T100435: Use evaluated material for line art loading.
Materials can be changed by other evaluations like geometry nodes,
now handles that kind of situation.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h | 1 | ||||
-rw-r--r-- | source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 224146d0032..8d34fb2ffb2 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -482,6 +482,7 @@ typedef struct LineartRenderTaskInfo { typedef struct LineartObjectInfo { struct LineartObjectInfo *next; struct Object *original_ob; + struct Object *original_ob_eval; /* For evaluated materials */ struct Mesh *original_me; double model_view_proj[4][4]; double model_view[4][4]; diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index a6b9f1420f1..f966af088c1 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1471,6 +1471,7 @@ typedef struct EdgeFeatData { LineartData *ld; Mesh *me; Object *ob; + Object *ob_eval; /* For evaluated materials. */ const MLoopTri *mlooptri; LineartTriangle *tri_array; LineartVert *v_array; @@ -1504,6 +1505,7 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userdata_chunk; Mesh *me = e_feat_data->me; Object *ob = e_feat_data->ob; + Object *ob_eval = e_feat_data->ob_eval; LineartEdgeNeighbor *edge_nabr = e_feat_data->edge_nabr; const MLoopTri *mlooptri = e_feat_data->mlooptri; @@ -1653,8 +1655,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, int mat2 = me->mpoly[mlooptri[f2].poly].mat_nr; if (mat1 != mat2) { - Material *m1 = BKE_object_material_get(ob, mat1 + 1); - Material *m2 = BKE_object_material_get(ob, mat2 + 1); + Material *m1 = BKE_object_material_get_eval(ob_eval, mat1 + 1); + Material *m2 = BKE_object_material_get_eval(ob_eval, mat2 + 1); if (m1 && m2 && ((m1->lineart.mat_occlusion == 0 && m2->lineart.mat_occlusion != 0) || (m2->lineart.mat_occlusion == 0 && m1->lineart.mat_occlusion != 0))) { @@ -1869,8 +1871,8 @@ static void lineart_load_tri_task(void *__restrict userdata, tri->v[2] = &vert_arr[v3]; /* Material mask bits and occlusion effectiveness assignment. */ - Material *mat = BKE_object_material_get(ob_info->original_ob, - me->mpoly[mlooptri->poly].mat_nr + 1); + Material *mat = BKE_object_material_get_eval(ob_info->original_ob_eval, + me->mpoly[mlooptri->poly].mat_nr + 1); tri->material_mask_bits |= ((mat && (mat->lineart.flags & LRT_MATERIAL_MASK_ENABLED)) ? mat->lineart.material_mask_bits : 0); @@ -2121,6 +2123,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info, edge_feat_data.ld = la_data; edge_feat_data.me = me; edge_feat_data.ob = orig_ob; + edge_feat_data.ob_eval = ob_info->original_ob_eval; edge_feat_data.mlooptri = mlooptri; edge_feat_data.edge_nabr = lineart_build_edge_neighbor(me, total_edges); edge_feat_data.tri_array = la_tri_arr; @@ -2511,6 +2514,7 @@ static void lineart_object_load_single_instance(LineartData *ld, obi->original_me = use_mesh; obi->original_ob = (ref_ob->id.orig_id ? (Object *)ref_ob->id.orig_id : (Object *)ref_ob); + obi->original_ob_eval = DEG_get_evaluated_object(depsgraph, obi->original_ob); lineart_geometry_load_assign_thread(olti, obi, thread_count, use_mesh->totpoly); } |