diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-10-26 20:00:55 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-10-26 20:01:43 +0300 |
commit | bc7de854c90dd45758e7ff59c88ed0121c8cccca (patch) | |
tree | 3c80f3d927e01b5f4e3774431abc361801c00bd0 | |
parent | 414d5429fe32587c56c423308ad0a40fad242dab (diff) |
Sculpt: fix T102067: Set material properly in new pbvh draw
Note: Still need to fix PBVH_BMESH.
-rw-r--r-- | source/blender/draw/intern/draw_pbvh.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 38fb6d55245..a4de9e4fa47 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -951,6 +951,13 @@ struct PBVHBatches { void create_index_faces(PBVH_GPU_Args *args) { + int *mat_index = static_cast<int*>(CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index")); + + if (mat_index && args->totprim) { + int poly_index = args->mlooptri[args->prim_indices[0]].poly; + material_index = mat_index[poly_index]; + } + /* Calculate number of edges*/ int edge_count = 0; for (int i = 0; i < args->totprim; i++) { @@ -959,6 +966,7 @@ struct PBVHBatches { if (args->hide_poly && args->hide_poly[lt->poly]) { continue; } + int r_edges[3]; BKE_mesh_looptri_get_real_edges(args->me, lt, r_edges); @@ -1030,6 +1038,14 @@ struct PBVHBatches { void create_index_grids(PBVH_GPU_Args *args) { + int *mat_index = static_cast<int *>( + CustomData_get_layer_named(args->pdata, CD_PROP_INT32, "material_index")); + + if (mat_index && args->totprim) { + int poly_index = BKE_subdiv_ccg_grid_to_face_index(args->subdiv_ccg, args->grid_indices[0]); + material_index = mat_index[poly_index]; + } + needs_tri_index = true; int gridsize = args->ccg_key.grid_size; int totgrid = args->totprim; |