From 290f2f05f7c2c061ba82f83594e4f7fb6a043ced Mon Sep 17 00:00:00 2001
From: Josh Bell <josh@lindenlab.com>
Date: Sat, 7 Jun 2008 00:47:05 +0000
Subject: [PATCH] svn merge -r 88991:89027
 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-22-2-Server -->
 release

Due to the gnarly history of the source branch and merge history of release, combine with cmake header and gcc-fu, this was an "interesting" merge.
---
 indra/llinventory/llparcel.h            |  6 ++--
 indra/llmath/llmath.h                   |  3 ++
 indra/llmath/llvolumemgr.cpp            |  4 +--
 indra/llmath/llvolumemgr.h              |  2 +-
 indra/llmath/v3dmath.h                  | 46 ++++++++++++++++++++++---
 indra/newview/app_settings/settings.xml | 11 ++++++
 indra/newview/llagent.h                 |  2 +-
 indra/newview/llvosky.h                 |  2 +-
 indra/newview/llworld.cpp               |  6 ++--
 indra/newview/pipeline.cpp              | 10 +++---
 10 files changed, 71 insertions(+), 21 deletions(-)

diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h
index ac5e1a1eae..5d3a2b01ec 100644
--- a/indra/llinventory/llparcel.h
+++ b/indra/llinventory/llparcel.h
@@ -514,7 +514,7 @@ public:
 	S32 getSimWidePrimCount() const { return mSimWidePrimCount; }
 
 	// this parcel only (not simwide)
-	S32		getMaxPrimCapacity() const	{ return mMaxPrimCapacity; }
+	S32		getMaxPrimCapacity() const	{ return mMaxPrimCapacity; }	// Does not include prim bonus
 	S32		getPrimCount() const		{ return mOwnerPrimCount + mGroupPrimCount + mOtherPrimCount + mSelectedPrimCount; }
 	S32		getOwnerPrimCount() const	{ return mOwnerPrimCount; }
 	S32		getGroupPrimCount() const	{ return mGroupPrimCount; }
@@ -525,7 +525,7 @@ public:
 
 	S32		getCleanOtherTime() const			{ return mCleanOtherTime; }
 
-	void	setMaxPrimCapacity(S32 max) { mMaxPrimCapacity = max; }
+	void	setMaxPrimCapacity(S32 max) { mMaxPrimCapacity = max; }		// Does not include prim bonus
 	// simwide
 	void	setSimWideMaxPrimCapacity(S32 current)	{ mSimWideMaxPrimCapacity = current; }
 	void setSimWidePrimCount(S32 current) { mSimWidePrimCount = current; }
@@ -604,7 +604,7 @@ protected:
 	F32					mPassHours;
 	LLVector3			mAABBMin;
 	LLVector3			mAABBMax;
-	S32					mMaxPrimCapacity;
+	S32					mMaxPrimCapacity;		// Prims allowed on parcel, does not include prim bonus
 	S32					mSimWidePrimCount;
 	S32					mSimWideMaxPrimCapacity;
 	//S32					mSimWidePrimCorrection;
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index bf98801508..9d31df12e2 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -92,6 +92,9 @@ const F32	F_APPROXIMATELY_ZERO = 0.00001f;
 const F32	F_LN2		= 0.69314718056f;
 const F32	OO_LN2		= 1.4426950408889634073599246810019f;
 
+const F32	F_ALMOST_ZERO	= 0.0001f;
+const F32	F_ALMOST_ONE	= 1.0f - F_ALMOST_ZERO;
+
 // BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above?
 const F32 FP_MAG_THRESHOLD = 0.0000001f;
 
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index 23ed0183b8..c4f10467a9 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -115,7 +115,7 @@ LLVolume* LLVolumeMgr::refVolume(const LLVolumeParams &volume_params, const S32
 	{
 		mDataMutex->unlock();
 	}
-	return volgroupp->getLODVolume(detail);
+	return volgroupp->refLOD(detail);
 }
 
 // virtual
@@ -294,7 +294,7 @@ bool LLVolumeLODGroup::cleanupRefs()
 	return res;
 }
 
