From 31eb3e8d242779f2dd470bca5c59a506142066de Mon Sep 17 00:00:00 2001 From: Shyotl Date: Fri, 3 May 2013 14:28:20 -0500 Subject: [PATCH] Cleaned up LLManipScale::nearestAxis to dodge a compiler crash that was found when playing with particular compiler options. --- indra/newview/llmanipscale.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp index 8cd1abe58..76aa99775 100644 --- a/indra/newview/llmanipscale.cpp +++ b/indra/newview/llmanipscale.cpp @@ -2012,36 +2012,34 @@ LLVector3 LLManipScale::nearestAxis( const LLVector3& v ) const // Note: yes, this is a slow but easy implementation // assumes v is normalized - F32 coords[][3] = + static LLVector3 coords[] = { - { 1.f, 0.f, 0.f }, - { 0.f, 1.f, 0.f }, - { 0.f, 0.f, 1.f }, - {-1.f, 0.f, 0.f }, - { 0.f,-1.f, 0.f }, - { 0.f, 0.f,-1.f } + LLVector3( 1.f, 0.f, 0.f ), + LLVector3( 0.f, 1.f, 0.f ), + LLVector3( 0.f, 0.f, 1.f ), + LLVector3(-1.f, 0.f, 0.f ), + LLVector3( 0.f,-1.f, 0.f ), + LLVector3( 0.f, 0.f,-1.f ) }; F32 cosine[6]; - cosine[0] = v * LLVector3( coords[0] ); - cosine[1] = v * LLVector3( coords[1] ); - cosine[2] = v * LLVector3( coords[2] ); + cosine[0] = v * coords[0]; + cosine[1] = v * coords[1]; + cosine[2] = v * coords[2]; cosine[3] = -cosine[0]; cosine[4] = -cosine[1]; cosine[5] = -cosine[2]; - F32 greatest_cos = cosine[0]; S32 greatest_index = 0; for( S32 i=1; i<6; i++ ) { - if( greatest_cos < cosine[i] ) + if( cosine[greatest_index] < cosine[i] ) { - greatest_cos = cosine[i]; greatest_index = i; } } - return LLVector3( coords[greatest_index] ); + return coords[greatest_index]; } // virtual