V2 llmath merge

This commit is contained in:
Shyotl
2011-02-22 21:44:04 -06:00
parent b31db27545
commit 7deee9336c
34 changed files with 371 additions and 192 deletions

View File

@@ -53,9 +53,6 @@ public:
LLVector3 getCenter() const { return (mMax - mMin) * 0.5f + mMin; }
LLVector3 getExtent() const { return mMax - mMin; }
BOOL containsPoint(const LLVector3& p) const;
BOOL intersects(const LLBBoxLocal& b) const;
void addPoint(const LLVector3& p);
void addBBox(const LLBBoxLocal& b) { addPoint( b.mMin ); addPoint( b.mMax ); }

View File

@@ -59,8 +59,11 @@ public:
{}
LLCoordGL(S32 x, S32 y) : LLCoord(x, y)
{}
bool operator==(const LLCoordGL& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordGL& other) const { return !(*this == other); }
};
//bool operator ==(const LLCoordGL& a, const LLCoordGL& b);
// Window coords include things like window borders,
// menu regions, etc.
@@ -71,6 +74,8 @@ public:
{}
LLCoordWindow(S32 x, S32 y) : LLCoord(x, y)
{}
bool operator==(const LLCoordWindow& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordWindow& other) const { return !(*this == other); }
};
@@ -82,6 +87,8 @@ public:
{}
LLCoordScreen(S32 x, S32 y) : LLCoord(x, y)
{}
bool operator==(const LLCoordScreen& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordScreen& other) const { return !(*this == other); }
};
class LLCoordFont : public LLCoord
@@ -96,6 +103,8 @@ public:
void set(S32 x, S32 y) { LLCoord::set(x,y); mZ = 0.f; }
void set(S32 x, S32 y, F32 z) { mX = x; mY = y; mZ = z; }
bool operator==(const LLCoordFont& other) const { return mX == other.mX && mY == other.mY; }
bool operator!=(const LLCoordFont& other) const { return !(*this == other); }
};

View File

@@ -32,6 +32,12 @@
#ifndef LL_LLINTERP_H
#define LL_LLINTERP_H
#if defined(LL_WINDOWS)
// macro definitions for common math constants (e.g. M_PI) are declared under the _USE_MATH_DEFINES
// on Windows system.
// So, let's define _USE_MATH_DEFINES before including math.h
#define _USE_MATH_DEFINES
#endif
#include "math.h"
// Class from which different types of interpolators can be derived
@@ -144,6 +150,7 @@ protected:
template <typename Type>
LLInterp<Type>::LLInterp()
: mStartVal(Type()), mEndVal(Type()), mCurVal(Type())
{
mStartTime = 0.f;
mEndTime = 1.f;

View File

@@ -206,7 +206,7 @@ inline S32 llfloor( F32 f )
}
return result;
#else
return (S32)floor(f);
return (S32)floorf(f);
#endif
}

View File

@@ -45,7 +45,11 @@
#endif
#define LL_OCTREE_PARANOIA_CHECK 0
#if LL_DARWIN
#define LL_OCTREE_MAX_CAPACITY 32
#else
#define LL_OCTREE_MAX_CAPACITY 128
#endif
template <class T> class LLOctreeNode;
@@ -61,7 +65,7 @@ public:
};
template <class T>
class LLOctreeTraveler : public LLTreeTraveler<T>
class LLOctreeTraveler
{
public:
virtual void traverse(const LLOctreeNode<T>* node);
@@ -179,7 +183,6 @@ public:
{
mMax.mdV[i] = mCenter.mdV[i] + mSize.mdV[i];
mMin.mdV[i] = mCenter.mdV[i] - mSize.mdV[i];
mCenter.mdV[i] = mCenter.mdV[i];
}
}

View File

@@ -121,7 +121,7 @@ void LLQuaternion::quantize16(F32 lower, F32 upper)
mQ[VZ] = z;
mQ[VS] = s;
normQuat();
normalize();
}
void LLQuaternion::quantize8(F32 lower, F32 upper)
@@ -131,7 +131,7 @@ void LLQuaternion::quantize8(F32 lower, F32 upper)
mQ[VZ] = U8_to_F32(F32_to_U8_ROUND(mQ[VZ], lower, upper), lower, upper);
mQ[VS] = U8_to_F32(F32_to_U8_ROUND(mQ[VS], lower, upper), lower, upper);
normQuat();
normalize();
}
// LLVector3 Magnitude and Normalization Functions
@@ -346,7 +346,7 @@ const LLQuaternion& LLQuaternion::setQuat(const LLMatrix4 &mat)
// mQ[VZ] = (F32)(cosX*cosY*sinZ - sinX*sinY*cosZ);
//#endif
//
// normQuat();
// normalize();
// return (*this);
}

View File