-LLVolume* LLVolumeLODGroup::getLODVolume(const S32 detail)
+LLVolume* LLVolumeLODGroup::refLOD(const S32 detail)
 {
 	llassert(detail >=0 && detail < NUM_LODS);
 	mAccessCount[detail]++;
diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h
index fac194165b..f4b44b3a12 100644
--- a/indra/llmath/llvolumemgr.h
+++ b/indra/llmath/llvolumemgr.h
@@ -59,7 +59,7 @@ public:
 	static void getDetailProximity(const F32 tan_angle, F32 &to_lower, F32& to_higher);
 	static F32 getVolumeScaleFromDetail(const S32 detail);
 
-	LLVolume* getLODVolume(const S32 detail);
+	LLVolume* refLOD(const S32 detail);
 	BOOL derefLOD(LLVolume *volumep);
 	S32 getNumRefs() const { return mRefs; }
 	
diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h
index 667c335f51..d5e5223571 100644
--- a/indra/llmath/v3dmath.h
+++ b/indra/llmath/v3dmath.h
@@ -95,6 +95,10 @@ class LLVector3d
 		F64		magVecSquared() const;		// Returns magnitude squared of LLVector3d
 		inline F64		normVec();					// Normalizes and returns the magnitude of LLVector3d
 
+		F64 length() const;			// Returns magnitude of LLVector3d
+		F64 lengthSquared() const;	// Returns magnitude squared of LLVector3d
+		inline F64 normalize();		// Normalizes and returns the magnitude of LLVector3d
+
 		const LLVector3d&	rotVec(const F64 angle, const LLVector3d &vec);	// Rotates about vec by angle radians
 		const LLVector3d&	rotVec(const F64 angle, const F64 x, const F64 y, const F64 z);		// Rotates about x,y,z by angle radians
 		const LLVector3d&	rotVec(const LLMatrix3 &mat);				// Rotates by LLMatrix4 mat
@@ -261,6 +265,28 @@ inline F64 LLVector3d::normVec(void)
 	return (mag);
 }
 
+inline F64 LLVector3d::normalize(void)
+{
+	F64 mag = fsqrtf(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+	F64 oomag;
+
+	if (mag > FP_MAG_THRESHOLD)
+	{
+		oomag = 1.f/mag;
+		mdV[0] *= oomag;
+		mdV[1] *= oomag;
+		mdV[2] *= oomag;
+	}
+	else
+	{
+		mdV[0] = 0.f;
+		mdV[1] = 0.f;
+		mdV[2] = 0.f;
+		mag = 0;
+	}
+	return (mag);
+}
+
 // LLVector3d Magnitude and Normalization Functions
 
 inline F64	LLVector3d::magVec(void) const
@@ -273,6 +299,16 @@ inline F64	LLVector3d::magVecSquared(void) const
 	return mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2];
 }
 
