[Bf-blender-cvs] [71184d2bc83] functions: fix overflow in color conversion

Jacques Lucke noreply at git.blender.org
Fri Sep 13 14:24:51 CEST 2019


Commit: 71184d2bc839d4283afab442753e19aa9c6f45e2
Author: Jacques Lucke
Date:   Fri Sep 13 14:24:47 2019 +0200
Branches: functions
https://developer.blender.org/rB71184d2bc839d4283afab442753e19aa9c6f45e2

fix overflow in color conversion

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

M	source/blender/simulations/bparticles/c_wrapper.cpp

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

diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index b9b2864c7db..b657ff4e1ae 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -32,6 +32,7 @@ using namespace BParticles;
 
 using BLI::ArrayRef;
 using BLI::float3;
+using BLI::rgba_b;
 using BLI::rgba_f;
 using BLI::StringRef;
 using BLI::Vector;
@@ -117,14 +118,12 @@ static void distribute_tetrahedons_range(Mesh *mesh,
     }
 
     rgba_f color_f = colors[instance];
-    MLoopCol color_b = {(uchar)(color_f.r * 255.0f),
-                        (uchar)(color_f.g * 255.0f),
-                        (uchar)(color_f.b * 255.0f),
-                        255};
+    rgba_b color_b = color_f;
+    MLoopCol loop_col = {color_b.r, color_b.g, color_b.b, color_b.a};
     for (uint i = 0; i < ARRAY_SIZE(tetrahedon_loop_vertices); i++) {
       mesh->mloop[loop_offset + i].v = vertex_offset + tetrahedon_loop_vertices[i];
       mesh->mloop[loop_offset + i].e = edge_offset + tetrahedon_loop_edges[i];
-      loop_colors[loop_offset + i] = color_b;
+      loop_colors[loop_offset + i] = loop_col;
     }
 
     for (uint i = 0; i < ARRAY_SIZE(tetrahedon_edges); i++) {



More information about the Bf-blender-cvs mailing list