@@ -469,20 +469,30 @@ inline const LLQuaternion& operator*=(LLQuaternion &a, const LLQuaternion &b)
return a;
}
const F32 ONE_PART_IN_A_MILLION = 0.000001f;
inline F32 LLQuaternion::normalize()
{
F32 mag = sqrtf(mQ[VX]*mQ[VX] + mQ[VY]*mQ[VY] + mQ[VZ]*mQ[VZ] + mQ[VS]*mQ[VS]);
if (mag > FP_MAG_THRESHOLD)
{
F32 oomag = 1.f/mag;
mQ[VX] *= oomag;
mQ[VY] *= oomag;
mQ[VZ] *= oomag;
mQ[VS] *= oomag;
// Floating point error can prevent some quaternions from achieving
// exact unity length. When trying to renormalize such quaternions we
// can oscillate between multiple quantized states. To prevent such
// drifts we only renomalize if the length is far enough from unity.
if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
{
F32 oomag = 1.f/mag;
mQ[VX] *= oomag;
mQ[VY] *= oomag;
mQ[VZ] *= oomag;
mQ[VS] *= oomag;
}
}
else
{
// we were given a very bad quaternion so we set it to identity
mQ[VX] = 0.f;
mQ[VY] = 0.f;
mQ[VZ] = 0.f;
@@ -499,11 +509,15 @@ inline F32 LLQuaternion::normQuat()
if (mag > FP_MAG_THRESHOLD)
{
F32 oomag = 1.f/mag;
mQ[VX] *= oomag;
mQ[VY] *= oomag;
mQ[VZ] *= oomag;
mQ[VS] *= oomag;
if (fabs(1.f - mag) > ONE_PART_IN_A_MILLION)
{
// only renormalize if length not close enough to 1.0 already
F32 oomag = 1.f/mag;
mQ[VX] *= oomag;
mQ[VY] *= oomag;
mQ[VZ] *= oomag;
mQ[VS] *= oomag;
}
}
else
{

View File

@@ -42,6 +42,7 @@
template <class Type> class LLRectBase
{
public:
typedef Type tCoordType;
Type mLeft;
Type mTop;
Type mRight;
@@ -64,23 +65,17 @@ public:
mLeft(left), mTop(top), mRight(right), mBottom(bottom)
{}
LLRectBase(const LLSD& sd)
/*explicit */LLRectBase(const LLSD& sd)
{
setValue(sd);
}
const LLRectBase& operator=(const LLSD& sd)
{
setValue(sd);
return *this;
}
void setValue(const LLSD& sd)
{
mLeft = sd[0].asInteger();
mTop = sd[1].asInteger();
mRight = sd[2].asInteger();
mBottom = sd[3].asInteger();
mLeft = (Type)sd[0].asInteger();
mTop = (Type)sd[1].asInteger();
mRight = (Type)sd[2].asInteger();
mBottom = (Type)sd[3].asInteger();
}
LLSD getValue() const
@@ -147,10 +142,20 @@ public:
// Note: Does NOT follow GL_QUAD conventions: the top and right edges ARE considered part of the rect
// returns TRUE if any part of rect is is inside this LLRect
BOOL rectInRect(const LLRectBase* rect) const
BOOL overlaps(const LLRectBase& rect) const
{
return mLeft <= rect->mRight && rect->mLeft <= mRight &&
mBottom <= rect->mTop && rect->mBottom <= mTop ;
return !(mLeft > rect.mRight
|| mRight < rect.mLeft
|| mBottom > rect.mTop
|| mTop < rect.mBottom);
}
BOOL contains(const LLRectBase& rect) const
{
return mLeft <= rect.mLeft
&& mRight >= rect.mRight
&& mBottom <= rect.mBottom
&& mTop >= rect.mTop;
}
LLRectBase& set(Type left, Type top, Type right, Type bottom)
@@ -229,26 +234,25 @@ public:
return mLeft <= mRight && mBottom <= mTop;
}
bool isNull() const
bool isEmpty() const
{
return mLeft == mRight || mBottom == mTop;
}
bool notNull() const
bool notEmpty() const
{
return !isNull();
return !isEmpty();
}
LLRectBase& unionWith(const LLRectBase &other)
void unionWith(const LLRectBase &other)
{
mLeft = llmin(mLeft, other.mLeft);
mRight = llmax(mRight, other.mRight);
mBottom = llmin(mBottom, other.mBottom);
mTop = llmax(mTop, other.mTop);
return *this;
}
LLRectBase& intersectWith(const LLRectBase &other)
void intersectWith(const LLRectBase &other)
{
mLeft = llmax(mLeft, other.mLeft);
mRight = llmin(mRight, other.mRight);
@@ -262,7 +266,6 @@ public:
{
mBottom = mTop;
}
return *this;
}
friend std::ostream &operator<<(std::ostream &s, const LLRectBase &rect)
@@ -271,8 +274,8 @@ public:
<< " W " << rect.getWidth() << " H " << rect.getHeight() << " }";
return s;
}
bool operator==(const LLRectBase &b)
bool operator==(const LLRectBase &b) const
{
return ((mLeft == b.mLeft) &&
(mTop == b.mTop) &&
@@ -280,7 +283,7 @@ public:
(mBottom == b.mBottom));
}
bool operator!=(const LLRectBase &b)
bool operator!=(const LLRectBase &b) const
{
return ((mLeft != b.mLeft) ||
(mTop != b.mTop) ||

View File

@@ -165,9 +165,6 @@ LLSD ll_sd_from_color4(const LLColor4& c)
LLColor4 ll_color4_from_sd(const LLSD& sd)
{
LLColor4 c;
c.mV[0] = (F32)sd[0].asReal();
c.mV[1] = (F32)sd[1].asReal();
c.mV[2] = (F32)sd[2].asReal();
c.mV[3] = (F32)sd[3].asReal();
c.setValue(sd);
return c;
}

View File

@@ -82,6 +82,8 @@ class LLTreeTraveler
{
public:
virtual ~LLTreeTraveler() { };
virtual void traverse(const LLTreeNode<T>* node) = 0;
virtual void visit(const LLTreeNode<T>* node) = 0;
};
template <class T>

View File

@@ -84,6 +84,7 @@ const F32 SKEW_MIN = -0.95f;
const F32 SKEW_MAX = 0.95f;
const F32 SCULPT_MIN_AREA = 0.002f;
const S32 SCULPT_MIN_AREA_DETAIL = 1;
BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm)
{
@@ -1687,7 +1688,7 @@ LLVolume::LLVolume(const LLVolumeParams &params, const F32 detail, const BOOL ge
mGenerateSingleFace = generate_single_face;
generate();
if (mParams.getSculptID().isNull())
if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE)
{
createVolumeFaces();
}
@@ -1863,6 +1864,11 @@ void LLVolume::createVolumeFaces()
LLProfile::Face& face = mProfilep->mFaces[i];
vf.mBeginS = face.mIndex;
vf.mNumS = face.mCount;
if (vf.mNumS < 0)
{
llerrs << "Volume face corruption detected." << llendl;
}
vf.mBeginT = 0;
vf.mNumT= getPath().mPath.size();
vf.mID = i;
@@ -1906,6 +1912,10 @@ void LLVolume::createVolumeFaces()
if (face.mFlat && vf.mNumS > 2)
{ //flat inner faces have to copy vert normals
vf.mNumS = vf.mNumS*2;
if (vf.mNumS < 0)
{
llerrs << "Volume face corruption detected." << llendl;
}
}
}
else
@@ -2237,10 +2247,14 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
if (!data_is_empty)
{
sculptGenerateMapVertices(sculpt_width, sculpt_height, sculpt_components, sculpt_data, sculpt_type);
if (sculptGetSurfaceArea() < SCULPT_MIN_AREA)
// don't test lowest LOD to support legacy content DEV-33670
if (mDetail > SCULPT_MIN_AREA_DETAIL)
{
data_is_empty = TRUE;
if (sculptGetSurfaceArea() < SCULPT_MIN_AREA)
{
data_is_empty = TRUE;
}
}
}
@@ -3818,6 +3832,7 @@ BOOL LLVolume::cleanupTriangleData( const S32 num_input_vertices,
// Generate the vertex mapping and the list of vertices without
// duplicates. This will crash if there are no vertices.
llassert(num_input_vertices > 0); // check for no vertices!
S32 *vertex_mapping = new S32[num_input_vertices];
LLVector3 *new_vertices = new LLVector3[num_input_vertices];
LLVertexIndexPair *prev_pairp = NULL;
@@ -4396,19 +4411,54 @@ std::ostream& operator<<(std::ostream &s, const LLVolume *volumep)
BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build)
{
BOOL ret = FALSE ;
if (mTypeMask & CAP_MASK)
{
return createCap(volume, partial_build);
ret = createCap(volume, partial_build);
}
else if ((mTypeMask & END_MASK) || (mTypeMask & SIDE_MASK))
{
return createSide(volume, partial_build);
ret = createSide(volume, partial_build);
}
else
{
llerrs << "Unknown/uninitialized face type!" << llendl;
return FALSE;
}
//update the range of the texture coordinates
if(ret)
{
mTexCoordExtents[0].setVec(1.f, 1.f) ;
mTexCoordExtents[1].setVec(0.f, 0.f) ;
U32 end = mVertices.size() ;
for(U32 i = 0 ; i < end ; i++)
{
if(mTexCoordExtents[0].mV[0] > mVertices[i].mTexCoord.mV[0])
{
mTexCoordExtents[0].mV[0] = mVertices[i].mTexCoord.mV[0] ;
}
if(mTexCoordExtents[1].mV[0] < mVertices[i].mTexCoord.mV[0])
{
mTexCoordExtents[1].mV[0] = mVertices[i].mTexCoord.mV[0] ;
}
if(mTexCoordExtents[0].mV[1] > mVertices[i].mTexCoord.mV[1])
{
mTexCoordExtents[0].mV[1] = mVertices[i].mTexCoord.mV[1] ;
}
if(mTexCoordExtents[1].mV[1] < mVertices[i].mTexCoord.mV[1])
{
mTexCoordExtents[1].mV[1] = mVertices[i].mTexCoord.mV[1] ;
}
}
mTexCoordExtents[0].mV[0] = llmax(0.f, mTexCoordExtents[0].mV[0]) ;
mTexCoordExtents[0].mV[1] = llmax(0.f, mTexCoordExtents[0].mV[1]) ;
mTexCoordExtents[1].mV[0] = llmin(1.f, mTexCoordExtents[1].mV[0]) ;
mTexCoordExtents[1].mV[1] = llmin(1.f, mTexCoordExtents[1].mV[1]) ;
}
return ret ;
}
void LerpPlanarVertex(LLVolumeFace::VertexData& v0,
@@ -4516,13 +4566,25 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build)
if (!partial_build)
{
int idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
for(int gx = 0;gx<grid_size;gx++){
for(int gy = 0;gy<grid_size;gy++){
if (mTypeMask & TOP_MASK){
for(int i=5;i>=0;i--)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
}else{
for(int i=0;i<6;i++)mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
S32 idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0};
for(S32 gx = 0;gx<grid_size;gx++)
{
for(S32 gy = 0;gy<grid_size;gy++)
{
if (mTypeMask & TOP_MASK)
{
for(S32 i=5;i>=0;i--)
{
mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
}
}
else
{
for(S32 i=0;i<6;i++)
{
mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]);
}
}
}
}
@@ -4977,12 +5039,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
mHasBinormals = FALSE;
}
LLVector3& face_min = mExtents[0];
LLVector3& face_max = mExtents[1];
mCenter.clearVec();
S32 begin_stex = llfloor( profile[mBeginS].mV[2] );
S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS;
@@ -5038,15 +5094,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
if (cur_vertex == 0)
{
face_min = face_max = mesh[i].mPos;
}
else
{
update_min_max(face_min, face_max, mesh[i].mPos);
}
cur_vertex++;
@@ -5080,12 +5127,22 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build)
mVertices[cur_vertex].mNormal = LLVector3(0,0,0);
mVertices[cur_vertex].mBinormal = LLVector3(0,0,0);
update_min_max(face_min,face_max,mesh[i].mPos);
cur_vertex++;
}
}
//get bounding box for this side
LLVector3& face_min = mExtents[0];
LLVector3& face_max = mExtents[1];
mCenter.clearVec();
face_min = face_max = mVertices[0].mPosition;
for (U32 i = 1; i < mVertices.size(); ++i)
{
update_min_max(face_min, face_max, mVertices[i].mPosition);
}
mCenter = (face_min + face_max) * 0.5f;
S32 cur_index = 0;

