[Bf-blender-cvs] [1eba76d8eda] master: Sculpt: Fix T101503: Memory corruption in multires faceset drawing

Joseph Eagar noreply at git.blender.org
Sat Oct 1 00:03:18 CEST 2022


Commit: 1eba76d8eda60a0110460e6c880ae0875dd7fd5f
Author: Joseph Eagar
Date:   Fri Sep 30 15:02:50 2022 -0700
Branches: master
https://developer.blender.org/rB1eba76d8eda60a0110460e6c880ae0875dd7fd5f

Sculpt: Fix T101503: Memory corruption in multires faceset drawing

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

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 a1ea18aa0d1..fbee8313041 100644
--- a/source/blender/draw/intern/draw_pbvh.cc
+++ b/source/blender/draw/intern/draw_pbvh.cc
@@ -61,7 +61,6 @@ using blender::IndexRange;
 using blender::Map;
 using blender::short3;
 using blender::uchar3;
-using blender::uchar4;
 using blender::ushort3;
 using blender::ushort4;
 using blender::Vector;
@@ -395,13 +394,13 @@ struct PBVHBatches {
 
           foreach_grids(
               [&](int /*x*/, int /*y*/, int /*grid_index*/, CCGElem * /*elems*/[4], int /*i*/) {
-                *static_cast<uchar4 *>(GPU_vertbuf_raw_step(&access)) = white;
+                *static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = white;
               });
         }
         else {
           foreach_grids(
               [&](int /*x*/, int /*y*/, int grid_index, CCGElem * /*elems*/[4], int /*i*/) {
-                uchar face_set_color[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
+                uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
 
                 if (face_sets) {
                   const int face_index = BKE_subdiv_ccg_grid_to_face_index(args->subdiv_ccg,
@@ -554,7 +553,7 @@ struct PBVHBatches {
 
         if (face_sets) {
           int last_poly = -1;
-          uchar fset_color[3] = {255, 255, 255};
+          uchar fset_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
 
           foreach_faces(
               [&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const MLoopTri *tri) {
@@ -569,7 +568,7 @@ struct PBVHBatches {
                   }
                   else {
                     /* Skip for the default color face set to render it white. */
-                    fset_color[0] = fset_color[1] = fset_color[2] = 255;
+                    fset_color[0] = fset_color[1] = fset_color[2] = UCHAR_MAX;
                   }
                 }
 
@@ -577,7 +576,7 @@ struct PBVHBatches {
               });
         }
         else {
-          uchar fset_color[3] = {255, 255, 255};
+          uchar fset_color[4] = {255, 255, 255, 255};
 
           foreach_faces(
               [&](int /*buffer_i*/, int /*tri_i*/, int /*vertex_i*/, const MLoopTri * /*tri*/) {
@@ -763,7 +762,7 @@ struct PBVHBatches {
         break;
       }
       case CD_PBVH_FSET_TYPE: {
-        uchar3 white(255, 255, 255);
+        uchar3 white(UCHAR_MAX, UCHAR_MAX, UCHAR_MAX);
 
         foreach_bmesh([&](BMLoop * /*l*/) {
           *static_cast<uchar3 *>(GPU_vertbuf_raw_step(&access)) = white;



More information about the Bf-blender-cvs mailing list