summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rwxr-xr-xindra/llmath/llcalc.cpp6
-rwxr-xr-xindra/llmath/llcalcparser.h5
-rwxr-xr-xindra/llmath/llcamera.cpp90
-rwxr-xr-xindra/llmath/llcamera.h10
-rwxr-xr-xindra/llmath/llcoordframe.cpp54
-rwxr-xr-xindra/llmath/llline.cpp4
-rwxr-xr-xindra/llmath/llmath.h15
-rwxr-xr-xindra/llmath/lloctree.h49
-rwxr-xr-xindra/llmath/llplane.h8
-rwxr-xr-xindra/llmath/llquaternion.cpp449
-rwxr-xr-xindra/llmath/llquaternion.h50
-rwxr-xr-xindra/llmath/lltreenode.h9
-rwxr-xr-xindra/llmath/llvolume.cpp84
-rwxr-xr-xindra/llmath/llvolume.h1
-rwxr-xr-xindra/llmath/llvolumemgr.cpp14
-rwxr-xr-xindra/llmath/llvolumeoctree.cpp6
-rwxr-xr-xindra/llmath/llvolumeoctree.h4
-rwxr-xr-xindra/llmath/v3dmath.h150
-rwxr-xr-xindra/llmath/v3math.h43
-rwxr-xr-xindra/llmath/v4color.cpp6
-rwxr-xr-xindra/llmath/v4color.h4
-rwxr-xr-xindra/llmath/xform.cpp4
-rwxr-xr-xindra/llmath/xform.h4
23 files changed, 623 insertions, 446 deletions
diff --git a/indra/llmath/llcalc.cpp b/indra/llmath/llcalc.cpp
index 1b2d609b67..edc6986cc9 100755
--- a/indra/llmath/llcalc.cpp
+++ b/indra/llmath/llcalc.cpp
@@ -141,20 +141,20 @@ bool LLCalc::evalString(const std::string& expression, F32& result)
try
{
info = parse(start, expr_upper.end(), calc, space_p);
- lldebugs << "Math expression: " << expression << " = " << result << llendl;
+ LL_DEBUGS() << "Math expression: " << expression << " = " << result << LL_ENDL;
}
catch(parser_error<std::string, std::string::iterator> &e)
{
mLastErrorPos = e.where - expr_upper.begin();
- llinfos << "Calc parser exception: " << e.descriptor << " at " << mLastErrorPos << " in expression: " << expression << llendl;
+ LL_INFOS() << "Calc parser exception: " << e.descriptor << " at " << mLastErrorPos << " in expression: " << expression << LL_ENDL;
return false;
}
if (!info.full)
{
mLastErrorPos = info.stop - expr_upper.begin();
- llinfos << "Unhandled syntax error at " << mLastErrorPos << " in expression: " << expression << llendl;
+ LL_INFOS() << "Unhandled syntax error at " << mLastErrorPos << " in expression: " << expression << LL_ENDL;
return false;
}
diff --git a/indra/llmath/llcalcparser.h b/indra/llmath/llcalcparser.h
index e0ad270266..faa699ff7b 100755
--- a/indra/llmath/llcalcparser.h
+++ b/indra/llmath/llcalcparser.h
@@ -163,7 +163,7 @@ private:
bool checkNaN(const F32& a) const { return !llisnan(a); }
- //FIX* non ambigious function fix making SIN() work for calc -Cryogenic Blitz
+ //FIX* non ambiguous function fix making SIN() work for calc -Cryogenic Blitz
F32 _sin(const F32& a) const { return sin(DEG_TO_RAD * a); }
F32 _cos(const F32& a) const { return cos(DEG_TO_RAD * a); }
F32 _tan(const F32& a) const { return tan(DEG_TO_RAD * a); }
@@ -176,11 +176,8 @@ private:
F32 _fabs(const F32& a) const { return fabs(a); }
F32 _floor(const F32& a) const { return (F32)llfloor(a); }
F32 _ceil(const F32& a) const { return llceil(a); }
-
F32 _atan2(const F32& a,const F32& b) const { return atan2(a,b); }
-
-
LLCalc::calc_map_t* mConstants;
LLCalc::calc_map_t* mVariables;
// LLCalc::calc_map_t* mUserVariables;
diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp
index 33cf185196..ff90532f75 100755
--- a/indra/llmath/llcamera.cpp
+++ b/indra/llmath/llcamera.cpp
@@ -183,8 +183,30 @@ static const LLVector4a sFrustumScaler[] =
LLVector4a( 1, 1, 1) // 8 entries
};
-S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
+bool LLCamera::isChanged()
{
+ bool changed = false;
+ for (U32 i = 0; i < mPlaneCount; i++)
+ {
+ U8 mask = mPlaneMask[i];
+ if (mask != 0xff && !changed)
+ {
+ changed = !mAgentPlanes[i].equal(mLastAgentPlanes[i]);
+ }
+ mLastAgentPlanes[i].set(mAgentPlanes[i]);
+ }
+
+ return changed;
+}
+
+S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius, const LLPlane* planes)
+{
+ if(!planes)
+ {
+ //use agent space
+ planes = mAgentPlanes;
+ }
+
U8 mask = 0;
bool result = false;
LLVector4a rscale, maxp, minp;
@@ -195,7 +217,7 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
mask = mPlaneMask[i];
if (mask < PLANE_MASK_NUM)
{
- const LLPlane& p(mAgentPlanes[i]);
+ const LLPlane& p(planes[i]);
p.getAt<3>(d);
rscale.setMul(radius, sFrustumScaler[mask]);
minp.setSub(center, rscale);
@@ -216,9 +238,21 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
return result?1:2;
}
+//exactly same as the function AABBInFrustum(...)
+//except uses mRegionPlanes instead of mAgentPlanes.
+S32 LLCamera::AABBInRegionFrustum(const LLVector4a& center, const LLVector4a& radius)
+{
+ return AABBInFrustum(center, radius, mRegionPlanes);
+}
-S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius)
+S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes)
{
+ if(!planes)
+ {
+ //use agent space
+ planes = mAgentPlanes;
+ }
+
U8 mask = 0;
bool result = false;
LLVector4a rscale, maxp, minp;
@@ -229,7 +263,7 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
mask = mPlaneMask[i];
if ((i != 5) && (mask < PLANE_MASK_NUM))
{
- const LLPlane& p(mAgentPlanes[i]);
+ const LLPlane& p(planes[i]);
p.getAt<3>(d);
rscale.setMul(radius, sFrustumScaler[mask]);
minp.setSub(center, rscale);
@@ -250,6 +284,13 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
return result?1:2;
}
+//exactly same as the function AABBInFrustumNoFarClip(...)
+//except uses mRegionPlanes instead of mAgentPlanes.
+S32 LLCamera::AABBInRegionFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius)
+{
+ return AABBInFrustumNoFarClip(center, radius, mRegionPlanes);
+}
+
int LLCamera::sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius)
{
LLVector3 dist = sphere_center-mFrustCenter;
@@ -586,6 +627,47 @@ void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
}
}
+//calculate regional planes from mAgentPlanes.
+//vector "shift" is the vector of the region origin in the agent space.
+void LLCamera::calcRegionFrustumPlanes(const LLVector3& shift, F32 far_clip_distance)
+{
+ F32 far_w;
+ {
+ LLVector3 p = getOrigin();
+ LLVector3 n(mAgentPlanes[5][0], mAgentPlanes[5][1], mAgentPlanes[5][2]);
+ F32 dd = n * p;
+ if(dd + mAgentPlanes[5][3] < 0) //signed distance
+ {
+ far_w = -far_clip_distance - dd;
+ }
+ else
+ {
+ far_w = far_clip_distance - dd;
+ }
+ far_w += n * shift;
+ }
+
+ F32 d;
+ LLVector3 n;
+ for(S32 i = 0 ; i < 7; i++)
+ {
+ if (mPlaneMask[i] != 0xff)
+ {
+ n.setVec(mAgentPlanes[i][0], mAgentPlanes[i][1], mAgentPlanes[i][2]);
+
+ if(i != 5)
+ {
+ d = mAgentPlanes[i][3] + n * shift;
+ }
+ else
+ {
+ d = far_w;
+ }
+ mRegionPlanes[i].setVec(n, d);
+ }
+ }
+}
+
void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom)
{
LLVector3 a, b, c;
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index 1283cfb16b..321b8ddcc4 100755
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -122,6 +122,8 @@ public:
private:
LL_ALIGN_16(LLPlane mAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]); //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+ LL_ALIGN_16(LLPlane mRegionPlanes[AGENT_PLANE_USER_CLIP_NUM]); //frustum planes in a local region space, derived from mAgentPlanes
+ LL_ALIGN_16(LLPlane mLastAgentPlanes[AGENT_PLANE_USER_CLIP_NUM]);
U8 mPlaneMask[PLANE_MASK_NUM]; // 8 for alignment
F32 mView; // angle between top and bottom frustum planes in radians.
@@ -150,6 +152,7 @@ public:
LLCamera(F32 vertical_fov_rads, F32 aspect_ratio, S32 view_height_in_pixels, F32 near_plane, F32 far_plane);
virtual ~LLCamera();
+ bool isChanged(); //check if mAgentPlanes changed since last frame.
void setUserClipPlane(LLPlane& plane);
void disableUserClipPlane();
@@ -191,6 +194,7 @@ public:
// Return number of bytes copied.
size_t readFrustumFromBuffer(const char *buffer);
void calcAgentFrustumPlanes(LLVector3* frust);
+ void calcRegionFrustumPlanes(const LLVector3& shift, F32 far_clip_distance); //calculate regional planes from mAgentPlanes.
void ignoreAgentFrustumPlane(S32 idx);
// Returns 1 if partly in, 2 if fully in.
@@ -199,8 +203,10 @@ public:
S32 sphereInFrustum(const LLVector3 &center, const F32 radius) const;
S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); }
S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); }
- S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius);
- S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
+ S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes = NULL);
+ S32 AABBInRegionFrustum(const LLVector4a& center, const LLVector4a& radius);
+ S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes = NULL);
+ S32 AABBInRegionFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
//does a quick 'n dirty sphere-sphere check
S32 sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius);
diff --git a/indra/llmath/llcoordframe.cpp b/indra/llmath/llcoordframe.cpp
index 7dd8e43185..1bf51ca0eb 100755
--- a/indra/llmath/llcoordframe.cpp
+++ b/indra/llmath/llcoordframe.cpp
@@ -59,7 +59,7 @@ LLCoordFrame::LLCoordFrame(const LLVector3 &origin) :
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -71,7 +71,7 @@ LLCoordFrame::LLCoordFrame(const LLVector3 &origin, const LLVector3 &direction)
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -86,7 +86,7 @@ LLCoordFrame::LLCoordFrame(const LLVector3 &x_axis,
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -102,7 +102,7 @@ LLCoordFrame::LLCoordFrame(const LLVector3 &origin,
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -117,7 +117,7 @@ LLCoordFrame::LLCoordFrame(const LLVector3 &origin,
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -132,7 +132,7 @@ LLCoordFrame::LLCoordFrame(const LLQuaternion &q) :
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -147,7 +147,7 @@ LLCoordFrame::LLCoordFrame(const LLVector3 &origin, const LLQuaternion &q) :
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -160,7 +160,7 @@ LLCoordFrame::LLCoordFrame(const LLMatrix4 &mat) :
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
@@ -176,7 +176,7 @@ LLCoordFrame::LLCoordFrame(const F32 *origin, const F32 *rotation) :
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
*/
@@ -191,7 +191,7 @@ LLCoordFrame::LLCoordFrame(const F32 *origin_and_rotation) :
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::LLCoordFrame()" << LL_ENDL;
}
}
*/
@@ -220,7 +220,7 @@ void LLCoordFrame::setOrigin(F32 x, F32 y, F32 z)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setOrigin()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setOrigin()" << LL_ENDL;
}
}
@@ -230,7 +230,7 @@ void LLCoordFrame::setOrigin(const LLVector3 &new_origin)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setOrigin()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setOrigin()" << LL_ENDL;
}
}
@@ -243,7 +243,7 @@ void LLCoordFrame::setOrigin(const F32 *origin)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setOrigin()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setOrigin()" << LL_ENDL;
}
}
@@ -254,7 +254,7 @@ void LLCoordFrame::setOrigin(const LLCoordFrame &frame)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setOrigin()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setOrigin()" << LL_ENDL;
}
}
@@ -271,7 +271,7 @@ void LLCoordFrame::setAxes(const LLVector3 &x_axis,
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setAxes()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setAxes()" << LL_ENDL;
}
}
@@ -284,7 +284,7 @@ void LLCoordFrame::setAxes(const LLMatrix3 &rotation_matrix)
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setAxes()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setAxes()" << LL_ENDL;
}
}
@@ -296,7 +296,7 @@ void LLCoordFrame::setAxes(const LLQuaternion &q )
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setAxes()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setAxes()" << LL_ENDL;
}
}
@@ -316,7 +316,7 @@ void LLCoordFrame::setAxes( const F32 *rotation_matrix )
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setAxes()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setAxes()" << LL_ENDL;
}
}
@@ -330,7 +330,7 @@ void LLCoordFrame::setAxes(const LLCoordFrame &frame)
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::setAxes()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::setAxes()" << LL_ENDL;
}
}
@@ -346,7 +346,7 @@ void LLCoordFrame::translate(F32 x, F32 y, F32 z)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::translate()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::translate()" << LL_ENDL;
}
}
@@ -358,7 +358,7 @@ void LLCoordFrame::translate(const LLVector3 &v)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::translate()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::translate()" << LL_ENDL;
}
}
@@ -372,7 +372,7 @@ void LLCoordFrame::translate(const F32 *origin)
if( !mOrigin.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::translate()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::translate()" << LL_ENDL;
}
}
@@ -409,7 +409,7 @@ void LLCoordFrame::rotate(const LLMatrix3 &rotation_matrix)
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::rotate()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::rotate()" << LL_ENDL;
}
}
@@ -423,7 +423,7 @@ void LLCoordFrame::roll(F32 angle)
if( !mYAxis.isFinite() || !mZAxis.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::roll()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::roll()" << LL_ENDL;
}
}
@@ -436,7 +436,7 @@ void LLCoordFrame::pitch(F32 angle)
if( !mXAxis.isFinite() || !mZAxis.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::pitch()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::pitch()" << LL_ENDL;
}
}
@@ -449,7 +449,7 @@ void LLCoordFrame::yaw(F32 angle)
if( !mXAxis.isFinite() || !mYAxis.isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::yaw()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::yaw()" << LL_ENDL;
}
}
@@ -509,7 +509,7 @@ size_t LLCoordFrame::readOrientation(const char *buffer)
if( !isFinite() )
{
reset();
- llwarns << "Non Finite in LLCoordFrame::readOrientation()" << llendl;
+ LL_WARNS() << "Non Finite in LLCoordFrame::readOrientation()" << LL_ENDL;
}
return 12*sizeof(F32);
diff --git a/indra/llmath/llline.cpp b/indra/llmath/llline.cpp
index ef10d1e7fa..f26231840b 100755
--- a/indra/llmath/llline.cpp
+++ b/indra/llmath/llline.cpp
@@ -82,10 +82,10 @@ LLVector3 LLLine::nearestApproach( const LLLine& other_line ) const
if ( one_minus_dir_dot_dir < SOME_VERY_SMALL_NUMBER )
{
#ifdef LL_DEBUG
- llwarns << "LLLine::nearestApproach() was given two very "
+ LL_WARNS() << "LLLine::nearestApproach() was given two very "
<< "nearly parallel lines dir1 = " << mDirection
<< " dir2 = " << other_line.mDirection << " with 1-dot_product = "
- << one_minus_dir_dot_dir << llendl;
+ << one_minus_dir_dot_dir << LL_ENDL;
#endif
// the lines are approximately parallel
// We shouldn't fall in here because this check should have been made
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index b93f89d674..a8b27ad189 100755
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -1,4 +1,4 @@
-/**
+/**
* @file llmath.h
* @brief Useful math constants and macros.
*
@@ -30,6 +30,7 @@
#include <cmath>
#include <cstdlib>
#include <vector>
+#include <limits>
#include "lldefs.h"
//#include "llstl.h" // *TODO: Remove when LLString is gone
//#include "llstring.h" // *TODO: Remove when LLString is gone
@@ -72,15 +73,21 @@ const F32 F_E = 2.71828182845904523536f;
const F32 F_SQRT2 = 1.4142135623730950488016887242097f;
const F32 F_SQRT3 = 1.73205080756888288657986402541f;
const F32 OO_SQRT2 = 0.7071067811865475244008443621049f;
+const F32 OO_SQRT3 = 0.577350269189625764509f;
const F32 DEG_TO_RAD = 0.017453292519943295769236907684886f;
const F32 RAD_TO_DEG = 57.295779513082320876798154814105f;
const F32 F_APPROXIMATELY_ZERO = 0.00001f;
+const F32 F_LN10 = 2.3025850929940456840179914546844f;
+const F32 OO_LN10 = 0.43429448190325182765112891891661;
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;
+const F32 GIMBAL_THRESHOLD = 0.000436f; // sets the gimballock threshold 0.025 away from +/-90 degrees
+// formula: GIMBAL_THRESHOLD = sin(DEG_TO_RAD * gimbal_threshold_angle);
+
// BUG: Eliminate in favor of F_APPROXIMATELY_ZERO above?
const F32 FP_MAG_THRESHOLD = 0.0000001f;
@@ -111,6 +118,12 @@ inline bool is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f <
// WARNING: Infinity is comparable with F32_MAX and negative
// infinity is comparable with F32_MIN
+// handles negative and positive zeros
+inline bool is_zero(F32 x)
+{
+ return (*(U32*)(&x) & 0x7fffffff) == 0;
+}
+
inline bool is_approx_equal(F32 x, F32 y)
{
const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02;
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index 7348904c61..7b5240c651 100755
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -36,6 +36,8 @@
extern U32 gOctreeMaxCapacity;
+extern float gOctreeMinSize;
+
/*#define LL_OCTREE_PARANOIA_CHECK 0
#if LL_DARWIN
#define LL_OCTREE_MAX_CAPACITY 32
@@ -106,6 +108,7 @@ public:
: mParent((oct_node*)parent),
mOctant(octant)
{
+ llassert(size[0] >= gOctreeMinSize*0.5f);
//always keep a NULL terminated list to avoid out of bounds exceptions in debug builds
mData.push_back(NULL);
mDataEnd = &mData[0];
@@ -213,7 +216,7 @@ public:
F32 size = mSize[0];
F32 p_size = size * 2.f;
- return (radius <= 0.001f && size <= 0.001f) ||
+ return (radius <= gOctreeMinSize && size <= gOctreeMinSize) ||
(radius <= p_size && radius > size);
}
@@ -265,12 +268,12 @@ public:
if (child->getOctant() != i)
{
- llerrs << "Invalid child map, bad octant data." << llendl;
+ LL_ERRS() << "Invalid child map, bad octant data." << LL_ENDL;
}
if (getOctant(child->getCenter()) != child->getOctant())
{
- llerrs << "Invalid child octant compared to position data." << llendl;
+ LL_ERRS() << "Invalid child octant compared to position data." << LL_ENDL;
}
}
}
@@ -311,7 +314,7 @@ public:
{
if (data == NULL || data->getBinIndex() != -1)
{
- OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
+ OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << LL_ENDL;
return false;
}
LLOctreeNode<T>* parent = getOctParent();
@@ -319,7 +322,7 @@ public:
//is it here?
if (isInside(data->getPositionGroup()))
{
- if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) ||
+ if (((getElementCount() < gOctreeMaxCapacity || getSize()[0] <= gOctreeMinSize) && contains(data->getBinRadius()) ||
(data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity)))
{ //it belongs here
mData.push_back(NULL);
@@ -356,8 +359,9 @@ public:
LLVector4a val;
val.setSub(center, getCenter());
val.setAbs(val);
-
- S32 lt = val.lessThan(LLVector4a::getEpsilon()).getGatheredBits() & 0x7;
+ LLVector4a min_diff(gOctreeMinSize);
+
+ S32 lt = val.lessThan(min_diff).getGatheredBits() & 0x7;
if( lt == 0x7 )
{
@@ -374,7 +378,7 @@ public:
if (getChildCount() == 8)
{
//this really isn't possible, something bad has happened
- OCT_ERRS << "Octree detected floating point error and gave up." << llendl;
+ OCT_ERRS << "Octree detected floating point error and gave up." << LL_ENDL;
return false;
}
@@ -383,12 +387,13 @@ public:
{
if (mChild[i]->getCenter().equals3(center))
{
- OCT_ERRS << "Octree detected duplicate child center and gave up." << llendl;
+ OCT_ERRS << "Octree detected duplicate child center and gave up." << LL_ENDL;
return false;
}
}
#endif
+ llassert(size[0] >= gOctreeMinSize*0.5f);
//make the new kid
child = new LLOctreeNode<T>(center, size, this);
addChild(child);
@@ -399,7 +404,7 @@ public:
else
{
//it's not in here, give it to the root
- OCT_ERRS << "Octree insertion failed, starting over from root!" << llendl;
+ OCT_ERRS << "Octree insertion failed, starting over from root!" << LL_ENDL;
oct_node* node = this;
@@ -483,7 +488,7 @@ public:
}
//node is now root
- llwarns << "!!! OCTREE REMOVING ELEMENT BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << llendl;
+ LL_WARNS() << "!!! OCTREE REMOVING ELEMENT BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << LL_ENDL;
node->removeByAddress(data);
llassert(data->getBinIndex() == -1);
return true;
@@ -496,7 +501,7 @@ public:
if (mData[i] == data)
{ //we have data
_remove(data, i);
- llwarns << "FOUND!" << llendl;
+ LL_WARNS() << "FOUND!" << LL_ENDL;
return;
}
}
@@ -524,7 +529,7 @@ public:
mChild[i]->validate();
if (mChild[i]->getParent() != this)
{
- llerrs << "Octree child has invalid parent." << llendl;
+ LL_ERRS() << "Octree child has invalid parent." << LL_ENDL;
}
}
#endif
@@ -550,24 +555,24 @@ public:
if (child->getSize().equals3(getSize()))
{
- OCT_ERRS << "Child size is same as parent size!" << llendl;
+ OCT_ERRS << "Child size is same as parent size!" << LL_ENDL;
}
for (U32 i = 0; i < getChildCount(); i++)
{
if(!mChild[i]->getSize().equals3(child->getSize()))
{
- OCT_ERRS <<"Invalid octree child size." << llendl;
+ OCT_ERRS <<"Invalid octree child size." << LL_ENDL;
}
if (mChild[i]->getCenter().equals3(child->getCenter()))
{
- OCT_ERRS <<"Duplicate octree child position." << llendl;
+ OCT_ERRS <<"Duplicate octree child position." << LL_ENDL;
}
}
if (mChild.size() >= 8)
{
- OCT_ERRS <<"Octree node has too many children... why?" << llendl;
+ OCT_ERRS <<"Octree node has too many children... why?" << LL_ENDL;
}
#endif
@@ -641,7 +646,7 @@ public:
}
}
- OCT_ERRS << "Octree failed to delete requested child." << llendl;
+ OCT_ERRS << "Octree failed to delete requested child." << LL_ENDL;
}
protected:
@@ -724,13 +729,13 @@ public:
{
if (data == NULL)
{
- OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << llendl;
+ OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << LL_ENDL;
return false;
}
if (data->getBinRadius() > 4096.0)
{
- OCT_ERRS << "!!! ELEMENT EXCEEDS MAXIMUM SIZE IN OCTREE ROOT !!!" << llendl;
+ OCT_ERRS << "!!! ELEMENT EXCEEDS MAXIMUM SIZE IN OCTREE ROOT !!!" << LL_ENDL;
return false;
}
@@ -746,7 +751,7 @@ public:
if (lt != 0x7)
{
- //OCT_ERRS << "!!! ELEMENT EXCEEDS RANGE OF SPATIAL PARTITION !!!" << llendl;
+ //OCT_ERRS << "!!! ELEMENT EXCEEDS RANGE OF SPATIAL PARTITION !!!" << LL_ENDL;
return false;
}
@@ -796,6 +801,8 @@ public:
this->setSize(size2);
this->updateMinMax();
+ llassert(size[0] >= gOctreeMinSize);
+
//copy our children to a new branch
LLOctreeNode<T>* newnode = new LLOctreeNode<T>(center, size, this);
diff --git a/indra/llmath/llplane.h b/indra/llmath/llplane.h
index 3c32441b11..64a3eed0e5 100755
--- a/indra/llmath/llplane.h
+++ b/indra/llmath/llplane.h
@@ -93,7 +93,13 @@ public:
{
return mV.greaterEqual(LLVector4a::getZero()).getGatheredBits() & LLVector4Logical::MASK_XYZ;
}
-
+
+ //check if two planes are nearly same
+ bool equal(const LLPlane& p) const
+ {
+ return mV.equals4(p.mV);
+ }
+
private:
LLVector4a mV;
} LL_ALIGN_POSTFIX(16);
diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp
index 7381d5eb99..47374c287f 100755
--- a/indra/llmath/llquaternion.cpp
+++ b/indra/llmath/llquaternion.cpp
@@ -1,4 +1,4 @@
-/**
+/**
* @file llquaternion.cpp
* @brief LLQuaternion class implementation.
*
@@ -58,34 +58,40 @@ LLQuaternion::LLQuaternion(const LLMatrix3 &mat)
LLQuaternion::LLQuaternion(F32 angle, const LLVector4 &vec)
{
- LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
- v.normalize();
-
- F32 c, s;
- c = cosf(angle*0.5f);
- s = sinf(angle*0.5f);
-
- mQ[VX] = v.mV[VX] * s;
- mQ[VY] = v.mV[VY] * s;
- mQ[VZ] = v.mV[VZ] * s;
- mQ[VW] = c;
- normalize();
+ F32 mag = sqrtf(vec.mV[VX] * vec.mV[VX] + vec.mV[VY] * vec.mV[VY] + vec.mV[VZ] * vec.mV[VZ]);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = vec.mV[VX] * s;
+ mQ[VY] = vec.mV[VY] * s;
+ mQ[VZ] = vec.mV[VZ] * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
}
LLQuaternion::LLQuaternion(F32 angle, const LLVector3 &vec)
{
- LLVector3 v(vec);
- v.normalize();
-
- F32 c, s;
- c = cosf(angle*0.5f);
- s = sinf(angle*0.5f);
-
- mQ[VX] = v.mV[VX] * s;
- mQ[VY] = v.mV[VY] * s;
- mQ[VZ] = v.mV[VZ] * s;
- mQ[VW] = c;
- normalize();
+ F32 mag = sqrtf(vec.mV[VX] * vec.mV[VX] + vec.mV[VY] * vec.mV[VY] + vec.mV[VZ] * vec.mV[VZ]);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = vec.mV[VX] * s;
+ mQ[VY] = vec.mV[VY] * s;
+ mQ[VZ] = vec.mV[VZ] * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
}
LLQuaternion::LLQuaternion(const LLVector3 &x_axis,
@@ -136,57 +142,61 @@ void LLQuaternion::quantize8(F32 lower, F32 upper)
const LLQuaternion& LLQuaternion::setAngleAxis(F32 angle, F32 x, F32 y, F32 z)
{
- LLVector3 vec(x, y, z);
- vec.normalize();
-
- angle *= 0.5f;
- F32 c, s;
- c = cosf(angle);
- s = sinf(angle);
-
- mQ[VX] = vec.mV[VX]*s;
- mQ[VY] = vec.mV[VY]*s;
- mQ[VZ] = vec.mV[VZ]*s;
- mQ[VW] = c;
-
- normalize();
+ F32 mag = sqrtf(x * x + y * y + z * z);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = x * s;
+ mQ[VY] = y * s;
+ mQ[VZ] = z * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
return (*this);
}
const LLQuaternion& LLQuaternion::setAngleAxis(F32 angle, const LLVector3 &vec)
{
- LLVector3 v(vec);
- v.normalize();
-
- angle *= 0.5f;
- F32 c, s;
- c = cosf(angle);
- s = sinf(angle);
-
- mQ[VX] = v.mV[VX]*s;
- mQ[VY] = v.mV[VY]*s;
- mQ[VZ] = v.mV[VZ]*s;
- mQ[VW] = c;
-
- normalize();
+ F32 mag = sqrtf(vec.mV[VX] * vec.mV[VX] + vec.mV[VY] * vec.mV[VY] + vec.mV[VZ] * vec.mV[VZ]);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = vec.mV[VX] * s;
+ mQ[VY] = vec.mV[VY] * s;
+ mQ[VZ] = vec.mV[VZ] * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
return (*this);
}
const LLQuaternion& LLQuaternion::setAngleAxis(F32 angle, const LLVector4 &vec)
{
- LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
- v.normalize();
-
- F32 c, s;
- c = cosf(angle*0.5f);
- s = sinf(angle*0.5f);
-
- mQ[VX] = v.mV[VX]*s;
- mQ[VY] = v.mV[VY]*s;
- mQ[VZ] = v.mV[VZ]*s;
- mQ[VW] = c;
-
- normalize();
+ F32 mag = sqrtf(vec.mV[VX] * vec.mV[VX] + vec.mV[VY] * vec.mV[VY] + vec.mV[VZ] * vec.mV[VZ]);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = vec.mV[VX] * s;
+ mQ[VY] = vec.mV[VY] * s;
+ mQ[VZ] = vec.mV[VZ] * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
return (*this);
}
@@ -219,68 +229,80 @@ const LLQuaternion& LLQuaternion::set(const LLMatrix4 &mat)
// deprecated
const LLQuaternion& LLQuaternion::setQuat(F32 angle, F32 x, F32 y, F32 z)
{
- LLVector3 vec(x, y, z);
- vec.normalize();
-
- angle *= 0.5f;
- F32 c, s;
- c = cosf(angle);
- s = sinf(angle);
-
- mQ[VX] = vec.mV[VX]*s;
- mQ[VY] = vec.mV[VY]*s;
- mQ[VZ] = vec.mV[VZ]*s;
- mQ[VW] = c;
-
- normalize();
+ F32 mag = sqrtf(x * x + y * y + z * z);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = x * s;
+ mQ[VY] = y * s;
+ mQ[VZ] = z * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
return (*this);
}
// deprecated
const LLQuaternion& LLQuaternion::setQuat(F32 angle, const LLVector3 &vec)
{
- LLVector3 v(vec);
- v.normalize();
-
- angle *= 0.5f;
- F32 c, s;
- c = cosf(angle);
- s = sinf(angle);
-
- mQ[VX] = v.mV[VX]*s;
- mQ[VY] = v.mV[VY]*s;
- mQ[VZ] = v.mV[VZ]*s;
- mQ[VW] = c;
-
- normalize();
+ F32 mag = sqrtf(vec.mV[VX] * vec.mV[VX] + vec.mV[VY] * vec.mV[VY] + vec.mV[VZ] * vec.mV[VZ]);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = vec.mV[VX] * s;
+ mQ[VY] = vec.mV[VY] * s;
+ mQ[VZ] = vec.mV[VZ] * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
return (*this);
}
const LLQuaternion& LLQuaternion::setQuat(F32 angle, const LLVector4 &vec)
{
- LLVector3 v(vec.mV[VX], vec.mV[VY], vec.mV[VZ]);
- v.normalize();
-
- F32 c, s;
- c = cosf(angle*0.5f);
- s = sinf(angle*0.5f);
-
- mQ[VX] = v.mV[VX]*s;
- mQ[VY] = v.mV[VY]*s;
- mQ[VZ] = v.mV[VZ]*s;
- mQ[VW] = c;
-
- normalize();
+ F32 mag = sqrtf(vec.mV[VX] * vec.mV[VX] + vec.mV[VY] * vec.mV[VY] + vec.mV[VZ] * vec.mV[VZ]);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ angle *= 0.5;
+ F32 c = cosf(angle);
+ F32 s = sinf(angle) / mag;
+ mQ[VX] = vec.mV[VX] * s;
+ mQ[VY] = vec.mV[VY] * s;
+ mQ[VZ] = vec.mV[VZ] * s;
+ mQ[VW] = c;
+ }
+ else
+ {
+ loadIdentity();
+ }
return (*this);
}
const LLQuaternion& LLQuaternion::setQuat(F32 roll, F32 pitch, F32 yaw)
{
- LLMatrix3 rot_mat(roll, pitch, yaw);
- rot_mat.orthogonalize();
- *this = rot_mat.quaternion();
-
- normalize();
+ roll *= 0.5f;
+ pitch *= 0.5f;
+ yaw *= 0.5f;
+ F32 sinX = sinf(roll);
+ F32 cosX = cosf(roll);
+ F32 sinY = sinf(pitch);
+ F32 cosY = cosf(pitch);
+ F32 sinZ = sinf(yaw);
+ F32 cosZ = cosf(yaw);
+ mQ[VW] = cosX * cosY * cosZ - sinX * sinY * sinZ;
+ mQ[VX] = sinX * cosY * cosZ + cosX * sinY * sinZ;
+ mQ[VY] = cosX * sinY * cosZ - sinX * cosY * sinZ;
+ mQ[VZ] = cosX * cosY * sinZ + sinX * sinY * cosZ;
return (*this);
}
@@ -425,68 +447,44 @@ LLMatrix4 LLQuaternion::getMatrix4(void) const
// calculate the shortest rotation from a to b
void LLQuaternion::shortestArc(const LLVector3 &a, const LLVector3 &b)
{
- // Make a local copy of both vectors.
- LLVector3 vec_a = a;
- LLVector3 vec_b = b;
-
- // Make sure neither vector is zero length. Also normalize
- // the vectors while we are at it.
- F32 vec_a_mag = vec_a.normalize();
- F32 vec_b_mag = vec_b.normalize();
- if (vec_a_mag < F_APPROXIMATELY_ZERO ||
- vec_b_mag < F_APPROXIMATELY_ZERO)
- {
- // Can't calculate a rotation from this.
- // Just return ZERO_ROTATION instead.
- loadIdentity();
- return;
- }
-
- // Create an axis to rotate around, and the cos of the angle to rotate.
- LLVector3 axis = vec_a % vec_b;
- F32 cos_theta = vec_a * vec_b;
-
- // Check the angle between the vectors to see if they are parallel or anti-parallel.
- if (cos_theta > 1.0 - F_APPROXIMATELY_ZERO)
- {
- // a and b are parallel. No rotation is necessary.
- loadIdentity();
- }
- else if (cos_theta < -1.0 + F_APPROXIMATELY_ZERO)
+ F32 ab = a * b; // dotproduct
+ LLVector3 c = a % b; // crossproduct
+ F32 cc = c * c; // squared length of the crossproduct
+ if (ab * ab + cc) // test if the arguments have sufficient magnitude
{
- // a and b are anti-parallel.
- // Rotate 180 degrees around some orthogonal axis.
- // Find the projection of the x-axis onto a, and try
- // using the vector between the projection and the x-axis
- // as the orthogonal axis.
- LLVector3 proj = vec_a.mV[VX] / (vec_a * vec_a) * vec_a;
- LLVector3 ortho_axis(1.f, 0.f, 0.f);
- ortho_axis -= proj;
-
- // Turn this into an orthonormal axis.
- F32 ortho_length = ortho_axis.normalize();
- // If the axis' length is 0, then our guess at an orthogonal axis
- // was wrong (a is parallel to the x-axis).
- if (ortho_length < F_APPROXIMATELY_ZERO)
+ if (cc > 0.0f) // test if the arguments are (anti)parallel
{
- // Use the z-axis instead.
- ortho_axis.setVec(0.f, 0.f, 1.f);
+ F32 s = sqrtf(ab * ab + cc) + ab; // note: don't try to optimize this line
+ F32 m = 1.0f / sqrtf(cc + s * s); // the inverted magnitude of the quaternion
+ mQ[VX] = c.mV[VX] * m;
+ mQ[VY] = c.mV[VY] * m;
+ mQ[VZ] = c.mV[VZ] * m;
+ mQ[VW] = s * m;
+ return;
+ }
+ if (ab < 0.0f) // test if the angle is bigger than PI/2 (anti parallel)
+ {
+ c = a - b; // the arguments are anti-parallel, we have to choose an axis
+ F32 m = sqrtf(c.mV[VX] * c.mV[VX] + c.mV[VY] * c.mV[VY]); // the length projected on the XY-plane
+ if (m > FP_MAG_THRESHOLD)
+ {
+ mQ[VX] = -c.mV[VY] / m; // return the quaternion with the axis in the XY-plane
+ mQ[VY] = c.mV[VX] / m;
+ mQ[VZ] = 0.0f;
+ mQ[VW] = 0.0f;
+ return;
+ }
+ else // the vectors are parallel to the Z-axis
+ {
+ mQ[VX] = 1.0f; // rotate around the X-axis
+ mQ[VY] = 0.0f;
+ mQ[VZ] = 0.0f;
+ mQ[VW] = 0.0f;
+ return;
+ }
}
-
- // Construct a quaternion from this orthonormal axis.
- mQ[VX] = ortho_axis.mV[VX];
- mQ[VY] = ortho_axis.mV[VY];
- mQ[VZ] = ortho_axis.mV[VZ];
- mQ[VW] = 0.f;
- }
- else
- {
- // a and b are NOT parallel or anti-parallel.
- // Return the rotation between these vectors.
- F32 theta = (F32)acos(cos_theta);
-
- setAngleAxis(theta, axis);
}
+ loadIdentity();
}
// constrains rotation to a cone angle specified in radians
@@ -838,79 +836,82 @@ LLQuaternion::Order StringToOrder( const char *str )
void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const
{
- F32 cos_a = mQ[VW];
- if (cos_a > 1.0f) cos_a = 1.0f;
- if (cos_a < -1.0f) cos_a = -1.0f;
-
- F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
-
- if ( fabs( sin_a ) < 0.0005f )
- sin_a = 1.0f;
- else
- sin_a = 1.f/sin_a;
-
- F32 temp_angle = 2.0f * (F32) acos( cos_a );
- if (temp_angle > F_PI)
- {
- // The (angle,axis) pair should never have angles outside [PI, -PI]
- // since we want the _shortest_ (angle,axis) solution.
- // Since acos is defined for [0, PI], and we multiply by 2.0, we
- // can push the angle outside the acceptible range.
- // When this happens we set the angle to the other portion of a
- // full 2PI rotation, and negate the axis, which reverses the
- // direction of the rotation (by the right-hand rule).
- *angle = 2.f * F_PI - temp_angle;
- vec.mV[VX] = - mQ[VX] * sin_a;
- vec.mV[VY] = - mQ[VY] * sin_a;
- vec.mV[VZ] = - mQ[VZ] * sin_a;
+ F32 v = sqrtf(mQ[VX] * mQ[VX] + mQ[VY] * mQ[VY] + mQ[VZ] * mQ[VZ]); // length of the vector-component
+ if (v > FP_MAG_THRESHOLD)
+ {
+ F32 oomag = 1.0f / v;
+ F32 w = mQ[VW];
+ if (mQ[VW] < 0.0f)
+ {
+ w = -w; // make VW positive
+ oomag = -oomag; // invert the axis
+ }
+ vec.mV[VX] = mQ[VX] * oomag; // normalize the axis
+ vec.mV[VY] = mQ[VY] * oomag;
+ vec.mV[VZ] = mQ[VZ] * oomag;
+ *angle = 2.0f * atan2f(v, w); // get the angle
}
else
{
- *angle = temp_angle;
- vec.mV[VX] = mQ[VX] * sin_a;
- vec.mV[VY] = mQ[VY] * sin_a;
- vec.mV[VZ] = mQ[VZ] * sin_a;
+ *angle = 0.0f; // no rotation
+ vec.mV[VX] = 0.0f; // around some dummy axis
+ vec.mV[VY] = 0.0f;
+ vec.mV[VZ] = 1.0f;
}
}
-
// quaternion does not need to be normalized
void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const
{
- LLMatrix3 rot_mat(*this);
- rot_mat.orthogonalize();
- rot_mat.getEulerAngles(roll, pitch, yaw);
-
-// // NOTE: LLQuaternion's are actually inverted with respect to
-// // the matrices, so this code also assumes inverted quaternions
-// // (-x, -y, -z, w). The result is that roll,pitch,yaw are applied
-// // in reverse order (yaw,pitch,roll).
-// F32 x = -mQ[VX], y = -mQ[VY], z = -mQ[VZ], w = mQ[VW];
-// F64 m20 = 2.0*(x*z-y*w);
-// if (1.0f - fabsf(m20) < F_APPROXIMATELY_ZERO)
-// {
-// *roll = 0.0f;
-// *pitch = (F32)asin(m20);
-// *yaw = (F32)atan2(2.0*(x*y-z*w), 1.0 - 2.0*(x*x+z*z));
-// }
-// else
-// {
-// *roll = (F32)atan2(-2.0*(y*z+x*w), 1.0-2.0*(x*x+y*y));
-// *pitch = (F32)asin(m20);
-// *yaw = (F32)atan2(-2.0*(x*y+z*w), 1.0-2.0*(y*y+z*z));
-// }
+ F32 sx = 2 * (mQ[VX] * mQ[VW] - mQ[VY] * mQ[VZ]); // sine of the roll
+ F32 sy = 2 * (mQ[VY] * mQ[VW] + mQ[VX] * mQ[VZ]); // sine of the pitch
+ F32 ys = mQ[VW] * mQ[VW] - mQ[VY] * mQ[VY]; // intermediate cosine 1
+ F32 xz = mQ[VX] * mQ[VX] - mQ[VZ] * mQ[VZ]; // intermediate cosine 2
+ F32 cx = ys - xz; // cosine of the roll
+ F32 cy = sqrtf(sx * sx + cx * cx); // cosine of the pitch
+ if (cy > GIMBAL_THRESHOLD) // no gimbal lock
+ {
+ *roll = atan2f(sx, cx);
+ *pitch = atan2f(sy, cy);
+ *yaw = atan2f(2 * (mQ[VZ] * mQ[VW] - mQ[VX] * mQ[VY]), ys + xz);
+ }
+ else // gimbal lock
+ {
+ if (sy > 0)
+ {
+ *pitch = F_PI_BY_TWO;
+ *yaw = 2 * atan2f(mQ[VZ] + mQ[VX], mQ[VW] + mQ[VY]);
+ }
+ else
+ {
+ *pitch = -F_PI_BY_TWO;
+ *yaw = 2 * atan2f(mQ[VZ] - mQ[VX], mQ[VW] - mQ[VY]);
+ }
+ *roll = 0;
+ }
}
// Saves space by using the fact that our quaternions are normalized
LLVector3 LLQuaternion::packToVector3() const
{
+ F32 x = mQ[VX];
+ F32 y = mQ[VY];
+ F32 z = mQ[VZ];
+ F32 w = mQ[VW];
+ F32 mag = sqrtf(x * x + y * y + z * z + w * w);
+ if (mag > FP_MAG_THRESHOLD)
+ {
+ x /= mag;
+ y /= mag;
+ z /= mag; // no need to normalize w, it's not used
+ }
if( mQ[VW] >= 0 )
{
- return LLVector3( mQ[VX], mQ[VY], mQ[VZ] );
+ return LLVector3( x, y , z );
}
else
{
- return LLVector3( -mQ[VX], -mQ[VY], -mQ[VZ] );
+ return LLVector3( -x, -y, -z );
}
}
diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h
index ca0dfe206b..e56929ed0f 100755
--- a/indra/llmath/llquaternion.h
+++ b/indra/llmath/llquaternion.h
@@ -1,4 +1,4 @@
-/**
+/**
* @file llquaternion.h
* @brief LLQuaternion class header file.
*
@@ -304,43 +304,29 @@ inline const LLQuaternion& LLQuaternion::setQuat(const F32 *q)
return (*this);
}
-// There may be a cheaper way that avoids the sqrt.
-// Does sin_a = VX*VX + VY*VY + VZ*VZ?
-// Copied from Matrix and Quaternion FAQ 1.12
inline void LLQuaternion::getAngleAxis(F32* angle, F32* x, F32* y, F32* z) const
{
- F32 cos_a = mQ[VW];
- if (cos_a > 1.0f) cos_a = 1.0f;
- if (cos_a < -1.0f) cos_a = -1.0f;
-
- F32 sin_a = (F32) sqrt( 1.0f - cos_a * cos_a );
-
- if ( fabs( sin_a ) < 0.0005f )
- sin_a = 1.0f;
- else
- sin_a = 1.f/sin_a;
-
- F32 temp_angle = 2.0f * (F32) acos( cos_a );
- if (temp_angle > F_PI)
+ F32 v = sqrtf(mQ[VX] * mQ[VX] + mQ[VY] * mQ[VY] + mQ[VZ] * mQ[VZ]); // length of the vector-component
+ if (v > FP_MAG_THRESHOLD)
{
- // The (angle,axis) pair should never have angles outside [PI, -PI]
- // since we want the _shortest_ (angle,axis) solution.
- // Since acos is defined for [0, PI], and we multiply by 2.0, we
- // can push the angle outside the acceptible range.
- // When this happens we set the angle to the other portion of a
- // full 2PI rotation, and negate the axis, which reverses the
- // direction of the rotation (by the right-hand rule).
- *angle = 2.f * F_PI - temp_angle;
- *x = - mQ[VX] * sin_a;
- *y = - mQ[VY] * sin_a;
- *z = - mQ[VZ] * sin_a;
+ F32 oomag = 1.0f / v;
+ F32 w = mQ[VW];
+ if (w < 0.0f)
+ {
+ w = -w; // make VW positive
+ oomag = -oomag; // invert the axis
+ }
+ *x = mQ[VX] * oomag; // normalize the axis
+ *y = mQ[VY] * oomag;
+ *z = mQ[VZ] * oomag;
+ *angle = 2.0f * atan2f(v, w); // get the angle
}
else
{
- *angle = temp_angle;
- *x = mQ[VX] * sin_a;
- *y = mQ[VY] * sin_a;
- *z = mQ[VZ] * sin_a;
+ *angle = 0.0f; // no rotation
+ *x = 0.0f; // around some dummy axis
+ *y = 0.0f;
+ *z = 1.0f;
}
}
diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h
index c66bc26176..0b479c4564 100755
--- a/indra/llmath/lltreenode.h
+++ b/indra/llmath/lltreenode.h
@@ -57,7 +57,14 @@ public:
virtual bool remove(T* data);
virtual void notifyRemoval(T* data);
virtual U32 getListenerCount() { return mListeners.size(); }
- virtual LLTreeListener<T>* getListener(U32 index) const { return mListeners[index]; }
+ virtual LLTreeListener<T>* getListener(U32 index) const
+ {
+ if(index < mListeners.size())
+ {
+ return mListeners[index];
+ }
+ return NULL;
+ }
virtual void addListener(LLTreeListener<T>* listener) { mListeners.push_back(listener); }
protected:
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index cc5742ff7a..d9a68cb577 100755
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -44,7 +44,6 @@
#include "m3math.h"
#include "llmatrix3a.h"
#include "lloctree.h"
-#include "lldarray.h"
#include "llvolume.h"
#include "llvolumeoctree.h"
#include "llstl.h"
@@ -427,7 +426,7 @@ public:
}
else
{
- llerrs << "Empty leaf" << llendl;
+ LL_ERRS() << "Empty leaf" << LL_ENDL;
}
for (S32 i = 0; i < branch->getChildCount(); ++i)
@@ -834,7 +833,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
if (detail < MIN_LOD)
{
- llinfos << "Generating profile with LOD < MIN_LOD. CLAMPING" << llendl;
+ LL_INFOS() << "Generating profile with LOD < MIN_LOD. CLAMPING" << LL_ENDL;
detail = MIN_LOD;
}
@@ -850,7 +849,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
// Quick validation to eliminate some server crashes.
if (begin > end - 0.01f)
{
- llwarns << "LLProfile::generate() assertion failed (begin >= end)" << llendl;
+ LL_WARNS() << "LLProfile::generate() assertion failed (begin >= end)" << LL_ENDL;
return FALSE;
}
@@ -1071,7 +1070,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai
}
break;
default:
- llerrs << "Unknown profile: getCurveType()=" << params.getCurveType() << llendl;
+ LL_ERRS() << "Unknown profile: getCurveType()=" << params.getCurveType() << LL_ENDL;
break;
};
@@ -1153,7 +1152,7 @@ BOOL LLProfileParams::importFile(LLFILE *fp)
}
else
{
- llwarns << "unknown keyword " << keyword << " in profile import" << llendl;
+ LL_WARNS() << "unknown keyword " << keyword << " in profile import" << LL_ENDL;
}
}
@@ -1225,7 +1224,7 @@ BOOL LLProfileParams::importLegacyStream(std::istream& input_stream)
}
else
{
- llwarns << "unknown keyword " << keyword << " in profile import" << llendl;
+ LL_WARNS() << "unknown keyword " << keyword << " in profile import" << LL_ENDL;
}
}
@@ -1547,7 +1546,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
if (detail < MIN_LOD)
{
- llinfos << "Generating path with LOD < MIN! Clamping to 1" << llendl;
+ LL_INFOS() << "Generating path with LOD < MIN! Clamping to 1" << LL_ENDL;
detail = MIN_LOD;
}
@@ -1649,7 +1648,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split,
F32 t = (F32)i * mStep;
mPath[i].mPos.set(0,
lerp(0, -sin(F_PI*params.getTwist()*t)*0.5f,t),
- lerp(-0.5, cos(F_PI*params.getTwist()*t)*0.5f,t));
+ lerp(-0.5f, cos(F_PI*params.getTwist()*t)*0.5f,t));
mPath[i].mScale.set(lerp(1,params.getScale().mV[0],t),
lerp(1,params.getScale().mV[1],t), 0,1);
mPath[i].mTexT = t;
@@ -1809,7 +1808,7 @@ BOOL LLPathParams::importFile(LLFILE *fp)
}
else
{
- llwarns << "unknown keyword " << " in path import" << llendl;
+ LL_WARNS() << "unknown keyword " << " in path import" << LL_ENDL;
}
}
return TRUE;
@@ -1949,7 +1948,7 @@ BOOL LLPathParams::importLegacyStream(std::istream& input_stream)
}
else
{
- llwarns << "unknown keyword " << " in path import" << llendl;
+ LL_WARNS() << "unknown keyword " << " in path import" << LL_ENDL;
}
}
return TRUE;
@@ -2040,7 +2039,7 @@ LLProfile::~LLProfile()
{
if(profile_delete_lock)
{
- llerrs << "LLProfile should not be deleted here!" << llendl ;
+ LL_ERRS() << "LLProfile should not be deleted here!" << LL_ENDL ;
}
}
@@ -2087,6 +2086,7 @@ void LLVolume::resizePath(S32 length)
{
mPathp->resizePath(length);
mVolumeFaces.clear();
+ setDirty();
}
void LLVolume::regen()
@@ -2375,7 +2375,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
LLSD mdl;
if (!unzip_llsd(mdl, is, size))
{
- LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD, will probably fetch from sim again." << llendl;
+ LL_DEBUGS("MeshStreaming") << "Failed to unzip LLSD blob for LoD, will probably fetch from sim again." << LL_ENDL;
return false;
}
@@ -2384,7 +2384,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
if (face_count == 0)
{ //no faces unpacked, treat as failed decode
- llwarns << "found no faces!" << llendl;
+ LL_WARNS() << "found no faces!" << LL_ENDL;
return false;
}
@@ -2417,7 +2417,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
if (idx.empty() || face.mNumIndices < 3)
{ //why is there an empty index list?
- llwarns <<"Empty face present!" << llendl;
+ LL_WARNS() <<"Empty face present!" << LL_ENDL;
continue;
}
@@ -2564,7 +2564,7 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size)
if (cur_vertex != num_verts || idx != weights.size())
{
- llwarns << "Vertex weight count does not match vertex count!" << llendl;
+ LL_WARNS() << "Vertex weight count does not match vertex count!" << LL_ENDL;
}
}
@@ -2730,7 +2730,7 @@ void LLVolume::createVolumeFaces()
vf.mNumS = face.mCount;
if (vf.mNumS < 0)
{
- llerrs << "Volume face corruption detected." << llendl;
+ LL_ERRS() << "Volume face corruption detected." << LL_ENDL;
}
vf.mBeginT = 0;
@@ -2778,7 +2778,7 @@ void LLVolume::createVolumeFaces()
vf.mNumS = vf.mNumS*2;
if (vf.mNumS < 0)
{
- llerrs << "Volume face corruption detected." << llendl;
+ LL_ERRS() << "Volume face corruption detected." << LL_ENDL;
}
}
}
@@ -3107,7 +3107,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
// weird crash bug - DEV-11158 - trying to collect more data:
if ((sizeS == 0) || (sizeT == 0))
{
- llwarns << "sculpt bad mesh size " << sizeS << " " << sizeT << llendl;
+ LL_WARNS() << "sculpt bad mesh size " << sizeS << " " << sizeT << LL_ENDL;
}
sNumMeshPoints -= mMesh.size();
@@ -3502,16 +3502,16 @@ bool LLVolumeParams::setType(U8 profile, U8 path)
// Bad profile. Make it square.
profile = LL_PCODE_PROFILE_SQUARE;
result = false;
- llwarns << "LLVolumeParams::setType changing bad profile type (" << profile_type
- << ") to be LL_PCODE_PROFILE_SQUARE" << llendl;
+ LL_WARNS() << "LLVolumeParams::setType changing bad profile type (" << profile_type
+ << ") to be LL_PCODE_PROFILE_SQUARE" << LL_ENDL;
}
else if (hole_type > LL_PCODE_HOLE_MAX)
{
// Bad hole. Make it the same.
profile = profile_type;
result = false;
- llwarns << "LLVolumeParams::setType changing bad hole type (" << hole_type
- << ") to be LL_PCODE_HOLE_SAME" << llendl;
+ LL_WARNS() << "LLVolumeParams::setType changing bad hole type (" << hole_type
+ << ") to be LL_PCODE_HOLE_SAME" << LL_ENDL;
}
if (path_type < LL_PCODE_PATH_MIN ||
@@ -3519,8 +3519,8 @@ bool LLVolumeParams::setType(U8 profile, U8 path)
{
// Bad path. Make it linear.
result = false;
- llwarns << "LLVolumeParams::setType changing bad path (" << path
- << ") to be LL_PCODE_PATH_LINE" << llendl;
+ LL_WARNS() << "LLVolumeParams::setType changing bad path (" << path
+ << ") to be LL_PCODE_PATH_LINE" << LL_ENDL;
path = LL_PCODE_PATH_LINE;
}
@@ -4112,7 +4112,7 @@ BOOL equalTriangle(const S32 *a, const S32 *b)
BOOL LLVolumeParams::importFile(LLFILE *fp)
{
- //llinfos << "importing volume" << llendl;
+ //LL_INFOS() << "importing volume" << LL_ENDL;
const S32 BUFSIZE = 16384;
char buffer[BUFSIZE]; /* Flawfinder: ignore */
// *NOTE: changing the size or type of this buffer will require
@@ -4146,7 +4146,7 @@ BOOL LLVolumeParams::importFile(LLFILE *fp)
}
else
{
- llwarns << "unknown keyword " << keyword << " in volume import" << llendl;
+ LL_WARNS() << "unknown keyword " << keyword << " in volume import" << LL_ENDL;
}
}
@@ -4166,7 +4166,7 @@ BOOL LLVolumeParams::exportFile(LLFILE *fp) const
BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
{
- //llinfos << "importing volume" << llendl;
+ //LL_INFOS() << "importing volume" << LL_ENDL;
const S32 BUFSIZE = 16384;
// *NOTE: changing the size or type of this buffer will require
// changing the sscanf below.
@@ -4196,7 +4196,7 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream)
}
else
{
- llwarns << "unknown keyword " << keyword << " in volume import" << llendl;
+ LL_WARNS() << "unknown keyword " << keyword << " in volume import" << LL_ENDL;
}
}
@@ -4408,7 +4408,7 @@ LLFaceID LLVolume::generateFaceMask()
}
break;
default:
- llerrs << "Unknown profile!" << llendl;
+ LL_ERRS() << "Unknown profile!" << LL_ENDL;
break;
}
@@ -4669,7 +4669,7 @@ LLVolumeFace::~LLVolumeFace()
void LLVolumeFace::freeData()
{
- ll_aligned_free(mPositions);
+ ll_aligned_free<64>(mPositions);
mPositions = NULL;
//normals and texture coordinates are part of the same buffer as mPositions, do not free them separately
@@ -4707,7 +4707,7 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
}
else
{
- llerrs << "Unknown/uninitialized face type!" << llendl;
+ LL_ERRS() << "Unknown/uninitialized face type!" << LL_ENDL;
}
return ret ;
@@ -5247,7 +5247,7 @@ void LLVolumeFace::cacheOptimize()
//allocate space for new buffer
S32 num_verts = mNumVertices;
S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF;
- LLVector4a* pos = (LLVector4a*) ll_aligned_malloc(sizeof(LLVector4a)*2*num_verts+size, 64);
+ LLVector4a* pos = (LLVector4a*) ll_aligned_malloc<64>(sizeof(LLVector4a)*2*num_verts+size);
LLVector4a* norm = pos + num_verts;
LLVector2* tc = (LLVector2*) (norm + num_verts);
@@ -5297,7 +5297,7 @@ void LLVolumeFace::cacheOptimize()
mIndices[i] = new_idx[mIndices[i]];
}
- ll_aligned_free(mPositions);
+ ll_aligned_free<64>(mPositions);
// DO NOT free mNormals and mTexCoords as they are part of mPositions buffer
ll_aligned_free_16(mWeights);
ll_aligned_free_16(mTangents);
@@ -5309,7 +5309,7 @@ void LLVolumeFace::cacheOptimize()
mTangents = binorm;
//std::string result = llformat("ACMR pre/post: %.3f/%.3f -- %d triangles %d breaks", pre_acmr, post_acmr, mNumIndices/3, breaks);
- //llinfos << result << llendl;
+ //LL_INFOS() << result << LL_ENDL;
}
@@ -6025,7 +6025,7 @@ void LLVolumeFace::createTangents()
void LLVolumeFace::resizeVertices(S32 num_verts)
{
- ll_aligned_free(mPositions);
+ ll_aligned_free<64>(mPositions);
//DO NOT free mNormals and mTexCoords as they are part of mPositions buffer
ll_aligned_free_16(mTangents);
@@ -6036,7 +6036,7 @@ void LLVolumeFace::resizeVertices(S32 num_verts)
//pad texture coordinate block end to allow for QWORD reads
S32 size = ((num_verts*sizeof(LLVector2)) + 0xF) & ~0xF;
- mPositions = (LLVector4a*) ll_aligned_malloc(sizeof(LLVector4a)*2*num_verts+size, 64);
+ mPositions = (LLVector4a*) ll_aligned_malloc<64>(sizeof(LLVector4a)*2*num_verts+size);
mNormals = mPositions+num_verts;
mTexCoords = (LLVector2*) (mNormals+num_verts);
@@ -6076,7 +6076,7 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
LLVector4a* old_buf = mPositions;
- mPositions = (LLVector4a*) ll_aligned_malloc(new_size, 64);
+ mPositions = (LLVector4a*) ll_aligned_malloc<64>(new_size);
mNormals = mPositions+new_verts;
mTexCoords = (LLVector2*) (mNormals+new_verts);
@@ -6092,7 +6092,7 @@ void LLVolumeFace::pushVertex(const LLVector4a& pos, const LLVector4a& norm, con
//just clear tangents
ll_aligned_free_16(mTangents);
mTangents = NULL;
- ll_aligned_free(old_buf);
+ ll_aligned_free<64>(old_buf);
mNumAllocatedVertices = new_verts;
@@ -6177,12 +6177,12 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
if (new_count > 65536)
{
- llerrs << "Cannot append face -- 16-bit overflow will occur." << llendl;
+ LL_ERRS() << "Cannot append face -- 16-bit overflow will occur." << LL_ENDL;
}
if (face.mNumVertices == 0)
{
- llerrs << "Cannot append empty face." << llendl;
+ LL_ERRS() << "Cannot append empty face." << LL_ENDL;
}
U32 old_vsize = mNumVertices*16;
@@ -6193,7 +6193,7 @@ void LLVolumeFace::appendFace(const LLVolumeFace& face, LLMatrix4& mat_in, LLMat
//allocate new buffer space
LLVector4a* old_buf = mPositions;
- mPositions = (LLVector4a*) ll_aligned_malloc(new_size, 64);
+ mPositions = (LLVector4a*) ll_aligned_malloc<64>(new_size);
mNormals = mPositions + new_count;
mTexCoords = (LLVector2*) (mNormals+new_count);
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 975227ea58..2f38ae7203 100755
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -41,7 +41,6 @@ class LLVolumeFace;
class LLVolume;
class LLVolumeTriangle;
-#include "lldarray.h"
#include "lluuid.h"
#include "v4color.h"
//#include "vmath.h"
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index 9083273ee5..3b8f08e0c6 100755
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -147,7 +147,7 @@ void LLVolumeMgr::unrefVolume(LLVolume *volumep)
volume_lod_group_map_t::iterator iter = mVolumeLODGroups.find(params);
if( iter == mVolumeLODGroups.end() )
{
- llerrs << "Warning! Tried to cleanup unknown volume type! " << *params << llendl;
+ LL_ERRS() << "Warning! Tried to cleanup unknown volume type! " << *params << LL_ENDL;
if (mDataMutex)
{
mDataMutex->unlock();
@@ -207,7 +207,7 @@ void LLVolumeMgr::dump()
{
mDataMutex->unlock();
}
- llinfos << "Average usage of LODs " << avg << llendl;
+ LL_INFOS() << "Average usage of LODs " << avg << LL_ENDL;
}
void LLVolumeMgr::useMutex()
@@ -270,18 +270,18 @@ bool LLVolumeLODGroup::cleanupRefs()
bool res = true;
if (mRefs != 0)
{
- llwarns << "Volume group has remaining refs:" << getNumRefs() << llendl;
+ LL_WARNS() << "Volume group has remaining refs:" << getNumRefs() << LL_ENDL;
mRefs = 0;
for (S32 i = 0; i < NUM_LODS; i++)
{
if (mLODRefs[i] > 0)
{
- llwarns << " LOD " << i << " refs = " << mLODRefs[i] << llendl;
+ LL_WARNS() << " LOD " << i << " refs = " << mLODRefs[i] << LL_ENDL;
mLODRefs[i] = 0;
mVolumeLODs[i] = NULL;
}
}
- llwarns << *getVolumeParams() << llendl;
+ LL_WARNS() << *getVolumeParams() << LL_ENDL;
res = false;
}
return res;
@@ -320,7 +320,7 @@ BOOL LLVolumeLODGroup::derefLOD(LLVolume *volumep)
return TRUE;
}
}
- llerrs << "Deref of non-matching LOD in volume LOD group" << llendl;
+ LL_ERRS() << "Deref of non-matching LOD in volume LOD group" << LL_ENDL;
return FALSE;
}
@@ -393,7 +393,7 @@ F32 LLVolumeLODGroup::dump()
std::string dump_str = llformat("%.3f %d %d %d %d", usage, mAccessCount[0], mAccessCount[1], mAccessCount[2], mAccessCount[3]);
- llinfos << dump_str << llendl;
+ LL_INFOS() << dump_str << LL_ENDL;
return usage;
}
diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp
index 0728b49c1f..fb232d5f6c 100755
--- a/indra/llmath/llvolumeoctree.cpp
+++ b/indra/llmath/llvolumeoctree.cpp
@@ -237,7 +237,7 @@ void LLVolumeOctreeValidate::visit(const LLOctreeNode<LLVolumeTriangle>* branch)
if (!test_min.equals3(min, 0.001f) ||
!test_max.equals3(max, 0.001f))
{
- llerrs << "Bad bounding box data found." << llendl;
+ LL_ERRS() << "Bad bounding box data found." << LL_ENDL;
}
test_min.sub(LLVector4a(0.001f));
@@ -251,7 +251,7 @@ void LLVolumeOctreeValidate::visit(const LLOctreeNode<LLVolumeTriangle>* branch)
if (child->mExtents[0].lessThan(test_min).areAnySet(LLVector4Logical::MASK_XYZ) ||
child->mExtents[1].greaterThan(test_max).areAnySet(LLVector4Logical::MASK_XYZ))
{
- llerrs << "Child protrudes from bounding box." << llendl;
+ LL_ERRS() << "Child protrudes from bounding box." << LL_ENDL;
}
}
@@ -267,7 +267,7 @@ void LLVolumeOctreeValidate::visit(const LLOctreeNode<LLVolumeTriangle>* branch)
if (tri->mV[i]->greaterThan(test_max).areAnySet(LLVector4Logical::MASK_XYZ) ||
tri->mV[i]->lessThan(test_min).areAnySet(LLVector4Logical::MASK_XYZ))
{
- llerrs << "Triangle protrudes from node." << llendl;
+ LL_ERRS() << "Triangle protrudes from node." << LL_ENDL;
}
}
}
diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h
index 80d6ced36d..13150028d8 100755
--- a/indra/llmath/llvolumeoctree.h
+++ b/indra/llmath/llvolumeoctree.h
@@ -59,7 +59,7 @@ public:
const LLVolumeTriangle& operator=(const LLVolumeTriangle& rhs)
{
- llerrs << "Illegal operation!" << llendl;
+ LL_ERRS() << "Illegal operation!" << LL_ENDL;
return *this;
}
@@ -110,7 +110,7 @@ public:
const LLVolumeOctreeListener& operator=(const LLVolumeOctreeListener& rhs)
{
- llerrs << "Illegal operation!" << llendl;
+ LL_ERRS() << "Illegal operation!" << LL_ENDL;
return *this;
}
diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h
index 578dcdc8ea..4938273d5b 100755
--- a/indra/llmath/v3dmath.h
+++ b/indra/llmath/v3dmath.h
@@ -72,17 +72,22 @@ class LLVector3d
BOOL clamp(const F64 min, const F64 max); // Clamps all values to (min,max), returns TRUE if data changed
BOOL abs(); // sets all values to absolute value of original value (first octant), returns TRUE if changed
- inline const LLVector3d& clearVec(); // Clears LLVector3d to (0, 0, 0, 1)
+ inline const LLVector3d& clear(); // Clears LLVector3d to (0, 0, 0, 1)
+ inline const LLVector3d& clearVec(); // deprecated
inline const LLVector3d& setZero(); // Zero LLVector3d to (0, 0, 0, 0)
inline const LLVector3d& zeroVec(); // deprecated
- inline const LLVector3d& setVec(const F64 x, const F64 y, const F64 z); // Sets LLVector3d to (x, y, z, 1)
- inline const LLVector3d& setVec(const LLVector3d &vec); // Sets LLVector3d to vec
- inline const LLVector3d& setVec(const F64 *vec); // Sets LLVector3d to vec
- inline const LLVector3d& setVec(const LLVector3 &vec);
-
- F64 magVec() const; // Returns magnitude of LLVector3d
- F64 magVecSquared() const; // Returns magnitude squared of LLVector3d
- inline F64 normVec(); // Normalizes and returns the magnitude of LLVector3d
+ inline const LLVector3d& set(const F64 x, const F64 y, const F64 z); // Sets LLVector3d to (x, y, z, 1)
+ inline const LLVector3d& set(const LLVector3d &vec); // Sets LLVector3d to vec
+ inline const LLVector3d& set(const F64 *vec); // Sets LLVector3d to vec
+ inline const LLVector3d& set(const LLVector3 &vec);
+ inline const LLVector3d& setVec(const F64 x, const F64 y, const F64 z); // deprecated
+ inline const LLVector3d& setVec(const LLVector3d &vec); // deprecated
+ inline const LLVector3d& setVec(const F64 *vec); // deprecated
+ inline const LLVector3d& setVec(const LLVector3 &vec); // deprecated
+
+ F64 magVec() const; // deprecated
+ F64 magVecSquared() const; // deprecated
+ inline F64 normVec(); // deprecated
F64 length() const; // Returns magnitude of LLVector3d
F64 lengthSquared() const; // Returns magnitude squared of LLVector3d
@@ -101,25 +106,25 @@ class LLVector3d
F64 operator[](int idx) const { return mdV[idx]; }
F64 &operator[](int idx) { return mdV[idx]; }
- friend LLVector3d operator+(const LLVector3d &a, const LLVector3d &b); // Return vector a + b
- friend LLVector3d operator-(const LLVector3d &a, const LLVector3d &b); // Return vector a minus b
- friend F64 operator*(const LLVector3d &a, const LLVector3d &b); // Return a dot b
- friend LLVector3d operator%(const LLVector3d &a, const LLVector3d &b); // Return a cross b
- friend LLVector3d operator*(const LLVector3d &a, const F64 k); // Return a times scaler k
- friend LLVector3d operator/(const LLVector3d &a, const F64 k); // Return a divided by scaler k
- friend LLVector3d operator*(const F64 k, const LLVector3d &a); // Return a times scaler k
- friend bool operator==(const LLVector3d &a, const LLVector3d &b); // Return a == b
- friend bool operator!=(const LLVector3d &a, const LLVector3d &b); // Return a != b
+ friend LLVector3d operator+(const LLVector3d& a, const LLVector3d& b); // Return vector a + b
+ friend LLVector3d operator-(const LLVector3d& a, const LLVector3d& b); // Return vector a minus b
+ friend F64 operator*(const LLVector3d& a, const LLVector3d& b); // Return a dot b
+ friend LLVector3d operator%(const LLVector3d& a, const LLVector3d& b); // Return a cross b
+ friend LLVector3d operator*(const LLVector3d& a, const F64 k); // Return a times scaler k
+ friend LLVector3d operator/(const LLVector3d& a, const F64 k); // Return a divided by scaler k
+ friend LLVector3d operator*(const F64 k, const LLVector3d& a); // Return a times scaler k
+ friend bool operator==(const LLVector3d& a, const LLVector3d& b); // Return a == b
+ friend bool operator!=(const LLVector3d& a, const LLVector3d& b); // Return a != b
- friend const LLVector3d& operator+=(LLVector3d &a, const LLVector3d &b); // Return vector a + b
- friend const LLVector3d& operator-=(LLVector3d &a, const LLVector3d &b); // Return vector a minus b
- friend const LLVector3d& operator%=(LLVector3d &a, const LLVector3d &b); // Return a cross b
- friend const LLVector3d& operator*=(LLVector3d &a, const F64 k); // Return a times scaler k
- friend const LLVector3d& operator/=(LLVector3d &a, const F64 k); // Return a divided by scaler k
+ friend const LLVector3d& operator+=(LLVector3d& a, const LLVector3d& b); // Return vector a + b
+ friend const LLVector3d& operator-=(LLVector3d& a, const LLVector3d& b); // Return vector a minus b
+ friend const LLVector3d& operator%=(LLVector3d& a, const LLVector3d& b); // Return a cross b
+ friend const LLVector3d& operator*=(LLVector3d& a, const F64 k); // Return a times scaler k
+ friend const LLVector3d& operator/=(LLVector3d& a, const F64 k); // Return a divided by scaler k
- friend LLVector3d operator-(const LLVector3d &a); // Return vector -a
+ friend LLVector3d operator-(const LLVector3d& a); // Return vector -a
- friend std::ostream& operator<<(std::ostream& s, const LLVector3d &a); // Stream a
+ friend std::ostream& operator<<(std::ostream& s, const LLVector3d& a); // Stream a
static BOOL parseVector3d(const std::string& buf, LLVector3d* value);
@@ -127,7 +132,15 @@ class LLVector3d
typedef LLVector3d LLGlobalVec;
-const LLVector3d &LLVector3d::setVec(const LLVector3 &vec)
+inline const LLVector3d &LLVector3d::set(const LLVector3 &vec)
+{
+ mdV[0] = vec.mV[0];
+ mdV[1] = vec.mV[1];
+ mdV[2] = vec.mV[2];
+ return *this;
+}
+
+inline const LLVector3d &LLVector3d::setVec(const LLVector3 &vec)
{
mdV[0] = vec.mV[0];
mdV[1] = vec.mV[1];
@@ -184,6 +197,14 @@ inline BOOL LLVector3d::isFinite() const
// Clear and Assignment Functions
+inline const LLVector3d& LLVector3d::clear(void)
+{
+ mdV[0] = 0.f;
+ mdV[1] = 0.f;
+ mdV[2]= 0.f;
+ return (*this);
+}
+
inline const LLVector3d& LLVector3d::clearVec(void)
{
mdV[0] = 0.f;
@@ -208,6 +229,30 @@ inline const LLVector3d& LLVector3d::zeroVec(void)
return (*this);
}
+inline const LLVector3d& LLVector3d::set(const F64 x, const F64 y, const F64 z)
+{
+ mdV[VX] = x;
+ mdV[VY] = y;
+ mdV[VZ] = z;
+ return (*this);
+}
+
+inline const LLVector3d& LLVector3d::set(const LLVector3d &vec)
+{
+ mdV[0] = vec.mdV[0];
+ mdV[1] = vec.mdV[1];
+ mdV[2] = vec.mdV[2];
+ return (*this);
+}
+
+inline const LLVector3d& LLVector3d::set(const F64 *vec)
+{
+ mdV[0] = vec[0];
+ mdV[1] = vec[1];
+ mdV[2] = vec[2];
+ return (*this);
+}
+
inline const LLVector3d& LLVector3d::setVec(const F64 x, const F64 y, const F64 z)
{
mdV[VX] = x;
@@ -298,59 +343,59 @@ 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)
+inline LLVector3d operator+(const LLVector3d& a, const LLVector3d& b)
{
LLVector3d c(a);
return c += b;
}
-inline LLVector3d operator-(const LLVector3d &a, const LLVector3d &b)
+inline LLVector3d operator-(const LLVector3d& a, const LLVector3d& b)
{
LLVector3d c(a);
return c -= b;
}
-inline F64 operator*(const LLVector3d &a, const LLVector3d &b)
+inline F64 operator*(const LLVector3d& a, const LLVector3d& b)
{
return (a.mdV[0]*b.mdV[0] + a.mdV[1]*b.mdV[1] + a.mdV[2]*b.mdV[2]);
}
-inline LLVector3d operator%(const LLVector3d &a, const LLVector3d &b)
+inline LLVector3d operator%(const LLVector3d& a, const LLVector3d& b)
{
return LLVector3d( a.mdV[1]*b.mdV[2] - b.mdV[1]*a.mdV[2], a.mdV[2]*b.mdV[0] - b.mdV[2]*a.mdV[0], a.mdV[0]*b.mdV[1] - b.mdV[0]*a.mdV[1] );
}
-inline LLVector3d operator/(const LLVector3d &a, const F64 k)
+inline LLVector3d operator/(const LLVector3d& a, const F64 k)
{
F64 t = 1.f / k;
return LLVector3d( a.mdV[0] * t, a.mdV[1] * t, a.mdV[2] * t );
}
-inline LLVector3d operator*(const LLVector3d &a, const F64 k)
+inline LLVector3d operator*(const LLVector3d& a, const F64 k)
{
return LLVector3d( a.mdV[0] * k, a.mdV[1] * k, a.mdV[2] * k );
}
-inline LLVector3d operator*(F64 k, const LLVector3d &a)
+inline LLVector3d operator*(F64 k, const LLVector3d& a)
{
return LLVector3d( a.mdV[0] * k, a.mdV[1] * k, a.mdV[2] * k );
}
-inline bool operator==(const LLVector3d &a, const LLVector3d &b)
+inline bool operator==(const LLVector3d& a, const LLVector3d& b)
{
return ( (a.mdV[0] == b.mdV[0])
&&(a.mdV[1] == b.mdV[1])
&&(a.mdV[2] == b.mdV[2]));
}
-inline bool operator!=(const LLVector3d &a, const LLVector3d &b)
+inline bool operator!=(const LLVector3d& a, const LLVector3d& b)
{
return ( (a.mdV[0] != b.mdV[0])
||(a.mdV[1] != b.mdV[1])
||(a.mdV[2] != b.mdV[2]));
}
-inline const LLVector3d& operator+=(LLVector3d &a, const LLVector3d &b)
+inline const LLVector3d& operator+=(LLVector3d& a, const LLVector3d& b)
{
a.mdV[0] += b.mdV[0];
a.mdV[1] += b.mdV[1];
@@ -358,7 +403,7 @@ inline const LLVector3d& operator+=(LLVector3d &a, const LLVector3d &b)
return a;
}
-inline const LLVector3d& operator-=(LLVector3d &a, const LLVector3d &b)
+inline const LLVector3d& operator-=(LLVector3d& a, const LLVector3d& b)
{
a.mdV[0] -= b.mdV[0];
a.mdV[1] -= b.mdV[1];
@@ -366,14 +411,14 @@ inline const LLVector3d& operator-=(LLVector3d &a, const LLVector3d &b)
return a;
}
-inline const LLVector3d& operator%=(LLVector3d &a, const LLVector3d &b)
+inline const LLVector3d& operator%=(LLVector3d& a, const LLVector3d& b)
{
LLVector3d ret( a.mdV[1]*b.mdV[2] - b.mdV[1]*a.mdV[2], a.mdV[2]*b.mdV[0] - b.mdV[2]*a.mdV[0], a.mdV[0]*b.mdV[1] - b.mdV[0]*a.mdV[1]);
a = ret;
return a;
}
-inline const LLVector3d& operator*=(LLVector3d &a, const F64 k)
+inline const LLVector3d& operator*=(LLVector3d& a, const F64 k)
{
a.mdV[0] *= k;
a.mdV[1] *= k;
@@ -381,7 +426,7 @@ inline const LLVector3d& operator*=(LLVector3d &a, const F64 k)
return a;
}
-inline const LLVector3d& operator/=(LLVector3d &a, const F64 k)
+inline const LLVector3d& operator/=(LLVector3d& a, const F64 k)
{
F64 t = 1.f / k;
a.mdV[0] *= t;
@@ -390,12 +435,12 @@ inline const LLVector3d& operator/=(LLVector3d &a, const F64 k)
return a;
}
-inline LLVector3d operator-(const LLVector3d &a)
+inline LLVector3d operator-(const LLVector3d& a)
{
return LLVector3d( -a.mdV[0], -a.mdV[1], -a.mdV[2] );
}
-inline F64 dist_vec(const LLVector3d &a, const LLVector3d &b)
+inline F64 dist_vec(const LLVector3d& a, const LLVector3d& b)
{
F64 x = a.mdV[0] - b.mdV[0];
F64 y = a.mdV[1] - b.mdV[1];
@@ -403,7 +448,7 @@ inline F64 dist_vec(const LLVector3d &a, const LLVector3d &b)
return (F32) sqrt( x*x + y*y + z*z );
}
-inline F64 dist_vec_squared(const LLVector3d &a, const LLVector3d &b)
+inline F64 dist_vec_squared(const LLVector3d& a, const LLVector3d& b)
{
F64 x = a.mdV[0] - b.mdV[0];
F64 y = a.mdV[1] - b.mdV[1];
@@ -411,14 +456,14 @@ inline F64 dist_vec_squared(const LLVector3d &a, const LLVector3d &b)
return x*x + y*y + z*z;
}
-inline F64 dist_vec_squared2D(const LLVector3d &a, const LLVector3d &b)
+inline F64 dist_vec_squared2D(const LLVector3d& a, const LLVector3d& b)
{
F64 x = a.mdV[0] - b.mdV[0];
F64 y = a.mdV[1] - b.mdV[1];
return x*x + y*y;
}
-inline LLVector3d lerp(const LLVector3d &a, const LLVector3d &b, const F64 u)
+inline LLVector3d lerp(const LLVector3d& a, const LLVector3d& b, const F64 u)
{
return LLVector3d(
a.mdV[VX] + (b.mdV[VX] - a.mdV[VX]) * u,
@@ -450,7 +495,7 @@ inline F64 angle_between(const LLVector3d& a, const LLVector3d& b)
return angle;
}
-inline BOOL are_parallel(const LLVector3d &a, const LLVector3d &b, const F64 epsilon)
+inline BOOL are_parallel(const LLVector3d& a, const LLVector3d& b, const F64 epsilon)
{
LLVector3d an = a;
LLVector3d bn = b;
@@ -465,11 +510,22 @@ inline BOOL are_parallel(const LLVector3d &a, const LLVector3d &b, const F64 eps
}
-inline LLVector3d projected_vec(const LLVector3d &a, const LLVector3d &b)
+inline LLVector3d projected_vec(const LLVector3d& a, const LLVector3d& b)
{
LLVector3d project_axis = b;
project_axis.normalize();
return project_axis * (a * project_axis);
}
+inline LLVector3d inverse_projected_vec(const LLVector3d& a, const LLVector3d& b)
+{
+ LLVector3d normalized_a = a;
+ normalized_a.normalize();
+ LLVector3d normalized_b = b;
+ F64 b_length = normalized_b.normalize();
+
+ F64 dot_product = normalized_a * normalized_b;
+ return normalized_a * (b_length / dot_product);
+}
+
#endif // LL_V3DMATH_H
diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h
index 0432aeba4c..f3fbce4843 100755
--- a/indra/llmath/v3math.h
+++ b/indra/llmath/v3math.h
@@ -1,4 +1,4 @@
-/**
+/**
* @file v3math.h
* @brief LLVector3 class header file.
*
@@ -159,6 +159,7 @@ F32 dist_vec(const LLVector3 &a, const LLVector3 &b); // Returns distance betwe
F32 dist_vec_squared(const LLVector3 &a, const LLVector3 &b);// Returns distance squared between a and b
F32 dist_vec_squared2D(const LLVector3 &a, const LLVector3 &b);// Returns distance squared between a and b ignoring Z component
LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b
+LLVector3 inverse_projected_vec(const LLVector3 &a, const LLVector3 &b); // Returns vector a scaled such that projected_vec(inverse_projected_vec(a, b), b) == b;
LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b); // Returns vector a projected on vector b (same as projected_vec)
LLVector3 orthogonal_component(const LLVector3 &a, const LLVector3 &b); // Returns component of vector a not parallel to vector b (same as projected_vec)
LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u); // Returns a vector that is a linear interpolation between a and b
@@ -490,9 +491,27 @@ inline F32 dist_vec_squared2D(const LLVector3 &a, const LLVector3 &b)
inline LLVector3 projected_vec(const LLVector3 &a, const LLVector3 &b)
{
- LLVector3 project_axis = b;
- project_axis.normalize();
- return project_axis * (a * project_axis);
+ F32 bb = b * b;
+ if (bb > FP_MAG_THRESHOLD * FP_MAG_THRESHOLD)
+ {
+ return ((a * b) / bb) * b;
+ }
+ else
+ {
+ return b.zero;
+ }
+}
+
+inline LLVector3 inverse_projected_vec(const LLVector3& a, const LLVector3& b)
+{
+ LLVector3 normalized_a = a;
+ normalized_a.normalize();
+ LLVector3 normalized_b = b;
+ F32 b_length = normalized_b.normalize();
+
+ F32 dot_product = normalized_a * normalized_b;
+ //NB: if a _|_ b, then returns an infinite vector
+ return normalized_a * (b_length / dot_product);
}
inline LLVector3 parallel_component(const LLVector3 &a, const LLVector3 &b)
@@ -556,15 +575,13 @@ inline void update_min_max(LLVector3& min, LLVector3& max, const F32* pos)
inline F32 angle_between(const LLVector3& a, const LLVector3& b)
{
- LLVector3 an = a;
- LLVector3 bn = b;
- an.normalize();
- bn.normalize();
- F32 cosine = an * bn;
- F32 angle = (cosine >= 1.0f) ? 0.0f :
- (cosine <= -1.0f) ? F_PI :
- (F32)acos(cosine);
- return angle;
+ F32 ab = a * b; // dotproduct
+ if (ab == -0.0f)
+ {
+ ab = 0.0f; // get rid of negative zero
+ }
+ LLVector3 c = a % b; // crossproduct
+ return atan2f(sqrtf(c * c), ab); // return the angle
}
inline BOOL are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon)
diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp
index 81ac62be56..cd2be7c8fd 100755
--- a/indra/llmath/v4color.cpp
+++ b/indra/llmath/v4color.cpp
@@ -245,7 +245,7 @@ void LLColor4::setValue(const LLSD& sd)
if (out_of_range)
{
- llwarns << "LLSD color value out of range!" << llendl;
+ LL_WARNS() << "LLSD color value out of range!" << LL_ENDL;
}
#else
mV[0] = (F32) sd[0].asReal();
@@ -417,7 +417,7 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color)
if (token_iter == tokens.end())
{
// This is a malformed vector.
- llwarns << "LLColor4::parseColor() malformed color " << buf << llendl;
+ LL_WARNS() << "LLColor4::parseColor() malformed color " << buf << LL_ENDL;
}
else
{
@@ -704,7 +704,7 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color)
}
else
{
- llwarns << "invalid color " << color_name << llendl;
+ LL_WARNS() << "invalid color " << color_name << LL_ENDL;
}
}
diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h
index 8c8c315808..0d632f59be 100755
--- a/indra/llmath/v4color.h
+++ b/indra/llmath/v4color.h
@@ -49,10 +49,10 @@ class LLColor4
LLColor4(); // Initializes LLColor4 to (0, 0, 0, 1)
LLColor4(F32 r, F32 g, F32 b); // Initializes LLColor4 to (r, g, b, 1)
LLColor4(F32 r, F32 g, F32 b, F32 a); // Initializes LLColor4 to (r. g, b, a)
- LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc))
- LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], vec[3])
LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a)
explicit LLColor4(const LLSD& sd);
+ explicit LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1)
+ explicit LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc))
explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion
explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion
diff --git a/indra/llmath/xform.cpp b/indra/llmath/xform.cpp
index b75aec6a27..5d8b93d5e8 100755
--- a/indra/llmath/xform.cpp
+++ b/indra/llmath/xform.cpp
@@ -36,10 +36,10 @@ LLXform::~LLXform()
{
}
-// Link optimization - don't inline these llwarns
+// Link optimization - don't inline these LL_WARNS()
void LLXform::warn(const char* const msg)
{
- llwarns << msg << llendl;
+ LL_WARNS() << msg << LL_ENDL;
}
LLXform* LLXform::getRoot() const
diff --git a/indra/llmath/xform.h b/indra/llmath/xform.h
index 1b50749b3e..54b0f6d9ec 100755
--- a/indra/llmath/xform.h
+++ b/indra/llmath/xform.h
@@ -103,9 +103,9 @@ public:
inline void setRotation(const F32 x, const F32 y, const F32 z, const F32 s);
// Above functions must be inline for speed, but also
- // need to emit warnings. llwarns causes inline LLError::CallSite
+ // need to emit warnings. LL_WARNS() causes inline LLError::CallSite
// static objects that make more work for the linker.
- // Avoid inline llwarns by calling this function.
+ // Avoid inline LL_WARNS() by calling this function.
void warn(const char* const msg);
void setChanged(const U32 bits) { mChanged |= bits; }