View File

@@ -837,6 +837,7 @@ public:
S32 mNumT;
LLVector3 mExtents[2]; //minimum and maximum point of face
LLVector2 mTexCoordExtents[2]; //minimum and maximum of texture coordinates of the face.
std::vector<VertexData> mVertices;
std::vector<U16> mIndices;

View File

@@ -678,32 +678,6 @@ LLVector4 operator*(const LLMatrix4 &a, const LLVector4 &b)
}
*/
// Operates "to the left" on row-vector a
//
// This used to be in the header file but was not actually inlined in practice.
// When avatar vertex programs are off, this function is a hot spot in profiles
// due to software skinning in LLViewerJointMesh::updateGeometry(). JC
LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b)
{
// This is better than making a temporary LLVector3. This eliminates an
// unnecessary LLVector3() constructor and also helps the compiler to
// realize that the output floats do not alias the input floats, hence
// eliminating redundant loads of a.mV[0], etc. JC
return LLVector3(a.mV[VX] * b.mMatrix[VX][VX] +
a.mV[VY] * b.mMatrix[VY][VX] +
a.mV[VZ] * b.mMatrix[VZ][VX] +
b.mMatrix[VW][VX],
a.mV[VX] * b.mMatrix[VX][VY] +
a.mV[VY] * b.mMatrix[VY][VY] +
a.mV[VZ] * b.mMatrix[VZ][VY] +
b.mMatrix[VW][VY],
a.mV[VX] * b.mMatrix[VX][VZ] +
a.mV[VY] * b.mMatrix[VY][VZ] +
a.mV[VZ] * b.mMatrix[VZ][VZ] +
b.mMatrix[VW][VZ]);
}
LLVector4 operator*(const LLVector4 &a, const LLMatrix4 &b)
{

View File

@@ -230,7 +230,7 @@ public:
// friend inline LLMatrix4 operator*(const LLMatrix4 &a, const LLMatrix4 &b); // Return a * b
friend LLVector4 operator*(const LLVector4 &a, const LLMatrix4 &b); // Return transform of vector a by matrix b
friend LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b); // Return full transform of a by matrix b
friend const LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b); // Return full transform of a by matrix b
friend LLVector4 rotate_vector(const LLVector4 &a, const LLMatrix4 &b); // Rotates a but does not translate
friend LLVector3 rotate_vector(const LLVector3 &a, const LLMatrix4 &b); // Rotates a but does not translate
@@ -353,7 +353,31 @@ inline const LLMatrix4& operator-=(LLMatrix4 &a, const LLMatrix4 &b)
return a;
}
// Operates "to the left" on row-vector a
//
// When avatar vertex programs are off, this function is a hot spot in profiles
// due to software skinning in LLViewerJointMesh::updateGeometry(). JC
inline const LLVector3 operator*(const LLVector3 &a, const LLMatrix4 &b)
{
// This is better than making a temporary LLVector3. This eliminates an
// unnecessary LLVector3() constructor and also helps the compiler to
// realize that the output floats do not alias the input floats, hence
// eliminating redundant loads of a.mV[0], etc. JC
return LLVector3(a.mV[VX] * b.mMatrix[VX][VX] +
a.mV[VY] * b.mMatrix[VY][VX] +
a.mV[VZ] * b.mMatrix[VZ][VX] +
b.mMatrix[VW][VX],
a.mV[VX] * b.mMatrix[VX][VY] +
a.mV[VY] * b.mMatrix[VY][VY] +
a.mV[VZ] * b.mMatrix[VZ][VY] +
b.mMatrix[VW][VY],
a.mV[VX] * b.mMatrix[VX][VZ] +
a.mV[VY] * b.mMatrix[VY][VZ] +
a.mV[VZ] * b.mMatrix[VZ][VZ] +
b.mMatrix[VW][VZ]);
}
#endif

