[Bf-blender-cvs] [bc7de854c90] master: Sculpt: fix T102067: Set material properly in new pbvh draw

Joseph Eagar noreply at git.blender.org
Wed Oct 26 19:01:43 CEST 2022


Commit: bc7de854c90dd45758e7ff59c88ed0121c8cccca
Author: Joseph Eagar
Date:   Wed Oct 26 19:00:55 2022 +0200
Branches: master
https://developer.blender.org/rBbc7de854c90dd45758e7ff59c88ed0121c8cccca

Sculpt: fix T102067: Set material properly in new pbvh draw

Note: Still need to fix PBVH_BMESH.

===================================================================

M	source/blender/draw/intern/draw_pbvh.cc

===================================================================

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;



More information about the Bf-blender-cvs mailing list