]> OCCT Git - occt-copy.git/commitdiff
0023433: Compiler warnings in Graphic3d_ArrayOfPrimitives.lxx
authorabv <abv@opencascade.com>
Fri, 14 Sep 2012 09:09:39 +0000 (13:09 +0400)
committerabv <abv@opencascade.com>
Fri, 21 Sep 2012 12:05:33 +0000 (16:05 +0400)
Conversion of color components from real [0,1] to char [0,255] corrected to avoid compiler warnings

src/Graphic3d/Graphic3d_ArrayOfPrimitives.lxx

index 462c94f7300244fd4673b2b079fa5e1bd3209091..dba08d15d84dc90dd96559b5db81a0de580c9c51 100755 (executable)
@@ -98,9 +98,9 @@ inline void Graphic3d_ArrayOfPrimitives::SetVertexColor(
   }
 
   if( myPrimitiveArray->vcolours ) {
-    unsigned char red   = (unsigned int)(R * 255.);
-    unsigned char green = (unsigned int)(G * 255.);
-    unsigned char blue  = (unsigned int)(B * 255.);
+    unsigned char red   = (unsigned char)(R <= 0. ? 0. : R >= 1. ? 255. : R * 255.);
+    unsigned char green = (unsigned char)(G <= 0. ? 0. : G >= 1. ? 255. : G * 255.);
+    unsigned char blue  = (unsigned char)(B <= 0. ? 0. : B >= 1. ? 255. : B * 255.);
     unsigned char alpha = 0;
     Standard_Integer outColor ;
     outColor = red;