View File

@@ -70,6 +70,8 @@ class LLVector2
void setVec(const LLVector2 &vec); // deprecated
void setVec(const F32 *vec); // deprecated
inline bool isFinite() const; // checks to see if all values of LLVector2 are finite
F32 length() const; // Returns magnitude of LLVector2
F32 lengthSquared() const; // Returns magnitude squared of LLVector2
F32 normalize(); // Normalizes and returns the magnitude of LLVector2
@@ -215,6 +217,7 @@ inline void LLVector2::setVec(const F32 *vec)
mV[VY] = vec[VY];
}
// LLVector2 Magnitude and Normalization Functions
inline F32 LLVector2::length(void) const
@@ -247,6 +250,12 @@ inline F32 LLVector2::normalize(void)
return (mag);
}
// checker
inline bool LLVector2::isFinite() const
{
return (llfinite(mV[VX]) && llfinite(mV[VY]));
}
// deprecated
inline F32 LLVector2::magVec(void) const
{

View File

@@ -56,9 +56,7 @@ LLColor3::LLColor3(const LLVector4 &a)
LLColor3::LLColor3(const LLSD &sd)
{
mV[0] = (F32) sd[0].asReal();
mV[1] = (F32) sd[1].asReal();
mV[2] = (F32) sd[2].asReal();
setValue(sd);
}
const LLColor3& LLColor3::operator=(const LLColor4 &a)
@@ -75,6 +73,42 @@ std::ostream& operator<<(std::ostream& s, const LLColor3 &a)
return s;
}
static F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn )
{
if ( valHUeIn < 0.0f ) valHUeIn += 1.0f;
if ( valHUeIn > 1.0f ) valHUeIn -= 1.0f;
if ( ( 6.0f * valHUeIn ) < 1.0f ) return ( val1In + ( val2In - val1In ) * 6.0f * valHUeIn );
if ( ( 2.0f * valHUeIn ) < 1.0f ) return ( val2In );
if ( ( 3.0f * valHUeIn ) < 2.0f ) return ( val1In + ( val2In - val1In ) * ( ( 2.0f / 3.0f ) - valHUeIn ) * 6.0f );
return ( val1In );
}
void LLColor3::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn)
{
if ( sValIn < 0.00001f )
{
mV[VRED] = lValIn;
mV[VGREEN] = lValIn;
mV[VBLUE] = lValIn;
}
else
{
F32 interVal1;
F32 interVal2;
if ( lValIn < 0.5f )
interVal2 = lValIn * ( 1.0f + sValIn );
else
interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn );
interVal1 = 2.0f * lValIn - interVal2;
mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) );
mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn );
mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) );
}
}
void LLColor3::calcHSL(F32* hue, F32* saturation, F32* luminance) const
{
F32 var_R = mV[VRED];

View File

@@ -79,6 +79,7 @@ public:
mV[2] = (F32) sd[2].asReal();;
}
void setHSL(F32 hue, F32 saturation, F32 luminance);
void calcHSL(F32* hue, F32* saturation, F32* luminance) const;
const LLColor3& setToBlack(); // Clears LLColor3 to (0, 0, 0)

