From dd71a9faacbf52ab5a741c86924149251fadc009 Mon Sep 17 00:00:00 2001
From: prep <prep@lindenlab.com>
Date: Wed, 30 Mar 2011 14:05:23 -0400
Subject: [PATCH] Fix for SH-1177 - Allowable range for an alternate pivot is
 -64 to 64

---
 indra/newview/llfloatermodelpreview.cpp | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 4d7c079a6ff..3cb756a006b 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -111,6 +111,8 @@ const S32 PREVIEW_HPAD = PREVIEW_RESIZE_HANDLE_SIZE;
 const S32 PREF_BUTTON_HEIGHT = 16 + 7 + 16;
 const S32 PREVIEW_TEXTURE_HEIGHT = 300;
 
+const F32 MAXIMUM_PIVOT_OFFSET = 64.0f;
+
 void drawBoxOutline(const LLVector3& pos, const LLVector3& size);
 
 
@@ -1913,8 +1915,19 @@ void LLModelLoader::handlePivotPoint( daeElement* pRoot )
 				if ( pTranslate )
 				{
 					extractTranslation( pTranslate, workingTransform );
-					mPreview->setModelPivot( workingTransform.getTranslation() );
-					mPreview->setHasPivot( true );
+					LLVector3 pivotTrans = workingTransform.getTranslation();
+					if ( pivotTrans[VX] > MAXIMUM_PIVOT_OFFSET || pivotTrans[VX] < -MAXIMUM_PIVOT_OFFSET || 
+						 pivotTrans[VY] > MAXIMUM_PIVOT_OFFSET || pivotTrans[VY] < -MAXIMUM_PIVOT_OFFSET || 
+						 pivotTrans[VZ] > MAXIMUM_PIVOT_OFFSET || pivotTrans[VZ] < -MAXIMUM_PIVOT_OFFSET ) 
+					{
+						llwarns<<"Asset Pivot Node contains an offset that is too large - values should be within (-"<<MAXIMUM_PIVOT_OFFSET<<","<<MAXIMUM_PIVOT_OFFSET<<")."<<llendl;
+						mPreview->setHasPivot( false );
+					}
+					else
+					{
+						mPreview->setModelPivot( pivotTrans );
+						mPreview->setHasPivot( true );					
+					}
 				}					
 			}
 		}
-- 
GitLab