+inline F64	LLVector3d::length(void) const
+{
+	return fsqrtf(mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2]);
+}
+
+inline F64	LLVector3d::lengthSquared(void) const
+{
+	return mdV[0]*mdV[0] + mdV[1]*mdV[1] + mdV[2]*mdV[2];
+}
+
 inline LLVector3d operator+(const LLVector3d &a, const LLVector3d &b)
 {
 	LLVector3d c(a);
@@ -416,8 +452,8 @@ inline F64 angle_between(const LLVector3d& a, const LLVector3d& b)
 {
 	LLVector3d an = a;
 	LLVector3d bn = b;
-	an.normVec();
-	bn.normVec();
+	an.normalize();
+	bn.normalize();
 	F64 cosine = an * bn;
 	F64 angle = (cosine >= 1.0f) ? 0.0f :
 				(cosine <= -1.0f) ? F_PI :
@@ -429,8 +465,8 @@ inline BOOL are_parallel(const LLVector3d &a, const LLVector3d &b, const F64 eps
 {
 	LLVector3d an = a;
 	LLVector3d bn = b;
-	an.normVec();
-	bn.normVec();
+	an.normalize();
+	bn.normalize();
 	F64 dot = an * bn;
 	if ( (1.0f - fabs(dot)) < epsilon)
 	{
@@ -443,7 +479,7 @@ inline BOOL are_parallel(const LLVector3d &a, const LLVector3d &b, const F64 eps
 inline LLVector3d projected_vec(const LLVector3d &a, const LLVector3d &b)
 {
 	LLVector3d project_axis = b;
-	project_axis.normVec();
+	project_axis.normalize();
 	return project_axis * (a * project_axis);
 }
 
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 987ae79d59..eb04b430d7 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4123,6 +4123,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>LSLFindCaseInsensitivity</key>
+        <map>
+        <key>Comment</key>
+            <string>Use case insensitivity when searching in LSL editor</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
     <key>LSLHelpRect</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index b50fb745ca..281b2d0c88 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -525,7 +525,7 @@ public:
 
 	BOOL			sitCameraEnabled() { return mSitCameraEnabled; }
 
-	F32				getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.magVec(); }
+	F32				getCurrentCameraBuildOffset() { return (F32)mCameraFocusOffset.length(); }
 
 	// look at behavior
 	BOOL			setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h
index c2ab9ae6a4..34bc7a794e 100644
--- a/indra/newview/llvosky.h
+++ b/indra/newview/llvosky.h
@@ -555,7 +555,7 @@ public:
 	LLColor4U getFadeColor() const						{ return mFadeColor; }
 	F32 getFogRatio() const								{ return mFogRatio; }
 	void setCloudDensity(F32 cloud_density)				{ mCloudDensity = cloud_density; }
-	void setWind ( const LLVector3& wind )				{ mWind = wind.magVec(); }
+	void setWind ( const LLVector3& wind )				{ mWind = wind.length(); }
 
 	const LLVector3 &getCameraPosAgent() const			{ return mCameraPosAgent; }
 	LLVector3 getEarthCenter() const					{ return mEarthCenter; }
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index 7a2acbb094..08c593755b 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -418,7 +418,7 @@ BOOL LLWorld::positionRegionValidGlobal(const LLVector3d &pos_global)
 F32 LLWorld::getMinAllowedZ(LLViewerObject* object)
 {
 	F32 land_height = resolveLandHeightGlobal(object->getPositionGlobal());
-	F32 radius = 0.5f * object->getScale().magVec();
+	F32 radius = 0.5f * object->getScale().length();
 	return land_height - radius;
 }
 
@@ -497,7 +497,7 @@ F32 LLWorld::resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d
 	}
 	
 	// calculate the length of the segment
-	F32 segment_length = (F32)((point_a - point_b).magVec());
+	F32 segment_length = (F32)((point_a - point_b).length());
 	if (0.0f == segment_length)
 	{
 		intersection = point_a;
@@ -775,7 +775,7 @@ void LLWorld::printPacketsLost()
 		{
 			LLVector3d range = regionp->getCenterGlobal() - gAgent.getPositionGlobal();
 				
-			llinfos << regionp->getHost() << ", range: " << range.magVec()
+			llinfos << regionp->getHost() << ", range: " << range.length()
 					<< " packets lost: " << cdp->getPacketsLost() << llendl;
 		}
 	}
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 643c1ec055..539379c9a1 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -870,7 +870,7 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj)
 	
 	//encompass completely sheared objects by taking 
 	//the most extreme point possible (<1,1,0.5>)
-	drawable->setRadius(LLVector3(1,1,0.5f).scaleVec(vobj->getScale()).magVec());
+	drawable->setRadius(LLVector3(1,1,0.5f).scaleVec(vobj->getScale()).length());
 	if (vobj->isOrphaned())
 	{
 		drawable->setState(LLDrawable::FORCE_INVISIBLE);
@@ -1124,7 +1124,7 @@ void LLPipeline::updateMove()
 F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera)
 {
 	LLVector3 lookAt = center - camera.getOrigin();
-	F32 dist = lookAt.magVec();
+	F32 dist = lookAt.length();
 
 	//ramp down distance for nearby objects
 	if (dist < 16.f)
@@ -1135,7 +1135,7 @@ F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera
 	}
 
 	//get area of circle around node
-	F32 app_angle = atanf(size.magVec()/dist);
+	F32 app_angle = atanf(size.length()/dist);
 	F32 radius = app_angle*LLDrawable::sCurPixelAngle;
 	return radius*radius * 3.14159f;
 }
@@ -3123,7 +3123,7 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_
 	F32 radius = light->getLightRadius();
 	BOOL selected = light->isSelected();
 	LLVector3 dpos = light->getRenderPosition() - cam_pos;
-	F32 dist2 = dpos.magVecSquared();
+	F32 dist2 = dpos.lengthSquared();
 	if (!selected && dist2 > (max_dist + radius)*(max_dist + radius))
 	{
 		return max_dist;
@@ -5143,7 +5143,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar)
 	glMatrixMode(GL_PROJECTION);
 	glPushMatrix();
 	//glh::matrix4f ortho = gl_ortho(-tdim.mV[0], tdim.mV[0], -tdim.mV[1], tdim.mV[1], 1.0, 256.0);
-	F32 distance = (pos-camera.getOrigin()).magVec();
+	F32 distance = (pos-camera.getOrigin()).length();
 	F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG;
 	F32 aspect = tdim.mV[0]/tdim.mV[1]; //128.f/256.f;
 	glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f);
-- 
GitLab