View File

@@ -53,7 +53,7 @@ class LLVector3d
inline LLVector3d(const F64 x, const F64 y, const F64 z); // Initializes LLVector3d to (x. y, z)
inline explicit LLVector3d(const F64 *vec); // Initializes LLVector3d to (vec[0]. vec[1], vec[2])
inline explicit LLVector3d(const LLVector3 &vec);
LLVector3d(const LLSD& sd)
/*explicit */LLVector3d(const LLSD& sd)
{
setValue(sd);
}
@@ -65,12 +65,6 @@ class LLVector3d
mdV[2] = sd[2].asReal();
}
const LLVector3d& operator=(const LLSD& sd)
{
setValue(sd);
return *this;
}
LLSD getValue() const
{
LLSD ret;

View File

@@ -134,7 +134,6 @@ BOOL LLVector3::clampLength( F32 length_limit )
mV[0] *= length_limit;
mV[1] *= length_limit;
mV[2] *= length_limit;
changed = TRUE;
}
}
@@ -186,14 +185,6 @@ void LLVector3::snap(S32 sig_digits)
mV[VZ] = snap_to_sig_figs(mV[VZ], sig_digits);
}
std::ostream& operator<<(std::ostream& s, const LLVector3 &a)
{
s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << " }";
return s;
}
const LLVector3& LLVector3::rotVec(const LLMatrix3 &mat)
{
*this = *this * mat;
@@ -315,12 +306,6 @@ void LLVector3::setValue(const LLSD& sd)
mV[2] = (F32) sd[2].asReal();
}
const LLVector3& LLVector3::operator=(const LLSD& sd)
{
setValue(sd);
return *this;
}
const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot)
{
const F32 rw = - rot.mQ[VX] * a.mV[VX] - rot.mQ[VY] * a.mV[VY] - rot.mQ[VZ] * a.mV[VZ];

View File

@@ -67,14 +67,12 @@ class LLVector3
explicit LLVector3(const LLVector2 &vec); // Initializes LLVector3 to (vec[0]. vec[1], 0)
explicit LLVector3(const LLVector3d &vec); // Initializes LLVector3 to (vec[0]. vec[1], vec[2])
explicit LLVector3(const LLVector4 &vec); // Initializes LLVector4 to (vec[0]. vec[1], vec[2])
LLVector3(const LLSD& sd);
/*explicit */LLVector3(const LLSD& sd);
LLSD getValue() const;
void setValue(const LLSD& sd);
const LLVector3& operator=(const LLSD& sd);
inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite
BOOL clamp(F32 min, F32 max); // Clamps all values to (min,max), returns TRUE if data changed
BOOL clampLength( F32 length_limit ); // Scales vector to limit length to a value
@@ -558,4 +556,9 @@ inline BOOL are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon)
return FALSE;
}
inline std::ostream& operator<<(std::ostream& s, const LLVector3 &a)
{
s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << " }";
return s;
}
#endif

View File

