From c9e7ad8b7689706e26683a56b5594651b78bfb0f Mon Sep 17 00:00:00 2001 From: Kyzentun Keeslala Date: Mon, 12 Oct 2015 02:18:15 -0600 Subject: [PATCH] Fixed bug in ActorMultiVertex::DrawPrimitives that converted RageColor channels to uint8 when applying the diffuse to verts, which made any channel not 1 into 0. --- src/ActorMultiVertex.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ActorMultiVertex.cpp b/src/ActorMultiVertex.cpp index 0eddf375df..6c20f59fed 100644 --- a/src/ActorMultiVertex.cpp +++ b/src/ActorMultiVertex.cpp @@ -236,11 +236,22 @@ void ActorMultiVertex::DrawPrimitives() for( size_t i=0; i < TS.vertices.size(); i++ ) { + // RageVColor uses a uint8_t for each channel. 0-255. + // RageColor uses a float. 0-1. + // So each channel of the RageVColor needs to be converted to a float, + // multiplied by the channel from the RageColor, then the result + // converted to uint8_t. If implicit conversion is allowed to happen, + // sometimes the compiler decides to turn the RageColor into a uint8_t, + // which makes any value other than 1 into 0. Thus, the explicit + // conversions. -Kyz +#define MULT_COLOR_ELEMENTS(color_a, color_b) \ + color_a= static_cast(static_cast(color_a) * color_b); // RageVColor * RageColor - TS.vertices[i].c.b *= m_pTempState->diffuse[0].b; - TS.vertices[i].c.r *= m_pTempState->diffuse[0].r; - TS.vertices[i].c.g *= m_pTempState->diffuse[0].g; - TS.vertices[i].c.a *= m_pTempState->diffuse[0].a; + MULT_COLOR_ELEMENTS(TS.vertices[i].c.b, m_pTempState->diffuse[0].b); + MULT_COLOR_ELEMENTS(TS.vertices[i].c.r, m_pTempState->diffuse[0].r); + MULT_COLOR_ELEMENTS(TS.vertices[i].c.g, m_pTempState->diffuse[0].g); + MULT_COLOR_ELEMENTS(TS.vertices[i].c.a, m_pTempState->diffuse[0].a); +#undef MULT_COLOR_ELEMENTS } }