@@ -227,6 +227,40 @@ const LLColor4& LLColor4::setVec(const LLColor3 &vec, F32 a)
return (*this);
}
void LLColor4::setValue(const LLSD& sd)
{
#if 0
// Clamping on setValue from LLSD is inconsistent with other set behavior
F32 val;
bool out_of_range = false;
val = sd[0].asReal();
mV[0] = llclamp(val, 0.f, 1.f);
out_of_range = mV[0] != val;
val = sd[1].asReal();
mV[1] = llclamp(val, 0.f, 1.f);
out_of_range |= mV[1] != val;
val = sd[2].asReal();
mV[2] = llclamp(val, 0.f, 1.f);
out_of_range |= mV[2] != val;
val = sd[3].asReal();
mV[3] = llclamp(val, 0.f, 1.f);
out_of_range |= mV[3] != val;
if (out_of_range)
{
llwarns << "LLSD color value out of range!" << llendl;
}
#else
mV[0] = (F32) sd[0].asReal();
mV[1] = (F32) sd[1].asReal();
mV[2] = (F32) sd[2].asReal();
mV[3] = (F32) sd[3].asReal();
#endif
}
const LLColor4& LLColor4::operator=(const LLColor3 &a)
{
mV[VX] = a.mV[VX];
@@ -271,6 +305,42 @@ LLColor4 vec3to4(const LLColor3 &vec)
return temp;
}
static F32 hueToRgb ( F32 val1In, F32 val2In, F32 valHUeIn )
{
if ( valHUeIn < 0.0f ) valHUeIn += 1.0f;
if ( valHUeIn > 1.0f ) valHUeIn -= 1.0f;
if ( ( 6.0f * valHUeIn ) < 1.0f ) return ( val1In + ( val2In - val1In ) * 6.0f * valHUeIn );
if ( ( 2.0f * valHUeIn ) < 1.0f ) return ( val2In );
if ( ( 3.0f * valHUeIn ) < 2.0f ) return ( val1In + ( val2In - val1In ) * ( ( 2.0f / 3.0f ) - valHUeIn ) * 6.0f );
return ( val1In );
}
void LLColor4::setHSL ( F32 hValIn, F32 sValIn, F32 lValIn)
{
if ( sValIn < 0.00001f )
{
mV[VRED] = lValIn;
mV[VGREEN] = lValIn;
mV[VBLUE] = lValIn;
}
else
{
F32 interVal1;
F32 interVal2;
if ( lValIn < 0.5f )
interVal2 = lValIn * ( 1.0f + sValIn );
else
interVal2 = ( lValIn + sValIn ) - ( sValIn * lValIn );
interVal1 = 2.0f * lValIn - interVal2;
mV[VRED] = hueToRgb ( interVal1, interVal2, hValIn + ( 1.f / 3.f ) );
mV[VGREEN] = hueToRgb ( interVal1, interVal2, hValIn );
mV[VBLUE] = hueToRgb ( interVal1, interVal2, hValIn - ( 1.f / 3.f ) );
}
}
void LLColor4::calcHSL(F32* hue, F32* saturation, F32* luminance) const
{
F32 var_R = mV[VRED];

View File

@@ -58,7 +58,7 @@ class LLColor4
LLColor4(U32 clr); // Initializes LLColor4 to (r=clr>>24, etc))
LLColor4(const F32 *vec); // Initializes LLColor4 to (vec[0]. vec[1], vec[2], 1)
LLColor4(const LLColor3 &vec, F32 a = 1.f); // Initializes LLColor4 to (vec, a)
LLColor4(const LLSD& sd);
/*explicit */LLColor4(const LLSD& sd);
explicit LLColor4(const LLColor4U& color4u); // "explicit" to avoid automatic conversion
explicit LLColor4(const LLVector4& vector4); // "explicit" to avoid automatic conversion
@@ -72,14 +72,9 @@ class LLColor4
return ret;
}
void setValue(const LLSD& sd)
{
mV[0] = (F32) sd[0].asReal();
mV[1] = (F32) sd[1].asReal();
mV[2] = (F32) sd[2].asReal();
mV[3] = (F32) sd[3].asReal();
}
void setValue(const LLSD& sd);
void setHSL(F32 hue, F32 saturation, F32 luminance);
void calcHSL(F32* hue, F32* saturation, F32* luminance) const;
const LLColor4& setToBlack(); // zero LLColor4 to (0, 0, 0, 1)
@@ -118,7 +113,6 @@ class LLColor4
F32 &operator[](int idx) { return mV[idx]; }
const LLColor4& operator=(const LLColor3 &a); // Assigns vec3 to vec4 and returns vec4
const LLColor4& operator=(const LLSD& sd);
friend std::ostream& operator<<(std::ostream& s, const LLColor4 &a); // Print a
friend LLColor4 operator+(const LLColor4 &a, const LLColor4 &b); // Return vector a + b
@@ -249,7 +243,7 @@ inline LLColor4::LLColor4(void)
inline LLColor4::LLColor4(const LLSD& sd)
{
*this = sd;
this->setValue(sd);
}
inline LLColor4::LLColor4(F32 r, F32 g, F32 b)
@@ -639,15 +633,5 @@ void LLColor4::clamp()
}
}
inline const LLColor4& LLColor4::operator=(const LLSD& sd)
{
mV[0] = (F32) sd[0].asReal();
mV[1] = (F32) sd[1].asReal();
mV[2] = (F32) sd[2].asReal();
mV[3] = (F32) sd[3].asReal();
return *this;
}
#endif

View File

@@ -66,7 +66,7 @@ public:
LLColor4U(U8 r, U8 g, U8 b); // Initializes LLColor4U to (r, g, b, 1)
LLColor4U(U8 r, U8 g, U8 b, U8 a); // Initializes LLColor4U to (r. g, b, a)
LLColor4U(const U8 *vec); // Initializes LLColor4U to (vec[0]. vec[1], vec[2], 1)
LLColor4U(const LLSD& sd)
/*explicit */LLColor4U(const LLSD& sd)
{
setValue(sd);
}
@@ -79,12 +79,6 @@ public:
mV[3] = sd[3].asInteger();
}
const LLColor4U& operator=(const LLSD& sd)
{
setValue(sd);
return *this;
}
LLSD getValue() const
{
LLSD ret;
@@ -138,6 +132,12 @@ public:
static BOOL parseColor4U(const std::string& buf, LLColor4U* value);
// conversion
operator const LLColor4() const
{
return LLColor4(*this);
}
static LLColor4U white;
static LLColor4U black;
static LLColor4U red;

View File

@@ -42,6 +42,11 @@ LLXform::~LLXform()
{
}
// Link optimization - don't inline these llwarns
void LLXform::warn(const char* const msg)
{
llwarns << msg << llendl;
}
LLXform* LLXform::getRoot() const
{

View File

@@ -107,6 +107,12 @@ public:
inline void setRotation(const LLQuaternion& rot);
inline void setRotation(const F32 x, const F32 y, const F32 z);
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
// static objects that make more work for the linker.
// Avoid inline llwarns by calling this function.
void warn(const char* const msg);
void setChanged(const U32 bits) { mChanged |= bits; }
BOOL isChanged() const { return mChanged; }
@@ -173,7 +179,7 @@ BOOL LLXform::setParent(LLXform* parent)
{
if (cur_par == this)
{
llwarns << "LLXform::setParent Creating loop when setting parent!" << llendl;
//warn("LLXform::setParent Creating loop when setting parent!");
return FALSE;
}
cur_par = cur_par->mParent;
@@ -191,7 +197,7 @@ void LLXform::setPosition(const LLVector3& pos)
else
{
mPosition.clearVec();
llwarns << "Non Finite in LLXform::setPosition(LLVector3)" << llendl;
warn("Non Finite in LLXform::setPosition(LLVector3)");
}
}
@@ -203,7 +209,7 @@ void LLXform::setPosition(const F32 x, const F32 y, const F32 z)
else
{
mPosition.clearVec();
llwarns << "Non Finite in LLXform::setPosition(F32,F32,F32)" << llendl;
warn("Non Finite in LLXform::setPosition(F32,F32,F32)");
}
}
@@ -215,7 +221,7 @@ void LLXform::setPositionX(const F32 x)
else
{
mPosition.mV[VX] = 0.f;
llwarns << "Non Finite in LLXform::setPositionX" << llendl;
warn("Non Finite in LLXform::setPositionX");
}
}
@@ -227,7 +233,7 @@ void LLXform::setPositionY(const F32 y)
else
{
mPosition.mV[VY] = 0.f;
llwarns << "Non Finite in LLXform::setPositionY" << llendl;
warn("Non Finite in LLXform::setPositionY");
}
}
@@ -239,7 +245,7 @@ void LLXform::setPositionZ(const F32 z)
else
{
mPosition.mV[VZ] = 0.f;
llwarns << "Non Finite in LLXform::setPositionZ" << llendl;
warn("Non Finite in LLXform::setPositionZ");
}
}
@@ -249,7 +255,7 @@ void LLXform::addPosition(const LLVector3& pos)
if (pos.isFinite())
mPosition += pos;
else
llwarns << "Non Finite in LLXform::addPosition" << llendl;
warn("Non Finite in LLXform::addPosition");
}
void LLXform::setScale(const LLVector3& scale)
@@ -260,7 +266,7 @@ void LLXform::setScale(const LLVector3& scale)
else
{
mScale.setVec(1.f, 1.f, 1.f);
llwarns << "Non Finite in LLXform::setScale" << llendl;
warn("Non Finite in LLXform::setScale");
}
}
void LLXform::setScale(const F32 x, const F32 y, const F32 z)
@@ -271,7 +277,7 @@ void LLXform::setScale(const F32 x, const F32 y, const F32 z)
else
{
mScale.setVec(1.f, 1.f, 1.f);
llwarns << "Non Finite in LLXform::setScale" << llendl;
warn("Non Finite in LLXform::setScale");
}
}
void LLXform::setRotation(const LLQuaternion& rot)
@@ -282,7 +288,7 @@ void LLXform::setRotation(const LLQuaternion& rot)
else
{
mRotation.loadIdentity();
llwarns << "Non Finite in LLXform::setRotation" << llendl;
warn("Non Finite in LLXform::setRotation");
}
}
void LLXform::setRotation(const F32 x, const F32 y, const F32 z)
@@ -295,7 +301,7 @@ void LLXform::setRotation(const F32 x, const F32 y, const F32 z)
else
{
mRotation.loadIdentity();
llwarns << "Non Finite in LLXform::setRotation" << llendl;
warn("Non Finite in LLXform::setRotation");
}
}
void LLXform::setRotation(const F32 x, const F32 y, const F32 z, const F32 s)
@@ -308,7 +314,7 @@ void LLXform::setRotation(const F32 x, const F32 y, const F32 z, const F32 s)
else
{
mRotation.loadIdentity();
llwarns << "Non Finite in LLXform::setRotation" << llendl;
warn("Non Finite in LLXform::setRotation");
}
}

View File

@@ -392,7 +392,7 @@ bool LLPluginClassMedia::textureValid(void)
bool LLPluginClassMedia::getDirty(LLRect *dirty_rect)
{
bool result = !mDirtyRect.isNull();
bool result = !mDirtyRect.isEmpty();
if(dirty_rect != NULL)
{
@@ -768,7 +768,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message)
newDirtyRect.mBottom = temp;
}
if(mDirtyRect.isNull())
if(mDirtyRect.isEmpty())
{
mDirtyRect = newDirtyRect;
}

View File

@@ -1910,7 +1910,7 @@ LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLF
if (sibling &&
sibling != neighbor &&
sibling->getVisible() &&
expanded_base_rect.rectInRect(&sibling->getRect()))
expanded_base_rect.contains(sibling->getRect()))
{
base_rect.unionWith(sibling->getRect());
}

View File

@@ -1171,7 +1171,7 @@ void LLLayoutStack::draw()
LLLocalClipRect clip(clip_rect);
// only force drawing invisible children if visible amount is non-zero
drawChild(panelp, 0, 0, !clip_rect.isNull());
drawChild(panelp, 0, 0, clip_rect.notEmpty());
}
}

View File

@@ -1355,7 +1355,7 @@ void LLView::draw()
{
// Only draw views that are within the root view
localRectToScreen(viewp->getRect(),&screenRect);
if ( rootRect.rectInRect(&screenRect) )
if ( rootRect.contains(screenRect) )
{
glMatrixMode(GL_MODELVIEW);
LLUI::pushMatrix();
@@ -1560,7 +1560,7 @@ void LLView::updateBoundingRect()
LLRect child_bounding_rect = childp->getBoundingRect();
if (local_bounding_rect.isNull())
if (local_bounding_rect.isEmpty())
{
// start out with bounding rect equal to first visible child's bounding rect
local_bounding_rect = child_bounding_rect;
@@ -1568,7 +1568,7 @@ void LLView::updateBoundingRect()
else
{
// accumulate non-null children rectangles
if (!child_bounding_rect.isNull())
if (child_bounding_rect.notEmpty())
{
local_bounding_rect.unionWith(child_bounding_rect);
}

View File

@@ -1049,7 +1049,7 @@ void LLHUDText::updateAll()
{
continue;
}
if (src_textp->mSoftScreenRect.rectInRect(&dst_textp->mSoftScreenRect))
if (src_textp->mSoftScreenRect.contains(dst_textp->mSoftScreenRect))
{
LLRectf intersect_rect = src_textp->mSoftScreenRect;
intersect_rect.intersectWith(dst_textp->mSoftScreenRect);

View File

@@ -1839,7 +1839,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
}
}
new_rot.normQuat();
new_rot.normalize();
if (gPingInterpolate)
{

View File

@@ -3050,7 +3050,7 @@ BOOL LLViewerWindow::handlePerFrameHover()
// snap floaters to top of chat bar/button strip
LLView* chatbar_and_buttons = gOverlayBar->getChild<LLView>("chatbar_and_buttons", TRUE);
// find top of chatbar and state buttons, if either are visible
if (chatbar_and_buttons && !chatbar_and_buttons->getLocalBoundingRect().isNull())
if (chatbar_and_buttons && chatbar_and_buttons->getLocalBoundingRect().notEmpty())
{
// convert top/left corner of chatbar/buttons container to gFloaterView-relative coordinates
S32 top, left;
@@ -3492,7 +3492,7 @@ void LLViewerWindow::schedulePick(LLPickInfo& pick_info)
return;
}
llassert_always(pick_info.mScreenRegion.notNull());
llassert_always(pick_info.mScreenRegion.notEmpty());
mPicks.push_back(pick_info);
/*S32 scaled_x = llround((F32)pick_info.mMousePt.mX * mDisplayScale.mV[VX]);

View File

@@ -3693,12 +3693,12 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
//Lindens are always more Linden than your friend, make that take precedence
if(LLMuteList::getInstance()->isLinden(getFullname()))
{
mClientColor = gSavedSettings.getColor4("AscentLindenColor").getValue();
mClientColor = gSavedSettings.getColor4("AscentLindenColor");
}
//check if they are an estate owner at their current position
else if(estate_owner.notNull() && this->getID() == estate_owner)
{
mClientColor = gSavedSettings.getColor4("AscentEstateOwnerColor").getValue();
mClientColor = gSavedSettings.getColor4("AscentEstateOwnerColor");
}
//without these dots, SL would suck.
else if (LLAvatarTracker::instance().getBuddyInfo(this->getID()) != NULL)
@@ -3708,7 +3708,7 @@ void LLVOAvatar::idleUpdateNameTag(const LLVector3& root_pos_last)
//big fat jerkface who is probably a jerk, display them as such.
else if(LLMuteList::getInstance()->isMuted(this->getID()))
{
mClientColor = gSavedSettings.getColor4("AscentMutedColor").getValue();
mClientColor = gSavedSettings.getColor4("AscentMutedColor");
}
}
@@ -8562,7 +8562,7 @@ S32 LLVOAvatar::getLocalDiscardLevel( ETextureIndex index )
// Returns true if the highest quality discard level exists for every texture
// in the layerset.
//-----------------------------------------------------------------------------
BOOL LLVOAvatar::isLocalTextureDataFinal( LLTexLayerSet* layerset )
BOOL LLVOAvatar::isLocalTextureDataFinal( const LLTexLayerSet* layerset )
{
for (U32 i = 0; i < mBakedTextureData.size(); i++)
{
@@ -8591,7 +8591,7 @@ BOOL LLVOAvatar::isLocalTextureDataFinal( LLTexLayerSet* layerset )
// Returns true if at least the lowest quality discard level exists for every texture
// in the layerset.
//-----------------------------------------------------------------------------
BOOL LLVOAvatar::isLocalTextureDataAvailable( LLTexLayerSet* layerset )
BOOL LLVOAvatar::isLocalTextureDataAvailable( const LLTexLayerSet* layerset )
{
/* if( layerset == mBakedTextureData[BAKED_HEAD].mTexLayerSet )
return getLocalDiscardLevel( TEX_HEAD_BODYPAINT ) >= 0; */

View File

@@ -333,8 +333,8 @@ public:
//--------------------------------------------------------------------
public:
LLColor4 getGlobalColor( const std::string& color_name );
BOOL isLocalTextureDataAvailable( LLTexLayerSet* layerset );
BOOL isLocalTextureDataFinal( LLTexLayerSet* layerset );
BOOL isLocalTextureDataAvailable( const LLTexLayerSet* layerset );
BOOL isLocalTextureDataFinal( const LLTexLayerSet* layerset );
LLVOAvatarDefines::ETextureIndex getBakedTE( LLTexLayerSet* layerset );
void updateComposites();
void onGlobalColorChanged( LLTexGlobalColor* global_color, BOOL set_by_user );