diff options
author | Brad Linden <46733234+brad-linden@users.noreply.github.com> | 2024-06-12 17:04:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-12 17:04:34 -0700 |
commit | 100ebbab2437de7f5d124a0d7b8279a7a7b57656 (patch) | |
tree | e8b4200dae16e89698c2f3eadae05634041681a1 /indra/llmath | |
parent | f5e2708a0fc4e08d3d0a5dc393bbd4bac09e1c55 (diff) | |
parent | ae74ca80692c8bcf157e903033fcfa1778706d64 (diff) |
Merge pull request #1745 from secondlife/project/gltf_development
move project/gltf development to develop
Diffstat (limited to 'indra/llmath')
53 files changed, 1402 insertions, 1398 deletions
diff --git a/indra/llmath/llbbox.cpp b/indra/llmath/llbbox.cpp index c4dffc8cf8..fa1253e421 100644 --- a/indra/llmath/llbbox.cpp +++ b/indra/llmath/llbbox.cpp @@ -38,7 +38,7 @@ void LLBBox::addPointLocal(const LLVector3& p) { mMinLocal = p; mMaxLocal = p; - mEmpty = FALSE; + mEmpty = false; } else { @@ -140,7 +140,7 @@ LLVector3 LLBBox::agentToLocalBasis(const LLVector3& v) const return v * m; } -BOOL LLBBox::containsPointLocal(const LLVector3& p) const +bool LLBBox::containsPointLocal(const LLVector3& p) const { if ( (p.mV[VX] < mMinLocal.mV[VX]) ||(p.mV[VX] > mMaxLocal.mV[VX]) @@ -149,12 +149,12 @@ BOOL LLBBox::containsPointLocal(const LLVector3& p) const ||(p.mV[VZ] < mMinLocal.mV[VZ]) ||(p.mV[VZ] > mMaxLocal.mV[VZ])) { - return FALSE; + return false; } - return TRUE; + return true; } -BOOL LLBBox::containsPointAgent(const LLVector3& p) const +bool LLBBox::containsPointAgent(const LLVector3& p) const { LLVector3 point_local = agentToLocal(p); return containsPointLocal(point_local); diff --git a/indra/llmath/llbbox.h b/indra/llmath/llbbox.h index aac8628762..5617eaebde 100644 --- a/indra/llmath/llbbox.h +++ b/indra/llmath/llbbox.h @@ -37,13 +37,13 @@ class LLBBox { public: - LLBBox() {mEmpty = TRUE;} + LLBBox() {mEmpty = true;} LLBBox( const LLVector3& pos_agent, const LLQuaternion& rot, const LLVector3& min_local, const LLVector3& max_local ) : - mMinLocal( min_local ), mMaxLocal( max_local ), mPosAgent(pos_agent), mRotation( rot), mEmpty( TRUE ) + mMinLocal( min_local ), mMaxLocal( max_local ), mPosAgent(pos_agent), mRotation( rot), mEmpty( true ) {} // Default copy constructor is OK. @@ -64,8 +64,8 @@ public: LLVector3 getExtentLocal() const { return mMaxLocal - mMinLocal; } - BOOL containsPointLocal(const LLVector3& p) const; - BOOL containsPointAgent(const LLVector3& p) const; + bool containsPointLocal(const LLVector3& p) const; + bool containsPointAgent(const LLVector3& p) const; void addPointAgent(LLVector3 p); void addBBoxAgent(const LLBBox& b); @@ -92,7 +92,7 @@ private: LLVector3 mMaxLocal; LLVector3 mPosAgent; // Position relative to Agent's Region LLQuaternion mRotation; - BOOL mEmpty; // Nothing has been added to this bbox yet + bool mEmpty; // Nothing has been added to this bbox yet }; //LLBBox operator*(const LLBBox &a, const LLMatrix4 &b); diff --git a/indra/llmath/llcoordframe.h b/indra/llmath/llcoordframe.h index 802b98425a..aaa701f792 100644 --- a/indra/llmath/llcoordframe.h +++ b/indra/llmath/llcoordframe.h @@ -61,7 +61,7 @@ public: //LLCoordFrame(const F32 *origin, const F32 *rotation); // Assumes "origin" is 1x3 and "rotation" is 1x9 array //LLCoordFrame(const F32 *origin_and_rotation); // Assumes "origin_and_rotation" is 1x12 array - BOOL isFinite() { return mOrigin.isFinite() && mXAxis.isFinite() && mYAxis.isFinite() && mZAxis.isFinite(); } + bool isFinite() { return mOrigin.isFinite() && mXAxis.isFinite() && mYAxis.isFinite() && mZAxis.isFinite(); } void reset(); void resetAxes(); diff --git a/indra/llmath/llinterp.h b/indra/llmath/llinterp.h index 116e949663..f4faa82a82 100644 --- a/indra/llmath/llinterp.h +++ b/indra/llmath/llinterp.h @@ -41,7 +41,6 @@ class LLInterpVal { public: virtual ~LLInterpVal() {} - virtual void interp(LLInterpVal &target, const F32 frac); // Linear interpolation for each type }; template <typename Type> @@ -52,7 +51,7 @@ public: virtual ~LLInterp() {} virtual void start(); - void update(const F32 time); + virtual void update(const F32 time) = 0; const Type &getCurVal() const; void setStartVal(const Type &start_val); @@ -67,15 +66,15 @@ public: void setEndTime(const F32 time); F32 getEndTime() const; - BOOL isActive() const; - BOOL isDone() const; + bool isActive() const; + bool isDone() const; protected: F32 mStartTime; F32 mEndTime; F32 mDuration; - BOOL mActive; - BOOL mDone; + bool mActive; + bool mDone; Type mStartVal; Type mEndVal; @@ -88,8 +87,8 @@ template <typename Type> class LLInterpLinear : public LLInterp<Type> { public: - /*virtual*/ void start(); - void update(const F32 time); + void start() override; + void update(const F32 time) override; F32 getCurFrac() const; protected: F32 mCurFrac; @@ -108,10 +107,10 @@ class LLInterpAttractor : public LLInterp<Type> { public: LLInterpAttractor(); - /*virtual*/ void start(); + void start() override; void setStartVel(const Type &vel); void setForce(const F32 force); - void update(const F32 time); + void update(const F32 time) override; protected: F32 mForce; Type mStartVel; @@ -123,7 +122,7 @@ class LLInterpFunc : public LLInterp<Type> { public: LLInterpFunc(); - void update(const F32 time); + void update(const F32 time) override; void setFunc(Type (*)(const F32, void *data), void *data); protected: @@ -151,8 +150,8 @@ LLInterp<Type>::LLInterp() mEndTime = 1.f; mDuration = 1.f; mCurTime = 0.f; - mDone = FALSE; - mActive = FALSE; + mDone = false; + mActive = false; } template <class Type> @@ -166,8 +165,8 @@ void LLInterp<Type>::start() { mCurVal = mStartVal; mCurTime = mStartTime; - mDone = FALSE; - mActive = FALSE; + mDone = false; + mActive = false; } template <class Type> @@ -225,13 +224,13 @@ F32 LLInterp<Type>::getEndTime() const template <class Type> -BOOL LLInterp<Type>::isDone() const +bool LLInterp<Type>::isDone() const { return mDone; } template <class Type> -BOOL LLInterp<Type>::isActive() const +bool LLInterp<Type>::isActive() const { return mActive; } @@ -254,7 +253,7 @@ void LLInterpLinear<Type>::update(const F32 time) F32 dfrac = target_frac - this->mCurFrac; if (target_frac >= 0.f) { - this->mActive = TRUE; + this->mActive = true; } if (target_frac > 1.f) @@ -262,7 +261,7 @@ void LLInterpLinear<Type>::update(const F32 time) this->mCurVal = this->mEndVal; this->mCurFrac = 1.f; this->mCurTime = time; - this->mDone = TRUE; + this->mDone = true; return; } @@ -332,7 +331,7 @@ void LLInterpAttractor<Type>::update(const F32 time) { if (time > this->mStartTime) { - this->mActive = TRUE; + this->mActive = true; } else { @@ -340,7 +339,7 @@ void LLInterpAttractor<Type>::update(const F32 time) } if (time > this->mEndTime) { - this->mDone = TRUE; + this->mDone = true; return; } @@ -362,8 +361,8 @@ void LLInterpAttractor<Type>::update(const F32 time) template <class Type> LLInterpFunc<Type>::LLInterpFunc() : LLInterp<Type>() { - mFunc = NULL; - mData = NULL; + mFunc = nullptr; + mData = nullptr; } template <class Type> @@ -378,7 +377,7 @@ void LLInterpFunc<Type>::update(const F32 time) { if (time > this->mStartTime) { - this->mActive = TRUE; + this->mActive = true; } else { @@ -386,7 +385,7 @@ void LLInterpFunc<Type>::update(const F32 time) } if (time > this->mEndTime) { - this->mDone = TRUE; + this->mDone = true; return; } @@ -405,7 +404,7 @@ void LLInterpExp<Type>::update(const F32 time) F32 target_frac = (time - this->mStartTime) / this->mDuration; if (target_frac >= 0.f) { - this->mActive = TRUE; + this->mActive = true; } if (target_frac > 1.f) @@ -413,7 +412,7 @@ void LLInterpExp<Type>::update(const F32 time) this->mCurVal = this->mEndVal; this->mCurFrac = 1.f; this->mCurTime = time; - this->mDone = TRUE; + this->mDone = true; return; } diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index f425b590e4..4e8fc56de0 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -59,34 +59,34 @@ #define tanf(x) ((F32)tan((F64)(x))) #endif*/ -const F32 GRAVITY = -9.8f; +constexpr F32 GRAVITY = -9.8f; // mathematical constants -const F32 F_PI = 3.1415926535897932384626433832795f; -const F32 F_TWO_PI = 6.283185307179586476925286766559f; -const F32 F_PI_BY_TWO = 1.5707963267948966192313216916398f; -const F32 F_SQRT_TWO_PI = 2.506628274631000502415765284811f; -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 +constexpr F32 F_PI = 3.1415926535897932384626433832795f; +constexpr F32 F_TWO_PI = 6.283185307179586476925286766559f; +constexpr F32 F_PI_BY_TWO = 1.5707963267948966192313216916398f; +constexpr F32 F_SQRT_TWO_PI = 2.506628274631000502415765284811f; +constexpr F32 F_E = 2.71828182845904523536f; +constexpr F32 F_SQRT2 = 1.4142135623730950488016887242097f; +constexpr F32 F_SQRT3 = 1.73205080756888288657986402541f; +constexpr F32 OO_SQRT2 = 0.7071067811865475244008443621049f; +constexpr F32 OO_SQRT3 = 0.577350269189625764509f; +constexpr F32 DEG_TO_RAD = 0.017453292519943295769236907684886f; +constexpr F32 RAD_TO_DEG = 57.295779513082320876798154814105f; +constexpr F32 F_APPROXIMATELY_ZERO = 0.00001f; +constexpr F32 F_LN10 = 2.3025850929940456840179914546844f; +constexpr F32 OO_LN10 = 0.43429448190325182765112891891661; +constexpr F32 F_LN2 = 0.69314718056f; +constexpr F32 OO_LN2 = 1.4426950408889634073599246810019f; + +constexpr F32 F_ALMOST_ZERO = 0.0001f; +constexpr F32 F_ALMOST_ONE = 1.0f - F_ALMOST_ZERO; + +constexpr 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; +constexpr F32 FP_MAG_THRESHOLD = 0.0000001f; // TODO: Replace with logic like is_approx_equal inline bool is_approx_zero( F32 f ) { return (-F_APPROXIMATELY_ZERO < f) && (f < F_APPROXIMATELY_ZERO); } @@ -123,13 +123,13 @@ inline bool is_zero(F32 x) inline bool is_approx_equal(F32 x, F32 y) { - const S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02; + constexpr S32 COMPARE_MANTISSA_UP_TO_BIT = 0x02; return (std::abs((S32) ((U32&)x - (U32&)y) ) < COMPARE_MANTISSA_UP_TO_BIT); } inline bool is_approx_equal(F64 x, F64 y) { - const S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02; + constexpr S64 COMPARE_MANTISSA_UP_TO_BIT = 0x02; return (std::abs((S32) ((U64&)x - (U64&)y) ) < COMPARE_MANTISSA_UP_TO_BIT); } @@ -272,8 +272,8 @@ inline F64 ll_round( F64 val, F64 nearest ) // peak error = -31.4 dB // RMS error = -28.1 dB -const F32 FAST_MAG_ALPHA = 0.960433870103f; -const F32 FAST_MAG_BETA = 0.397824734759f; +constexpr F32 FAST_MAG_ALPHA = 0.960433870103f; +constexpr F32 FAST_MAG_BETA = 0.397824734759f; // these provide minimum RMS error // @@ -281,8 +281,8 @@ const F32 FAST_MAG_BETA = 0.397824734759f; // peak error = -32.6 dB // RMS error = -25.7 dB // -//const F32 FAST_MAG_ALPHA = 0.948059448969f; -//const F32 FAST_MAG_BETA = 0.392699081699f; +//constexpr F32 FAST_MAG_ALPHA = 0.948059448969f; +//constexpr F32 FAST_MAG_BETA = 0.392699081699f; inline F32 fastMagnitude(F32 a, F32 b) { @@ -299,8 +299,8 @@ inline F32 fastMagnitude(F32 a, F32 b) // // Culled from www.stereopsis.com/FPU.html -const F64 LL_DOUBLE_TO_FIX_MAGIC = 68719476736.0*1.5; //2^36 * 1.5, (52-_shiftamt=36) uses limited precisicion to floor -const S32 LL_SHIFT_AMOUNT = 16; //16.16 fixed point representation, +constexpr F64 LL_DOUBLE_TO_FIX_MAGIC = 68719476736.0*1.5; //2^36 * 1.5, (52-_shiftamt=36) uses limited precisicion to floor +constexpr S32 LL_SHIFT_AMOUNT = 16; //16.16 fixed point representation, // Endian dependent code #ifdef LL_LITTLE_ENDIAN diff --git a/indra/llmath/llmatrix4a.h b/indra/llmath/llmatrix4a.h index cf4e522467..3b423f783a 100644 --- a/indra/llmath/llmatrix4a.h +++ b/indra/llmath/llmatrix4a.h @@ -46,6 +46,34 @@ public: loadu(val); } + explicit LLMatrix4a(const F32* val) + { + loadu(val); + } + + static const LLMatrix4a& identity() + { + static const F32 v[] = + { 1.f, 0.f, 0.f, 0.f, + 0.f, 1.f, 0.f, 0.f, + 0.f, 0.f, 1.f, 0.f, + 0.f, 0.f, 0.f, 1.f + }; + static LLMatrix4a identity_mat(v); + + return identity_mat; + } + + bool operator==(const LLMatrix4a& rhs) const + { + return mMatrix[0] == rhs.mMatrix[0] && mMatrix[1] == rhs.mMatrix[1] && mMatrix[2] == rhs.mMatrix[2] && mMatrix[3] == rhs.mMatrix[3]; + } + + bool operator!=(const LLMatrix4a& rhs) const + { + return !(*this == rhs); + } + inline F32* getF32ptr() { return (F32*) &mMatrix; diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 88ba006269..eaa2763d2d 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -453,7 +453,7 @@ public: S32 i = data->getBinIndex(); - if (i >= 0 && i < getElementCount()) + if (i >= 0 && i < (S32)getElementCount()) { if (mData[i] == data) { //found it @@ -548,7 +548,7 @@ public: } } - void addChild(oct_node* child, BOOL silent = FALSE) + void addChild(oct_node* child, bool silent = false) { #if LL_OCTREE_PARANOIA_CHECK @@ -591,7 +591,7 @@ public: } } - void removeChild(S32 index, BOOL destroy = FALSE) + void removeChild(S32 index, bool destroy = false) { for (U32 i = 0; i < this->getListenerCount(); i++) { @@ -638,7 +638,7 @@ public: { if (getChild(i) == node) { - removeChild(i, TRUE); + removeChild(i, true); return; } } @@ -707,7 +707,7 @@ public: //(don't notify listeners of addition) for (U32 i = 0; i < child->getChildCount(); i++) { - this->addChild(child->getChild(i), TRUE); + this->addChild(child->getChild(i), true); } //destroy child @@ -723,7 +723,7 @@ public: // LLOctreeRoot::insert bool insert(T* data) override { - if (data == NULL) + if (data == nullptr) { OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE ROOT !!!" << LL_ENDL; return false; diff --git a/indra/llmath/llquaternion.cpp b/indra/llmath/llquaternion.cpp index ce0a88c26f..aefb82b2f0 100644 --- a/indra/llmath/llquaternion.cpp +++ b/indra/llmath/llquaternion.cpp @@ -653,14 +653,14 @@ LLQuaternion slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b ) F32 cos_t = a.mQ[0]*b.mQ[0] + a.mQ[1]*b.mQ[1] + a.mQ[2]*b.mQ[2] + a.mQ[3]*b.mQ[3]; // if b is on opposite hemisphere from a, use -a instead - int bflip; + bool bflip; if (cos_t < 0.0f) { cos_t = -cos_t; - bflip = TRUE; + bflip = true; } else - bflip = FALSE; + bflip = false; // if B is (within precision limits) the same as A, // just linear interpolate between A and B. @@ -959,11 +959,11 @@ void LLQuaternion::unpackFromVector3( const LLVector3& vec ) } } -BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value) +bool LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value) { if( buf.empty() || value == NULL) { - return FALSE; + return false; } LLQuaternion quat; @@ -971,10 +971,10 @@ BOOL LLQuaternion::parseQuat(const std::string& buf, LLQuaternion* value) if( 4 == count ) { value->set( quat ); - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h index fbe4da97f7..2caa993007 100644 --- a/indra/llmath/llquaternion.h +++ b/indra/llmath/llquaternion.h @@ -69,9 +69,9 @@ public: LLSD getValue() const; void setValue(const LLSD& sd); - BOOL isIdentity() const; - BOOL isNotIdentity() const; - BOOL isFinite() const; // checks to see if all values of LLQuaternion are finite + bool isIdentity() const; + bool isNotIdentity() const; + bool isFinite() const; // checks to see if all values of LLQuaternion are finite void quantize16(F32 lower, F32 upper); // changes the vector to reflect quatization void quantize8(F32 lower, F32 upper); // changes the vector to reflect quatization void loadIdentity(); // Loads the quaternion that represents the identity rotation @@ -167,7 +167,7 @@ public: friend const char *OrderToString( const Order order ); friend Order StringToOrder( const char *str ); - static BOOL parseQuat(const std::string& buf, LLQuaternion* value); + static bool parseQuat(const std::string& buf, LLQuaternion* value); // For debugging, only //static U32 mMultCount; @@ -192,12 +192,12 @@ inline void LLQuaternion::setValue(const LLSD& sd) } // checker -inline BOOL LLQuaternion::isFinite() const +inline bool LLQuaternion::isFinite() const { return (llfinite(mQ[VX]) && llfinite(mQ[VY]) && llfinite(mQ[VZ]) && llfinite(mQ[VS])); } -inline BOOL LLQuaternion::isIdentity() const +inline bool LLQuaternion::isIdentity() const { return ( mQ[VX] == 0.f ) && @@ -206,7 +206,7 @@ inline BOOL LLQuaternion::isIdentity() const ( mQ[VS] == 1.f ); } -inline BOOL LLQuaternion::isNotIdentity() const +inline bool LLQuaternion::isNotIdentity() const { return ( mQ[VX] != 0.f ) || diff --git a/indra/llmath/llrect.h b/indra/llmath/llrect.h index 6c872611ba..317578da06 100644 --- a/indra/llmath/llrect.h +++ b/indra/llmath/llrect.h @@ -83,14 +83,14 @@ public: } // Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect - BOOL pointInRect(const Type x, const Type y) const + bool pointInRect(const Type x, const Type y) const { return mLeft <= x && x < mRight && mBottom <= y && y < mTop; } //// Note: follows GL_QUAD conventions: the top and right edges are not considered part of the rect - BOOL localPointInRect(const Type x, const Type y) const + bool localPointInRect(const Type x, const Type y) const { return 0 <= x && x < getWidth() && 0 <= y && y < getHeight(); @@ -137,8 +137,8 @@ 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 overlaps(const LLRectBase& rect) const + // returns true if any part of rect is is inside this LLRect + bool overlaps(const LLRectBase& rect) const { return !(mLeft > rect.mRight || mRight < rect.mLeft @@ -146,7 +146,7 @@ public: || mTop < rect.mBottom); } - BOOL contains(const LLRectBase& rect) const + bool contains(const LLRectBase& rect) const { return mLeft <= rect.mLeft && mRight >= rect.mRight diff --git a/indra/llmath/llsimdtypes.h b/indra/llmath/llsimdtypes.h index 9db152adf8..11462170fb 100644 --- a/indra/llmath/llsimdtypes.h +++ b/indra/llmath/llsimdtypes.h @@ -60,7 +60,7 @@ public: inline operator bool() const { return static_cast<const bool&>(m_bool); } private: - int m_bool; + int m_bool{ 0 }; }; #if LL_WINDOWS @@ -118,7 +118,7 @@ public: } private: - LLQuad mQ; + LLQuad mQ{}; }; #endif //LL_SIMD_TYPES_H diff --git a/indra/llmath/llsphere.cpp b/indra/llmath/llsphere.cpp index 75f9ef1772..5f48764455 100644 --- a/indra/llmath/llsphere.cpp +++ b/indra/llmath/llsphere.cpp @@ -69,18 +69,18 @@ F32 LLSphere::getRadius() const return mRadius; } -// returns 'TRUE' if this sphere completely contains other_sphere -BOOL LLSphere::contains(const LLSphere& other_sphere) const +// returns 'true' if this sphere completely contains other_sphere +bool LLSphere::contains(const LLSphere& other_sphere) const { F32 separation = (mCenter - other_sphere.mCenter).length(); - return (mRadius >= separation + other_sphere.mRadius) ? TRUE : FALSE; + return mRadius >= separation + other_sphere.mRadius; } -// returns 'TRUE' if this sphere completely contains other_sphere -BOOL LLSphere::overlaps(const LLSphere& other_sphere) const +// returns 'true' if this sphere completely contains other_sphere +bool LLSphere::overlaps(const LLSphere& other_sphere) const { F32 separation = (mCenter - other_sphere.mCenter).length(); - return (separation <= mRadius + other_sphere.mRadius) ? TRUE : FALSE; + return mRadius >= separation - other_sphere.mRadius; } // returns overlap @@ -93,9 +93,8 @@ F32 LLSphere::getOverlap(const LLSphere& other_sphere) const bool LLSphere::operator==(const LLSphere& rhs) const { - // TODO? -- use approximate equality for centers? - return (mRadius == rhs.mRadius - && mCenter == rhs.mCenter); + return fabs(mRadius - rhs.mRadius) <= FLT_EPSILON && + (mCenter - rhs.mCenter).length() <= FLT_EPSILON; } std::ostream& operator<<( std::ostream& output_stream, const LLSphere& sphere) @@ -186,7 +185,7 @@ LLSphere LLSphere::getBoundingSphere(const std::vector<LLSphere>& sphere_list) // TODO -- improve the accuracy for small collections of spheres LLSphere bounding_sphere( LLVector3(0.f, 0.f, 0.f), 0.f ); - S32 sphere_count = sphere_list.size(); + auto sphere_count = sphere_list.size(); if (1 == sphere_count) { // trivial case -- single sphere diff --git a/indra/llmath/llsphere.h b/indra/llmath/llsphere.h index 62bcadf16d..cb923dcd3c 100644 --- a/indra/llmath/llsphere.h +++ b/indra/llmath/llsphere.h @@ -47,11 +47,11 @@ public: const LLVector3& getCenter() const; F32 getRadius() const; - // returns TRUE if this sphere completely contains other_sphere - BOOL contains(const LLSphere& other_sphere) const; + // returns true if this sphere completely contains other_sphere + bool contains(const LLSphere& other_sphere) const; - // returns TRUE if this sphere overlaps other_sphere - BOOL overlaps(const LLSphere& other_sphere) const; + // returns true if this sphere overlaps other_sphere + bool overlaps(const LLSphere& other_sphere) const; // returns overlap distance // negative overlap is closest approach diff --git a/indra/llmath/lltreenode.h b/indra/llmath/lltreenode.h index a0b90e3511..e3d30206b7 100644 --- a/indra/llmath/lltreenode.h +++ b/indra/llmath/lltreenode.h @@ -56,10 +56,11 @@ public: virtual bool insert(T* data); virtual bool remove(T* data); virtual void notifyRemoval(T* data); - virtual U32 getListenerCount() { return mListeners.size(); } + virtual U32 hasListeners() const { return !mListeners.empty(); } + virtual U32 getListenerCount() const { return static_cast<U32>(mListeners.size()); } virtual LLTreeListener<T>* getListener(U32 index) const { - if(index < mListeners.size()) + if (index < mListeners.size()) { return mListeners[index]; } diff --git a/indra/llmath/llvector4a.h b/indra/llmath/llvector4a.h index 8f0ee4b739..8ef560dadf 100644 --- a/indra/llmath/llvector4a.h +++ b/indra/llmath/llvector4a.h @@ -117,6 +117,49 @@ public: mQ = q; } + bool operator==(const LLVector4a& rhs) const + { + return equals4(rhs); + } + + bool operator!=(const LLVector4a& rhs) const + { + return !(*this == rhs); + } + + const LLVector4a& operator+=(const LLVector4a& rhs) + { + add(rhs); + return *this; + } + + const LLVector4a& operator-=(const LLVector4a& rhs) + { + sub(rhs); + return *this; + } + + LLVector4a operator+(const LLVector4a& rhs) const + { + LLVector4a result = *this; + result.add(rhs); + return result; + } + + LLVector4a operator-(const LLVector4a& rhs) const + { + LLVector4a result = *this; + result.sub(rhs); + return result; + } + + LLVector4a cross3(const LLVector4a& b) const + { + LLVector4a result; + result.setCross3(*this, b); + return result; + } + //////////////////////////////////// // LOAD/STORE //////////////////////////////////// @@ -322,7 +365,7 @@ public: inline operator LLQuad() const; private: - LLQuad mQ; + LLQuad mQ{}; }; inline void update_min_max(LLVector4a& min, LLVector4a& max, const LLVector4a& p) diff --git a/indra/llmath/llvector4logical.h b/indra/llmath/llvector4logical.h index d08b5513d9..70759eef5c 100644 --- a/indra/llmath/llvector4logical.h +++ b/indra/llmath/llvector4logical.h @@ -120,7 +120,7 @@ public: private: - LLQuad mQ; + LLQuad mQ{}; }; #endif //LL_VECTOR4ALOGICAL_H diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 41e614524e..f3db9424d9 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -61,66 +61,66 @@ #define DEBUG_SILHOUETTE_NORMALS 0 // TomY: Use this to display normals using the silhouette #define DEBUG_SILHOUETTE_EDGE_MAP 0 // DaveP: Use this to display edge map using the silhouette -const F32 MIN_CUT_DELTA = 0.02f; +constexpr F32 MIN_CUT_DELTA = 0.02f; -const F32 HOLLOW_MIN = 0.f; -const F32 HOLLOW_MAX = 0.95f; -const F32 HOLLOW_MAX_SQUARE = 0.7f; +constexpr F32 HOLLOW_MIN = 0.f; +constexpr F32 HOLLOW_MAX = 0.95f; +constexpr F32 HOLLOW_MAX_SQUARE = 0.7f; -const F32 TWIST_MIN = -1.f; -const F32 TWIST_MAX = 1.f; +constexpr F32 TWIST_MIN = -1.f; +constexpr F32 TWIST_MAX = 1.f; -const F32 RATIO_MIN = 0.f; -const F32 RATIO_MAX = 2.f; // Tom Y: Inverted sense here: 0 = top taper, 2 = bottom taper +constexpr F32 RATIO_MIN = 0.f; +constexpr F32 RATIO_MAX = 2.f; // Tom Y: Inverted sense here: 0 = top taper, 2 = bottom taper -const F32 HOLE_X_MIN= 0.05f; -const F32 HOLE_X_MAX= 1.0f; +constexpr F32 HOLE_X_MIN= 0.05f; +constexpr F32 HOLE_X_MAX= 1.0f; -const F32 HOLE_Y_MIN= 0.05f; -const F32 HOLE_Y_MAX= 0.5f; +constexpr F32 HOLE_Y_MIN= 0.05f; +constexpr F32 HOLE_Y_MAX= 0.5f; -const F32 SHEAR_MIN = -0.5f; -const F32 SHEAR_MAX = 0.5f; +constexpr F32 SHEAR_MIN = -0.5f; +constexpr F32 SHEAR_MAX = 0.5f; -const F32 REV_MIN = 1.f; -const F32 REV_MAX = 4.f; +constexpr F32 REV_MIN = 1.f; +constexpr F32 REV_MAX = 4.f; -const F32 TAPER_MIN = -1.f; -const F32 TAPER_MAX = 1.f; +constexpr F32 TAPER_MIN = -1.f; +constexpr F32 TAPER_MAX = 1.f; -const F32 SKEW_MIN = -0.95f; -const F32 SKEW_MAX = 0.95f; +constexpr F32 SKEW_MIN = -0.95f; +constexpr F32 SKEW_MAX = 0.95f; -const F32 SCULPT_MIN_AREA = 0.002f; -const S32 SCULPT_MIN_AREA_DETAIL = 1; +constexpr F32 SCULPT_MIN_AREA = 0.002f; +constexpr S32 SCULPT_MIN_AREA_DETAIL = 1; -BOOL gDebugGL = FALSE; // See settings.xml "RenderDebugGL" +bool gDebugGL = false; // See settings.xml "RenderDebugGL" -BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) +bool check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) { LLVector3 test = (pt2-pt1)%(pt3-pt2); //answer if(test * norm < 0) { - return FALSE; + return false; } else { - return TRUE; + return true; } } -BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size) +bool LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size) { return LLLineSegmentBoxIntersect(start.mV, end.mV, center.mV, size.mV); } -BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size) +bool LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size) { - F32 fAWdU[3]; - F32 dir[3]; - F32 diff[3]; + F32 fAWdU[3]{}; + F32 dir[3]{}; + F32 diff[3]{}; for (U32 i = 0; i < 3; i++) { @@ -218,11 +218,11 @@ void calc_tangent_from_triangle( // intersect test between triangle vert0, vert1, vert2 and a ray from orig in direction dir. -// returns TRUE if intersecting and returns barycentric coordinates in intersection_a, intersection_b, +// returns true if intersecting and returns barycentric coordinates in intersection_a, intersection_b, // and returns the intersection point along dir in intersection_t. // Moller-Trumbore algorithm -BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, +bool LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, F32& intersection_a, F32& intersection_b, F32& intersection_t) { @@ -284,15 +284,15 @@ BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, co intersection_a = u[0]; intersection_b = v[0]; intersection_t = t[0]; - return TRUE; + return true; } } } - return FALSE; + return false; } -BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, +bool LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, F32& intersection_a, F32& intersection_b, F32& intersection_t) { F32 u, v, t; @@ -315,7 +315,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v if (det > -F_APPROXIMATELY_ZERO && det < F_APPROXIMATELY_ZERO) { - return FALSE; + return false; } F32 inv_det = 1.f / det; @@ -328,7 +328,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v u = (tvec.dot3(pvec).getF32()) * inv_det; if (u < 0.f || u > 1.f) { - return FALSE; + return false; } /* prepare to test V parameter */ @@ -339,7 +339,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v if (v < 0.f || u + v > 1.f) { - return FALSE; + return false; } /* calculate t, ray intersects triangle */ @@ -350,30 +350,7 @@ BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& v intersection_t = t; - return TRUE; -} - -//helper for non-aligned vectors -BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir, - F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided) -{ - LLVector4a vert0a, vert1a, vert2a, origa, dira; - vert0a.load3(vert0.mV); - vert1a.load3(vert1.mV); - vert2a.load3(vert2.mV); - origa.load3(orig.mV); - dira.load3(dir.mV); - - if (two_sided) - { - return LLTriangleRayIntersectTwoSided(vert0a, vert1a, vert2a, origa, dira, - intersection_a, intersection_b, intersection_t); - } - else - { - return LLTriangleRayIntersect(vert0a, vert1a, vert2a, origa, dira, - intersection_a, intersection_b, intersection_t); - } + return true; } //------------------------------------------------------------------- @@ -390,12 +367,12 @@ LLProfile::Face* LLProfile::addCap(S16 faceID) face->mIndex = 0; face->mCount = mTotal; face->mScaleU= 1.0f; - face->mCap = TRUE; + face->mCap = true; face->mFaceID = faceID; return face; } -LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BOOL flat) +LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, bool flat) { Face *face = vector_append(mFaces, 1); @@ -404,7 +381,7 @@ LLProfile::Face* LLProfile::addFace(S32 i, S32 count, F32 scaleU, S16 faceID, BO face->mScaleU= scaleU; face->mFlat = flat; - face->mCap = FALSE; + face->mCap = false; face->mFaceID = faceID; return face; } @@ -479,7 +456,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 { // Generate an n-sided "circular" path. // 0 is (1,0), and we go counter-clockwise along a circular path from there. - static const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; + constexpr F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; F32 scale = 0.5f; F32 t, t_step, t_first, t_fraction, ang, ang_step; LLVector4a pt1,pt2; @@ -579,13 +556,13 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 { if ((end - begin)*ang_scale > 0.5f) { - mConcave = TRUE; + mConcave = true; } else { - mConcave = FALSE; + mConcave = false; } - mOpen = TRUE; + mOpen = true; if (params.getHollow() <= 0) { // put center point if not hollow. @@ -595,8 +572,8 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 else { // The profile isn't open. - mOpen = FALSE; - mConcave = FALSE; + mOpen = false; + mConcave = false; } mTotal = mProfile.size(); @@ -605,7 +582,7 @@ void LLProfile::genNGon(const LLProfileParams& params, S32 sides, F32 offset, F3 // Hollow is percent of the original bounding box, not of this particular // profile's geometry. Thus, a swept triangle needs lower hollow values than // a swept square. -LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F32 sides, F32 offset, F32 box_hollow, F32 ang_scale, S32 split) +LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, bool flat, F32 sides, F32 offset, F32 box_hollow, F32 ang_scale, S32 split) { // Note that addHole will NOT work for non-"circular" profiles, if we ever decide to use them. @@ -644,8 +621,8 @@ LLProfile::Face* LLProfile::addHole(const LLProfileParams& params, BOOL flat, F3 } //static -S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split, - BOOL is_sculpted, S32 sculpt_size) +S32 LLProfile::getNumPoints(const LLProfileParams& params, bool path_open,F32 detail, S32 split, + bool is_sculpted, S32 sculpt_size) { // this is basically LLProfile::generate stripped down to only operations that influence the number of points if (detail < MIN_LOD) { @@ -754,16 +731,16 @@ S32 LLProfile::getNumPoints(const LLProfileParams& params, BOOL path_open,F32 de } -BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detail, S32 split, - BOOL is_sculpted, S32 sculpt_size) +bool LLProfile::generate(const LLProfileParams& params, bool path_open,F32 detail, S32 split, + bool is_sculpted, S32 sculpt_size) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME if ((!mDirty) && (!is_sculpted)) { - return FALSE; + return false; } - mDirty = FALSE; + mDirty = false; if (detail < MIN_LOD) { @@ -784,7 +761,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai if (begin > end - 0.01f) { LL_WARNS() << "LLProfile::generate() assertion failed (begin >= end)" << LL_ENDL; - return FALSE; + return false; } S32 face_num = 0; @@ -801,7 +778,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai for (i = llfloor(begin * 4.f); i < llfloor(end * 4.f + .999f); i++) { - addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, TRUE); + addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, true); } LLVector4a scale(1,1,4,1); @@ -819,16 +796,16 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai { case LL_PCODE_HOLE_TRIANGLE: // This offset is not correct, but we can't change it now... DK 11/17/04 - addHole(params, TRUE, 3, -0.375f, hollow, 1.f, split); + addHole(params, true, 3, -0.375f, hollow, 1.f, split); break; case LL_PCODE_HOLE_CIRCLE: // TODO: Compute actual detail levels for cubes - addHole(params, FALSE, MIN_DETAIL_FACES * detail, -0.375f, hollow, 1.f); + addHole(params, false, MIN_DETAIL_FACES * detail, -0.375f, hollow, 1.f); break; case LL_PCODE_HOLE_SAME: case LL_PCODE_HOLE_SQUARE: default: - addHole(params, TRUE, 4, -0.375f, hollow, 1.f, split); + addHole(params, true, 4, -0.375f, hollow, 1.f, split); break; } } @@ -858,7 +835,7 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai for (i = llfloor(begin * 3.f); i < llfloor(end * 3.f + .999f); i++) { - addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, TRUE); + addFace((face_num++) * (split +1), split+2, 1, LL_FACE_OUTER_SIDE_0 << i, true); } if (hollow) { @@ -870,15 +847,15 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai { case LL_PCODE_HOLE_CIRCLE: // TODO: Actually generate level of detail for triangles - addHole(params, FALSE, MIN_DETAIL_FACES * detail, 0, triangle_hollow, 1.f); + addHole(params, false, MIN_DETAIL_FACES * detail, 0, triangle_hollow, 1.f); break; case LL_PCODE_HOLE_SQUARE: - addHole(params, TRUE, 4, 0, triangle_hollow, 1.f, split); + addHole(params, true, 4, 0, triangle_hollow, 1.f, split); break; case LL_PCODE_HOLE_SAME: case LL_PCODE_HOLE_TRIANGLE: default: - addHole(params, TRUE, 3, 0, triangle_hollow, 1.f, split); + addHole(params, true, 3, 0, triangle_hollow, 1.f, split); break; } } @@ -915,11 +892,11 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai if (mOpen && !hollow) { - addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, FALSE); + addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, false); } else { - addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, FALSE); + addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, false); } if (hollow) @@ -927,15 +904,15 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai switch (hole_type) { case LL_PCODE_HOLE_SQUARE: - addHole(params, TRUE, 4, 0, hollow, 1.f, split); + addHole(params, true, 4, 0, hollow, 1.f, split); break; case LL_PCODE_HOLE_TRIANGLE: - addHole(params, TRUE, 3, 0, hollow, 1.f, split); + addHole(params, true, 3, 0, hollow, 1.f, split); break; case LL_PCODE_HOLE_CIRCLE: case LL_PCODE_HOLE_SAME: default: - addHole(params, FALSE, circle_detail, 0, hollow, 1.f); + addHole(params, true, circle_detail, 0, hollow, 1.f); break; } } @@ -965,11 +942,11 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai } if (mOpen && !params.getHollow()) { - addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, FALSE); + addFace(0,mTotal-1,0,LL_FACE_OUTER_SIDE_0, false); } else { - addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, FALSE); + addFace(0,mTotal,0,LL_FACE_OUTER_SIDE_0, false); } if (hollow) @@ -977,15 +954,15 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai switch (hole_type) { case LL_PCODE_HOLE_SQUARE: - addHole(params, TRUE, 2, 0.5f, hollow, 0.5f, split); + addHole(params, true, 2, 0.5f, hollow, 0.5f, split); break; case LL_PCODE_HOLE_TRIANGLE: - addHole(params, TRUE, 3, 0.5f, hollow, 0.5f, split); + addHole(params, true, 3, 0.5f, hollow, 0.5f, split); break; case LL_PCODE_HOLE_CIRCLE: case LL_PCODE_HOLE_SAME: default: - addHole(params, FALSE, circle_detail, 0.5f, hollow, 0.5f); + addHole(params, false, circle_detail, 0.5f, hollow, 0.5f); break; } } @@ -993,11 +970,11 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai // Special case for openness of sphere if ((params.getEnd() - params.getBegin()) < 1.f) { - mOpen = TRUE; + mOpen = true; } else if (!hollow) { - mOpen = FALSE; + mOpen = false; mProfile.push_back(mProfile[0]); mTotal++; } @@ -1015,24 +992,24 @@ BOOL LLProfile::generate(const LLProfileParams& params, BOOL path_open,F32 detai if ( mOpen) // interior edge caps { - addFace(mTotal-1, 2,0.5,LL_FACE_PROFILE_BEGIN, TRUE); + addFace(mTotal-1, 2,0.5,LL_FACE_PROFILE_BEGIN, true); if (hollow) { - addFace(mTotalOut-1, 2,0.5,LL_FACE_PROFILE_END, TRUE); + addFace(mTotalOut-1, 2,0.5,LL_FACE_PROFILE_END, true); } else { - addFace(mTotal-2, 2,0.5,LL_FACE_PROFILE_END, TRUE); + addFace(mTotal-2, 2,0.5,LL_FACE_PROFILE_END, true); } } - return TRUE; + return true; } -BOOL LLProfileParams::importFile(LLFILE *fp) +bool LLProfileParams::importFile(LLFILE *fp) { const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ @@ -1090,11 +1067,11 @@ BOOL LLProfileParams::importFile(LLFILE *fp) } } - return TRUE; + return true; } -BOOL LLProfileParams::exportFile(LLFILE *fp) const +bool LLProfileParams::exportFile(LLFILE *fp) const { fprintf(fp,"\t\tprofile 0\n"); fprintf(fp,"\t\t{\n"); @@ -1103,11 +1080,11 @@ BOOL LLProfileParams::exportFile(LLFILE *fp) const fprintf(fp,"\t\t\tend\t%g\n", getEnd()); fprintf(fp,"\t\t\thollow\t%g\n", getHollow()); fprintf(fp, "\t\t}\n"); - return TRUE; + return true; } -BOOL LLProfileParams::importLegacyStream(std::istream& input_stream) +bool LLProfileParams::importLegacyStream(std::istream& input_stream) { const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ @@ -1162,11 +1139,11 @@ BOOL LLProfileParams::importLegacyStream(std::istream& input_stream) } } - return TRUE; + return true; } -BOOL LLProfileParams::exportLegacyStream(std::ostream& output_stream) const +bool LLProfileParams::exportLegacyStream(std::ostream& output_stream) const { output_stream <<"\t\tprofile 0\n"; output_stream <<"\t\t{\n"; @@ -1175,7 +1152,7 @@ BOOL LLProfileParams::exportLegacyStream(std::ostream& output_stream) const output_stream <<"\t\t\tend\t" << getEnd() << "\n"; output_stream <<"\t\t\thollow\t" << getHollow() << "\n"; output_stream << "\t\t}\n"; - return TRUE; + return true; } LLSD LLProfileParams::asLLSD() const @@ -1242,7 +1219,7 @@ void LLPath::genNGon(const LLPathParams& params, S32 sides, F32 startOff, F32 en LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME // Generates a circular path, starting at (1, 0, 0), counterclockwise along the xz plane. - static const F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; + constexpr F32 tableScale[] = { 1, 1, 1, 0.5f, 0.707107f, 0.53f, 0.525f, 0.5f }; F32 revolutions = params.getRevolutions(); F32 skew = params.getSkew(); @@ -1472,14 +1449,14 @@ S32 LLPath::getNumPoints(const LLPathParams& params, F32 detail) return np; } -BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, - BOOL is_sculpted, S32 sculpt_size) +bool LLPath::generate(const LLPathParams& params, F32 detail, S32 split, + bool is_sculpted, S32 sculpt_size) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME if ((!mDirty) && (!is_sculpted)) { - return FALSE; + return false; } if (detail < MIN_LOD) @@ -1488,11 +1465,11 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, detail = MIN_LOD; } - mDirty = FALSE; + mDirty = false; S32 np = 2; // hardcode for line mPath.resize(0); - mOpen = TRUE; + mOpen = true; // Is this 0xf0 mask really necessary? DK 03/02/05 switch (params.getCurveType() & 0xf0) @@ -1552,7 +1529,7 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, if (params.getEnd() - params.getBegin() >= 0.99f && params.getScaleX() >= .99f) { - mOpen = FALSE; + mOpen = false; } //genNGon(params, llfloor(MIN_DETAIL_FACES * detail), 4.f, 0.f); @@ -1596,19 +1573,19 @@ BOOL LLPath::generate(const LLPathParams& params, F32 detail, S32 split, break; }; - if (params.getTwist() != params.getTwistBegin()) mOpen = TRUE; + if (params.getTwist() != params.getTwistBegin()) mOpen = true; //if ((int(fabsf(params.getTwist() - params.getTwistBegin())*100))%100 != 0) { - // mOpen = TRUE; + // mOpen = true; //} - return TRUE; + return true; } -BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split, - BOOL is_sculpted, S32 sculpt_size) +bool LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split, + bool is_sculpted, S32 sculpt_size) { - mOpen = TRUE; // Draw end caps + mOpen = true; // Draw end caps if (getPathLength() == 0) { // Path hasn't been generated yet. @@ -1627,11 +1604,11 @@ BOOL LLDynamicPath::generate(const LLPathParams& params, F32 detail, S32 split, } } - return TRUE; + return true; } -BOOL LLPathParams::importFile(LLFILE *fp) +bool LLPathParams::importFile(LLFILE *fp) { const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ @@ -1746,11 +1723,11 @@ BOOL LLPathParams::importFile(LLFILE *fp) LL_WARNS() << "unknown keyword " << " in path import" << LL_ENDL; } } - return TRUE; + return true; } -BOOL LLPathParams::exportFile(LLFILE *fp) const +bool LLPathParams::exportFile(LLFILE *fp) const { fprintf(fp, "\t\tpath 0\n"); fprintf(fp, "\t\t{\n"); @@ -1771,11 +1748,11 @@ BOOL LLPathParams::exportFile(LLFILE *fp) const fprintf(fp,"\t\t\tskew\t%g\n", getSkew()); fprintf(fp, "\t\t}\n"); - return TRUE; + return true; } -BOOL LLPathParams::importLegacyStream(std::istream& input_stream) +bool LLPathParams::importLegacyStream(std::istream& input_stream) { const S32 BUFSIZE = 16384; char buffer[BUFSIZE]; /* Flawfinder: ignore */ @@ -1886,11 +1863,11 @@ BOOL LLPathParams::importLegacyStream(std::istream& input_stream) LL_WARNS() << "unknown keyword " << " in path import" << LL_ENDL; } } - return TRUE; + return true; } -BOOL LLPathParams::exportLegacyStream(std::ostream& output_stream) const +bool LLPathParams::exportLegacyStream(std::ostream& output_stream) const { output_stream << "\t\tpath 0\n"; output_stream << "\t\t{\n"; @@ -1911,7 +1888,7 @@ BOOL LLPathParams::exportLegacyStream(std::ostream& output_stream) const output_stream <<"\t\t\tskew\t" << getSkew() << "\n"; output_stream << "\t\t}\n"; - return TRUE; + return true; } LLSD LLPathParams::asLLSD() const @@ -1976,7 +1953,7 @@ LLProfile::~LLProfile() S32 LLVolume::sNumMeshPoints = 0; -LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL generate_single_face, const BOOL is_unique) +LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const bool generate_single_face, const bool is_unique) : mParams(params) { mUnique = is_unique; @@ -1987,8 +1964,8 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL ge mIsMeshAssetLoaded = false; mIsMeshAssetUnavaliable = false; mLODScaleBias.setVec(1,1,1); - mHullPoints = NULL; - mHullIndices = NULL; + mHullPoints = nullptr; + mHullIndices = nullptr; mNumHullPoints = 0; mNumHullIndices = 0; @@ -2050,7 +2027,7 @@ LLVolume::~LLVolume() mHullIndices = NULL; } -BOOL LLVolume::generate() +bool LLVolume::generate() { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME @@ -2094,8 +2071,8 @@ BOOL LLVolume::generate() } } - BOOL regenPath = mPathp->generate(mParams.getPathParams(), path_detail, split); - BOOL regenProf = mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(),profile_detail, split); + bool regenPath = mPathp->generate(mParams.getPathParams(), path_detail, split); + bool regenProf = mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(),profile_detail, split); if (regenPath || regenProf ) { @@ -2158,11 +2135,11 @@ BOOL LLVolume::generate() mFaceMask |= id; } LL_CHECK_MEMORY - return TRUE; + return true; } LL_CHECK_MEMORY - return FALSE; + return false; } void LLVolumeFace::VertexData::init() @@ -2343,7 +2320,7 @@ bool LLVolume::unpackVolumeFaces(U8* in_data, S32 size) bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) { { - U32 face_count = mdl.size(); + auto face_count = mdl.size(); if (face_count == 0) { //no faces unpacked, treat as failed decode @@ -2375,7 +2352,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) LLSD::Binary idx = mdl[i]["TriangleList"]; //copy out indices - S32 num_indices = idx.size() / 2; + auto num_indices = idx.size() / 2; const S32 indices_to_discard = num_indices % 3; if (indices_to_discard > 0) { @@ -2383,7 +2360,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) LL_WARNS() << "Incomplete triangle discarded from face! Indices count " << num_indices << " was not divisible by 3. face index: " << i << " Total: " << face_count << LL_ENDL; num_indices -= indices_to_discard; } - face.resizeIndices(num_indices); + face.resizeIndices(static_cast<S32>(num_indices)); if (num_indices > 2 && !face.mIndices) { @@ -2404,7 +2381,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) } //copy out vertices - U32 num_verts = pos.size()/(3*2); + U32 num_verts = static_cast<U32>(pos.size())/(3*2); face.resizeVertices(num_verts); if (num_verts > 0 && !face.mPositions) @@ -2668,7 +2645,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) if (do_reverse_triangles) { - for (U32 j = 0; j < face.mNumIndices; j += 3) + for (S32 j = 0; j < face.mNumIndices; j += 3) { // swap the 2nd and 3rd index S32 swap = face.mIndices[j+1]; @@ -2705,7 +2682,7 @@ bool LLVolume::unpackVolumeFacesInternal(const LLSD& mdl) min_tc = face.mTexCoords[0]; max_tc = face.mTexCoords[0]; - for (U32 j = 1; j < face.mNumVertices; ++j) + for (S32 j = 1; j < face.mNumVertices; ++j) { update_min_max(min_tc, max_tc, face.mTexCoords[j]); } @@ -2808,10 +2785,10 @@ void LLVolume::createVolumeFaces() else { S32 num_faces = getNumFaces(); - BOOL partial_build = TRUE; + bool partial_build = true; if (num_faces != mVolumeFaces.size()) { - partial_build = FALSE; + partial_build = false; mVolumeFaces.resize(num_faces); } // Initialize volume faces with parameter data @@ -3046,9 +3023,9 @@ void LLVolume::sculptGenerateSpherePlaceholder() void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, U8 sculpt_type) { U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK; - BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT; - BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR; - BOOL reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR + bool sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT; + bool sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR; + bool reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR S32 sizeS = mPathp->mPath.size(); S32 sizeT = mProfilep->mProfile.size(); @@ -3133,14 +3110,13 @@ void LLVolume::sculptGenerateMapVertices(U16 sculpt_width, U16 sculpt_height, S8 } -const S32 SCULPT_REZ_1 = 6; // changed from 4 to 6 - 6 looks round whereas 4 looks square -const S32 SCULPT_REZ_2 = 8; -const S32 SCULPT_REZ_3 = 16; -const S32 SCULPT_REZ_4 = 32; +constexpr S32 SCULPT_REZ_1 = 6; // changed from 4 to 6 - 6 looks round whereas 4 looks square +constexpr S32 SCULPT_REZ_2 = 8; +constexpr S32 SCULPT_REZ_3 = 16; +constexpr S32 SCULPT_REZ_4 = 32; S32 sculpt_sides(F32 detail) { - // detail is usually one of: 1, 1.5, 2.5, 4.0. if (detail <= 1.0) @@ -3203,12 +3179,12 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, { U8 sculpt_type = mParams.getSculptType(); - BOOL data_is_empty = FALSE; + bool data_is_empty = false; if (sculpt_width == 0 || sculpt_height == 0 || sculpt_components < 3 || sculpt_data == NULL) { sculpt_level = -1; - data_is_empty = TRUE; + data_is_empty = true; } S32 requested_sizeS = 0; @@ -3216,8 +3192,8 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, sculpt_calc_mesh_resolution(sculpt_width, sculpt_height, sculpt_type, mDetail, requested_sizeS, requested_sizeT); - mPathp->generate(mParams.getPathParams(), mDetail, 0, TRUE, requested_sizeS); - mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(), mDetail, 0, TRUE, requested_sizeT); + mPathp->generate(mParams.getPathParams(), mDetail, 0, true, requested_sizeS); + mProfilep->generate(mParams.getProfileParams(), mPathp->isOpen(), mDetail, 0, true, requested_sizeT); S32 sizeS = mPathp->mPath.size(); // we requested a specific size, now see what we really got S32 sizeT = mProfilep->mProfile.size(); // we requested a specific size, now see what we really got @@ -3248,7 +3224,7 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, if (area < SCULPT_MIN_AREA || area > SCULPT_MAX_AREA) { - data_is_empty = TRUE; + data_is_empty = true; visible_placeholder = true; } } @@ -3267,8 +3243,6 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, } } - - for (S32 i = 0; i < (S32)mProfilep->mFaces.size(); i++) { mFaceMask |= mProfilep->mFaces[i].mFaceID; @@ -3285,12 +3259,12 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, -BOOL LLVolume::isCap(S32 face) +bool LLVolume::isCap(S32 face) { return mProfilep->mFaces[face].mCap; } -BOOL LLVolume::isFlat(S32 face) +bool LLVolume::isFlat(S32 face) { return mProfilep->mFaces[face].mFlat; } @@ -3353,7 +3327,7 @@ void LLVolumeParams::copyParams(const LLVolumeParams ¶ms) } // Less restricitve approx 0 for volumes -const F32 APPROXIMATELY_ZERO = 0.001f; +constexpr F32 APPROXIMATELY_ZERO = 0.001f; bool approx_zero( F32 f, F32 tolerance = APPROXIMATELY_ZERO) { return (f >= -tolerance) && (f <= tolerance); @@ -3609,7 +3583,7 @@ bool LLVolumeParams::setSkew(const F32 skew_value) return valid; } -bool LLVolumeParams::setSculptID(const LLUUID sculpt_id, U8 sculpt_type) +bool LLVolumeParams::setSculptID(const LLUUID& sculpt_id, U8 sculpt_type) { mSculptID = sculpt_id; mSculptType = sculpt_type; @@ -3804,7 +3778,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, LLVector4a* v = (LLVector4a*)face.mPositions; LLVector4a* n = (LLVector4a*)face.mNormals; - for (U32 j = 0; j < face.mNumIndices / 3; j++) + for (S32 j = 0; j < face.mNumIndices / 3; j++) { for (S32 k = 0; k < 3; k++) { @@ -3839,7 +3813,6 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, } else { - //============================================== //DEBUG draw edge map instead of silhouette edge //============================================== @@ -3921,8 +3894,8 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, //DEBUG //============================================== - static const U8 AWAY = 0x01, - TOWARDS = 0x02; + constexpr U8 AWAY = 0x01, + TOWARDS = 0x02; //for each triangle std::vector<U8> fFacing; @@ -3931,7 +3904,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, LLVector4a* v = (LLVector4a*) face.mPositions; LLVector4a* n = (LLVector4a*) face.mNormals; - for (U32 j = 0; j < face.mNumIndices/3; j++) + for (S32 j = 0; j < face.mNumIndices/3; j++) { //approximate normal S32 v1 = face.mIndices[j*3+0]; @@ -3968,7 +3941,7 @@ void LLVolume::generateSilhouetteVertices(std::vector<LLVector3> &vertices, } //for each triangle - for (U32 j = 0; j < face.mNumIndices/3; j++) + for (S32 j = 0; j < face.mNumIndices/3; j++) { if (fFacing[j] == (AWAY | TOWARDS)) { //this is a degenerate triangle @@ -4192,7 +4165,7 @@ LLVertexIndexPair::LLVertexIndexPair(const LLVector3 &vertex, const S32 index) mIndex = index; } -const F32 VERTEX_SLOP = 0.00001f; +constexpr F32 VERTEX_SLOP = 0.00001f; struct lessVertex { @@ -4202,32 +4175,32 @@ struct lessVertex if (a->mVertex.mV[0] + slop < b->mVertex.mV[0]) { - return TRUE; + return true; } else if (a->mVertex.mV[0] - slop > b->mVertex.mV[0]) { - return FALSE; + return false; } if (a->mVertex.mV[1] + slop < b->mVertex.mV[1]) { - return TRUE; + return true; } else if (a->mVertex.mV[1] - slop > b->mVertex.mV[1]) { - return FALSE; + return false; } if (a->mVertex.mV[2] + slop < b->mVertex.mV[2]) { - return TRUE; + return true; } else if (a->mVertex.mV[2] - slop > b->mVertex.mV[2]) { - return FALSE; + return false; } - return FALSE; + return false; } }; @@ -4237,45 +4210,45 @@ struct lessTriangle { if (*a < *b) { - return TRUE; + return true; } else if (*a > *b) { - return FALSE; + return false; } if (*(a+1) < *(b+1)) { - return TRUE; + return true; } else if (*(a+1) > *(b+1)) { - return FALSE; + return false; } if (*(a+2) < *(b+2)) { - return TRUE; + return true; } else if (*(a+2) > *(b+2)) { - return FALSE; + return false; } - return FALSE; + return false; } }; -BOOL equalTriangle(const S32 *a, const S32 *b) +bool equalTriangle(const S32 *a, const S32 *b) { if ((*a == *b) && (*(a+1) == *(b+1)) && (*(a+2) == *(b+2))) { - return TRUE; + return true; } - return FALSE; + return false; } -BOOL LLVolumeParams::importFile(LLFILE *fp) +bool LLVolumeParams::importFile(LLFILE *fp) { //LL_INFOS() << "importing volume" << LL_ENDL; const S32 BUFSIZE = 16384; @@ -4315,21 +4288,21 @@ BOOL LLVolumeParams::importFile(LLFILE *fp) } } - return TRUE; + return true; } -BOOL LLVolumeParams::exportFile(LLFILE *fp) const +bool LLVolumeParams::exportFile(LLFILE *fp) const { fprintf(fp,"\tshape 0\n"); fprintf(fp,"\t{\n"); mPathParams.exportFile(fp); mProfileParams.exportFile(fp); fprintf(fp, "\t}\n"); - return TRUE; + return true; } -BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream) +bool LLVolumeParams::importLegacyStream(std::istream& input_stream) { //LL_INFOS() << "importing volume" << LL_ENDL; const S32 BUFSIZE = 16384; @@ -4365,17 +4338,17 @@ BOOL LLVolumeParams::importLegacyStream(std::istream& input_stream) } } - return TRUE; + return true; } -BOOL LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const +bool LLVolumeParams::exportLegacyStream(std::ostream& output_stream) const { output_stream <<"\tshape 0\n"; output_stream <<"\t{\n"; mPathParams.exportLegacyStream(output_stream); mProfileParams.exportLegacyStream(output_stream); output_stream << "\t}\n"; - return TRUE; + return true; } LLSD LLVolumeParams::sculptAsLLSD() const @@ -4447,14 +4420,14 @@ void LLVolumeParams::reduceT(F32 begin, F32 end) const F32 MIN_CONCAVE_PROFILE_WEDGE = 0.125f; // 1/8 unity const F32 MIN_CONCAVE_PATH_WEDGE = 0.111111f; // 1/9 unity -// returns TRUE if the shape can be approximated with a convex shape +// returns true if the shape can be approximated with a convex shape // for collison purposes -BOOL LLVolumeParams::isConvex() const +bool LLVolumeParams::isConvex() const { if (!getSculptID().isNull()) { // can't determine, be safe and say no: - return FALSE; + return false; } F32 path_length = mPathParams.getEnd() - mPathParams.getBegin(); @@ -4467,11 +4440,11 @@ BOOL LLVolumeParams::isConvex() const && LL_PCODE_PATH_LINE != path_type) ) ) { // twist along a "not too short" path is concave - return FALSE; + return false; } F32 profile_length = mProfileParams.getEnd() - mProfileParams.getBegin(); - BOOL same_hole = hollow == 0.f + bool same_hole = hollow == 0.f || (mProfileParams.getCurveType() & LL_PCODE_HOLE_MASK) == LL_PCODE_HOLE_SAME; F32 min_profile_wedge = MIN_CONCAVE_PROFILE_WEDGE; @@ -4482,7 +4455,7 @@ BOOL LLVolumeParams::isConvex() const min_profile_wedge = 2.f * MIN_CONCAVE_PROFILE_WEDGE; } - BOOL convex_profile = ( ( profile_length == 1.f + bool convex_profile = ( ( profile_length == 1.f || profile_length <= 0.5f ) && hollow == 0.f ) // trivially convex || ( profile_length <= min_profile_wedge @@ -4491,36 +4464,36 @@ BOOL LLVolumeParams::isConvex() const if (!convex_profile) { // profile is concave - return FALSE; + return false; } if ( LL_PCODE_PATH_LINE == path_type ) { // straight paths with convex profile - return TRUE; + return true; } - BOOL concave_path = (path_length < 1.0f) && (path_length > 0.5f); + bool concave_path = (path_length < 1.0f) && (path_length > 0.5f); if (concave_path) { - return FALSE; + return false; } // we're left with spheres, toroids and tubes if ( LL_PCODE_PROFILE_CIRCLE_HALF == profile_type ) { // at this stage all spheres must be convex - return TRUE; + return true; } // it's a toroid or tube if ( path_length <= MIN_CONCAVE_PATH_WEDGE ) { // effectively convex - return TRUE; + return true; } - return FALSE; + return false; } // debug @@ -4598,7 +4571,7 @@ LLFaceID LLVolume::generateFaceMask() return new_mask; } -BOOL LLVolume::isFaceMaskValid(LLFaceID face_mask) +bool LLVolume::isFaceMaskValid(LLFaceID face_mask) { LLFaceID test_mask = 0; for(S32 i = 0; i < getNumFaces(); i++) @@ -4609,9 +4582,9 @@ BOOL LLVolume::isFaceMaskValid(LLFaceID face_mask) return test_mask == face_mask; } -BOOL LLVolume::isConvex() const +bool LLVolume::isConvex() const { - // mParams.isConvex() may return FALSE even though the final + // mParams.isConvex() may return false even though the final // geometry is actually convex due to LOD approximations. // TODO -- provide LLPath and LLProfile with isConvex() methods // that correctly determine convexity. -- Leviathan @@ -4717,10 +4690,10 @@ LLVolumeFace::LLVolumeFace() : mJustWeights(NULL), mJointIndices(NULL), #endif - mWeightsScrubbed(FALSE), + mWeightsScrubbed(false), mOctree(NULL), mOctreeTriangles(NULL), - mOptimized(FALSE) + mOptimized(false) { mExtents = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*3); mExtents[0].splat(-0.5f); @@ -4748,7 +4721,7 @@ LLVolumeFace::LLVolumeFace(const LLVolumeFace& src) mJustWeights(NULL), mJointIndices(NULL), #endif - mWeightsScrubbed(FALSE), + mWeightsScrubbed(false), mOctree(NULL), mOctreeTriangles(NULL) { @@ -4822,7 +4795,7 @@ LLVolumeFace& LLVolumeFace::operator=(const LLVolumeFace& src) { ll_aligned_free_16(mWeights); mWeights = NULL; - mWeightsScrubbed = FALSE; + mWeightsScrubbed = false; } #if USE_SEPARATE_JOINT_INDICES_AND_WEIGHTS @@ -4895,7 +4868,7 @@ void LLVolumeFace::freeData() destroyOctree(); } -BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build) +bool LLVolumeFace::create(LLVolume* volume, bool partial_build) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME @@ -4903,7 +4876,7 @@ BOOL LLVolumeFace::create(LLVolume* volume, BOOL partial_build) destroyOctree(); LL_CHECK_MEMORY - BOOL ret = FALSE ; + bool ret = false ; if (mTypeMask & CAP_MASK) { ret = createCap(volume, partial_build); @@ -4970,13 +4943,13 @@ void LLVolumeFace::remap() { // Generate a remap buffer std::vector<unsigned int> remap(mNumVertices); - S32 remap_vertices_count = LLMeshOptimizer::generateRemapMultiU16(&remap[0], + S32 remap_vertices_count = static_cast<S32>(LLMeshOptimizer::generateRemapMultiU16(&remap[0], mIndices, mNumIndices, mPositions, mNormals, mTexCoords, - mNumVertices); + mNumVertices)); // Allocate new buffers S32 size = ((mNumIndices * sizeof(U16)) + 0xF) & ~0xF; @@ -5021,7 +4994,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff) range.setSub(mExtents[1],mExtents[0]); //remove redundant vertices - for (U32 i = 0; i < mNumIndices; ++i) + for (S32 i = 0; i < mNumIndices; ++i) { U16 index = mIndices[i]; @@ -5039,7 +5012,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff) LLVolumeFace::VertexData cv; getVertexData(index, cv); - BOOL found = FALSE; + bool found = false; LLVector4a pos; pos.setSub(mPositions[index], mExtents[0]); @@ -5060,7 +5033,7 @@ void LLVolumeFace::optimize(F32 angle_cutoff) LLVolumeFace::VertexData& tv = (point_iter->second)[j]; if (tv.compareNormal(cv, angle_cutoff)) { - found = TRUE; + found = true; new_face.pushIndex((point_iter->second)[j].mIndex); break; } @@ -5167,12 +5140,12 @@ public: } }; -const F64 FindVertexScore_CacheDecayPower = 1.5; -const F64 FindVertexScore_LastTriScore = 0.75; -const F64 FindVertexScore_ValenceBoostScale = 2.0; -const F64 FindVertexScore_ValenceBoostPower = 0.5; -const U32 MaxSizeVertexCache = 32; -const F64 FindVertexScore_Scaler = 1.0/(MaxSizeVertexCache-3); +constexpr F64 FindVertexScore_CacheDecayPower = 1.5; +constexpr F64 FindVertexScore_LastTriScore = 0.75; +constexpr F64 FindVertexScore_ValenceBoostScale = 2.0; +constexpr F64 FindVertexScore_ValenceBoostPower = 0.5; +constexpr U32 MaxSizeVertexCache = 32; +constexpr F64 FindVertexScore_Scaler = 1.0/(MaxSizeVertexCache-3); F64 find_vertex_score(LLVCacheVertexData& data) { @@ -5407,7 +5380,7 @@ struct MikktData LLVector3 inv_scale(1.f / face->mNormalizedScale.mV[0], 1.f / face->mNormalizedScale.mV[1], 1.f / face->mNormalizedScale.mV[2]); - for (int i = 0; i < face->mNumIndices; ++i) + for (S32 i = 0; i < face->mNumIndices; ++i) { U32 idx = face->mIndices[i]; @@ -5418,17 +5391,6 @@ struct MikktData n[i].normalize(); tc[i].set(face->mTexCoords[idx]); - if (idx >= face->mNumVertices) - { - // invalid index - // replace with a valid index to avoid crashes - idx = face->mNumVertices - 1; - face->mIndices[i] = idx; - - // Needs better logging - LL_DEBUGS_ONCE("LLVOLUME") << "Invalid index, substituting" << LL_ENDL; - } - if (face->mWeights) { w[i].set(face->mWeights[idx].getF32ptr()); @@ -5475,7 +5437,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) { //optimize for vertex cache according to Forsyth method: LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; llassert(!mOptimized); - mOptimized = TRUE; + mOptimized = true; if (gen_tangents && mNormals && mTexCoords) { // generate mikkt space tangents before cache optimizing since the index buffer may change @@ -5500,7 +5462,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) U32 stream_count = data.w.empty() ? 4 : 5; - size_t vert_count = meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count); + S32 vert_count = static_cast<S32>(meshopt_generateVertexRemapMulti(&remap[0], nullptr, data.p.size(), data.p.size(), mos, stream_count)); if (vert_count < 65535 && vert_count != 0) { @@ -5514,11 +5476,11 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) allocateTangents(mNumVertices); - for (int i = 0; i < mNumIndices; ++i) + for (S32 i = 0; i < mNumIndices; ++i) { U32 src_idx = i; U32 dst_idx = remap[i]; - if (dst_idx >= mNumVertices) + if (dst_idx >= (U32)mNumVertices) { dst_idx = mNumVertices - 1; // Shouldn't happen, figure out what gets returned in remap and why. @@ -5545,7 +5507,7 @@ bool LLVolumeFace::cacheOptimize(bool gen_tangents) scale.load3(mNormalizedScale.mV); scale.getF32ptr()[3] = 1.f; - for (int i = 0; i < mNumVertices; ++i) + for (S32 i = 0; i < mNumVertices; ++i) { mPositions[i].mul(inv_scale); mNormals[i].mul(scale); @@ -5706,7 +5668,7 @@ void LerpPlanarVertex(LLVolumeFace::VertexData& v0, vout.setNormal(v0.getNormal()); } -BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) +bool LLVolumeFace::createUnCutCubeCap(LLVolume* volume, bool partial_build) { LL_CHECK_MEMORY @@ -5938,11 +5900,11 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) } LL_CHECK_MEMORY - return TRUE; + return true; } -BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) +bool LLVolumeFace::createCap(LLVolume* volume, bool partial_build) { if (!(mTypeMask & HOLLOW_MASK) && !(mTypeMask & OPEN_MASK) && @@ -6099,7 +6061,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) //if (partial_build) //{ - // return TRUE; + // return true; //} if (mTypeMask & HOLLOW_MASK) @@ -6148,36 +6110,36 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) (paV[0]*pbV[1] - pbV[0]*paV[1]) + (pbV[0]*p2V[1] - p2V[0]*pbV[1]); - BOOL use_tri1a2 = TRUE; - BOOL tri_1a2 = TRUE; - BOOL tri_21b = TRUE; + bool use_tri1a2 = true; + bool tri_1a2 = true; + bool tri_21b = true; if (area_1a2 < 0) { - tri_1a2 = FALSE; + tri_1a2 = false; } if (area_2ab < 0) { // Can't use, because it contains point b - tri_1a2 = FALSE; + tri_1a2 = false; } if (area_21b < 0) { - tri_21b = FALSE; + tri_21b = false; } if (area_1ba < 0) { // Can't use, because it contains point b - tri_21b = FALSE; + tri_21b = false; } if (!tri_1a2) { - use_tri1a2 = FALSE; + use_tri1a2 = false; } else if (!tri_21b) { - use_tri1a2 = TRUE; + use_tri1a2 = true; } else { @@ -6189,11 +6151,11 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) if (d1.dot3(d1) < d2.dot3(d2)) { - use_tri1a2 = TRUE; + use_tri1a2 = true; } else { - use_tri1a2 = FALSE; + use_tri1a2 = false; } } @@ -6254,36 +6216,36 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) (paV[0]*pbV[1] - pbV[0]*paV[1]) + (pbV[0]*p2V[1] - p2V[0]*pbV[1]); - BOOL use_tri1a2 = TRUE; - BOOL tri_1a2 = TRUE; - BOOL tri_21b = TRUE; + bool use_tri1a2 = true; + bool tri_1a2 = true; + bool tri_21b = true; if (area_1a2 < 0) { - tri_1a2 = FALSE; + tri_1a2 = false; } if (area_2ab < 0) { // Can't use, because it contains point b - tri_1a2 = FALSE; + tri_1a2 = false; } if (area_21b < 0) { - tri_21b = FALSE; + tri_21b = false; } if (area_1ba < 0) { // Can't use, because it contains point b - tri_21b = FALSE; + tri_21b = false; } if (!tri_1a2) { - use_tri1a2 = FALSE; + use_tri1a2 = false; } else if (!tri_21b) { - use_tri1a2 = TRUE; + use_tri1a2 = true; } else { @@ -6294,11 +6256,11 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) if (d1.dot3(d1) < d2.dot3(d2)) { - use_tri1a2 = TRUE; + use_tri1a2 = true; } else { - use_tri1a2 = FALSE; + use_tri1a2 = false; } } @@ -6377,7 +6339,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) norm[i].load4a(normal.getF32ptr()); } - return TRUE; + return true; } void LLVolumeFace::createTangents() @@ -6400,7 +6362,7 @@ void LLVolumeFace::createTangents() LLCalculateTangentArray(mNumVertices, mPositions, mNormals, mTexCoords, mNumIndices / 3, mIndices, mTangents); //normalize normals - for (U32 i = 0; i < mNumVertices; i++) + for (S32 i = 0; i < mNumVertices; i++) { //bump map/planar projection code requires normals to be normalized mNormals[i].normalize3fast(); @@ -6576,8 +6538,8 @@ void LLVolumeFace::pushIndex(const U16& idx) void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, std::vector<U16>& idx) { - resizeVertices(v.size()); - resizeIndices(idx.size()); + resizeVertices(static_cast<S32>(v.size())); + resizeIndices(static_cast<S32>(idx.size())); for (U32 i = 0; i < v.size(); ++i) { @@ -6592,18 +6554,18 @@ void LLVolumeFace::fillFromLegacyData(std::vector<LLVolumeFace::VertexData>& v, } } -BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) +bool LLVolumeFace::createSide(LLVolume* volume, bool partial_build) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME LL_CHECK_MEMORY - BOOL flat = mTypeMask & FLAT_MASK; + bool flat = mTypeMask & FLAT_MASK; U8 sculpt_type = volume->getParams().getSculptType(); U8 sculpt_stitching = sculpt_type & LL_SCULPT_TYPE_MASK; - BOOL sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT; - BOOL sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR; - BOOL sculpt_reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR + bool sculpt_invert = sculpt_type & LL_SCULPT_FLAG_INVERT; + bool sculpt_mirror = sculpt_type & LL_SCULPT_FLAG_MIRROR; + bool sculpt_reverse_horizontal = (sculpt_invert ? !sculpt_mirror : sculpt_mirror); // XOR S32 num_vertices, num_indices; @@ -6619,7 +6581,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) num_vertices = mNumS*mNumT; num_indices = (mNumS-1)*(mNumT-1)*6; - partial_build = (num_vertices > mNumVertices || num_indices > mNumIndices) ? FALSE : partial_build; + partial_build = (num_vertices > mNumVertices || num_indices > mNumIndices) ? false : partial_build; if (!partial_build) { @@ -6672,7 +6634,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) { // Get s value for tex-coord. S32 index = mBeginS + s; - if (index >= profile.size()) + if (index >= (S32)profile.size()) { // edge? ss = flat ? 1.f - begin_stex : 1.f; @@ -6790,7 +6752,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) S32 cur_index = 0; S32 cur_edge = 0; - BOOL flat_face = mTypeMask & FLAT_MASK; + bool flat_face = mTypeMask & FLAT_MASK; if (!partial_build) { @@ -6806,45 +6768,63 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) mIndices[cur_index++] = s+1 + mNumS*t; //bottom right mIndices[cur_index++] = s+1 + mNumS*(t+1); //top right - mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1; //bottom left/top right neighbor face - if (t < mNumT-2) { //top right/top left neighbor face + // bottom left/top right neighbor face + mEdge[cur_edge++] = (mNumS-1)*2*t+s*2+1; + + if (t < mNumT-2) + { // top right/top left neighbor face mEdge[cur_edge++] = (mNumS-1)*2*(t+1)+s*2+1; } - else if (mNumT <= 3 || volume->getPath().isOpen() == TRUE) { //no neighbor + else if (mNumT <= 3 || volume->getPath().isOpen()) + { // no neighbor mEdge[cur_edge++] = -1; } - else { //wrap on T + else + { // wrap on T mEdge[cur_edge++] = s*2+1; } - if (s > 0) { //top left/bottom left neighbor face + + if (s > 0) + { // top left/bottom left neighbor face mEdge[cur_edge++] = (mNumS-1)*2*t+s*2-1; } - else if (flat_face || volume->getProfile().isOpen() == TRUE) { //no neighbor + else if (flat_face || volume->getProfile().isOpen()) + { // no neighbor mEdge[cur_edge++] = -1; } - else { //wrap on S + else + { // wrap on S mEdge[cur_edge++] = (mNumS-1)*2*t+(mNumS-2)*2+1; } - if (t > 0) { //bottom left/bottom right neighbor face + if (t > 0) + { // bottom left/bottom right neighbor face mEdge[cur_edge++] = (mNumS-1)*2*(t-1)+s*2; } - else if (mNumT <= 3 || volume->getPath().isOpen() == TRUE) { //no neighbor + else if (mNumT <= 3 || volume->getPath().isOpen()) + { // no neighbor mEdge[cur_edge++] = -1; } - else { //wrap on T + else + { // wrap on T mEdge[cur_edge++] = (mNumS-1)*2*(mNumT-2)+s*2; } - if (s < mNumS-2) { //bottom right/top right neighbor face + + if (s < mNumS-2) + { // bottom right/top right neighbor face mEdge[cur_edge++] = (mNumS-1)*2*t+(s+1)*2; } - else if (flat_face || volume->getProfile().isOpen() == TRUE) { //no neighbor + else if (flat_face || volume->getProfile().isOpen()) + { // no neighbor mEdge[cur_edge++] = -1; } - else { //wrap on S + else + { // wrap on S mEdge[cur_edge++] = (mNumS-1)*2*t; } - mEdge[cur_edge++] = (mNumS-1)*2*t+s*2; //top right/bottom left neighbor face + + // top right/bottom left neighbor face + mEdge[cur_edge++] = (mNumS-1)*2*t+s*2; } } } @@ -6974,14 +6954,14 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) LLVector4a top; top.setSub(pos[0], pos[mNumS*(mNumT-2)]); - BOOL s_bottom_converges = (top.dot3(top) < 0.000001f); + bool s_bottom_converges = (top.dot3(top) < 0.000001f); top.setSub(pos[mNumS-1], pos[mNumS*(mNumT-2)+mNumS-1]); - BOOL s_top_converges = (top.dot3(top) < 0.000001f); + bool s_top_converges = (top.dot3(top) < 0.000001f); if (sculpt_stitching == LL_SCULPT_TYPE_NONE) // logic for non-sculpt volumes { - if (volume->getPath().isOpen() == FALSE) + if (!volume->getPath().isOpen()) { //wrap normals on T for (S32 i = 0; i < mNumS; i++) { @@ -6992,7 +6972,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } } - if ((volume->getProfile().isOpen() == FALSE) && !(s_bottom_converges)) + if (!volume->getProfile().isOpen() && !s_bottom_converges) { //wrap normals on S for (S32 i = 0; i < mNumT; i++) { @@ -7025,20 +7005,20 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } else // logic for sculpt volumes { - BOOL average_poles = FALSE; - BOOL wrap_s = FALSE; - BOOL wrap_t = FALSE; + bool average_poles = false; + bool wrap_s = false; + bool wrap_t = false; if (sculpt_stitching == LL_SCULPT_TYPE_SPHERE) - average_poles = TRUE; + average_poles = true; if ((sculpt_stitching == LL_SCULPT_TYPE_SPHERE) || (sculpt_stitching == LL_SCULPT_TYPE_TORUS) || (sculpt_stitching == LL_SCULPT_TYPE_CYLINDER)) - wrap_s = TRUE; + wrap_s = true; if (sculpt_stitching == LL_SCULPT_TYPE_TORUS) - wrap_t = TRUE; + wrap_t = true; if (average_poles) @@ -7103,7 +7083,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) LL_CHECK_MEMORY - return TRUE; + return true; } //adapted from Lengyel, Eric. "Computing Tangent Space Basis Vectors for an Arbitrary Mesh". Terathon Software 3D Graphics Library, 2001. http://www.terathon.com/code/tangent.html diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h index d53ca2a4b3..bbb2a16b0b 100644 --- a/indra/llmath/llvolume.h +++ b/indra/llmath/llvolume.h @@ -63,146 +63,148 @@ class LLVolumeOctree; //============================================================================ -const S32 MIN_DETAIL_FACES = 6; -const S32 MIN_LOD = 0; -const S32 MAX_LOD = 3; +constexpr S32 MIN_DETAIL_FACES = 6; +constexpr S32 MIN_LOD = 0; +constexpr S32 MAX_LOD = 3; // These are defined here but are not enforced at this level, // rather they are here for the convenience of code that uses // the LLVolume class. -const F32 MIN_VOLUME_PROFILE_WIDTH = 0.05f; -const F32 MIN_VOLUME_PATH_WIDTH = 0.05f; +constexpr F32 MIN_VOLUME_PROFILE_WIDTH = 0.05f; +constexpr F32 MIN_VOLUME_PATH_WIDTH = 0.05f; -const F32 CUT_QUANTA = 0.00002f; -const F32 SCALE_QUANTA = 0.01f; -const F32 SHEAR_QUANTA = 0.01f; -const F32 TAPER_QUANTA = 0.01f; -const F32 REV_QUANTA = 0.015f; -const F32 HOLLOW_QUANTA = 0.00002f; +constexpr F32 CUT_QUANTA = 0.00002f; +constexpr F32 SCALE_QUANTA = 0.01f; +constexpr F32 SHEAR_QUANTA = 0.01f; +constexpr F32 TAPER_QUANTA = 0.01f; +constexpr F32 REV_QUANTA = 0.015f; +constexpr F32 HOLLOW_QUANTA = 0.00002f; -const S32 MAX_VOLUME_TRIANGLE_INDICES = 10000; +constexpr S32 MAX_VOLUME_TRIANGLE_INDICES = 10000; //============================================================================ // useful masks -const LLPCode LL_PCODE_HOLLOW_MASK = 0x80; // has a thickness -const LLPCode LL_PCODE_SEGMENT_MASK = 0x40; // segments (1 angle) -const LLPCode LL_PCODE_PATCH_MASK = 0x20; // segmented segments (2 angles) -const LLPCode LL_PCODE_HEMI_MASK = 0x10; // half-primitives get their own type per PR's dictum -const LLPCode LL_PCODE_BASE_MASK = 0x0F; +constexpr LLPCode LL_PCODE_HOLLOW_MASK = 0x80; // has a thickness +constexpr LLPCode LL_PCODE_SEGMENT_MASK = 0x40; // segments (1 angle) +constexpr LLPCode LL_PCODE_PATCH_MASK = 0x20; // segmented segments (2 angles) +constexpr LLPCode LL_PCODE_HEMI_MASK = 0x10; // half-primitives get their own type per PR's dictum +constexpr LLPCode LL_PCODE_BASE_MASK = 0x0F; // primitive shapes -const LLPCode LL_PCODE_CUBE = 1; -const LLPCode LL_PCODE_PRISM = 2; -const LLPCode LL_PCODE_TETRAHEDRON = 3; -const LLPCode LL_PCODE_PYRAMID = 4; -const LLPCode LL_PCODE_CYLINDER = 5; -const LLPCode LL_PCODE_CONE = 6; -const LLPCode LL_PCODE_SPHERE = 7; -const LLPCode LL_PCODE_TORUS = 8; -const LLPCode LL_PCODE_VOLUME = 9; +constexpr LLPCode LL_PCODE_CUBE = 1; +constexpr LLPCode LL_PCODE_PRISM = 2; +constexpr LLPCode LL_PCODE_TETRAHEDRON = 3; +constexpr LLPCode LL_PCODE_PYRAMID = 4; +constexpr LLPCode LL_PCODE_CYLINDER = 5; +constexpr LLPCode LL_PCODE_CONE = 6; +constexpr LLPCode LL_PCODE_SPHERE = 7; +constexpr LLPCode LL_PCODE_TORUS = 8; +constexpr LLPCode LL_PCODE_VOLUME = 9; // surfaces -//const LLPCode LL_PCODE_SURFACE_TRIANGLE = 10; -//const LLPCode LL_PCODE_SURFACE_SQUARE = 11; -//const LLPCode LL_PCODE_SURFACE_DISC = 12; +//constexpr LLPCode LL_PCODE_SURFACE_TRIANGLE = 10; +//constexpr LLPCode LL_PCODE_SURFACE_SQUARE = 11; +//constexpr LLPCode LL_PCODE_SURFACE_DISC = 12; -const LLPCode LL_PCODE_APP = 14; // App specific pcode (for viewer/sim side only objects) -const LLPCode LL_PCODE_LEGACY = 15; +constexpr LLPCode LL_PCODE_APP = 14; // App specific pcode (for viewer/sim side only objects) +constexpr LLPCode LL_PCODE_LEGACY = 15; // Pcodes for legacy objects -//const LLPCode LL_PCODE_LEGACY_ATOR = 0x10 | LL_PCODE_LEGACY; // ATOR -const LLPCode LL_PCODE_LEGACY_AVATAR = 0x20 | LL_PCODE_LEGACY; // PLAYER -//const LLPCode LL_PCODE_LEGACY_BIRD = 0x30 | LL_PCODE_LEGACY; // BIRD -//const LLPCode LL_PCODE_LEGACY_DEMON = 0x40 | LL_PCODE_LEGACY; // DEMON -const LLPCode LL_PCODE_LEGACY_GRASS = 0x50 | LL_PCODE_LEGACY; // GRASS -const LLPCode LL_PCODE_TREE_NEW = 0x60 | LL_PCODE_LEGACY; // new trees -//const LLPCode LL_PCODE_LEGACY_ORACLE = 0x70 | LL_PCODE_LEGACY; // ORACLE -const LLPCode LL_PCODE_LEGACY_PART_SYS = 0x80 | LL_PCODE_LEGACY; // PART_SYS -const LLPCode LL_PCODE_LEGACY_ROCK = 0x90 | LL_PCODE_LEGACY; // ROCK -//const LLPCode LL_PCODE_LEGACY_SHOT = 0xA0 | LL_PCODE_LEGACY; // BASIC_SHOT -//const LLPCode LL_PCODE_LEGACY_SHOT_BIG = 0xB0 | LL_PCODE_LEGACY; -//const LLPCode LL_PCODE_LEGACY_SMOKE = 0xC0 | LL_PCODE_LEGACY; // SMOKE -//const LLPCode LL_PCODE_LEGACY_SPARK = 0xD0 | LL_PCODE_LEGACY;// SPARK -const LLPCode LL_PCODE_LEGACY_TEXT_BUBBLE = 0xE0 | LL_PCODE_LEGACY; // TEXTBUBBLE -const LLPCode LL_PCODE_LEGACY_TREE = 0xF0 | LL_PCODE_LEGACY; // TREE +//constexpr LLPCode LL_PCODE_LEGACY_ATOR = 0x10 | LL_PCODE_LEGACY; // ATOR +constexpr LLPCode LL_PCODE_LEGACY_AVATAR = 0x20 | LL_PCODE_LEGACY; // PLAYER +//constexpr LLPCode LL_PCODE_LEGACY_BIRD = 0x30 | LL_PCODE_LEGACY; // BIRD +//constexpr LLPCode LL_PCODE_LEGACY_DEMON = 0x40 | LL_PCODE_LEGACY; // DEMON +constexpr LLPCode LL_PCODE_LEGACY_GRASS = 0x50 | LL_PCODE_LEGACY; // GRASS +constexpr LLPCode LL_PCODE_TREE_NEW = 0x60 | LL_PCODE_LEGACY; // new trees +//constexpr LLPCode LL_PCODE_LEGACY_ORACLE = 0x70 | LL_PCODE_LEGACY; // ORACLE +constexpr LLPCode LL_PCODE_LEGACY_PART_SYS = 0x80 | LL_PCODE_LEGACY; // PART_SYS +constexpr LLPCode LL_PCODE_LEGACY_ROCK = 0x90 | LL_PCODE_LEGACY; // ROCK +//constexpr LLPCode LL_PCODE_LEGACY_SHOT = 0xA0 | LL_PCODE_LEGACY; // BASIC_SHOT +//constexpr LLPCode LL_PCODE_LEGACY_SHOT_BIG = 0xB0 | LL_PCODE_LEGACY; +//constexpr LLPCode LL_PCODE_LEGACY_SMOKE = 0xC0 | LL_PCODE_LEGACY; // SMOKE +//constexpr LLPCode LL_PCODE_LEGACY_SPARK = 0xD0 | LL_PCODE_LEGACY;// SPARK +constexpr LLPCode LL_PCODE_LEGACY_TEXT_BUBBLE = 0xE0 | LL_PCODE_LEGACY; // TEXTBUBBLE +constexpr LLPCode LL_PCODE_LEGACY_TREE = 0xF0 | LL_PCODE_LEGACY; // TREE // hemis -const LLPCode LL_PCODE_CYLINDER_HEMI = LL_PCODE_CYLINDER | LL_PCODE_HEMI_MASK; -const LLPCode LL_PCODE_CONE_HEMI = LL_PCODE_CONE | LL_PCODE_HEMI_MASK; -const LLPCode LL_PCODE_SPHERE_HEMI = LL_PCODE_SPHERE | LL_PCODE_HEMI_MASK; -const LLPCode LL_PCODE_TORUS_HEMI = LL_PCODE_TORUS | LL_PCODE_HEMI_MASK; +constexpr LLPCode LL_PCODE_CYLINDER_HEMI = LL_PCODE_CYLINDER | LL_PCODE_HEMI_MASK; +constexpr LLPCode LL_PCODE_CONE_HEMI = LL_PCODE_CONE | LL_PCODE_HEMI_MASK; +constexpr LLPCode LL_PCODE_SPHERE_HEMI = LL_PCODE_SPHERE | LL_PCODE_HEMI_MASK; +constexpr LLPCode LL_PCODE_TORUS_HEMI = LL_PCODE_TORUS | LL_PCODE_HEMI_MASK; // Volumes consist of a profile at the base that is swept around // a path to make a volume. // The profile code -const U8 LL_PCODE_PROFILE_MASK = 0x0f; -const U8 LL_PCODE_PROFILE_MIN = 0x00; -const U8 LL_PCODE_PROFILE_CIRCLE = 0x00; -const U8 LL_PCODE_PROFILE_SQUARE = 0x01; -const U8 LL_PCODE_PROFILE_ISOTRI = 0x02; -const U8 LL_PCODE_PROFILE_EQUALTRI = 0x03; -const U8 LL_PCODE_PROFILE_RIGHTTRI = 0x04; -const U8 LL_PCODE_PROFILE_CIRCLE_HALF = 0x05; -const U8 LL_PCODE_PROFILE_MAX = 0x05; +constexpr U8 LL_PCODE_PROFILE_MASK = 0x0f; +constexpr U8 LL_PCODE_PROFILE_MIN = 0x00; +constexpr U8 LL_PCODE_PROFILE_CIRCLE = 0x00; +constexpr U8 LL_PCODE_PROFILE_SQUARE = 0x01; +constexpr U8 LL_PCODE_PROFILE_ISOTRI = 0x02; +constexpr U8 LL_PCODE_PROFILE_EQUALTRI = 0x03; +constexpr U8 LL_PCODE_PROFILE_RIGHTTRI = 0x04; +constexpr U8 LL_PCODE_PROFILE_CIRCLE_HALF = 0x05; +constexpr U8 LL_PCODE_PROFILE_MAX = 0x05; // Stored in the profile byte -const U8 LL_PCODE_HOLE_MASK = 0xf0; -const U8 LL_PCODE_HOLE_MIN = 0x00; -const U8 LL_PCODE_HOLE_SAME = 0x00; // same as outside profile -const U8 LL_PCODE_HOLE_CIRCLE = 0x10; -const U8 LL_PCODE_HOLE_SQUARE = 0x20; -const U8 LL_PCODE_HOLE_TRIANGLE = 0x30; -const U8 LL_PCODE_HOLE_MAX = 0x03; // min/max needs to be >> 4 of real min/max - -const U8 LL_PCODE_PATH_IGNORE = 0x00; -const U8 LL_PCODE_PATH_MIN = 0x01; // min/max needs to be >> 4 of real min/max -const U8 LL_PCODE_PATH_LINE = 0x10; -const U8 LL_PCODE_PATH_CIRCLE = 0x20; -const U8 LL_PCODE_PATH_CIRCLE2 = 0x30; -const U8 LL_PCODE_PATH_TEST = 0x40; -const U8 LL_PCODE_PATH_FLEXIBLE = 0x80; -const U8 LL_PCODE_PATH_MAX = 0x08; +constexpr U8 LL_PCODE_HOLE_MASK = 0xf0; +constexpr U8 LL_PCODE_HOLE_MIN = 0x00; +constexpr U8 LL_PCODE_HOLE_SAME = 0x00; // same as outside profile +constexpr U8 LL_PCODE_HOLE_CIRCLE = 0x10; +constexpr U8 LL_PCODE_HOLE_SQUARE = 0x20; +constexpr U8 LL_PCODE_HOLE_TRIANGLE = 0x30; +constexpr U8 LL_PCODE_HOLE_MAX = 0x03; // min/max needs to be >> 4 of real min/max + +constexpr U8 LL_PCODE_PATH_IGNORE = 0x00; +constexpr U8 LL_PCODE_PATH_MIN = 0x01; // min/max needs to be >> 4 of real min/max +constexpr U8 LL_PCODE_PATH_LINE = 0x10; +constexpr U8 LL_PCODE_PATH_CIRCLE = 0x20; +constexpr U8 LL_PCODE_PATH_CIRCLE2 = 0x30; +constexpr U8 LL_PCODE_PATH_TEST = 0x40; +constexpr U8 LL_PCODE_PATH_FLEXIBLE = 0x80; +constexpr U8 LL_PCODE_PATH_MAX = 0x08; //============================================================================ // face identifiers typedef U16 LLFaceID; -const LLFaceID LL_FACE_PATH_BEGIN = 0x1 << 0; -const LLFaceID LL_FACE_PATH_END = 0x1 << 1; -const LLFaceID LL_FACE_INNER_SIDE = 0x1 << 2; -const LLFaceID LL_FACE_PROFILE_BEGIN = 0x1 << 3; -const LLFaceID LL_FACE_PROFILE_END = 0x1 << 4; -const LLFaceID LL_FACE_OUTER_SIDE_0 = 0x1 << 5; -const LLFaceID LL_FACE_OUTER_SIDE_1 = 0x1 << 6; -const LLFaceID LL_FACE_OUTER_SIDE_2 = 0x1 << 7; -const LLFaceID LL_FACE_OUTER_SIDE_3 = 0x1 << 8; +constexpr LLFaceID LL_FACE_PATH_BEGIN = 0x1 << 0; +constexpr LLFaceID LL_FACE_PATH_END = 0x1 << 1; +constexpr LLFaceID LL_FACE_INNER_SIDE = 0x1 << 2; +constexpr LLFaceID LL_FACE_PROFILE_BEGIN = 0x1 << 3; +constexpr LLFaceID LL_FACE_PROFILE_END = 0x1 << 4; +constexpr LLFaceID LL_FACE_OUTER_SIDE_0 = 0x1 << 5; +constexpr LLFaceID LL_FACE_OUTER_SIDE_1 = 0x1 << 6; +constexpr LLFaceID LL_FACE_OUTER_SIDE_2 = 0x1 << 7; +constexpr LLFaceID LL_FACE_OUTER_SIDE_3 = 0x1 << 8; //============================================================================ // sculpt types + flags -const U8 LL_SCULPT_TYPE_NONE = 0; -const U8 LL_SCULPT_TYPE_SPHERE = 1; -const U8 LL_SCULPT_TYPE_TORUS = 2; -const U8 LL_SCULPT_TYPE_PLANE = 3; -const U8 LL_SCULPT_TYPE_CYLINDER = 4; -const U8 LL_SCULPT_TYPE_MESH = 5; -const U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | - LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH; +constexpr U8 LL_SCULPT_TYPE_NONE = 0; +constexpr U8 LL_SCULPT_TYPE_SPHERE = 1; +constexpr U8 LL_SCULPT_TYPE_TORUS = 2; +constexpr U8 LL_SCULPT_TYPE_PLANE = 3; +constexpr U8 LL_SCULPT_TYPE_CYLINDER = 4; +constexpr U8 LL_SCULPT_TYPE_MESH = 5; +constexpr U8 LL_SCULPT_TYPE_GLTF = 6; +constexpr U8 LL_SCULPT_TYPE_MAX = LL_SCULPT_TYPE_GLTF; + +constexpr U8 LL_SCULPT_TYPE_MASK = LL_SCULPT_TYPE_SPHERE | LL_SCULPT_TYPE_TORUS | LL_SCULPT_TYPE_PLANE | + LL_SCULPT_TYPE_CYLINDER | LL_SCULPT_TYPE_MESH | LL_SCULPT_TYPE_GLTF; // for value checks, assign new value after adding new types -const U8 LL_SCULPT_TYPE_MAX = LL_SCULPT_TYPE_MESH; -const U8 LL_SCULPT_FLAG_INVERT = 64; -const U8 LL_SCULPT_FLAG_MIRROR = 128; -const U8 LL_SCULPT_FLAG_MASK = LL_SCULPT_FLAG_INVERT | LL_SCULPT_FLAG_MIRROR; +constexpr U8 LL_SCULPT_FLAG_INVERT = 64; +constexpr U8 LL_SCULPT_FLAG_MIRROR = 128; +constexpr U8 LL_SCULPT_FLAG_MASK = LL_SCULPT_FLAG_INVERT | LL_SCULPT_FLAG_MIRROR; -const S32 LL_SCULPT_MESH_MAX_FACES = 8; +constexpr S32 LL_SCULPT_MESH_MAX_FACES = 8; -extern BOOL gDebugGL; +extern bool gDebugGL; class LLProfileParams { @@ -255,11 +257,11 @@ public: void copyParams(const LLProfileParams ¶ms); - BOOL importFile(LLFILE *fp); - BOOL exportFile(LLFILE *fp) const; + bool importFile(LLFILE *fp); + bool exportFile(LLFILE *fp) const; - BOOL importLegacyStream(std::istream& input_stream); - BOOL exportLegacyStream(std::ostream& output_stream) const; + bool importLegacyStream(std::istream& input_stream); + bool exportLegacyStream(std::ostream& output_stream) const; LLSD asLLSD() const; operator LLSD() const { return asLLSD(); } @@ -391,11 +393,11 @@ public: void copyParams(const LLPathParams ¶ms); - BOOL importFile(LLFILE *fp); - BOOL exportFile(LLFILE *fp) const; + bool importFile(LLFILE *fp); + bool exportFile(LLFILE *fp) const; - BOOL importLegacyStream(std::istream& input_stream); - BOOL exportLegacyStream(std::ostream& output_stream) const; + bool importLegacyStream(std::istream& input_stream); + bool exportLegacyStream(std::ostream& output_stream) const; LLSD asLLSD() const; operator LLSD() const { return asLLSD(); } @@ -583,11 +585,11 @@ public: const LLPathParams &getPathParams() const {return mPathParams;} LLPathParams &getPathParams() {return mPathParams;} - BOOL importFile(LLFILE *fp); - BOOL exportFile(LLFILE *fp) const; + bool importFile(LLFILE *fp); + bool exportFile(LLFILE *fp) const; - BOOL importLegacyStream(std::istream& input_stream); - BOOL exportLegacyStream(std::ostream& output_stream) const; + bool importLegacyStream(std::istream& input_stream); + bool exportLegacyStream(std::ostream& output_stream) const; LLSD sculptAsLLSD() const; bool sculptFromLLSD(LLSD& sd); @@ -621,7 +623,7 @@ public: bool setRevolutions(const F32 revolutions); // 1 to 4 bool setRadiusOffset(const F32 radius_offset); bool setSkew(const F32 skew); - bool setSculptID(const LLUUID sculpt_id, U8 sculpt_type); + bool setSculptID(const LLUUID& sculpt_id, U8 sculpt_type); static bool validate(U8 prof_curve, F32 prof_begin, F32 prof_end, F32 hollow, U8 path_curve, F32 path_begin, F32 path_end, @@ -653,7 +655,7 @@ public: const U8& getSculptType() const { return mSculptType; } bool isSculpt() const; bool isMeshSculpt() const; - BOOL isConvex() const; + bool isConvex() const; // 'begin' and 'end' should be in range [0, 1] (they will be clamped) // (begin, end) = (0, 1) will not change the volume @@ -688,9 +690,9 @@ class LLProfile public: LLProfile() - : mOpen(FALSE), - mConcave(FALSE), - mDirty(TRUE), + : mOpen(false), + mConcave(false), + mDirty(true), mTotalOut(0), mTotal(2) { @@ -698,23 +700,23 @@ public: S32 getTotal() const { return mTotal; } S32 getTotalOut() const { return mTotalOut; } // Total number of outside points - BOOL isFlat(S32 face) const { return (mFaces[face].mCount == 2); } - BOOL isOpen() const { return mOpen; } - void setDirty() { mDirty = TRUE; } - - static S32 getNumPoints(const LLProfileParams& params, BOOL path_open, F32 detail = 1.0f, S32 split = 0, - BOOL is_sculpted = FALSE, S32 sculpt_size = 0); - BOOL generate(const LLProfileParams& params, BOOL path_open, F32 detail = 1.0f, S32 split = 0, - BOOL is_sculpted = FALSE, S32 sculpt_size = 0); - BOOL isConcave() const { return mConcave; } + bool isFlat(S32 face) const { return (mFaces[face].mCount == 2); } + bool isOpen() const { return mOpen; } + void setDirty() { mDirty = true; } + + static S32 getNumPoints(const LLProfileParams& params, bool path_open, F32 detail = 1.0f, S32 split = 0, + bool is_sculpted = false, S32 sculpt_size = 0); + bool generate(const LLProfileParams& params, bool path_open, F32 detail = 1.0f, S32 split = 0, + bool is_sculpted = false, S32 sculpt_size = 0); + bool isConcave() const { return mConcave; } public: struct Face { S32 mIndex; S32 mCount; F32 mScaleU; - BOOL mCap; - BOOL mFlat; + bool mCap; + bool mFlat; LLFaceID mFaceID; }; @@ -733,14 +735,14 @@ protected: static S32 getNumNGonPoints(const LLProfileParams& params, S32 sides, F32 offset=0.0f, F32 bevel = 0.0f, F32 ang_scale = 1.f, S32 split = 0); void genNGon(const LLProfileParams& params, S32 sides, F32 offset=0.0f, F32 bevel = 0.0f, F32 ang_scale = 1.f, S32 split = 0); - Face* addHole(const LLProfileParams& params, BOOL flat, F32 sides, F32 offset, F32 box_hollow, F32 ang_scale, S32 split = 0); + Face* addHole(const LLProfileParams& params, bool flat, F32 sides, F32 offset, F32 box_hollow, F32 ang_scale, S32 split = 0); Face* addCap (S16 faceID); - Face* addFace(S32 index, S32 count, F32 scaleU, S16 faceID, BOOL flat); + Face* addFace(S32 index, S32 count, F32 scaleU, S16 faceID, bool flat); protected: - BOOL mOpen; - BOOL mConcave; - BOOL mDirty; + bool mOpen; + bool mConcave; + bool mDirty; S32 mTotalOut; S32 mTotal; @@ -780,9 +782,9 @@ public: public: LLPath() - : mOpen(FALSE), + : mOpen(false), mTotal(0), - mDirty(TRUE), + mDirty(true), mStep(1) { } @@ -793,12 +795,12 @@ public: static S32 getNumNGonPoints(const LLPathParams& params, S32 sides, F32 offset=0.0f, F32 end_scale = 1.f, F32 twist_scale = 1.f); void genNGon(const LLPathParams& params, S32 sides, F32 offset=0.0f, F32 end_scale = 1.f, F32 twist_scale = 1.f); - virtual BOOL generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0, - BOOL is_sculpted = FALSE, S32 sculpt_size = 0); + virtual bool generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0, + bool is_sculpted = false, S32 sculpt_size = 0); - BOOL isOpen() const { return mOpen; } + bool isOpen() const { return mOpen; } F32 getStep() const { return mStep; } - void setDirty() { mDirty = TRUE; } + void setDirty() { mDirty = true; } S32 getPathLength() const { return (S32)mPath.size(); } @@ -810,9 +812,9 @@ public: LLAlignedArray<PathPt, 64> mPath; protected: - BOOL mOpen; + bool mOpen; S32 mTotal; - BOOL mDirty; + bool mDirty; F32 mStep; }; @@ -820,8 +822,8 @@ class LLDynamicPath : public LLPath { public: LLDynamicPath() : LLPath() { } - /*virtual*/ BOOL generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0, - BOOL is_sculpted = FALSE, S32 sculpt_size = 0); + /*virtual*/ bool generate(const LLPathParams& params, F32 detail=1.0f, S32 split = 0, + bool is_sculpted = false, S32 sculpt_size = 0); }; // Yet another "face" class - caches volume-specific, but not instance-specific data for faces) @@ -871,7 +873,7 @@ private: void freeData(); public: - BOOL create(LLVolume* volume, BOOL partial_build = FALSE); + bool create(LLVolume* volume, bool partial_build = false); void createTangents(); void resizeVertices(S32 num_verts); @@ -973,14 +975,14 @@ public: U8* mJointIndices; #endif - mutable BOOL mWeightsScrubbed; + mutable bool mWeightsScrubbed; // Which joints are rigged to, and the bounding box of any rigged // vertices per joint. LLJointRiggingInfoTab mJointRiggingInfoTab; //whether or not face has been cache optimized - BOOL mOptimized; + bool mOptimized; // if this is a mesh asset, scale and translation that were applied // when encoding the source mesh into a unit cube @@ -991,9 +993,9 @@ private: LLVolumeOctree* mOctree; LLVolumeTriangle* mOctreeTriangles; - BOOL createUnCutCubeCap(LLVolume* volume, BOOL partial_build = FALSE); - BOOL createCap(LLVolume* volume, BOOL partial_build = FALSE); - BOOL createSide(LLVolume* volume, BOOL partial_build = FALSE); + bool createUnCutCubeCap(LLVolume* volume, bool partial_build = false); + bool createCap(LLVolume* volume, bool partial_build = false); + bool createSide(LLVolume* volume, bool partial_build = false); }; class LLVolume : public LLRefCount @@ -1015,12 +1017,12 @@ public: S32 mCountT; }; - LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL generate_single_face = FALSE, const BOOL is_unique = FALSE); + LLVolume(const LLVolumeParams ¶ms, const F32 detail, const bool generate_single_face = false, const bool is_unique = false); U8 getProfileType() const { return mParams.getProfileParams().getCurveType(); } U8 getPathType() const { return mParams.getPathParams().getCurveType(); } S32 getNumFaces() const; - S32 getNumVolumeFaces() const { return mVolumeFaces.size(); } + S32 getNumVolumeFaces() const { return static_cast<S32>(mVolumeFaces.size()); } F32 getDetail() const { return mDetail; } F32 getSurfaceArea() const { return mSurfaceArea; } const LLVolumeParams& getParams() const { return mParams; } @@ -1037,10 +1039,10 @@ public: void regen(); void genTangents(S32 face); - BOOL isConvex() const; - BOOL isCap(S32 face); - BOOL isFlat(S32 face); - BOOL isUnique() const { return mUnique; } + bool isConvex() const; + bool isCap(S32 face); + bool isFlat(S32 face); + bool isUnique() const { return mUnique; } S32 getSculptLevel() const { return mSculptLevel; } void setSculptLevel(S32 level) { mSculptLevel = level; } @@ -1048,7 +1050,7 @@ public: static void getLoDTriangleCounts(const LLVolumeParams& params, S32* counts); - S32 getNumTriangles(S32* vcount = NULL) const; + S32 getNumTriangles(S32* vcount = nullptr) const; void generateSilhouetteVertices(std::vector<LLVector3> &vertices, std::vector<LLVector3> &normals, @@ -1062,15 +1064,15 @@ public: //Line segment must be in volume space. S32 lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face = -1, // which face to check, -1 = ALL_SIDES - LLVector4a* intersection = NULL, // return the intersection point - LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point - LLVector4a* normal = NULL, // return the surface normal at the intersection point - LLVector4a* tangent = NULL // return the surface tangent at the intersection point + LLVector4a* intersection = nullptr, // return the intersection point + LLVector2* tex_coord = nullptr, // return the texture coordinates of the intersection point + LLVector4a* normal = nullptr, // return the surface normal at the intersection point + LLVector4a* tangent = nullptr // return the surface tangent at the intersection point ); LLFaceID generateFaceMask(); - BOOL isFaceMaskValid(LLFaceID face_mask); + bool isFaceMaskValid(LLFaceID face_mask); static S32 sNumMeshPoints; friend std::ostream& operator<<(std::ostream &s, const LLVolume &volume); @@ -1099,11 +1101,9 @@ private: F32 sculptGetSurfaceArea(); void sculptGenerateEmptyPlaceholder(); void sculptGenerateSpherePlaceholder(); - void sculptCalcMeshResolution(U16 width, U16 height, U8 type, S32& s, S32& t); - protected: - BOOL generate(); + bool generate(); void createVolumeFaces(); public: bool unpackVolumeFaces(std::istream& is, S32 size); @@ -1118,7 +1118,7 @@ public: virtual bool isMeshAssetUnavaliable(); protected: - BOOL mUnique; + bool mUnique; F32 mDetail; S32 mSculptLevel; F32 mSurfaceArea; //unscaled surface area @@ -1131,7 +1131,7 @@ public: LLAlignedArray<LLVector4a,64> mMesh; - BOOL mGenerateSingleFace; + bool mGenerateSingleFace; face_list_t mVolumeFaces; public: @@ -1145,18 +1145,13 @@ std::ostream& operator<<(std::ostream &s, const LLVolumeParams &volume_params); void LLCalculateTangentArray(U32 vertexCount, const LLVector4a *vertex, const LLVector4a *normal, const LLVector2 *texcoord, U32 triangleCount, const U16* index_array, LLVector4a *tangent); -BOOL LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size); -BOOL LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size); -BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size); - -//BOOL LLTriangleRayIntersect(const LLVector3& vert0, const LLVector3& vert1, const LLVector3& vert2, const LLVector3& orig, const LLVector3& dir, -// F32& intersection_a, F32& intersection_b, F32& intersection_t, BOOL two_sided); +bool LLLineSegmentBoxIntersect(const F32* start, const F32* end, const F32* center, const F32* size); +bool LLLineSegmentBoxIntersect(const LLVector3& start, const LLVector3& end, const LLVector3& center, const LLVector3& size); +bool LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size); -BOOL LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, +bool LLTriangleRayIntersect(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, F32& intersection_a, F32& intersection_b, F32& intersection_t); -BOOL LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, +bool LLTriangleRayIntersectTwoSided(const LLVector4a& vert0, const LLVector4a& vert1, const LLVector4a& vert2, const LLVector4a& orig, const LLVector4a& dir, F32& intersection_a, F32& intersection_b, F32& intersection_t); - - #endif diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp index 6f82335b3f..bb0c94d513 100644 --- a/indra/llmath/llvolumemgr.cpp +++ b/indra/llmath/llvolumemgr.cpp @@ -59,9 +59,9 @@ LLVolumeMgr::~LLVolumeMgr() mDataMutex = NULL; } -BOOL LLVolumeMgr::cleanup() +bool LLVolumeMgr::cleanup() { - BOOL no_refs = TRUE; + bool no_refs = true; if (mDataMutex) { mDataMutex->lock(); @@ -71,9 +71,9 @@ BOOL LLVolumeMgr::cleanup() iter != end; iter++) { LLVolumeLODGroup *volgroupp = iter->second; - if (volgroupp->cleanupRefs() == false) + if (!volgroupp->cleanupRefs()) { - no_refs = FALSE; + no_refs = false; } delete volgroupp; } @@ -301,7 +301,7 @@ LLVolume* LLVolumeLODGroup::refLOD(const S32 lod) return mVolumeLODs[lod]; } -BOOL LLVolumeLODGroup::derefLOD(LLVolume *volumep) +bool LLVolumeLODGroup::derefLOD(LLVolume *volumep) { llassert_always(mRefs > 0); mRefs--; @@ -317,11 +317,11 @@ BOOL LLVolumeLODGroup::derefLOD(LLVolume *volumep) mVolumeLODs[i] = NULL; } #endif - return TRUE; + return true; } } LL_ERRS() << "Deref of non-matching LOD in volume LOD group" << LL_ENDL; - return FALSE; + return false; } S32 LLVolumeLODGroup::getDetailFromTan(const F32 tan_angle) diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h index b46e9aa725..2e0ce3e88a 100644 --- a/indra/llmath/llvolumemgr.h +++ b/indra/llmath/llvolumemgr.h @@ -56,7 +56,7 @@ public: static S32 getVolumeDetailFromScale(F32 scale); LLVolume* refLOD(const S32 detail); - BOOL derefLOD(LLVolume *volumep); + bool derefLOD(LLVolume *volumep); S32 getNumRefs() const { return mRefs; } const LLVolumeParams* getVolumeParams() const { return &mVolumeParams; }; @@ -80,7 +80,7 @@ class LLVolumeMgr public: LLVolumeMgr(); virtual ~LLVolumeMgr(); - BOOL cleanup(); // Cleanup all volumes being managed, returns TRUE if no dangling references + bool cleanup(); // Cleanup all volumes being managed, returns true if no dangling references virtual LLVolumeLODGroup* getGroup( const LLVolumeParams& volume_params ) const; diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp index 341b9a6465..71288daa89 100644 --- a/indra/llmath/llvolumeoctree.cpp +++ b/indra/llmath/llvolumeoctree.cpp @@ -27,7 +27,7 @@ #include "llvolumeoctree.h" #include "llvector4a.h" -BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size) +bool LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, const LLVector4a& center, const LLVector4a& size) { LLVector4a fAWdU; LLVector4a dir; @@ -71,10 +71,9 @@ BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, c grt = f.greaterThan(rhs).getGatheredBits(); - return (grt & 0x7) ? false : true; + return (grt & 0x7) == 0; } - LLVolumeOctreeListener::LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle, LLVolumeTriangle*>* node) { node->addListener(this); @@ -114,7 +113,7 @@ void LLOctreeTriangleRayIntersect::traverse(const LLOctreeNode<LLVolumeTriangle, if (LLLineSegmentBoxIntersect(mStart, mEnd, vl->mBounds[0], vl->mBounds[1])) { node->accept(this); - for (S32 i = 0; i < node->getChildCount(); ++i) + for (U32 i = 0; i < node->getChildCount(); ++i) { traverse(node->getChild(i)); } @@ -152,7 +151,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle, LL U32 idx1 = tri->mIndex[1]; U32 idx2 = tri->mIndex[2]; - if (mTexCoord != NULL) + if (mTexCoord != NULL && mFace->mTexCoords) { LLVector2* tc = (LLVector2*) mFace->mTexCoords; *mTexCoord = ((1.f - a - b) * tc[idx0] + @@ -161,7 +160,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle, LL } - if (mNormal != NULL) + if (mNormal != NULL && mFace->mNormals) { LLVector4a* norm = mFace->mNormals; @@ -181,7 +180,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle, LL *mNormal = n1; } - if (mTangent != NULL) + if (mTangent != NULL && mFace->mTangents) { LLVector4a* tangents = mFace->mTangents; diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index cf176b5afe..05d45f7b5f 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -48,12 +48,6 @@ public: *this = rhs; } - const LLVolumeTriangle& operator=(const LLVolumeTriangle& rhs) - { - LL_ERRS() << "Illegal operation!" << LL_ENDL; - return *this; - } - ~LLVolumeTriangle() { @@ -192,7 +186,7 @@ public: llassert(!branch->isLeaf()); // Empty leaf } - for (S32 i = 0; i < branch->getChildCount(); ++i) + for (U32 i = 0; i < branch->getChildCount(); ++i) { //stretch by child extents LLVolumeOctreeListener* child = (LLVolumeOctreeListener*)branch->getChild(i)->getListener(0); min.setMin(min, child->mExtents[0]); diff --git a/indra/llmath/m3math.cpp b/indra/llmath/m3math.cpp index 2cefc44da3..472d340af5 100644 --- a/indra/llmath/m3math.cpp +++ b/indra/llmath/m3math.cpp @@ -528,10 +528,10 @@ bool operator==(const LLMatrix3 &a, const LLMatrix3 &b) for (j = 0; j < NUM_VALUES_IN_MAT3; j++) { if (a.mMatrix[j][i] != b.mMatrix[j][i]) - return FALSE; + return false; } } - return TRUE; + return true; } bool operator!=(const LLMatrix3 &a, const LLMatrix3 &b) @@ -542,10 +542,10 @@ bool operator!=(const LLMatrix3 &a, const LLMatrix3 &b) for (j = 0; j < NUM_VALUES_IN_MAT3; j++) { if (a.mMatrix[j][i] != b.mMatrix[j][i]) - return TRUE; + return true; } } - return FALSE; + return false; } const LLMatrix3& operator*=(LLMatrix3 &a, const LLMatrix3 &b) diff --git a/indra/llmath/m4math.cpp b/indra/llmath/m4math.cpp index 16ce00d963..c46ee587cb 100644 --- a/indra/llmath/m4math.cpp +++ b/indra/llmath/m4math.cpp @@ -744,10 +744,10 @@ bool operator==(const LLMatrix4 &a, const LLMatrix4 &b) for (j = 0; j < NUM_VALUES_IN_MAT4; j++) { if (a.mMatrix[j][i] != b.mMatrix[j][i]) - return FALSE; + return false; } } - return TRUE; + return true; } bool operator!=(const LLMatrix4 &a, const LLMatrix4 &b) @@ -758,10 +758,10 @@ bool operator!=(const LLMatrix4 &a, const LLMatrix4 &b) for (j = 0; j < NUM_VALUES_IN_MAT4; j++) { if (a.mMatrix[j][i] != b.mMatrix[j][i]) - return TRUE; + return true; } } - return FALSE; + return false; } bool operator<(const LLMatrix4& a, const LLMatrix4 &b) diff --git a/indra/llmath/raytrace.cpp b/indra/llmath/raytrace.cpp index de51313fa2..893bf1fc70 100644 --- a/indra/llmath/raytrace.cpp +++ b/indra/llmath/raytrace.cpp @@ -34,7 +34,7 @@ #include "raytrace.h" -BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, +bool line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, const LLVector3 &plane_point, const LLVector3 plane_normal, LLVector3 &intersection) { @@ -43,18 +43,18 @@ BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, { // line is perpendicular to plane normal // so it is either entirely on plane, or not on plane at all - return FALSE; + return false; } // Ax + By, + Cz + D = 0 // D = - (plane_point * plane_normal) // N = line_direction * plane_normal // intersection = line_point - ((D + plane_normal * line_point) / N) * line_direction intersection = line_point - ((plane_normal * line_point - plane_point * plane_normal) / N) * line_direction; - return TRUE; + return true; } -BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &plane_point, const LLVector3 plane_normal, LLVector3 &intersection) { @@ -63,7 +63,7 @@ BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, { // ray is perpendicular to plane normal // so it is either entirely on plane, or not on plane at all - return FALSE; + return false; } // Ax + By, + Cz + D = 0 // D = - (plane_point * plane_normal) @@ -73,14 +73,14 @@ BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (alpha < 0.0f) { // ray points away from plane - return FALSE; + return false; } intersection = ray_point + alpha * ray_direction; - return TRUE; + return true; } -BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, LLVector3 &intersection) { @@ -88,14 +88,14 @@ BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, { if (circle_radius >= (intersection - circle_center).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -112,15 +112,15 @@ BOOL ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, intersection_normal * (side_12 % (intersection - point_1)) >= 0.0f && intersection_normal * (side_20 % (intersection - point_2)) >= 0.0f) { - return TRUE; + return true; } } - return FALSE; + return false; } // assumes a parallelogram -BOOL ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -140,14 +140,14 @@ BOOL ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, intersection_normal * (side_23 % (intersection - point_2)) >= 0.0f && intersection_normal * (side_30 % (intersection - point_3)) >= 0.0f) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &sphere_center, F32 sphere_radius, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -160,7 +160,7 @@ BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, F32 radius_squared = sphere_radius * sphere_radius; if (shortest_distance > radius_squared) { - return FALSE; + return false; } F32 half_chord = (F32) sqrt(radius_squared - shortest_distance); @@ -170,7 +170,7 @@ BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (dot < 0.0f) { // ray shoots away from sphere and is not inside it - return FALSE; + return false; } shortest_distance = ray_direction * ((closest_approach - half_chord * ray_direction) - ray_point); @@ -195,11 +195,11 @@ BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, intersection_normal.setVec(0.0f, 0.0f, 0.0f); } - return TRUE; + return true; } -BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -242,7 +242,7 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (dot > 0.0f) { // ray points away from cylinder bottom - return FALSE; + return false; } // ray hit bottom of cylinder from outside intersection = ray_point - shortest_distance * cyl_axis; @@ -270,15 +270,15 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (dot < 0.0f) { // ray points away from cylinder bottom - return FALSE; + return false; } // ray hit top from outside intersection = ray_point - (shortest_distance + cyl_length) * cyl_axis; intersection_normal = -cyl_axis; } - return TRUE; + return true; } - return FALSE; + return false; } // check for intersection with infinite cylinder @@ -298,8 +298,8 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, out = dist_to_closest_point + half_chord_length; // dist to exiting point if (out < 0.0f) { - // cylinder is behind the ray, so we return FALSE - return FALSE; + // cylinder is behind the ray, so we return false + return false; } in = dist_to_closest_point - half_chord_length; // dist to entering point @@ -341,14 +341,14 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (shortest_distance > out) { // ray missed the finite cylinder - return FALSE; + return false; } if (shortest_distance > in) { // ray intersects cylinder at top plane intersection = temp_vector; intersection_normal = -cyl_axis; - return TRUE; + return true; } } else @@ -357,7 +357,7 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (shortest_distance < in) { // missed the finite cylinder - return FALSE; + return false; } } @@ -370,14 +370,14 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (shortest_distance > out) { // ray missed the finite cylinder - return FALSE; + return false; } if (shortest_distance > in) { // ray intersects cylinder at bottom plane intersection = temp_vector; intersection_normal = cyl_axis; - return TRUE; + return true; } } else @@ -386,7 +386,7 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (shortest_distance < in) { // ray missed the finite cylinder - return FALSE; + return false; } } @@ -399,14 +399,14 @@ BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (shortest_distance < 0.0f || shortest_distance > cyl_length) { // ray missed finite cylinder - return FALSE; + return false; } } - return TRUE; + return true; } - return FALSE; + return false; } @@ -710,7 +710,7 @@ U32 ray_box(const LLVector3 &ray_point, const LLVector3 &ray_direction, } -BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -751,7 +751,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, point5 = (point5 * prism_rotation) + prism_center; // test ray intersection for each face - BOOL b_hit = FALSE; + bool b_hit = false; LLVector3 face_intersection, face_normal; F32 distance_squared = 0.0f; F32 temp; @@ -761,14 +761,14 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, ray_quadrangle(ray_point, ray_direction, point5, point2, point0, intersection, intersection_normal)) { distance_squared = (ray_point - intersection).magVecSquared(); - b_hit = TRUE; + b_hit = true; } // face 1 if (ray_direction * ( (point0 - point3) % (point2 - point3)) < 0.0f && ray_triangle(ray_point, ray_direction, point2, point3, point0, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -783,7 +783,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -791,7 +791,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point1 - point4) % (point3 - point4)) < 0.0f && ray_quadrangle(ray_point, ray_direction, point3, point4, point1, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -806,7 +806,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -814,7 +814,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point5 - point4) % (point1 - point4)) < 0.0f && ray_triangle(ray_point, ray_direction, point1, point4, point5, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -829,7 +829,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -837,7 +837,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point4 - point5) % (point2 - point5)) < 0.0f && ray_quadrangle(ray_point, ray_direction, point2, point5, point4, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -852,7 +852,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -860,7 +860,7 @@ BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, } -BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -890,7 +890,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, point3 = (point3 * t_rotation) + t_center; // test ray intersection for each face - BOOL b_hit = FALSE; + bool b_hit = false; LLVector3 face_intersection, face_normal; F32 distance_squared = 1.0e12f; F32 temp; @@ -900,14 +900,14 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, ray_triangle(ray_point, ray_direction, point1, point2, point0, intersection, intersection_normal)) { distance_squared = (ray_point - intersection).magVecSquared(); - b_hit = TRUE; + b_hit = true; } // face 1 if (ray_direction * ( (point3 - point2) % (point0 - point2)) < 0.0f && ray_triangle(ray_point, ray_direction, point2, point3, point0, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -922,7 +922,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -930,7 +930,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point1 - point3) % (point0 - point3)) < 0.0f && ray_triangle(ray_point, ray_direction, point3, point1, point0, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -945,7 +945,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -953,7 +953,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point2 - point3) % (point1 - point3)) < 0.0f && ray_triangle(ray_point, ray_direction, point3, point2, point1, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -966,7 +966,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, { intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -974,7 +974,7 @@ BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, } -BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -997,7 +997,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, point4 = (point4 * p_rotation) + p_center; // test ray intersection for each face - BOOL b_hit = FALSE; + bool b_hit = false; LLVector3 face_intersection, face_normal; F32 distance_squared = 1.0e12f; F32 temp; @@ -1007,14 +1007,14 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, ray_triangle(ray_point, ray_direction, point4, point1, point0, intersection, intersection_normal)) { distance_squared = (ray_point - intersection).magVecSquared(); - b_hit = TRUE; + b_hit = true; } // face 1 if (ray_direction * ( (point2 - point1) % (point0 - point1)) < 0.0f && ray_triangle(ray_point, ray_direction, point1, point2, point0, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -1029,7 +1029,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -1037,7 +1037,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point3 - point2) % (point0 - point2)) < 0.0f && ray_triangle(ray_point, ray_direction, point2, point3, point0, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -1052,7 +1052,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -1060,7 +1060,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point4 - point3) % (point0 - point3)) < 0.0f && ray_triangle(ray_point, ray_direction, point3, point4, point0, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -1075,7 +1075,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, distance_squared = (ray_point - face_intersection).magVecSquared(); intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -1083,7 +1083,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, if (ray_direction * ( (point3 - point4) % (point2 - point4)) < 0.0f && ray_quadrangle(ray_point, ray_direction, point4, point3, point2, face_intersection, face_normal)) { - if (TRUE == b_hit) + if (b_hit) { temp = (ray_point - face_intersection).magVecSquared(); if (temp < distance_squared) @@ -1096,7 +1096,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, { intersection = face_intersection; intersection_normal = face_normal; - b_hit = TRUE; + b_hit = true; } } @@ -1104,7 +1104,7 @@ BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, } -BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, LLVector3 &intersection) { @@ -1115,14 +1115,14 @@ BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1133,14 +1133,14 @@ BOOL linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1151,14 +1151,14 @@ BOOL linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &sphere_center, F32 sphere_radius, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1169,14 +1169,14 @@ BOOL linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1187,10 +1187,10 @@ BOOL linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } @@ -1215,7 +1215,7 @@ U32 linesegment_box(const LLVector3 &point_a, const LLVector3 &point_b, } -BOOL linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1226,14 +1226,14 @@ BOOL linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1244,14 +1244,14 @@ BOOL linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } -BOOL linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation, LLVector3 &intersection, LLVector3 &intersection_normal) { @@ -1262,13 +1262,8 @@ BOOL linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b, { if (segment_length >= (point_a - intersection).magVec()) { - return TRUE; + return true; } } - return FALSE; + return false; } - - - - - diff --git a/indra/llmath/raytrace.h b/indra/llmath/raytrace.h index 01b8ee64f4..b55f29aef6 100644 --- a/indra/llmath/raytrace.h +++ b/indra/llmath/raytrace.h @@ -38,8 +38,8 @@ class LLQuaternion; // Vector arguments of the form "shape_scale" represent the scale of the // object along the three axes. // -// All functions return the expected TRUE or FALSE, unless otherwise noted. -// When FALSE is returned, any resulting values that might have been stored +// All functions return the expected true or false, unless otherwise noted. +// When false is returned, any resulting values that might have been stored // are undefined. // // Rays are defined by a "ray_point" and a "ray_direction" (unit). @@ -61,25 +61,25 @@ class LLQuaternion; // frame. -// returns TRUE iff line is not parallel to plane. -BOOL line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, +// returns true if line is not parallel to plane. +bool line_plane(const LLVector3 &line_point, const LLVector3 &line_direction, const LLVector3 &plane_point, const LLVector3 plane_normal, LLVector3 &intersection); -// returns TRUE iff line is not parallel to plane. -BOOL ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, +// returns true if line is not parallel to plane. +bool ray_plane(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &plane_point, const LLVector3 plane_normal, LLVector3 &intersection); -BOOL ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_circle(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, LLVector3 &intersection); // point_0 through point_2 define the plane_normal via the right-hand rule: // circle from point_0 to point_2 with fingers ==> thumb points in direction of normal -BOOL ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal); @@ -88,24 +88,24 @@ BOOL ray_triangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, // right-hand-rule... curl fingers from lower-left toward lower-right then toward upper-right // ==> thumb points in direction of normal // assumes a parallelogram, so point_3 is determined by the other points -BOOL ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_quadrangle(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_sphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &sphere_center, F32 sphere_radius, LLVector3 &intersection, LLVector3 &intersection_normal); // finite right cylinder is defined by end centers: "cyl_top", "cyl_bottom", // and by the cylinder radius "cyl_radius" -BOOL ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_cylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -// this function doesn't just return a BOOL because the return is currently +// this function doesn't just return a bool because the return is currently // used to decide how to break up boxes that have been hit by shots... // a hack that will probably be changed later // @@ -117,66 +117,66 @@ U32 ray_box(const LLVector3 &ray_point, const LLVector3 &ray_direction, /* TODO -BOOL ray_ellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_ellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &e_center, const LLVector3 &e_scale, const LLQuaternion &e_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_cone(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_cone(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &cone_tip, const LLVector3 &cone_bottom, const LLVector3 &cone_scale, const LLQuaternion &cone_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); */ -BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_tetrahedron(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_pyramid(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); /* TODO -BOOL ray_hemiellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_hemiellipsoid(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &e_center, const LLVector3 &e_scale, const LLQuaternion &e_rotation, const LLVector3 &e_cut_normal, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_hemisphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_hemisphere(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &sphere_center, F32 sphere_radius, const LLVector3 &sphere_cut_normal, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_hemicylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_hemicylinder(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &cyl_top, const LLVector3 &cyl_bottom, F32 cyl_radius, const LLVector3 &cyl_cut_normal, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL ray_hemicone(const LLVector3 &ray_point, const LLVector3 &ray_direction, +bool ray_hemicone(const LLVector3 &ray_point, const LLVector3 &ray_direction, const LLVector3 &cone_tip, const LLVector3 &cone_bottom, const LLVector3 &cone_scale, const LLVector3 &cyl_cut_normal, LLVector3 &intersection, LLVector3 &intersection_normal); */ -BOOL linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_circle(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &circle_center, const LLVector3 plane_normal, F32 circle_radius, LLVector3 &intersection); // point_0 through point_2 define the plane_normal via the right-hand rule: // circle from point_0 to point_2 with fingers ==> thumb points in direction of normal -BOOL linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal); @@ -185,24 +185,24 @@ BOOL linesegment_triangle(const LLVector3 &point_a, const LLVector3 &point_b, // right-hand-rule... curl fingers from lower-left toward lower-right then toward upper-right // ==> thumb points in direction of normal // assumes a parallelogram, so point_3 is determined by the other points -BOOL linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_quadrangle(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &point_0, const LLVector3 &point_1, const LLVector3 &point_2, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_sphere(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &sphere_center, F32 sphere_radius, LLVector3 &intersection, LLVector3 &intersection_normal); // finite right cylinder is defined by end centers: "cyl_top", "cyl_bottom", // and by the cylinder radius "cyl_radius" -BOOL linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_cylinder(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &cyl_center, const LLVector3 &cyl_scale, const LLQuaternion &cyl_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -// this function doesn't just return a BOOL because the return is currently +// this function doesn't just return a bool because the return is currently // used to decide how to break up boxes that have been hit by shots... // a hack that will probably be changed later // @@ -213,20 +213,17 @@ U32 linesegment_box(const LLVector3 &point_a, const LLVector3 &point_b, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_prism(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_tetrahedron(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &t_center, const LLVector3 &t_scale, const LLQuaternion &t_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); -BOOL linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b, +bool linesegment_pyramid(const LLVector3 &point_a, const LLVector3 &point_b, const LLVector3 &p_center, const LLVector3 &p_scale, const LLQuaternion &p_rotation, LLVector3 &intersection, LLVector3 &intersection_normal); - - #endif - diff --git a/indra/llmath/tests/llbbox_test.cpp b/indra/llmath/tests/llbbox_test.cpp index 1f2cd96ab2..bd6bd9e4b0 100644 --- a/indra/llmath/tests/llbbox_test.cpp +++ b/indra/llmath/tests/llbbox_test.cpp @@ -340,11 +340,11 @@ namespace tut LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 2.0f, 3.0f), LLVector3(3.0f, 4.0f, 5.0f)); - ensure("containsPointLocal(0,0,0)", bbox1.containsPointLocal(LLVector3(0.0f, 0.0f, 0.0f)) == FALSE); - ensure("containsPointLocal(1,2,3)", bbox1.containsPointLocal(LLVector3(1.0f, 2.0f, 3.0f)) == TRUE); - ensure("containsPointLocal(0.999,2,3)", bbox1.containsPointLocal(LLVector3(0.999f, 2.0f, 3.0f)) == FALSE); - ensure("containsPointLocal(3,4,5)", bbox1.containsPointLocal(LLVector3(3.0f, 4.0f, 5.0f)) == TRUE); - ensure("containsPointLocal(3,4,5.001)", bbox1.containsPointLocal(LLVector3(3.0f, 4.0f, 5.001f)) == FALSE); + ensure("containsPointLocal(0,0,0)", bbox1.containsPointLocal(LLVector3(0.0f, 0.0f, 0.0f)) == false); + ensure("containsPointLocal(1,2,3)", bbox1.containsPointLocal(LLVector3(1.0f, 2.0f, 3.0f)) == true); + ensure("containsPointLocal(0.999,2,3)", bbox1.containsPointLocal(LLVector3(0.999f, 2.0f, 3.0f)) == false); + ensure("containsPointLocal(3,4,5)", bbox1.containsPointLocal(LLVector3(3.0f, 4.0f, 5.0f)) == true); + ensure("containsPointLocal(3,4,5.001)", bbox1.containsPointLocal(LLVector3(3.0f, 4.0f, 5.001f)) == false); } template<> template<> @@ -357,11 +357,11 @@ namespace tut LLBBox bbox1(LLVector3(1.0f, 1.0f, 1.0f), LLQuaternion(), LLVector3(1.0f, 2.0f, 3.0f), LLVector3(3.0f, 4.0f, 5.0f)); - ensure("containsPointAgent(0,0,0)", bbox1.containsPointAgent(LLVector3(0.0f, 0.0f, 0.0f)) == FALSE); - ensure("containsPointAgent(2,3,4)", bbox1.containsPointAgent(LLVector3(2.0f, 3.0f, 4.0f)) == TRUE); - ensure("containsPointAgent(2,2.999,4)", bbox1.containsPointAgent(LLVector3(2.0f, 2.999f, 4.0f)) == FALSE); - ensure("containsPointAgent(4,5,6)", bbox1.containsPointAgent(LLVector3(4.0f, 5.0f, 6.0f)) == TRUE); - ensure("containsPointAgent(4,5.001,6)", bbox1.containsPointAgent(LLVector3(4.0f, 5.001f, 6.0f)) == FALSE); + ensure("containsPointAgent(0,0,0)", bbox1.containsPointAgent(LLVector3(0.0f, 0.0f, 0.0f)) == false); + ensure("containsPointAgent(2,3,4)", bbox1.containsPointAgent(LLVector3(2.0f, 3.0f, 4.0f)) == true); + ensure("containsPointAgent(2,2.999,4)", bbox1.containsPointAgent(LLVector3(2.0f, 2.999f, 4.0f)) == false); + ensure("containsPointAgent(4,5,6)", bbox1.containsPointAgent(LLVector3(4.0f, 5.0f, 6.0f)) == true); + ensure("containsPointAgent(4,5.001,6)", bbox1.containsPointAgent(LLVector3(4.0f, 5.001f, 6.0f)) == false); } } diff --git a/indra/llmath/tests/llrect_test.cpp b/indra/llmath/tests/llrect_test.cpp index ca042a60d7..0fd5602d4a 100644 --- a/indra/llmath/tests/llrect_test.cpp +++ b/indra/llmath/tests/llrect_test.cpp @@ -471,13 +471,13 @@ namespace tut LLRectf rect(1.0f, 3.0f, 3.0f, 1.0f); - ensure("(0,0) not in rect", rect.pointInRect(0.0f, 0.0f) == FALSE); - ensure("(2,2) in rect", rect.pointInRect(2.0f, 2.0f) == TRUE); - ensure("(1,1) in rect", rect.pointInRect(1.0f, 1.0f) == TRUE); - ensure("(3,3) not in rect", rect.pointInRect(3.0f, 3.0f) == FALSE); - ensure("(2.999,2.999) in rect", rect.pointInRect(2.999f, 2.999f) == TRUE); - ensure("(2.999,3.0) not in rect", rect.pointInRect(2.999f, 3.0f) == FALSE); - ensure("(3.0,2.999) not in rect", rect.pointInRect(3.0f, 2.999f) == FALSE); + ensure("(0,0) not in rect", rect.pointInRect(0.0f, 0.0f) == false); + ensure("(2,2) in rect", rect.pointInRect(2.0f, 2.0f) == true); + ensure("(1,1) in rect", rect.pointInRect(1.0f, 1.0f) == true); + ensure("(3,3) not in rect", rect.pointInRect(3.0f, 3.0f) == false); + ensure("(2.999,2.999) in rect", rect.pointInRect(2.999f, 2.999f) == true); + ensure("(2.999,3.0) not in rect", rect.pointInRect(2.999f, 3.0f) == false); + ensure("(3.0,2.999) not in rect", rect.pointInRect(3.0f, 2.999f) == false); } template<> template<> @@ -489,13 +489,13 @@ namespace tut LLRectf rect(1.0f, 3.0f, 3.0f, 1.0f); - ensure("(0,0) in local rect", rect.localPointInRect(0.0f, 0.0f) == TRUE); - ensure("(-0.0001,-0.0001) not in local rect", rect.localPointInRect(-0.0001f, -0.001f) == FALSE); - ensure("(1,1) in local rect", rect.localPointInRect(1.0f, 1.0f) == TRUE); - ensure("(2,2) not in local rect", rect.localPointInRect(2.0f, 2.0f) == FALSE); - ensure("(1.999,1.999) in local rect", rect.localPointInRect(1.999f, 1.999f) == TRUE); - ensure("(1.999,2.0) not in local rect", rect.localPointInRect(1.999f, 2.0f) == FALSE); - ensure("(2.0,1.999) not in local rect", rect.localPointInRect(2.0f, 1.999f) == FALSE); + ensure("(0,0) in local rect", rect.localPointInRect(0.0f, 0.0f) == true); + ensure("(-0.0001,-0.0001) not in local rect", rect.localPointInRect(-0.0001f, -0.001f) == false); + ensure("(1,1) in local rect", rect.localPointInRect(1.0f, 1.0f) == true); + ensure("(2,2) not in local rect", rect.localPointInRect(2.0f, 2.0f) == false); + ensure("(1.999,1.999) in local rect", rect.localPointInRect(1.999f, 1.999f) == true); + ensure("(1.999,2.0) not in local rect", rect.localPointInRect(1.999f, 2.0f) == false); + ensure("(2.0,1.999) not in local rect", rect.localPointInRect(2.0f, 1.999f) == false); } template<> template<> diff --git a/indra/llmath/tests/mathmisc_test.cpp b/indra/llmath/tests/mathmisc_test.cpp index 163cf02350..ff0899e975 100644 --- a/indra/llmath/tests/mathmisc_test.cpp +++ b/indra/llmath/tests/mathmisc_test.cpp @@ -454,7 +454,7 @@ namespace tut template<> template<> void line_object::test<1>() { - // this is a test for LLLine::intersects(point) which returns TRUE + // this is a test for LLLine::intersects(point) which returns true // if the line passes within some tolerance of point // these tests will have some floating point error, diff --git a/indra/llmath/tests/v2math_test.cpp b/indra/llmath/tests/v2math_test.cpp index f66142c6a7..860e3ef672 100644 --- a/indra/llmath/tests/v2math_test.cpp +++ b/indra/llmath/tests/v2math_test.cpp @@ -93,15 +93,15 @@ namespace tut { F32 x =-2.0f, y = -3.0f ; LLVector2 vec2(x,y); - ensure_equals("abs():Fail", vec2.abs(), TRUE); + ensure_equals("abs():Fail", vec2.abs(), true); ensure("abs() x", is_approx_equal(vec2.mV[VX], 2.f)); ensure("abs() y", is_approx_equal(vec2.mV[VY], 3.f)); - ensure("isNull():Fail ", FALSE == vec2.isNull()); //Returns TRUE if vector has a _very_small_ length + ensure("isNull():Fail ", false == vec2.isNull()); //Returns true if vector has a _very_small_ length x =.00000001f, y = .000001001f; vec2.setVec(x, y); - ensure("isNull(): Fail ", TRUE == vec2.isNull()); + ensure("isNull(): Fail ", true == vec2.isNull()); } template<> template<> @@ -111,12 +111,12 @@ namespace tut LLVector2 vec2(x, y), vec3; vec3 = vec3.scaleVec(vec2); ensure("scaleVec: Fail ", vec3.mV[VX] == 0. && vec3.mV[VY] == 0.); - ensure("isExactlyZero(): Fail", TRUE == vec3.isExactlyZero()); + ensure("isExactlyZero(): Fail", true == vec3.isExactlyZero()); vec3.setVec(2.f, 1.f); vec3 = vec3.scaleVec(vec2); ensure("scaleVec: Fail ", (2.f == vec3.mV[VX]) && (2.f == vec3.mV[VY])); - ensure("isExactlyZero():Fail", FALSE == vec3.isExactlyZero()); + ensure("isExactlyZero():Fail", false == vec3.isExactlyZero()); } template<> template<> @@ -254,7 +254,7 @@ namespace tut vec3.clearVec(); vec2.setVec(x1, y1); vec3.setVec(vec2); - ensure("2:operator!= failed", (FALSE == (vec2 != vec3))); + ensure("2:operator!= failed", (false == (vec2 != vec3))); } template<> template<> void v2math_object::test<13>() @@ -373,7 +373,7 @@ namespace tut x1 = 1.0f, y1 = 2.0f, x2 = 1.0f, y2 = 3.2234f; vec2.setVec(x1, y1); vec3.setVec(x2, y2); - ensure("2:operator < failed", (FALSE == (vec3 < vec2))); + ensure("2:operator < failed", (false == (vec3 < vec2))); } template<> template<> diff --git a/indra/llmath/tests/v3color_test.cpp b/indra/llmath/tests/v3color_test.cpp index d1baa53a9b..8897d48365 100644 --- a/indra/llmath/tests/v3color_test.cpp +++ b/indra/llmath/tests/v3color_test.cpp @@ -209,7 +209,7 @@ namespace tut ensure("1:operator!= failed",(llcolor3 != llcolor3a)); llcolor3.setToBlack(); llcolor3a.setVec(llcolor3); - ensure("2:operator!= failed", ( FALSE == (llcolor3a != llcolor3))); + ensure("2:operator!= failed", ( false == (llcolor3a != llcolor3))); } template<> template<> diff --git a/indra/llmath/tests/v3dmath_test.cpp b/indra/llmath/tests/v3dmath_test.cpp index 6b58cbd007..db08419012 100644 --- a/indra/llmath/tests/v3dmath_test.cpp +++ b/indra/llmath/tests/v3dmath_test.cpp @@ -128,15 +128,15 @@ namespace tut LLVector3d vec3D(x,y,z); vec3D.abs(); ensure("1:abs:Fail ", ((-x == vec3D.mdV[VX]) && (y == vec3D.mdV[VY]) && (-z == vec3D.mdV[VZ]))); - ensure("2:isNull():Fail ", (FALSE == vec3D.isNull())); + ensure("2:isNull():Fail ", (false == vec3D.isNull())); vec3D.clearVec(); x =.00000001, y = .000001001, z = .000001001; vec3D.setVec(x,y,z); - ensure("3:isNull():Fail ", (TRUE == vec3D.isNull())); - ensure("4:isExactlyZero():Fail ", (FALSE == vec3D.isExactlyZero())); + ensure("3:isNull():Fail ", (true == vec3D.isNull())); + ensure("4:isExactlyZero():Fail ", (false == vec3D.isExactlyZero())); x =.0000000, y = .00000000, z = .00000000; vec3D.setVec(x,y,z); - ensure("5:isExactlyZero():Fail ", (TRUE == vec3D.isExactlyZero())); + ensure("5:isExactlyZero():Fail ", (true == vec3D.isExactlyZero())); } template<> template<> @@ -353,7 +353,7 @@ namespace tut { F64 x1 = 1., y1 = 2., z1 = -1.1; LLVector3d vec3D(x1,y1,z1), vec3Da; - ensure("1:operator!= failed",(TRUE == (vec3D !=vec3Da))); + ensure("1:operator!= failed",(true == (vec3D !=vec3Da))); vec3Da = vec3D; ensure("2:operator== failed",(vec3D ==vec3Da)); vec3D.clearVec(); @@ -362,7 +362,7 @@ namespace tut vec3D.setVec(x1,y1,z1); vec3Da.setVec(x1,y1,z1); ensure("3:operator== failed",(vec3D ==vec3Da)); - ensure("4:operator!= failed",(FALSE == (vec3D !=vec3Da))); + ensure("4:operator!= failed",(false == (vec3D !=vec3Da))); } template<> template<> @@ -482,10 +482,10 @@ namespace tut F64 x = 2.32, y = 1.212, z = -.12; F64 min = 0.0001, max = 3.0; LLVector3d vec3d(x,y,z); - ensure("1:clamp:Fail ", (TRUE == (vec3d.clamp(min, max)))); + ensure("1:clamp:Fail ", (true == (vec3d.clamp(min, max)))); x = 0.000001f, z = 5.3f; vec3d.setVec(x,y,z); - ensure("2:clamp:Fail ", (TRUE == (vec3d.clamp(min, max)))); + ensure("2:clamp:Fail ", (true == (vec3d.clamp(min, max)))); } template<> template<> @@ -494,11 +494,11 @@ namespace tut F64 x = 10., y = 20., z = -15.; F64 epsilon = .23425; LLVector3d vec3Da(x,y,z), vec3Db(x,y,z); - ensure("1:are_parallel: Fail ", (TRUE == are_parallel(vec3Da,vec3Db,epsilon))); + ensure("1:are_parallel: Fail ", (true == are_parallel(vec3Da,vec3Db,epsilon))); F64 x1 = -12., y1 = -20., z1 = -100.; vec3Db.clearVec(); vec3Db.setVec(x1,y1,z1); - ensure("2:are_parallel: Fail ", (FALSE == are_parallel(vec3Da,vec3Db,epsilon))); + ensure("2:are_parallel: Fail ", (false == are_parallel(vec3Da,vec3Db,epsilon))); } template<> template<> diff --git a/indra/llmath/tests/v3math_test.cpp b/indra/llmath/tests/v3math_test.cpp index 7f93aba354..6d95a9e5b7 100644 --- a/indra/llmath/tests/v3math_test.cpp +++ b/indra/llmath/tests/v3math_test.cpp @@ -99,7 +99,7 @@ namespace tut { F32 x = 2.32f, y = 1.212f, z = -.12f; LLVector3 vec3(x,y,z); - ensure("1:isFinite= Fail to initialize ", (TRUE == vec3.isFinite()));//need more test cases: + ensure("1:isFinite= Fail to initialize ", (true == vec3.isFinite()));//need more test cases: vec3.clearVec(); ensure("2:clearVec:Fail to set values ", ((0.f == vec3.mV[VX]) && (0.f == vec3.mV[VY]) && (0.f == vec3.mV[VZ]))); vec3.setVec(x,y,z); @@ -137,10 +137,10 @@ namespace tut F32 x = 2.32f, y = 3.212f, z = -.12f; F32 min = 0.0001f, max = 3.0f; LLVector3 vec3(x,y,z); - ensure("1:clamp:Fail ", TRUE == vec3.clamp(min, max) && x == vec3.mV[VX] && max == vec3.mV[VY] && min == vec3.mV[VZ]); + ensure("1:clamp:Fail ", true == vec3.clamp(min, max) && x == vec3.mV[VX] && max == vec3.mV[VY] && min == vec3.mV[VZ]); x = 1.f, y = 2.2f, z = 2.8f; vec3.setVec(x,y,z); - ensure("2:clamp:Fail ", FALSE == vec3.clamp(min, max)); + ensure("2:clamp:Fail ", false == vec3.clamp(min, max)); } template<> template<> @@ -157,11 +157,11 @@ namespace tut { F32 x =-2.0f, y = -3.0f, z = 1.23f ; LLVector3 vec3(x,y,z); - ensure("1:abs():Fail ", (TRUE == vec3.abs())); - ensure("2:isNull():Fail", (FALSE == vec3.isNull())); //Returns TRUE if vector has a _very_small_ length + ensure("1:abs():Fail ", (true == vec3.abs())); + ensure("2:isNull():Fail", (false == vec3.isNull())); //Returns true if vector has a _very_small_ length x =.00000001f, y = .000001001f, z = .000001001f; vec3.setVec(x,y,z); - ensure("3:isNull(): Fail ", (TRUE == vec3.isNull())); + ensure("3:isNull(): Fail ", (true == vec3.isNull())); } template<> template<> @@ -169,13 +169,13 @@ namespace tut { F32 x =-2.0f, y = -3.0f, z = 1.f ; LLVector3 vec3(x,y,z),vec3a; - ensure("1:isExactlyZero():Fail ", (TRUE == vec3a.isExactlyZero())); + ensure("1:isExactlyZero():Fail ", (true == vec3a.isExactlyZero())); vec3a = vec3a.scaleVec(vec3); ensure("2:scaleVec: Fail ", vec3a.mV[VX] == 0.f && vec3a.mV[VY] == 0.f && vec3a.mV[VZ] == 0.f); vec3a.setVec(x,y,z); vec3a = vec3a.scaleVec(vec3); ensure("3:scaleVec: Fail ", ((4 == vec3a.mV[VX]) && (9 == vec3a.mV[VY]) &&(1 == vec3a.mV[VZ]))); - ensure("4:isExactlyZero():Fail ", (FALSE == vec3.isExactlyZero())); + ensure("4:isExactlyZero():Fail ", (false == vec3.isExactlyZero())); } template<> template<> @@ -356,7 +356,7 @@ namespace tut vec3.clearVec(); vec3.clearVec(); vec3a.setVec(vec3); - ensure("2:operator!= failed", ( FALSE == (vec3a != vec3))); + ensure("2:operator!= failed", ( false == (vec3a != vec3))); } template<> template<> @@ -454,15 +454,15 @@ namespace tut { F32 x1 =-2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, y2 = 1.11f, z2 = 1234.234f; LLVector3 vec3(x1,y1,z1), vec3a(x2,y2,z2); - ensure("1:operator< failed", (TRUE == (vec3 < vec3a))); + ensure("1:operator< failed", (true == (vec3 < vec3a))); x1 =-2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, y2 = 2.f, z2 = 1234.234f; vec3.setVec(x1,y1,z1); vec3a.setVec(x2,y2,z2); - ensure("2:operator< failed ", (TRUE == (vec3 < vec3a))); + ensure("2:operator< failed ", (true == (vec3 < vec3a))); x1 =2.3f, y1 = 2.f,z1 = 1.2f, x2 = 1.3f, vec3.setVec(x1,y1,z1); vec3a.setVec(x2,y2,z2); - ensure("3:operator< failed ", (FALSE == (vec3 < vec3a))); + ensure("3:operator< failed ", (false == (vec3 < vec3a))); } template<> template<> diff --git a/indra/llmath/tests/v4color_test.cpp b/indra/llmath/tests/v4color_test.cpp index 3b3adbda0d..e5d914a065 100644 --- a/indra/llmath/tests/v4color_test.cpp +++ b/indra/llmath/tests/v4color_test.cpp @@ -49,23 +49,23 @@ namespace tut void v4color_object::test<1>() { LLColor4 llcolor4; - ensure("1:LLColor4:Fail to initialize ", ((0 == llcolor4.mV[VX]) && (0 == llcolor4.mV[VY]) && (0 == llcolor4.mV[VZ])&& (1.0f == llcolor4.mV[VW]))); + ensure("1:LLColor4:Fail to initialize ", ((0 == llcolor4.mV[VRED]) && (0 == llcolor4.mV[VGREEN]) && (0 == llcolor4.mV[VBLUE])&& (1.0f == llcolor4.mV[VALPHA]))); F32 r = 0x20, g = 0xFFFF, b = 0xFF, a = 0xAF; LLColor4 llcolor4a(r,g,b); - ensure("2:LLColor4:Fail to initialize ", ((r == llcolor4a.mV[VX]) && (g == llcolor4a.mV[VY]) && (b == llcolor4a.mV[VZ])&& (1.0f == llcolor4a.mV[VW]))); + ensure("2:LLColor4:Fail to initialize ", ((r == llcolor4a.mV[VRED]) && (g == llcolor4a.mV[VGREEN]) && (b == llcolor4a.mV[VBLUE])&& (1.0f == llcolor4a.mV[VALPHA]))); LLColor4 llcolor4b(r,g,b,a); - ensure("3:LLColor4:Fail to initialize ", ((r == llcolor4b.mV[VX]) && (g == llcolor4b.mV[VY]) && (b == llcolor4b.mV[VZ])&& (a == llcolor4b.mV[VW]))); + ensure("3:LLColor4:Fail to initialize ", ((r == llcolor4b.mV[VRED]) && (g == llcolor4b.mV[VGREEN]) && (b == llcolor4b.mV[VBLUE])&& (a == llcolor4b.mV[VALPHA]))); const F32 vec[4] = {.112f ,23.2f, -4.2f, -.0001f}; LLColor4 llcolor4c(vec); - ensure("4:LLColor4:Fail to initialize ", ((vec[0] == llcolor4c.mV[VX]) && (vec[1] == llcolor4c.mV[VY]) && (vec[2] == llcolor4c.mV[VZ])&& (vec[3] == llcolor4c.mV[VW]))); + ensure("4:LLColor4:Fail to initialize ", ((vec[0] == llcolor4c.mV[VRED]) && (vec[1] == llcolor4c.mV[VGREEN]) && (vec[2] == llcolor4c.mV[VBLUE])&& (vec[3] == llcolor4c.mV[VALPHA]))); LLColor3 llcolor3(-2.23f,1.01f,42.3f); F32 val = -.1f; LLColor4 llcolor4d(llcolor3,val); - ensure("5:LLColor4:Fail to initialize ", ((llcolor3.mV[VX] == llcolor4d.mV[VX]) && (llcolor3.mV[VY] == llcolor4d.mV[VY]) && (llcolor3.mV[VZ] == llcolor4d.mV[VZ])&& (val == llcolor4d.mV[VW]))); + ensure("5:LLColor4:Fail to initialize ", ((llcolor3.mV[VRED] == llcolor4d.mV[VRED]) && (llcolor3.mV[VGREEN] == llcolor4d.mV[VGREEN]) && (llcolor3.mV[VBLUE] == llcolor4d.mV[VBLUE])&& (val == llcolor4d.mV[VALPHA]))); LLSD sd = llcolor4d.getValue(); LLColor4 llcolor4e(sd); @@ -76,7 +76,7 @@ namespace tut LLColor4 llcolor4g(color4u); const F32 SCALE = 1.f/255.f; F32 r2 = r1*SCALE, g2 = g1* SCALE, b2 = b1* SCALE; - ensure("7:LLColor4:Fail to initialize ", ((r2 == llcolor4g.mV[VX]) && (g2 == llcolor4g.mV[VY]) && (b2 == llcolor4g.mV[VZ]))); + ensure("7:LLColor4:Fail to initialize ", ((r2 == llcolor4g.mV[VRED]) && (g2 == llcolor4g.mV[VGREEN]) && (b2 == llcolor4g.mV[VBLUE]))); } template<> template<> @@ -98,10 +98,10 @@ namespace tut F32 r = 0x20, g = 0xFFFF, b = 0xFF,a = 0xAF; LLColor4 llcolor4(r,g,b,a); llcolor4.setToBlack(); - ensure("setToBlack:Fail to set the black ", ((0 == llcolor4.mV[VX]) && (0 == llcolor4.mV[VY]) && (0 == llcolor4.mV[VZ])&& (1.0f == llcolor4.mV[VW]))); + ensure("setToBlack:Fail to set the black ", ((0 == llcolor4.mV[VRED]) && (0 == llcolor4.mV[VGREEN]) && (0 == llcolor4.mV[VBLUE])&& (1.0f == llcolor4.mV[VALPHA]))); llcolor4.setToWhite(); - ensure("setToWhite:Fail to set the white ", ((1.f == llcolor4.mV[VX]) && (1.f == llcolor4.mV[VY]) && (1.f == llcolor4.mV[VZ])&& (1.0f == llcolor4.mV[VW]))); + ensure("setToWhite:Fail to set the white ", ((1.f == llcolor4.mV[VRED]) && (1.f == llcolor4.mV[VGREEN]) && (1.f == llcolor4.mV[VBLUE])&& (1.0f == llcolor4.mV[VALPHA]))); } template<> template<> @@ -110,10 +110,10 @@ namespace tut F32 r = 0x20, g = 0xFFFF, b = 0xFF, a = 0xAF; LLColor4 llcolor4; llcolor4.setVec(r,g,b); - ensure("1:setVec:Fail to set the values ", ((r == llcolor4.mV[VX]) && (g == llcolor4.mV[VY]) && (b == llcolor4.mV[VZ])&& (1.f == llcolor4.mV[VW]))); + ensure("1:setVec:Fail to set the values ", ((r == llcolor4.mV[VRED]) && (g == llcolor4.mV[VGREEN]) && (b == llcolor4.mV[VBLUE])&& (1.f == llcolor4.mV[VALPHA]))); llcolor4.setVec(r,g,b,a); - ensure("2:setVec:Fail to set the values ", ((r == llcolor4.mV[VX]) && (g == llcolor4.mV[VY]) && (b == llcolor4.mV[VZ])&& (a == llcolor4.mV[VW]))); + ensure("2:setVec:Fail to set the values ", ((r == llcolor4.mV[VRED]) && (g == llcolor4.mV[VGREEN]) && (b == llcolor4.mV[VBLUE])&& (a == llcolor4.mV[VALPHA]))); LLColor4 llcolor4a; llcolor4a.setVec(llcolor4); @@ -121,23 +121,23 @@ namespace tut LLColor3 llcolor3(-2.23f,1.01f,42.3f); llcolor4a.setVec(llcolor3); - ensure("4:setVec:Fail to set the values ", ((llcolor3.mV[VX] == llcolor4a.mV[VX]) && (llcolor3.mV[VY] == llcolor4a.mV[VY]) && (llcolor3.mV[VZ] == llcolor4a.mV[VZ]))); + ensure("4:setVec:Fail to set the values ", ((llcolor3.mV[VRED] == llcolor4a.mV[VRED]) && (llcolor3.mV[VGREEN] == llcolor4a.mV[VGREEN]) && (llcolor3.mV[VBLUE] == llcolor4a.mV[VBLUE]))); F32 val = -.33f; llcolor4a.setVec(llcolor3,val); - ensure("4:setVec:Fail to set the values ", ((llcolor3.mV[VX] == llcolor4a.mV[VX]) && (llcolor3.mV[VY] == llcolor4a.mV[VY]) && (llcolor3.mV[VZ] == llcolor4a.mV[VZ]) && (val == llcolor4a.mV[VW]))); + ensure("4:setVec:Fail to set the values ", ((llcolor3.mV[VRED] == llcolor4a.mV[VRED]) && (llcolor3.mV[VGREEN] == llcolor4a.mV[VGREEN]) && (llcolor3.mV[VBLUE] == llcolor4a.mV[VBLUE]) && (val == llcolor4a.mV[VALPHA]))); const F32 vec[4] = {.112f ,23.2f, -4.2f, -.0001f}; LLColor4 llcolor4c; llcolor4c.setVec(vec); - ensure("5:setVec:Fail to initialize ", ((vec[0] == llcolor4c.mV[VX]) && (vec[1] == llcolor4c.mV[VY]) && (vec[2] == llcolor4c.mV[VZ])&& (vec[3] == llcolor4c.mV[VW]))); + ensure("5:setVec:Fail to initialize ", ((vec[0] == llcolor4c.mV[VRED]) && (vec[1] == llcolor4c.mV[VGREEN]) && (vec[2] == llcolor4c.mV[VBLUE])&& (vec[3] == llcolor4c.mV[VALPHA]))); U8 r1 = 0xF2, g1 = 0xFA, b1= 0xBF; LLColor4U color4u(r1,g1,b1); llcolor4.setVec(color4u); const F32 SCALE = 1.f/255.f; F32 r2 = r1*SCALE, g2 = g1* SCALE, b2 = b1* SCALE; - ensure("6:setVec:Fail to initialize ", ((r2 == llcolor4.mV[VX]) && (g2 == llcolor4.mV[VY]) && (b2 == llcolor4.mV[VZ]))); + ensure("6:setVec:Fail to initialize ", ((r2 == llcolor4.mV[VRED]) && (g2 == llcolor4.mV[VGREEN]) && (b2 == llcolor4.mV[VBLUE]))); } template<> template<> @@ -146,7 +146,7 @@ namespace tut F32 alpha = 0xAF; LLColor4 llcolor4; llcolor4.setAlpha(alpha); - ensure("setAlpha:Fail to initialize ", (alpha == llcolor4.mV[VW])); + ensure("setAlpha:Fail to initialize ", (alpha == llcolor4.mV[VALPHA])); } template<> template<> @@ -209,7 +209,7 @@ namespace tut LLColor3 llcolor3(r,g,b); LLColor4 llcolor4a,llcolor4b; llcolor4a = llcolor3; - ensure("Operator=:Fail to initialize ", ((llcolor3.mV[0] == llcolor4a.mV[VX]) && (llcolor3.mV[1] == llcolor4a.mV[VY]) && (llcolor3.mV[2] == llcolor4a.mV[VZ]))); + ensure("Operator=:Fail to initialize ", ((llcolor3.mV[0] == llcolor4a.mV[VRED]) && (llcolor3.mV[1] == llcolor4a.mV[VGREEN]) && (llcolor3.mV[2] == llcolor4a.mV[VBLUE]))); LLSD sd = llcolor4a.getValue(); llcolor4b = LLColor4(sd); ensure_equals("Operator= LLSD:Fail ", llcolor4a, llcolor4b); @@ -234,10 +234,10 @@ namespace tut F32 r2 = 0xABF, g2 = 0xFB, b2 = 0xFFF; LLColor4 llcolor4a(r1,g1,b1),llcolor4b(r2,g2,b2),llcolor4c; llcolor4c = llcolor4b + llcolor4a; - ensure("operator+:Fail to Add the values ", (is_approx_equal(r1+r2,llcolor4c.mV[VX]) && is_approx_equal(g1+g2,llcolor4c.mV[VY]) && is_approx_equal(b1+b2,llcolor4c.mV[VZ]))); + ensure("operator+:Fail to Add the values ", (is_approx_equal(r1+r2,llcolor4c.mV[VRED]) && is_approx_equal(g1+g2,llcolor4c.mV[VGREEN]) && is_approx_equal(b1+b2,llcolor4c.mV[VBLUE]))); llcolor4b += llcolor4a; - ensure("operator+=:Fail to Add the values ", (is_approx_equal(r1+r2,llcolor4b.mV[VX]) && is_approx_equal(g1+g2,llcolor4b.mV[VY]) && is_approx_equal(b1+b2,llcolor4b.mV[VZ]))); + ensure("operator+=:Fail to Add the values ", (is_approx_equal(r1+r2,llcolor4b.mV[VRED]) && is_approx_equal(g1+g2,llcolor4b.mV[VGREEN]) && is_approx_equal(b1+b2,llcolor4b.mV[VBLUE]))); } template<> template<> @@ -247,10 +247,10 @@ namespace tut F32 r2 = 0xABF, g2 = 0xFB, b2 = 0xFFF; LLColor4 llcolor4a(r1,g1,b1),llcolor4b(r2,g2,b2),llcolor4c; llcolor4c = llcolor4a - llcolor4b; - ensure("operator-:Fail to subtract the values ", (is_approx_equal(r1-r2,llcolor4c.mV[VX]) && is_approx_equal(g1-g2,llcolor4c.mV[VY]) && is_approx_equal(b1-b2,llcolor4c.mV[VZ]))); + ensure("operator-:Fail to subtract the values ", (is_approx_equal(r1-r2,llcolor4c.mV[VRED]) && is_approx_equal(g1-g2,llcolor4c.mV[VGREEN]) && is_approx_equal(b1-b2,llcolor4c.mV[VBLUE]))); llcolor4a -= llcolor4b; - ensure("operator-=:Fail to subtract the values ", (is_approx_equal(r1-r2,llcolor4a.mV[VX]) && is_approx_equal(g1-g2,llcolor4a.mV[VY]) && is_approx_equal(b1-b2,llcolor4a.mV[VZ]))); + ensure("operator-=:Fail to subtract the values ", (is_approx_equal(r1-r2,llcolor4a.mV[VRED]) && is_approx_equal(g1-g2,llcolor4a.mV[VGREEN]) && is_approx_equal(b1-b2,llcolor4a.mV[VBLUE]))); } template<> template<> @@ -260,20 +260,20 @@ namespace tut F32 r2 = 0xABF, g2 = 0xFB, b2 = 0xFFF; LLColor4 llcolor4a(r1,g1,b1),llcolor4b(r2,g2,b2),llcolor4c; llcolor4c = llcolor4a * llcolor4b; - ensure("1:operator*:Fail to multiply the values", (is_approx_equal(r1*r2,llcolor4c.mV[VX]) && is_approx_equal(g1*g2,llcolor4c.mV[VY]) && is_approx_equal(b1*b2,llcolor4c.mV[VZ]))); + ensure("1:operator*:Fail to multiply the values", (is_approx_equal(r1*r2,llcolor4c.mV[VRED]) && is_approx_equal(g1*g2,llcolor4c.mV[VGREEN]) && is_approx_equal(b1*b2,llcolor4c.mV[VBLUE]))); F32 mulVal = 3.33f; llcolor4c = llcolor4a * mulVal; - ensure("2:operator*:Fail ", (is_approx_equal(r1*mulVal,llcolor4c.mV[VX]) && is_approx_equal(g1*mulVal,llcolor4c.mV[VY]) && is_approx_equal(b1*mulVal,llcolor4c.mV[VZ]))); + ensure("2:operator*:Fail ", (is_approx_equal(r1*mulVal,llcolor4c.mV[VRED]) && is_approx_equal(g1*mulVal,llcolor4c.mV[VGREEN]) && is_approx_equal(b1*mulVal,llcolor4c.mV[VBLUE]))); llcolor4c = mulVal * llcolor4a; - ensure("3:operator*:Fail to multiply the values", (is_approx_equal(r1*mulVal,llcolor4c.mV[VX]) && is_approx_equal(g1*mulVal,llcolor4c.mV[VY]) && is_approx_equal(b1*mulVal,llcolor4c.mV[VZ]))); + ensure("3:operator*:Fail to multiply the values", (is_approx_equal(r1*mulVal,llcolor4c.mV[VRED]) && is_approx_equal(g1*mulVal,llcolor4c.mV[VGREEN]) && is_approx_equal(b1*mulVal,llcolor4c.mV[VBLUE]))); llcolor4a *= mulVal; - ensure("4:operator*=:Fail to multiply the values ", (is_approx_equal(r1*mulVal,llcolor4a.mV[VX]) && is_approx_equal(g1*mulVal,llcolor4a.mV[VY]) && is_approx_equal(b1*mulVal,llcolor4a.mV[VZ]))); + ensure("4:operator*=:Fail to multiply the values ", (is_approx_equal(r1*mulVal,llcolor4a.mV[VRED]) && is_approx_equal(g1*mulVal,llcolor4a.mV[VGREEN]) && is_approx_equal(b1*mulVal,llcolor4a.mV[VBLUE]))); LLColor4 llcolor4d(r1,g1,b1),llcolor4e(r2,g2,b2); llcolor4e *= llcolor4d; - ensure("5:operator*=:Fail to multiply the values ", (is_approx_equal(r1*r2,llcolor4e.mV[VX]) && is_approx_equal(g1*g2,llcolor4e.mV[VY]) && is_approx_equal(b1*b2,llcolor4e.mV[VZ]))); + ensure("5:operator*=:Fail to multiply the values ", (is_approx_equal(r1*r2,llcolor4e.mV[VRED]) && is_approx_equal(g1*g2,llcolor4e.mV[VGREEN]) && is_approx_equal(b1*b2,llcolor4e.mV[VBLUE]))); } template<> template<> @@ -283,13 +283,13 @@ namespace tut F32 div = 12.345f; LLColor4 llcolor4a(r,g,b,a),llcolor4b; llcolor4b = llcolor4a % div;//chnage only alpha value nor r,g,b; - ensure("1operator%:Fail ", (is_approx_equal(r,llcolor4b.mV[VX]) && is_approx_equal(g,llcolor4b.mV[VY]) && is_approx_equal(b,llcolor4b.mV[VZ])&& is_approx_equal(div*a,llcolor4b.mV[VW]))); + ensure("1operator%:Fail ", (is_approx_equal(r,llcolor4b.mV[VRED]) && is_approx_equal(g,llcolor4b.mV[VGREEN]) && is_approx_equal(b,llcolor4b.mV[VBLUE])&& is_approx_equal(div*a,llcolor4b.mV[VALPHA]))); llcolor4b = div % llcolor4a; - ensure("2operator%:Fail ", (is_approx_equal(r,llcolor4b.mV[VX]) && is_approx_equal(g,llcolor4b.mV[VY]) && is_approx_equal(b,llcolor4b.mV[VZ])&& is_approx_equal(div*a,llcolor4b.mV[VW]))); + ensure("2operator%:Fail ", (is_approx_equal(r,llcolor4b.mV[VRED]) && is_approx_equal(g,llcolor4b.mV[VGREEN]) && is_approx_equal(b,llcolor4b.mV[VBLUE])&& is_approx_equal(div*a,llcolor4b.mV[VALPHA]))); llcolor4a %= div; - ensure("operator%=:Fail ", (is_approx_equal(a*div,llcolor4a.mV[VW]))); + ensure("operator%=:Fail ", (is_approx_equal(a*div,llcolor4a.mV[VALPHA]))); } template<> template<> @@ -312,7 +312,7 @@ namespace tut F32 r = 0x20, g = 0xFFFF, b = 0xFF; LLColor4 llcolor4a(r,g,b),llcolor4b; LLColor3 llcolor3 = vec4to3(llcolor4a); - ensure("vec4to3:Fail to convert vec4 to vec3 ", (is_approx_equal(llcolor3.mV[VX],llcolor4a.mV[VX]) && is_approx_equal(llcolor3.mV[VY],llcolor4a.mV[VY]) && is_approx_equal(llcolor3.mV[VZ],llcolor4a.mV[VZ]))); + ensure("vec4to3:Fail to convert vec4 to vec3 ", (is_approx_equal(llcolor3.mV[VRED],llcolor4a.mV[VRED]) && is_approx_equal(llcolor3.mV[VGREEN],llcolor4a.mV[VGREEN]) && is_approx_equal(llcolor3.mV[VBLUE],llcolor4a.mV[VBLUE]))); llcolor4b = vec3to4(llcolor3); ensure_equals("vec3to4:Fail to convert vec3 to vec4 ", llcolor4b, llcolor4a); } @@ -324,7 +324,7 @@ namespace tut F32 r2 = 0xABF, g2 = 0xFB, b2 = 0xFFF; LLColor4 llcolor4a(r1,g1,b1),llcolor4b(r2,g2,b2),llcolor4c; llcolor4c = lerp(llcolor4a,llcolor4b,val); - ensure("lerp:Fail ", (is_approx_equal(r1 + (r2 - r1)* val,llcolor4c.mV[VX]) && is_approx_equal(g1 + (g2 - g1)* val,llcolor4c.mV[VY]) && is_approx_equal(b1 + (b2 - b1)* val,llcolor4c.mV[VZ]))); + ensure("lerp:Fail ", (is_approx_equal(r1 + (r2 - r1)* val,llcolor4c.mV[VRED]) && is_approx_equal(g1 + (g2 - g1)* val,llcolor4c.mV[VGREEN]) && is_approx_equal(b1 + (b2 - b1)* val,llcolor4c.mV[VBLUE]))); } template<> template<> diff --git a/indra/llmath/tests/v4coloru_test.cpp b/indra/llmath/tests/v4coloru_test.cpp index 2b6ee952a3..9d707d18c5 100644 --- a/indra/llmath/tests/v4coloru_test.cpp +++ b/indra/llmath/tests/v4coloru_test.cpp @@ -48,18 +48,18 @@ namespace tut void v4coloru_object::test<1>() { LLColor4U llcolor4u; - ensure("1:LLColor4u:Fail to initialize ", ((0 == llcolor4u.mV[VX]) && (0 == llcolor4u.mV[VY]) && (0 == llcolor4u.mV[VZ])&& (255 == llcolor4u.mV[VW]))); + ensure("1:LLColor4u:Fail to initialize ", ((0 == llcolor4u.mV[VRED]) && (0 == llcolor4u.mV[VGREEN]) && (0 == llcolor4u.mV[VBLUE])&& (255 == llcolor4u.mV[VALPHA]))); U8 r = 0x12, g = 0xFF, b = 0xAF, a = 0x23; LLColor4U llcolor4u1(r,g,b); - ensure("2:LLColor4u:Fail to initialize ", ((r == llcolor4u1.mV[VX]) && (g == llcolor4u1.mV[VY]) && (b == llcolor4u1.mV[VZ])&& (255 == llcolor4u1.mV[VW]))); + ensure("2:LLColor4u:Fail to initialize ", ((r == llcolor4u1.mV[VRED]) && (g == llcolor4u1.mV[VGREEN]) && (b == llcolor4u1.mV[VBLUE])&& (255 == llcolor4u1.mV[VALPHA]))); LLColor4U llcolor4u2(r,g,b,a); - ensure("3:LLColor4u:Fail to initialize ", ((r == llcolor4u2.mV[VX]) && (g == llcolor4u2.mV[VY]) && (b == llcolor4u2.mV[VZ])&& (a == llcolor4u2.mV[VW]))); + ensure("3:LLColor4u:Fail to initialize ", ((r == llcolor4u2.mV[VRED]) && (g == llcolor4u2.mV[VGREEN]) && (b == llcolor4u2.mV[VBLUE])&& (a == llcolor4u2.mV[VALPHA]))); const U8 vec[4] = {0x12,0xFF,0xAF,0x23}; LLColor4U llcolor4u3(vec); - ensure("4:LLColor4u:Fail to initialize ", ((vec[0] == llcolor4u3.mV[VX]) && (vec[1] == llcolor4u3.mV[VY]) && (vec[2] == llcolor4u3.mV[VZ])&& (vec[3] == llcolor4u3.mV[VW]))); + ensure("4:LLColor4u:Fail to initialize ", ((vec[0] == llcolor4u3.mV[VRED]) && (vec[1] == llcolor4u3.mV[VGREEN]) && (vec[2] == llcolor4u3.mV[VBLUE])&& (vec[3] == llcolor4u3.mV[VALPHA]))); LLSD sd = llcolor4u3.getValue(); LLColor4U llcolor4u4(sd); @@ -82,10 +82,10 @@ namespace tut U8 r = 0x12, g = 0xFF, b = 0xAF, a = 0x23; LLColor4U llcolor4u(r,g,b,a); llcolor4u.setToBlack(); - ensure("setToBlack:Fail to set black ", ((0 == llcolor4u.mV[VX]) && (0 == llcolor4u.mV[VY]) && (0 == llcolor4u.mV[VZ])&& (255 == llcolor4u.mV[VW]))); + ensure("setToBlack:Fail to set black ", ((0 == llcolor4u.mV[VRED]) && (0 == llcolor4u.mV[VGREEN]) && (0 == llcolor4u.mV[VBLUE])&& (255 == llcolor4u.mV[VALPHA]))); llcolor4u.setToWhite(); - ensure("setToWhite:Fail to white ", ((255 == llcolor4u.mV[VX]) && (255 == llcolor4u.mV[VY]) && (255 == llcolor4u.mV[VZ])&& (255 == llcolor4u.mV[VW]))); + ensure("setToWhite:Fail to white ", ((255 == llcolor4u.mV[VRED]) && (255 == llcolor4u.mV[VGREEN]) && (255 == llcolor4u.mV[VBLUE])&& (255 == llcolor4u.mV[VALPHA]))); } template<> template<> @@ -104,11 +104,11 @@ namespace tut U8 r = 0x12, g = 0xFF, b = 0xAF, a = 0x23; LLColor4U llcolor4u; llcolor4u.setVec(r,g,b,a); - ensure("1:setVec:Fail to set the values ", ((r == llcolor4u.mV[VX]) && (g == llcolor4u.mV[VY]) && (b == llcolor4u.mV[VZ])&& (a == llcolor4u.mV[VW]))); + ensure("1:setVec:Fail to set the values ", ((r == llcolor4u.mV[VRED]) && (g == llcolor4u.mV[VGREEN]) && (b == llcolor4u.mV[VBLUE])&& (a == llcolor4u.mV[VALPHA]))); llcolor4u.setToBlack(); llcolor4u.setVec(r,g,b); - ensure("2:setVec:Fail to set the values ", ((r == llcolor4u.mV[VX]) && (g == llcolor4u.mV[VY]) && (b == llcolor4u.mV[VZ])&& (255 == llcolor4u.mV[VW]))); + ensure("2:setVec:Fail to set the values ", ((r == llcolor4u.mV[VRED]) && (g == llcolor4u.mV[VGREEN]) && (b == llcolor4u.mV[VBLUE])&& (255 == llcolor4u.mV[VALPHA]))); LLColor4U llcolor4u1; llcolor4u1.setVec(llcolor4u); @@ -117,7 +117,7 @@ namespace tut const U8 vec[4] = {0x12,0xFF,0xAF,0x23}; LLColor4U llcolor4u2; llcolor4u2.setVec(vec); - ensure("4:setVec:Fail to set the values ", ((vec[0] == llcolor4u2.mV[VX]) && (vec[1] == llcolor4u2.mV[VY]) && (vec[2] == llcolor4u2.mV[VZ])&& (vec[3] == llcolor4u2.mV[VW]))); + ensure("4:setVec:Fail to set the values ", ((vec[0] == llcolor4u2.mV[VRED]) && (vec[1] == llcolor4u2.mV[VGREEN]) && (vec[2] == llcolor4u2.mV[VBLUE])&& (vec[3] == llcolor4u2.mV[VALPHA]))); } template<> template<> @@ -126,7 +126,7 @@ namespace tut U8 alpha = 0x12; LLColor4U llcolor4u; llcolor4u.setAlpha(alpha); - ensure("setAlpha:Fail to set alpha value ", (alpha == llcolor4u.mV[VW])); + ensure("setAlpha:Fail to set alpha value ", (alpha == llcolor4u.mV[VALPHA])); } template<> template<> @@ -159,29 +159,29 @@ namespace tut llcolor4u3 = llcolor4u1 + llcolor4u2; ensure_equals( "1a.operator+:Fail to Add the values ", - llcolor4u3.mV[VX], + llcolor4u3.mV[VRED], (U8)(r1+r2)); ensure_equals( "1b.operator+:Fail to Add the values ", - llcolor4u3.mV[VY], + llcolor4u3.mV[VGREEN], (U8)(g1+g2)); ensure_equals( "1c.operator+:Fail to Add the values ", - llcolor4u3.mV[VZ], + llcolor4u3.mV[VBLUE], (U8)(b1+b2)); llcolor4u2 += llcolor4u1; ensure_equals( "2a.operator+=:Fail to Add the values ", - llcolor4u2.mV[VX], + llcolor4u2.mV[VRED], (U8)(r1+r2)); ensure_equals( "2b.operator+=:Fail to Add the values ", - llcolor4u2.mV[VY], + llcolor4u2.mV[VGREEN], (U8)(g1+g2)); ensure_equals( "2c.operator+=:Fail to Add the values ", - llcolor4u2.mV[VZ], + llcolor4u2.mV[VBLUE], (U8)(b1+b2)); } @@ -194,29 +194,29 @@ namespace tut llcolor4u3 = llcolor4u1 - llcolor4u2; ensure_equals( "1a. operator-:Fail to Add the values ", - llcolor4u3.mV[VX], + llcolor4u3.mV[VRED], (U8)(r1-r2)); ensure_equals( "1b. operator-:Fail to Add the values ", - llcolor4u3.mV[VY], + llcolor4u3.mV[VGREEN], (U8)(g1-g2)); ensure_equals( "1c. operator-:Fail to Add the values ", - llcolor4u3.mV[VZ], + llcolor4u3.mV[VBLUE], (U8)(b1-b2)); llcolor4u1 -= llcolor4u2; ensure_equals( "2a. operator-=:Fail to Add the values ", - llcolor4u1.mV[VX], + llcolor4u1.mV[VRED], (U8)(r1-r2)); ensure_equals( "2b. operator-=:Fail to Add the values ", - llcolor4u1.mV[VY], + llcolor4u1.mV[VGREEN], (U8)(g1-g2)); ensure_equals( "2c. operator-=:Fail to Add the values ", - llcolor4u1.mV[VZ], + llcolor4u1.mV[VBLUE], (U8)(b1-b2)); } @@ -229,30 +229,30 @@ namespace tut llcolor4u3 = llcolor4u1 * llcolor4u2; ensure_equals( "1a. operator*:Fail to multiply the values", - llcolor4u3.mV[VX], + llcolor4u3.mV[VRED], (U8)(r1*r2)); ensure_equals( "1b. operator*:Fail to multiply the values", - llcolor4u3.mV[VY], + llcolor4u3.mV[VGREEN], (U8)(g1*g2)); ensure_equals( "1c. operator*:Fail to multiply the values", - llcolor4u3.mV[VZ], + llcolor4u3.mV[VBLUE], (U8)(b1*b2)); U8 mulVal = 123; llcolor4u1 *= mulVal; ensure_equals( "2a. operator*=:Fail to multiply the values", - llcolor4u1.mV[VX], + llcolor4u1.mV[VRED], (U8)(r1*mulVal)); ensure_equals( "2b. operator*=:Fail to multiply the values", - llcolor4u1.mV[VY], + llcolor4u1.mV[VGREEN], (U8)(g1*mulVal)); ensure_equals( "2c. operator*=:Fail to multiply the values", - llcolor4u1.mV[VZ], + llcolor4u1.mV[VBLUE], (U8)(b1*mulVal)); } @@ -274,7 +274,7 @@ namespace tut LLColor4U llcolor4u(r,g,b,a); U8 modVal = 45; llcolor4u %= modVal; - ensure_equals("operator%=:Fail ", llcolor4u.mV[VW], (U8)(a * modVal)); + ensure_equals("operator%=:Fail ", llcolor4u.mV[VALPHA], (U8)(a * modVal)); } template<> template<> @@ -284,13 +284,13 @@ namespace tut LLColor4U llcolor4u1(r,g,b,a); std::string color("12, 23, 132, 50"); LLColor4U::parseColor4U(color, &llcolor4u1); - ensure("parseColor4U() failed to parse the color value ", ((12 == llcolor4u1.mV[VX]) && (23 == llcolor4u1.mV[VY]) && (132 == llcolor4u1.mV[VZ])&& (50 == llcolor4u1.mV[VW]))); + ensure("parseColor4U() failed to parse the color value ", ((12 == llcolor4u1.mV[VRED]) && (23 == llcolor4u1.mV[VGREEN]) && (132 == llcolor4u1.mV[VBLUE])&& (50 == llcolor4u1.mV[VALPHA]))); color = "12, 23, 132"; - ensure("2:parseColor4U() failed to parse the color value ", (FALSE == LLColor4U::parseColor4U(color, &llcolor4u1))); + ensure("2:parseColor4U() failed to parse the color value ", (false == LLColor4U::parseColor4U(color, &llcolor4u1))); color = "12"; - ensure("2:parseColor4U() failed to parse the color value ", (FALSE == LLColor4U::parseColor4U(color, &llcolor4u1))); + ensure("2:parseColor4U() failed to parse the color value ", (false == LLColor4U::parseColor4U(color, &llcolor4u1))); } template<> template<> @@ -300,8 +300,8 @@ namespace tut LLColor4U llcolor4u(r,g,b,a),llcolor4u1; const F32 fVal = 3.f; llcolor4u1 = llcolor4u.multAll(fVal); - ensure("multAll:Fail to multiply ", (((U8)ll_round(r * fVal) == llcolor4u1.mV[VX]) && (U8)ll_round(g * fVal) == llcolor4u1.mV[VY] - && ((U8)ll_round(b * fVal) == llcolor4u1.mV[VZ])&& ((U8)ll_round(a * fVal) == llcolor4u1.mV[VW]))); + ensure("multAll:Fail to multiply ", (((U8)ll_round(r * fVal) == llcolor4u1.mV[VRED]) && (U8)ll_round(g * fVal) == llcolor4u1.mV[VGREEN] + && ((U8)ll_round(b * fVal) == llcolor4u1.mV[VBLUE])&& ((U8)ll_round(a * fVal) == llcolor4u1.mV[VALPHA]))); } template<> template<> @@ -311,13 +311,13 @@ namespace tut U8 r2 = 23, g2 = 230, b2 = 124, a2 = 255; LLColor4U llcolor4u(r1,g1,b1,a1),llcolor4u1(r2,g2,b2,a2); llcolor4u1 = llcolor4u1.addClampMax(llcolor4u); - ensure("1:addClampMax():Fail to add the value ", ((r1+r2 == llcolor4u1.mV[VX]) && (255 == llcolor4u1.mV[VY]) && (b1+b2 == llcolor4u1.mV[VZ])&& (255 == llcolor4u1.mV[VW]))); + ensure("1:addClampMax():Fail to add the value ", ((r1+r2 == llcolor4u1.mV[VRED]) && (255 == llcolor4u1.mV[VGREEN]) && (b1+b2 == llcolor4u1.mV[VBLUE])&& (255 == llcolor4u1.mV[VALPHA]))); r1 = 132, g1 = 3, b1 = 3, a1 = 2; r2 = 123, g2 = 230, b2 = 154, a2 = 25; LLColor4U llcolor4u2(r1,g1,b1,a1),llcolor4u3(r2,g2,b2,a2); llcolor4u3 = llcolor4u3.addClampMax(llcolor4u2); - ensure("2:addClampMax():Fail to add the value ", ((255 == llcolor4u3.mV[VX]) && (g1+g2 == llcolor4u3.mV[VY]) && (b1+b2 == llcolor4u3.mV[VZ])&& (a1+a2 == llcolor4u3.mV[VW]))); + ensure("2:addClampMax():Fail to add the value ", ((255 == llcolor4u3.mV[VRED]) && (g1+g2 == llcolor4u3.mV[VGREEN]) && (b1+b2 == llcolor4u3.mV[VBLUE])&& (a1+a2 == llcolor4u3.mV[VALPHA]))); } template<> template<> @@ -331,6 +331,6 @@ namespace tut F32 color_scale_factor = MAX_COLOR/r; S32 r2 = ll_round(r * color_scale_factor); S32 g2 = ll_round(g * color_scale_factor); - ensure("setVecScaleClamp():Fail to add the value ", ((r2 == llcolor4u.mV[VX]) && (g2 == llcolor4u.mV[VY]) && (0 == llcolor4u.mV[VZ])&& (255 == llcolor4u.mV[VW]))); + ensure("setVecScaleClamp():Fail to add the value ", ((r2 == llcolor4u.mV[VRED]) && (g2 == llcolor4u.mV[VGREEN]) && (0 == llcolor4u.mV[VBLUE])&& (255 == llcolor4u.mV[VALPHA]))); } } diff --git a/indra/llmath/tests/v4math_test.cpp b/indra/llmath/tests/v4math_test.cpp index 07099cd417..236585f13b 100644 --- a/indra/llmath/tests/v4math_test.cpp +++ b/indra/llmath/tests/v4math_test.cpp @@ -123,9 +123,9 @@ namespace tut vec4.abs(); ensure("abs:Fail " ,((x == vec4.mV[VX]) && (-y == vec4.mV[VY]) && (-z == vec4.mV[VZ])&& (-w == vec4.mV[VW]))); vec4.clearVec(); - ensure("isExactlyClear:Fail " ,(TRUE == vec4.isExactlyClear())); + ensure("isExactlyClear:Fail " ,(true == vec4.isExactlyClear())); vec4.zeroVec(); - ensure("isExactlyZero:Fail " ,(TRUE == vec4.isExactlyZero())); + ensure("isExactlyZero:Fail " ,(true == vec4.isExactlyZero())); } template<> template<> @@ -303,11 +303,11 @@ namespace tut { F32 x = 1.f, y = 2.f, z = -1.1f,epsilon = .23425f; LLVector4 vec4(x,y,z), vec4a(x,y,z); - ensure("1:are_parallel: Fail " ,(TRUE == are_parallel(vec4a,vec4,epsilon))); + ensure("1:are_parallel: Fail " ,(true == are_parallel(vec4a,vec4,epsilon))); x = 21.f, y = 12.f, z = -123.1f; vec4a.clearVec(); vec4a.setVec(x,y,z); - ensure("2:are_parallel: Fail " ,(FALSE == are_parallel(vec4a,vec4,epsilon))); + ensure("2:are_parallel: Fail " ,(false == are_parallel(vec4a,vec4,epsilon))); } template<> template<> diff --git a/indra/llmath/tests/xform_test.cpp b/indra/llmath/tests/xform_test.cpp index ad56cdb15c..6d6a64ec4c 100644 --- a/indra/llmath/tests/xform_test.cpp +++ b/indra/llmath/tests/xform_test.cpp @@ -91,7 +91,7 @@ namespace tut xform_obj.setPositionZ(z); ensure("setPositionX/Y/Z failed: ", xform_obj.getPosition() == vec); - xform_obj.setScaleChildOffset(TRUE); + xform_obj.setScaleChildOffset(true); ensure("setScaleChildOffset failed: ", xform_obj.getScaleChildOffset()); vec.setVec(x, y, z); @@ -121,7 +121,7 @@ namespace tut // Is that the expected behavior? } - // test cases for inline BOOL setParent(LLXform *parent) and getParent() fn. + // test cases for inline bool setParent(LLXform *parent) and getParent() fn. template<> template<> void xform_test_object_t::test<3>() { @@ -216,7 +216,7 @@ namespace tut parent.setPosition(llvecpospar); LLVector3 llvecparentscale(1.0, 2.0, 0); - parent.setScaleChildOffset(TRUE); + parent.setScaleChildOffset(true); parent.setScale(llvecparentscale); LLQuaternion quat(1, 2, 3, 4); diff --git a/indra/llmath/v2math.cpp b/indra/llmath/v2math.cpp index ecbfe7378c..4649e13376 100644 --- a/indra/llmath/v2math.cpp +++ b/indra/llmath/v2math.cpp @@ -42,13 +42,13 @@ LLVector2 LLVector2::zero(0,0); // Non-member functions // Sets all values to absolute value of their original values -// Returns TRUE if data changed -BOOL LLVector2::abs() +// Returns true if data changed +bool LLVector2::abs() { - BOOL ret = FALSE; + bool ret{ false }; - if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = TRUE; } - if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = TRUE; } + if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; } + if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; } return ret; } @@ -67,7 +67,7 @@ F32 angle_between(const LLVector2& a, const LLVector2& b) return angle; } -BOOL are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon) +bool are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon) { LLVector2 an = a; LLVector2 bn = b; @@ -76,9 +76,9 @@ BOOL are_parallel(const LLVector2 &a, const LLVector2 &b, float epsilon) F32 dot = an * bn; if ( (1.0f - fabs(dot)) < epsilon) { - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h index 5c756a7f84..a61c946304 100644 --- a/indra/llmath/v2math.h +++ b/indra/llmath/v2math.h @@ -78,12 +78,12 @@ class LLVector2 F32 magVecSquared() const; // deprecated F32 normVec(); // deprecated - BOOL abs(); // sets all values to absolute value of original value (first octant), returns TRUE if changed + bool abs(); // sets all values to absolute value of original value (first octant), returns true if changed const LLVector2& scaleVec(const LLVector2& vec); // scales per component by vec - BOOL isNull(); // Returns TRUE if vector has a _very_small_ length - BOOL isExactlyZero() const { return !mV[VX] && !mV[VY]; } + bool isNull(); // Returns true if vector has a _very_small_ length + bool isExactlyZero() const { return !mV[VX] && !mV[VY]; } F32 operator[](int idx) const { return mV[idx]; } F32 &operator[](int idx) { return mV[idx]; } @@ -114,7 +114,7 @@ class LLVector2 // Non-member functions F32 angle_between(const LLVector2 &a, const LLVector2 &b); // Returns angle (radians) between a and b -BOOL are_parallel(const LLVector2 &a, const LLVector2 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns TRUE if a and b are very close to parallel +bool are_parallel(const LLVector2 &a, const LLVector2 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel F32 dist_vec(const LLVector2 &a, const LLVector2 &b); // Returns distance between a and b F32 dist_vec_squared(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b F32 dist_vec_squared2D(const LLVector2 &a, const LLVector2 &b);// Returns distance squared between a and b ignoring Z component @@ -232,7 +232,7 @@ inline F32 LLVector2::lengthSquared(void) const return mV[0]*mV[0] + mV[1]*mV[1]; } -inline F32 LLVector2::normalize(void) +inline F32 LLVector2::normalize(void) { F32 mag = (F32) sqrt(mV[0]*mV[0] + mV[1]*mV[1]); F32 oomag; @@ -299,13 +299,13 @@ inline const LLVector2& LLVector2::scaleVec(const LLVector2& vec) return *this; } -inline BOOL LLVector2::isNull() +inline bool LLVector2::isNull() { if ( F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY] ) { - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/indra/llmath/v3color.cpp b/indra/llmath/v3color.cpp index 9fe9c8d5e5..4367b993f8 100644 --- a/indra/llmath/v3color.cpp +++ b/indra/llmath/v3color.cpp @@ -63,7 +63,7 @@ const LLColor3& LLColor3::operator=(const LLColor4 &a) std::ostream& operator<<(std::ostream& s, const LLColor3 &a) { - s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << " }"; + s << "{ " << a.mV[VRED] << ", " << a.mV[VGREEN] << ", " << a.mV[VBLUE] << " }"; return s; } diff --git a/indra/llmath/v3color.h b/indra/llmath/v3color.h index ea26e9eb76..7b92f85a0c 100644 --- a/indra/llmath/v3color.h +++ b/indra/llmath/v3color.h @@ -196,17 +196,17 @@ inline LLColor3::LLColor3(void) inline LLColor3::LLColor3(F32 r, F32 g, F32 b) { - mV[VX] = r; - mV[VY] = g; - mV[VZ] = b; + mV[VRED] = r; + mV[VGREEN] = g; + mV[VBLUE] = b; } inline LLColor3::LLColor3(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; } #if LL_WINDOWS @@ -226,11 +226,11 @@ inline LLColor3::LLColor3(const char* color_string) // takes a string of format char tempstr[7]; strncpy(tempstr,color_string,6); /* Flawfinder: ignore */ tempstr[6] = '\0'; - mV[VZ] = (F32)strtol(&tempstr[4],NULL,16)/255.f; + mV[VBLUE] = (F32)strtol(&tempstr[4],NULL,16)/255.f; tempstr[4] = '\0'; - mV[VY] = (F32)strtol(&tempstr[2],NULL,16)/255.f; + mV[VGREEN] = (F32)strtol(&tempstr[2],NULL,16)/255.f; tempstr[2] = '\0'; - mV[VX] = (F32)strtol(&tempstr[0],NULL,16)/255.f; + mV[VRED] = (F32)strtol(&tempstr[0],NULL,16)/255.f; } inline const LLColor3& LLColor3::setToBlack(void) diff --git a/indra/llmath/v3dmath.cpp b/indra/llmath/v3dmath.cpp index 6ecd1a00ac..bb55c812b5 100644 --- a/indra/llmath/v3dmath.cpp +++ b/indra/llmath/v3dmath.cpp @@ -52,31 +52,31 @@ const LLVector3d LLVector3d::z_axis_neg(0, 0, -1); // Clamps each values to range (min,max). -// Returns TRUE if data changed. -BOOL LLVector3d::clamp(F64 min, F64 max) +// Returns true if data changed. +bool LLVector3d::clamp(F64 min, F64 max) { - BOOL ret = FALSE; + bool ret{ false }; - if (mdV[0] < min) { mdV[0] = min; ret = TRUE; } - if (mdV[1] < min) { mdV[1] = min; ret = TRUE; } - if (mdV[2] < min) { mdV[2] = min; ret = TRUE; } + if (mdV[0] < min) { mdV[0] = min; ret = true; } + if (mdV[1] < min) { mdV[1] = min; ret = true; } + if (mdV[2] < min) { mdV[2] = min; ret = true; } - if (mdV[0] > max) { mdV[0] = max; ret = TRUE; } - if (mdV[1] > max) { mdV[1] = max; ret = TRUE; } - if (mdV[2] > max) { mdV[2] = max; ret = TRUE; } + if (mdV[0] > max) { mdV[0] = max; ret = true; } + if (mdV[1] > max) { mdV[1] = max; ret = true; } + if (mdV[2] > max) { mdV[2] = max; ret = true; } return ret; } // Sets all values to absolute value of their original values -// Returns TRUE if data changed -BOOL LLVector3d::abs() +// Returns true if data changed +bool LLVector3d::abs() { - BOOL ret = FALSE; + bool ret{ false }; - if (mdV[0] < 0.0) { mdV[0] = -mdV[0]; ret = TRUE; } - if (mdV[1] < 0.0) { mdV[1] = -mdV[1]; ret = TRUE; } - if (mdV[2] < 0.0) { mdV[2] = -mdV[2]; ret = TRUE; } + if (mdV[0] < 0.0) { mdV[0] = -mdV[0]; ret = true; } + if (mdV[1] < 0.0) { mdV[1] = -mdV[1]; ret = true; } + if (mdV[2] < 0.0) { mdV[2] = -mdV[2]; ret = true; } return ret; } @@ -127,11 +127,11 @@ const LLVector3d& LLVector3d::rotVec(F64 angle, F64 x, F64 y, F64 z) } -BOOL LLVector3d::parseVector3d(const std::string& buf, LLVector3d* value) +bool LLVector3d::parseVector3d(const std::string& buf, LLVector3d* value) { - if( buf.empty() || value == NULL) + if( buf.empty() || value == nullptr) { - return FALSE; + return false; } LLVector3d v; @@ -139,9 +139,9 @@ BOOL LLVector3d::parseVector3d(const std::string& buf, LLVector3d* value) if( 3 == count ) { value->setVec( v ); - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/indra/llmath/v3dmath.h b/indra/llmath/v3dmath.h index 99c6905e70..ece8c54ea4 100644 --- a/indra/llmath/v3dmath.h +++ b/indra/llmath/v3dmath.h @@ -68,9 +68,9 @@ class LLVector3d return ret; } - inline BOOL isFinite() const; // checks to see if all values of LLVector3d are finite - 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 bool isFinite() const; // checks to see if all values of LLVector3d are finite + 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& clear(); // Clears LLVector3d to (0, 0, 0, 1) inline const LLVector3d& clearVec(); // deprecated @@ -98,8 +98,8 @@ class LLVector3d const LLVector3d& rotVec(const LLMatrix3 &mat); // Rotates by LLMatrix4 mat const LLVector3d& rotVec(const LLQuaternion &q); // Rotates by LLQuaternion q - BOOL isNull() const; // Returns TRUE if vector has a _very_small_ length - BOOL isExactlyZero() const { return !mdV[VX] && !mdV[VY] && !mdV[VZ]; } + bool isNull() const; // Returns true if vector has a _very_small_ length + bool isExactlyZero() const { return !mdV[VX] && !mdV[VY] && !mdV[VZ]; } const LLVector3d& operator=(const LLVector4 &a); @@ -126,7 +126,7 @@ class LLVector3d friend std::ostream& operator<<(std::ostream& s, const LLVector3d& a); // Stream a - static BOOL parseVector3d(const std::string& buf, LLVector3d* value); + static bool parseVector3d(const std::string& buf, LLVector3d* value); }; @@ -189,7 +189,7 @@ inline LLVector3d::LLVector3d(const LLVector3d ©) // Destructors // checker -inline BOOL LLVector3d::isFinite() const +inline bool LLVector3d::isFinite() const { return (llfinite(mdV[VX]) && llfinite(mdV[VY]) && llfinite(mdV[VZ])); } @@ -472,13 +472,13 @@ inline LLVector3d lerp(const LLVector3d& a, const LLVector3d& b, const F64 u) } -inline BOOL LLVector3d::isNull() const +inline bool LLVector3d::isNull() const { if ( F_APPROXIMATELY_ZERO > mdV[VX]*mdV[VX] + mdV[VY]*mdV[VY] + mdV[VZ]*mdV[VZ] ) { - return TRUE; + return true; } - return FALSE; + return false; } @@ -495,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; @@ -504,10 +504,9 @@ inline BOOL are_parallel(const LLVector3d& a, const LLVector3d& b, const F64 eps F64 dot = an * bn; if ( (1.0f - fabs(dot)) < epsilon) { - return TRUE; + return true; } - return FALSE; - + return false; } inline LLVector3d projected_vec(const LLVector3d& a, const LLVector3d& b) diff --git a/indra/llmath/v3math.cpp b/indra/llmath/v3math.cpp index a867b9f578..73ad2a4ed6 100644 --- a/indra/llmath/v3math.cpp +++ b/indra/llmath/v3math.cpp @@ -53,27 +53,27 @@ const LLVector3 LLVector3::all_one(1.f,1.f,1.f); // Clamps each values to range (min,max). -// Returns TRUE if data changed. -BOOL LLVector3::clamp(F32 min, F32 max) +// Returns true if data changed. +bool LLVector3::clamp(F32 min, F32 max) { - BOOL ret = FALSE; + bool ret{ false }; - if (mV[0] < min) { mV[0] = min; ret = TRUE; } - if (mV[1] < min) { mV[1] = min; ret = TRUE; } - if (mV[2] < min) { mV[2] = min; ret = TRUE; } + if (mV[0] < min) { mV[0] = min; ret = true; } + if (mV[1] < min) { mV[1] = min; ret = true; } + if (mV[2] < min) { mV[2] = min; ret = true; } - if (mV[0] > max) { mV[0] = max; ret = TRUE; } - if (mV[1] > max) { mV[1] = max; ret = TRUE; } - if (mV[2] > max) { mV[2] = max; ret = TRUE; } + if (mV[0] > max) { mV[0] = max; ret = true; } + if (mV[1] > max) { mV[1] = max; ret = true; } + if (mV[2] > max) { mV[2] = max; ret = true; } return ret; } // Clamps length to an upper limit. -// Returns TRUE if the data changed -BOOL LLVector3::clampLength( F32 length_limit ) +// Returns true if the data changed +bool LLVector3::clampLength( F32 length_limit ) { - BOOL changed = FALSE; + bool changed{ false }; F32 len = length(); if (llfinite(len)) @@ -88,7 +88,7 @@ BOOL LLVector3::clampLength( F32 length_limit ) mV[0] *= length_limit; mV[1] *= length_limit; mV[2] *= length_limit; - changed = TRUE; + changed = true; } } else @@ -108,7 +108,7 @@ BOOL LLVector3::clampLength( F32 length_limit ) { // no it can't be salvaged --> clear it clear(); - changed = TRUE; + changed = true; break; } } @@ -134,31 +134,31 @@ BOOL LLVector3::clampLength( F32 length_limit ) return changed; } -BOOL LLVector3::clamp(const LLVector3 &min_vec, const LLVector3 &max_vec) +bool LLVector3::clamp(const LLVector3 &min_vec, const LLVector3 &max_vec) { - BOOL ret = FALSE; + bool ret{ false }; - if (mV[0] < min_vec[0]) { mV[0] = min_vec[0]; ret = TRUE; } - if (mV[1] < min_vec[1]) { mV[1] = min_vec[1]; ret = TRUE; } - if (mV[2] < min_vec[2]) { mV[2] = min_vec[2]; ret = TRUE; } + if (mV[0] < min_vec[0]) { mV[0] = min_vec[0]; ret = true; } + if (mV[1] < min_vec[1]) { mV[1] = min_vec[1]; ret = true; } + if (mV[2] < min_vec[2]) { mV[2] = min_vec[2]; ret = true; } - if (mV[0] > max_vec[0]) { mV[0] = max_vec[0]; ret = TRUE; } - if (mV[1] > max_vec[1]) { mV[1] = max_vec[1]; ret = TRUE; } - if (mV[2] > max_vec[2]) { mV[2] = max_vec[2]; ret = TRUE; } + if (mV[0] > max_vec[0]) { mV[0] = max_vec[0]; ret = true; } + if (mV[1] > max_vec[1]) { mV[1] = max_vec[1]; ret = true; } + if (mV[2] > max_vec[2]) { mV[2] = max_vec[2]; ret = true; } return ret; } // Sets all values to absolute value of their original values -// Returns TRUE if data changed -BOOL LLVector3::abs() +// Returns true if data changed +bool LLVector3::abs() { - BOOL ret = FALSE; + bool ret{ false }; - if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = TRUE; } - if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = TRUE; } - if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = TRUE; } + if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; } + if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; } + if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = true; } return ret; } @@ -358,11 +358,11 @@ const LLVector3& operator*=(LLVector3 &a, const LLQuaternion &rot) } // static -BOOL LLVector3::parseVector3(const std::string& buf, LLVector3* value) +bool LLVector3::parseVector3(const std::string& buf, LLVector3* value) { - if( buf.empty() || value == NULL) + if( buf.empty() || value == nullptr) { - return FALSE; + return false; } LLVector3 v; @@ -370,10 +370,10 @@ BOOL LLVector3::parseVector3(const std::string& buf, LLVector3* value) if( 3 == count ) { value->setVec( v ); - return TRUE; + return true; } - return FALSE; + return false; } // Displacement from query point to nearest neighbor point on bounding box. diff --git a/indra/llmath/v3math.h b/indra/llmath/v3math.h index 0f4a4a07ae..d063b15c74 100644 --- a/indra/llmath/v3math.h +++ b/indra/llmath/v3math.h @@ -71,16 +71,16 @@ class LLVector3 void setValue(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 clamp(const LLVector3 &min_vec, const LLVector3 &max_vec); // Scales vector by another vector - BOOL clampLength( F32 length_limit ); // Scales vector to limit length to a value + 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 clamp(const LLVector3 &min_vec, const LLVector3 &max_vec); // Scales vector by another vector + bool clampLength( F32 length_limit ); // Scales vector to limit length to a value void quantize16(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz); // changes the vector to reflect quatization void quantize8(F32 lowerxy, F32 upperxy, F32 lowerz, F32 upperz); // changes the vector to reflect quatization void snap(S32 sig_digits); // snaps x,y,z to sig_digits decimal places - BOOL abs(); // sets all values to absolute value of original value (first octant), returns TRUE if changed + bool abs(); // sets all values to absolute value of original value (first octant), returns true if changed inline void clear(); // Clears LLVector3 to (0, 0, 0) inline void setZero(); // Clears LLVector3 to (0, 0, 0) @@ -108,7 +108,7 @@ class LLVector3 inline F32 normalize(); // Normalizes and returns the magnitude of LLVector3 inline F32 normVec(); // deprecated - inline BOOL inRange( F32 min, F32 max ) const; // Returns true if all values of the vector are between min and max + inline bool inRange( F32 min, F32 max ) const; // Returns true if all values of the vector are between min and max const LLVector3& rotVec(F32 angle, const LLVector3 &vec); // Rotates about vec by angle radians const LLVector3& rotVec(F32 angle, F32 x, F32 y, F32 z); // Rotates about x,y,z by angle radians @@ -119,8 +119,8 @@ class LLVector3 const LLVector3& scaleVec(const LLVector3& vec); // scales per component by vec LLVector3 scaledVec(const LLVector3& vec) const; // get a copy of this vector scaled by vec - BOOL isNull() const; // Returns TRUE if vector has a _very_small_ length - BOOL isExactlyZero() const { return !mV[VX] && !mV[VY] && !mV[VZ]; } + bool isNull() const; // Returns true if vector has a _very_small_ length + bool isExactlyZero() const { return !mV[VX] && !mV[VY] && !mV[VZ]; } F32 operator[](int idx) const { return mV[idx]; } F32 &operator[](int idx) { return mV[idx]; } @@ -149,7 +149,7 @@ class LLVector3 friend std::ostream& operator<<(std::ostream& s, const LLVector3 &a); // Stream a - static BOOL parseVector3(const std::string& buf, LLVector3* value); + static bool parseVector3(const std::string& buf, LLVector3* value); }; typedef LLVector3 LLSimLocalVec; @@ -157,7 +157,7 @@ typedef LLVector3 LLSimLocalVec; // Non-member functions F32 angle_between(const LLVector3 &a, const LLVector3 &b); // Returns angle (radians) between a and b -BOOL are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns TRUE if a and b are very close to parallel +bool are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel F32 dist_vec(const LLVector3 &a, const LLVector3 &b); // Returns distance between a and b 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 @@ -202,7 +202,7 @@ inline LLVector3::LLVector3(const LLVector3 ©) // Destructors // checker -inline BOOL LLVector3::isFinite() const +inline bool LLVector3::isFinite() const { return (llfinite(mV[VX]) && llfinite(mV[VY]) && llfinite(mV[VZ])); } @@ -350,7 +350,7 @@ inline F32 LLVector3::magVecSquared(void) const return mV[0]*mV[0] + mV[1]*mV[1] + mV[2]*mV[2]; } -inline BOOL LLVector3::inRange( F32 min, F32 max ) const +inline bool LLVector3::inRange( F32 min, F32 max ) const { return mV[0] >= min && mV[0] <= max && mV[1] >= min && mV[1] <= max && @@ -539,13 +539,13 @@ inline LLVector3 lerp(const LLVector3 &a, const LLVector3 &b, F32 u) } -inline BOOL LLVector3::isNull() const +inline bool LLVector3::isNull() const { if ( F_APPROXIMATELY_ZERO > mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ] ) { - return TRUE; + return true; } - return FALSE; + return false; } inline void update_min_max(LLVector3& min, LLVector3& max, const LLVector3& pos) @@ -589,7 +589,7 @@ inline F32 angle_between(const LLVector3& a, const LLVector3& b) return atan2f(sqrtf(c * c), ab); // return the angle } -inline BOOL are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon) +inline bool are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon) { LLVector3 an = a; LLVector3 bn = b; @@ -598,9 +598,9 @@ inline BOOL are_parallel(const LLVector3 &a, const LLVector3 &b, F32 epsilon) F32 dot = an * bn; if ( (1.0f - fabs(dot)) < epsilon) { - return TRUE; + return true; } - return FALSE; + return false; } inline std::ostream& operator<<(std::ostream& s, const LLVector3 &a) diff --git a/indra/llmath/v4color.cpp b/indra/llmath/v4color.cpp index 497281c27e..ad13656bbd 100644 --- a/indra/llmath/v4color.cpp +++ b/indra/llmath/v4color.cpp @@ -133,57 +133,57 @@ LLColor4::operator LLColor4U() const LLColor4::LLColor4(const LLColor3 &vec, F32 a) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = a; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = a; } LLColor4::LLColor4(const LLColor4U& color4u) { const F32 SCALE = 1.f/255.f; - mV[VX] = color4u.mV[VX] * SCALE; - mV[VY] = color4u.mV[VY] * SCALE; - mV[VZ] = color4u.mV[VZ] * SCALE; - mV[VW] = color4u.mV[VW] * SCALE; + mV[VRED] = color4u.mV[VRED] * SCALE; + mV[VGREEN] = color4u.mV[VGREEN] * SCALE; + mV[VBLUE] = color4u.mV[VBLUE] * SCALE; + mV[VALPHA] = color4u.mV[VALPHA] * SCALE; } LLColor4::LLColor4(const LLVector4& vector4) { - mV[VX] = vector4.mV[VX]; - mV[VY] = vector4.mV[VY]; - mV[VZ] = vector4.mV[VZ]; - mV[VW] = vector4.mV[VW]; + mV[VRED] = vector4.mV[VRED]; + mV[VGREEN] = vector4.mV[VGREEN]; + mV[VBLUE] = vector4.mV[VBLUE]; + mV[VALPHA] = vector4.mV[VALPHA]; } const LLColor4& LLColor4::set(const LLColor4U& color4u) { const F32 SCALE = 1.f/255.f; - mV[VX] = color4u.mV[VX] * SCALE; - mV[VY] = color4u.mV[VY] * SCALE; - mV[VZ] = color4u.mV[VZ] * SCALE; - mV[VW] = color4u.mV[VW] * SCALE; + mV[VRED] = color4u.mV[VRED] * SCALE; + mV[VGREEN] = color4u.mV[VGREEN] * SCALE; + mV[VBLUE] = color4u.mV[VBLUE] * SCALE; + mV[VALPHA] = color4u.mV[VALPHA] * SCALE; return (*this); } const LLColor4& LLColor4::set(const LLColor3 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; // no change to alpha! -// mV[VW] = 1.f; +// mV[VALPHA] = 1.f; return (*this); } const LLColor4& LLColor4::set(const LLColor3 &vec, F32 a) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = a; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = a; return (*this); } @@ -191,22 +191,22 @@ const LLColor4& LLColor4::set(const LLColor3 &vec, F32 a) const LLColor4& LLColor4::setVec(const LLColor4U& color4u) { const F32 SCALE = 1.f/255.f; - mV[VX] = color4u.mV[VX] * SCALE; - mV[VY] = color4u.mV[VY] * SCALE; - mV[VZ] = color4u.mV[VZ] * SCALE; - mV[VW] = color4u.mV[VW] * SCALE; + mV[VRED] = color4u.mV[VRED] * SCALE; + mV[VGREEN] = color4u.mV[VGREEN] * SCALE; + mV[VBLUE] = color4u.mV[VBLUE] * SCALE; + mV[VALPHA] = color4u.mV[VALPHA] * SCALE; return (*this); } // deprecated -- use set() const LLColor4& LLColor4::setVec(const LLColor3 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; // no change to alpha! -// mV[VW] = 1.f; +// mV[VALPHA] = 1.f; return (*this); } @@ -214,10 +214,10 @@ const LLColor4& LLColor4::setVec(const LLColor3 &vec) // deprecated -- use set() const LLColor4& LLColor4::setVec(const LLColor3 &vec, F32 a) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = a; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = a; return (*this); } @@ -257,45 +257,45 @@ void LLColor4::setValue(const LLSD& sd) const LLColor4& LLColor4::operator=(const LLColor3 &a) { - mV[VX] = a.mV[VX]; - mV[VY] = a.mV[VY]; - mV[VZ] = a.mV[VZ]; + mV[VRED] = a.mV[VRED]; + mV[VGREEN] = a.mV[VGREEN]; + mV[VBLUE] = a.mV[VBLUE]; // converting from an rgb sets a=1 (opaque) - mV[VW] = 1.f; + mV[VALPHA] = 1.f; return (*this); } std::ostream& operator<<(std::ostream& s, const LLColor4 &a) { - s << "{ " << a.mV[VX] << ", " << a.mV[VY] << ", " << a.mV[VZ] << ", " << a.mV[VW] << " }"; + s << "{ " << a.mV[VRED] << ", " << a.mV[VGREEN] << ", " << a.mV[VBLUE] << ", " << a.mV[VALPHA] << " }"; return s; } bool operator==(const LLColor4 &a, const LLColor3 &b) { - return ( (a.mV[VX] == b.mV[VX]) - &&(a.mV[VY] == b.mV[VY]) - &&(a.mV[VZ] == b.mV[VZ])); + return ( (a.mV[VRED] == b.mV[VRED]) + &&(a.mV[VGREEN] == b.mV[VGREEN]) + &&(a.mV[VBLUE] == b.mV[VBLUE])); } bool operator!=(const LLColor4 &a, const LLColor3 &b) { - return ( (a.mV[VX] != b.mV[VX]) - ||(a.mV[VY] != b.mV[VY]) - ||(a.mV[VZ] != b.mV[VZ])); + return ( (a.mV[VRED] != b.mV[VRED]) + ||(a.mV[VGREEN] != b.mV[VGREEN]) + ||(a.mV[VBLUE] != b.mV[VBLUE])); } LLColor3 vec4to3(const LLColor4 &vec) { - LLColor3 temp(vec.mV[VX], vec.mV[VY], vec.mV[VZ]); + LLColor3 temp(vec.mV[VRED], vec.mV[VGREEN], vec.mV[VBLUE]); return temp; } LLColor4 vec3to4(const LLColor3 &vec) { - LLColor3 temp(vec.mV[VX], vec.mV[VY], vec.mV[VZ]); + LLColor3 temp(vec.mV[VRED], vec.mV[VGREEN], vec.mV[VBLUE]); return temp; } @@ -385,18 +385,18 @@ void LLColor4::calcHSL(F32* hue, F32* saturation, F32* luminance) const } // static -BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color) +bool LLColor4::parseColor(const std::string& buf, LLColor4* color) { - if( buf.empty() || color == NULL) + if( buf.empty() || color == nullptr) { - return FALSE; + return false; } boost_tokenizer tokens(buf, boost::char_separator<char>(", ")); boost_tokenizer::iterator token_iter = tokens.begin(); if (token_iter == tokens.end()) { - return FALSE; + return false; } // Grab the first token into a string, since we don't know @@ -408,10 +408,10 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color) { // There are more tokens to read. This must be a vector. LLColor4 v; - LLStringUtil::convertToF32( color_name, v.mV[VX] ); - LLStringUtil::convertToF32( *token_iter, v.mV[VY] ); - v.mV[VZ] = 0.0f; - v.mV[VW] = 1.0f; + LLStringUtil::convertToF32( color_name, v.mV[VRED] ); + LLStringUtil::convertToF32( *token_iter, v.mV[VGREEN] ); + v.mV[VBLUE] = 0.0f; + v.mV[VALPHA] = 1.0f; ++token_iter; if (token_iter == tokens.end()) @@ -422,18 +422,18 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color) else { // There is a z-component. - LLStringUtil::convertToF32( *token_iter, v.mV[VZ] ); + LLStringUtil::convertToF32( *token_iter, v.mV[VBLUE] ); ++token_iter; if (token_iter != tokens.end()) { // There is an alpha component. - LLStringUtil::convertToF32( *token_iter, v.mV[VW] ); + LLStringUtil::convertToF32( *token_iter, v.mV[VALPHA] ); } } // Make sure all values are between 0 and 1. - if (v.mV[VX] > 1.f || v.mV[VY] > 1.f || v.mV[VZ] > 1.f || v.mV[VW] > 1.f) + if (v.mV[VRED] > 1.f || v.mV[VGREEN] > 1.f || v.mV[VBLUE] > 1.f || v.mV[VALPHA] > 1.f) { v = v * (1.f / 255.f); } @@ -708,15 +708,15 @@ BOOL LLColor4::parseColor(const std::string& buf, LLColor4* color) } } - return TRUE; + return true; } // static -BOOL LLColor4::parseColor4(const std::string& buf, LLColor4* value) +bool LLColor4::parseColor4(const std::string& buf, LLColor4* value) { - if( buf.empty() || value == NULL) + if( buf.empty() || value == nullptr) { - return FALSE; + return false; } LLColor4 v; @@ -729,10 +729,10 @@ BOOL LLColor4::parseColor4(const std::string& buf, LLColor4* value) if( 4 == count ) { value->setVec( v ); - return TRUE; + return true; } - return FALSE; + return false; } // EOF diff --git a/indra/llmath/v4color.h b/indra/llmath/v4color.h index 3168c8b43a..e9bb6a07ba 100644 --- a/indra/llmath/v4color.h +++ b/indra/llmath/v4color.h @@ -111,7 +111,7 @@ class LLColor4 F32 lengthSquared() const; // Returns magnitude squared of LLColor4 F32 normalize(); // deprecated -- use normalize() - BOOL isOpaque() { return mV[VALPHA] == 1.f; } + bool isOpaque() { return mV[VALPHA] == 1.f; } F32 operator[](int idx) const { return mV[idx]; } F32 &operator[](int idx) { return mV[idx]; } @@ -226,8 +226,8 @@ class LLColor4 static LLColor4 cyan5; static LLColor4 cyan6; - static BOOL parseColor(const std::string& buf, LLColor4* color); - static BOOL parseColor4(const std::string& buf, LLColor4* color); + static bool parseColor(const std::string& buf, LLColor4* color); + static bool parseColor4(const std::string& buf, LLColor4* color); inline void clamp(); }; @@ -242,10 +242,10 @@ LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u); inline LLColor4::LLColor4(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; - mV[VZ] = 0.f; - mV[VW] = 1.f; + mV[VRED] = 0.f; + mV[VGREEN] = 0.f; + mV[VBLUE] = 0.f; + mV[VALPHA] = 1.f; } inline LLColor4::LLColor4(const LLSD& sd) @@ -255,113 +255,113 @@ inline LLColor4::LLColor4(const LLSD& sd) inline LLColor4::LLColor4(F32 r, F32 g, F32 b) { - mV[VX] = r; - mV[VY] = g; - mV[VZ] = b; - mV[VW] = 1.f; + mV[VRED] = r; + mV[VGREEN] = g; + mV[VBLUE] = b; + mV[VALPHA] = 1.f; } inline LLColor4::LLColor4(F32 r, F32 g, F32 b, F32 a) { - mV[VX] = r; - mV[VY] = g; - mV[VZ] = b; - mV[VW] = a; + mV[VRED] = r; + mV[VGREEN] = g; + mV[VBLUE] = b; + mV[VALPHA] = a; } inline LLColor4::LLColor4(U32 clr) { - mV[VX] = (clr&0xff) * (1.0f/255.0f); - mV[VY] = ((clr>>8)&0xff) * (1.0f/255.0f); - mV[VZ] = ((clr>>16)&0xff) * (1.0f/255.0f); - mV[VW] = (clr>>24) * (1.0f/255.0f); + mV[VRED] = (clr&0xff) * (1.0f/255.0f); + mV[VGREEN] = ((clr>>8)&0xff) * (1.0f/255.0f); + mV[VBLUE] = ((clr>>16)&0xff) * (1.0f/255.0f); + mV[VALPHA] = (clr>>24) * (1.0f/255.0f); } inline LLColor4::LLColor4(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; - mV[VW] = vec[VW]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; + mV[VALPHA] = vec[VALPHA]; } inline const LLColor4& LLColor4::setToBlack(void) { - mV[VX] = 0.f; - mV[VY] = 0.f; - mV[VZ] = 0.f; - mV[VW] = 1.f; + mV[VRED] = 0.f; + mV[VGREEN] = 0.f; + mV[VBLUE] = 0.f; + mV[VALPHA] = 1.f; return (*this); } inline const LLColor4& LLColor4::setToWhite(void) { - mV[VX] = 1.f; - mV[VY] = 1.f; - mV[VZ] = 1.f; - mV[VW] = 1.f; + mV[VRED] = 1.f; + mV[VGREEN] = 1.f; + mV[VBLUE] = 1.f; + mV[VALPHA] = 1.f; return (*this); } inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z) { - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; + mV[VRED] = x; + mV[VGREEN] = y; + mV[VBLUE] = z; // no change to alpha! -// mV[VW] = 1.f; +// mV[VALPHA] = 1.f; return (*this); } inline const LLColor4& LLColor4::set(F32 x, F32 y, F32 z, F32 a) { - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; - mV[VW] = a; + mV[VRED] = x; + mV[VGREEN] = y; + mV[VBLUE] = z; + mV[VALPHA] = a; return (*this); } inline const LLColor4& LLColor4::set(const LLColor4 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = vec.mV[VW]; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = vec.mV[VALPHA]; return (*this); } inline const LLColor4& LLColor4::set(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; - mV[VW] = vec[VW]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; + mV[VALPHA] = vec[VALPHA]; return (*this); } inline const LLColor4& LLColor4::set(const F64 *vec) { - mV[VX] = static_cast<F32>(vec[VX]); - mV[VY] = static_cast<F32>(vec[VY]); - mV[VZ] = static_cast<F32>(vec[VZ]); - mV[VW] = static_cast<F32>(vec[VW]); + mV[VRED] = static_cast<F32>(vec[VRED]); + mV[VGREEN] = static_cast<F32>(vec[VGREEN]); + mV[VBLUE] = static_cast<F32>(vec[VBLUE]); + mV[VALPHA] = static_cast<F32>(vec[VALPHA]); return (*this); } // deprecated inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z) { - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; + mV[VRED] = x; + mV[VGREEN] = y; + mV[VBLUE] = z; // no change to alpha! -// mV[VW] = 1.f; +// mV[VALPHA] = 1.f; return (*this); } @@ -369,20 +369,20 @@ inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z) // deprecated inline const LLColor4& LLColor4::setVec(F32 x, F32 y, F32 z, F32 a) { - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; - mV[VW] = a; + mV[VRED] = x; + mV[VGREEN] = y; + mV[VBLUE] = z; + mV[VALPHA] = a; return (*this); } // deprecated inline const LLColor4& LLColor4::setVec(const LLColor4 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = vec.mV[VW]; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = vec.mV[VALPHA]; return (*this); } @@ -390,16 +390,16 @@ inline const LLColor4& LLColor4::setVec(const LLColor4 &vec) // deprecated inline const LLColor4& LLColor4::setVec(const F32 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; - mV[VW] = vec[VW]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; + mV[VALPHA] = vec[VALPHA]; return (*this); } inline const LLColor4& LLColor4::setAlpha(F32 a) { - mV[VW] = a; + mV[VALPHA] = a; return (*this); } @@ -407,25 +407,25 @@ inline const LLColor4& LLColor4::setAlpha(F32 a) inline F32 LLColor4::length(void) const { - return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + return (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); } inline F32 LLColor4::lengthSquared(void) const { - return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; + return mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]; } inline F32 LLColor4::normalize(void) { - F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + F32 mag = (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); F32 oomag; if (mag) { oomag = 1.f/mag; - mV[VX] *= oomag; - mV[VY] *= oomag; - mV[VZ] *= oomag; + mV[VRED] *= oomag; + mV[VGREEN] *= oomag; + mV[VBLUE] *= oomag; } return (mag); } @@ -433,27 +433,27 @@ inline F32 LLColor4::normalize(void) // deprecated inline F32 LLColor4::magVec(void) const { - return (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + return (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); } // deprecated inline F32 LLColor4::magVecSquared(void) const { - return mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]; + return mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]; } // deprecated inline F32 LLColor4::normVec(void) { - F32 mag = (F32) sqrt(mV[VX]*mV[VX] + mV[VY]*mV[VY] + mV[VZ]*mV[VZ]); + F32 mag = (F32) sqrt(mV[VRED]*mV[VRED] + mV[VGREEN]*mV[VGREEN] + mV[VBLUE]*mV[VBLUE]); F32 oomag; if (mag) { oomag = 1.f/mag; - mV[VX] *= oomag; - mV[VY] *= oomag; - mV[VZ] *= oomag; + mV[VRED] *= oomag; + mV[VGREEN] *= oomag; + mV[VBLUE] *= oomag; } return (mag); } @@ -464,135 +464,135 @@ inline F32 LLColor4::normVec(void) inline LLColor4 operator+(const LLColor4 &a, const LLColor4 &b) { return LLColor4( - a.mV[VX] + b.mV[VX], - a.mV[VY] + b.mV[VY], - a.mV[VZ] + b.mV[VZ], - a.mV[VW] + b.mV[VW]); + a.mV[VRED] + b.mV[VRED], + a.mV[VGREEN] + b.mV[VGREEN], + a.mV[VBLUE] + b.mV[VBLUE], + a.mV[VALPHA] + b.mV[VALPHA]); } inline LLColor4 operator-(const LLColor4 &a, const LLColor4 &b) { return LLColor4( - a.mV[VX] - b.mV[VX], - a.mV[VY] - b.mV[VY], - a.mV[VZ] - b.mV[VZ], - a.mV[VW] - b.mV[VW]); + a.mV[VRED] - b.mV[VRED], + a.mV[VGREEN] - b.mV[VGREEN], + a.mV[VBLUE] - b.mV[VBLUE], + a.mV[VALPHA] - b.mV[VALPHA]); } inline LLColor4 operator*(const LLColor4 &a, const LLColor4 &b) { return LLColor4( - a.mV[VX] * b.mV[VX], - a.mV[VY] * b.mV[VY], - a.mV[VZ] * b.mV[VZ], - a.mV[VW] * b.mV[VW]); + a.mV[VRED] * b.mV[VRED], + a.mV[VGREEN] * b.mV[VGREEN], + a.mV[VBLUE] * b.mV[VBLUE], + a.mV[VALPHA] * b.mV[VALPHA]); } inline LLColor4 operator*(const LLColor4 &a, F32 k) { // only affects rgb (not a!) return LLColor4( - a.mV[VX] * k, - a.mV[VY] * k, - a.mV[VZ] * k, - a.mV[VW]); + a.mV[VRED] * k, + a.mV[VGREEN] * k, + a.mV[VBLUE] * k, + a.mV[VALPHA]); } inline LLColor4 operator/(const LLColor4 &a, F32 k) { return LLColor4( - a.mV[VX] / k, - a.mV[VY] / k, - a.mV[VZ] / k, - a.mV[VW]); + a.mV[VRED] / k, + a.mV[VGREEN] / k, + a.mV[VBLUE] / k, + a.mV[VALPHA]); } inline LLColor4 operator*(F32 k, const LLColor4 &a) { // only affects rgb (not a!) return LLColor4( - a.mV[VX] * k, - a.mV[VY] * k, - a.mV[VZ] * k, - a.mV[VW]); + a.mV[VRED] * k, + a.mV[VGREEN] * k, + a.mV[VBLUE] * k, + a.mV[VALPHA]); } inline LLColor4 operator%(F32 k, const LLColor4 &a) { // only affects alpha (not rgb!) return LLColor4( - a.mV[VX], - a.mV[VY], - a.mV[VZ], - a.mV[VW] * k); + a.mV[VRED], + a.mV[VGREEN], + a.mV[VBLUE], + a.mV[VALPHA] * k); } inline LLColor4 operator%(const LLColor4 &a, F32 k) { // only affects alpha (not rgb!) return LLColor4( - a.mV[VX], - a.mV[VY], - a.mV[VZ], - a.mV[VW] * k); + a.mV[VRED], + a.mV[VGREEN], + a.mV[VBLUE], + a.mV[VALPHA] * k); } inline bool operator==(const LLColor4 &a, const LLColor4 &b) { - return ( (a.mV[VX] == b.mV[VX]) - &&(a.mV[VY] == b.mV[VY]) - &&(a.mV[VZ] == b.mV[VZ]) - &&(a.mV[VW] == b.mV[VW])); + return ( (a.mV[VRED] == b.mV[VRED]) + &&(a.mV[VGREEN] == b.mV[VGREEN]) + &&(a.mV[VBLUE] == b.mV[VBLUE]) + &&(a.mV[VALPHA] == b.mV[VALPHA])); } inline bool operator!=(const LLColor4 &a, const LLColor4 &b) { - return ( (a.mV[VX] != b.mV[VX]) - ||(a.mV[VY] != b.mV[VY]) - ||(a.mV[VZ] != b.mV[VZ]) - ||(a.mV[VW] != b.mV[VW])); + return ( (a.mV[VRED] != b.mV[VRED]) + ||(a.mV[VGREEN] != b.mV[VGREEN]) + ||(a.mV[VBLUE] != b.mV[VBLUE]) + ||(a.mV[VALPHA] != b.mV[VALPHA])); } inline const LLColor4& operator+=(LLColor4 &a, const LLColor4 &b) { - a.mV[VX] += b.mV[VX]; - a.mV[VY] += b.mV[VY]; - a.mV[VZ] += b.mV[VZ]; - a.mV[VW] += b.mV[VW]; + a.mV[VRED] += b.mV[VRED]; + a.mV[VGREEN] += b.mV[VGREEN]; + a.mV[VBLUE] += b.mV[VBLUE]; + a.mV[VALPHA] += b.mV[VALPHA]; return a; } inline const LLColor4& operator-=(LLColor4 &a, const LLColor4 &b) { - a.mV[VX] -= b.mV[VX]; - a.mV[VY] -= b.mV[VY]; - a.mV[VZ] -= b.mV[VZ]; - a.mV[VW] -= b.mV[VW]; + a.mV[VRED] -= b.mV[VRED]; + a.mV[VGREEN] -= b.mV[VGREEN]; + a.mV[VBLUE] -= b.mV[VBLUE]; + a.mV[VALPHA] -= b.mV[VALPHA]; return a; } inline const LLColor4& operator*=(LLColor4 &a, F32 k) { // only affects rgb (not a!) - a.mV[VX] *= k; - a.mV[VY] *= k; - a.mV[VZ] *= k; + a.mV[VRED] *= k; + a.mV[VGREEN] *= k; + a.mV[VBLUE] *= k; return a; } inline const LLColor4& operator *=(LLColor4 &a, const LLColor4 &b) { - a.mV[VX] *= b.mV[VX]; - a.mV[VY] *= b.mV[VY]; - a.mV[VZ] *= b.mV[VZ]; -// a.mV[VW] *= b.mV[VW]; + a.mV[VRED] *= b.mV[VRED]; + a.mV[VGREEN] *= b.mV[VGREEN]; + a.mV[VBLUE] *= b.mV[VBLUE]; +// a.mV[VALPHA] *= b.mV[VALPHA]; return a; } inline const LLColor4& operator%=(LLColor4 &a, F32 k) { // only affects alpha (not rgb!) - a.mV[VW] *= k; + a.mV[VALPHA] *= k; return a; } @@ -614,10 +614,10 @@ inline F32 distVec_squared(const LLColor4 &a, const LLColor4 &b) inline LLColor4 lerp(const LLColor4 &a, const LLColor4 &b, F32 u) { return LLColor4( - a.mV[VX] + (b.mV[VX] - a.mV[VX]) * u, - a.mV[VY] + (b.mV[VY] - a.mV[VY]) * u, - a.mV[VZ] + (b.mV[VZ] - a.mV[VZ]) * u, - a.mV[VW] + (b.mV[VW] - a.mV[VW]) * u); + a.mV[VRED] + (b.mV[VRED] - a.mV[VRED]) * u, + a.mV[VGREEN] + (b.mV[VGREEN] - a.mV[VGREEN]) * u, + a.mV[VBLUE] + (b.mV[VBLUE] - a.mV[VBLUE]) * u, + a.mV[VALPHA] + (b.mV[VALPHA] - a.mV[VALPHA]) * u); } inline bool LLColor4::operator<(const LLColor4& rhs) const diff --git a/indra/llmath/v4coloru.cpp b/indra/llmath/v4coloru.cpp index 92127933b2..acf349245a 100644 --- a/indra/llmath/v4coloru.cpp +++ b/indra/llmath/v4coloru.cpp @@ -53,10 +53,10 @@ LLColor4U::operator LLColor4() /* LLColor4U::LLColor4U(const LLColor3 &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = 255; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = 255; } */ @@ -70,12 +70,12 @@ LLColor4U::LLColor4U(const LLColor3 &vec) /* LLColor4U LLColor4U::operator=(const LLColor3 &a) { - mV[VX] = a.mV[VX]; - mV[VY] = a.mV[VY]; - mV[VZ] = a.mV[VZ]; + mV[VRED] = a.mV[VRED]; + mV[VGREEN] = a.mV[VGREEN]; + mV[VBLUE] = a.mV[VBLUE]; // converting from an rgb sets a=1 (opaque) - mV[VW] = 255; + mV[VALPHA] = 255; return (*this); } */ @@ -83,16 +83,16 @@ LLColor4U LLColor4U::operator=(const LLColor3 &a) std::ostream& operator<<(std::ostream& s, const LLColor4U &a) { - s << "{ " << (S32)a.mV[VX] << ", " << (S32)a.mV[VY] << ", " << (S32)a.mV[VZ] << ", " << (S32)a.mV[VW] << " }"; + s << "{ " << (S32)a.mV[VRED] << ", " << (S32)a.mV[VGREEN] << ", " << (S32)a.mV[VBLUE] << ", " << (S32)a.mV[VALPHA] << " }"; return s; } // static -BOOL LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value) +bool LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value) { - if( buf.empty() || value == NULL) + if( buf.empty() || value == nullptr) { - return FALSE; + return false; } U32 v[4]; @@ -104,17 +104,17 @@ BOOL LLColor4U::parseColor4U(const std::string& buf, LLColor4U* value) } if( 4 != count ) { - return FALSE; + return false; } for( S32 i = 0; i < 4; i++ ) { if( v[i] > U8_MAX ) { - return FALSE; + return false; } } value->set( U8(v[0]), U8(v[1]), U8(v[2]), U8(v[3]) ); - return TRUE; + return true; } diff --git a/indra/llmath/v4coloru.h b/indra/llmath/v4coloru.h index ecfecc167f..29128a08a7 100644 --- a/indra/llmath/v4coloru.h +++ b/indra/llmath/v4coloru.h @@ -112,12 +112,11 @@ public: LLColor4U addClampMax(const LLColor4U &color); // Add and clamp the max LLColor4U multAll(const F32 k); // Multiply ALL channels by scalar k - const LLColor4U& combine(); inline void setVecScaleClamp(const LLColor3 &color); inline void setVecScaleClamp(const LLColor4 &color); - static BOOL parseColor4U(const std::string& buf, LLColor4U* value); + static bool parseColor4U(const std::string& buf, LLColor4U* value); // conversion operator LLColor4() const @@ -143,34 +142,34 @@ F32 distVec_squared(const LLColor4U &a, const LLColor4U &b); // Returns d inline LLColor4U::LLColor4U() { - mV[VX] = 0; - mV[VY] = 0; - mV[VZ] = 0; - mV[VW] = 255; + mV[VRED] = 0; + mV[VGREEN] = 0; + mV[VBLUE] = 0; + mV[VALPHA] = 255; } inline LLColor4U::LLColor4U(U8 r, U8 g, U8 b) { - mV[VX] = r; - mV[VY] = g; - mV[VZ] = b; - mV[VW] = 255; + mV[VRED] = r; + mV[VGREEN] = g; + mV[VBLUE] = b; + mV[VALPHA] = 255; } inline LLColor4U::LLColor4U(U8 r, U8 g, U8 b, U8 a) { - mV[VX] = r; - mV[VY] = g; - mV[VZ] = b; - mV[VW] = a; + mV[VRED] = r; + mV[VGREEN] = g; + mV[VBLUE] = b; + mV[VALPHA] = a; } inline LLColor4U::LLColor4U(const U8 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; - mV[VW] = vec[VW]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; + mV[VALPHA] = vec[VALPHA]; } /* @@ -182,30 +181,30 @@ inline LLColor4U::operator LLColor4() inline const LLColor4U& LLColor4U::setToBlack(void) { - mV[VX] = 0; - mV[VY] = 0; - mV[VZ] = 0; - mV[VW] = 255; + mV[VRED] = 0; + mV[VGREEN] = 0; + mV[VBLUE] = 0; + mV[VALPHA] = 255; return (*this); } inline const LLColor4U& LLColor4U::setToWhite(void) { - mV[VX] = 255; - mV[VY] = 255; - mV[VZ] = 255; - mV[VW] = 255; + mV[VRED] = 255; + mV[VGREEN] = 255; + mV[VBLUE] = 255; + mV[VALPHA] = 255; return (*this); } inline const LLColor4U& LLColor4U::set(const U8 x, const U8 y, const U8 z) { - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; + mV[VRED] = x; + mV[VGREEN] = y; + mV[VBLUE] = z; // no change to alpha! -// mV[VW] = 255; +// mV[VALPHA] = 255; return (*this); } @@ -221,31 +220,31 @@ inline const LLColor4U& LLColor4U::set(const U8 r, const U8 g, const U8 b, U8 a) inline const LLColor4U& LLColor4U::set(const LLColor4U &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = vec.mV[VW]; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = vec.mV[VALPHA]; return (*this); } inline const LLColor4U& LLColor4U::set(const U8 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; - mV[VW] = vec[VW]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; + mV[VALPHA] = vec[VALPHA]; return (*this); } // deprecated inline const LLColor4U& LLColor4U::setVec(const U8 x, const U8 y, const U8 z) { - mV[VX] = x; - mV[VY] = y; - mV[VZ] = z; + mV[VRED] = x; + mV[VGREEN] = y; + mV[VBLUE] = z; // no change to alpha! -// mV[VW] = 255; +// mV[VALPHA] = 255; return (*this); } @@ -263,26 +262,26 @@ inline const LLColor4U& LLColor4U::setVec(const U8 r, const U8 g, const U8 b, U8 // deprecated inline const LLColor4U& LLColor4U::setVec(const LLColor4U &vec) { - mV[VX] = vec.mV[VX]; - mV[VY] = vec.mV[VY]; - mV[VZ] = vec.mV[VZ]; - mV[VW] = vec.mV[VW]; + mV[VRED] = vec.mV[VRED]; + mV[VGREEN] = vec.mV[VGREEN]; + mV[VBLUE] = vec.mV[VBLUE]; + mV[VALPHA] = vec.mV[VALPHA]; return (*this); } // deprecated inline const LLColor4U& LLColor4U::setVec(const U8 *vec) { - mV[VX] = vec[VX]; - mV[VY] = vec[VY]; - mV[VZ] = vec[VZ]; - mV[VW] = vec[VW]; + mV[VRED] = vec[VRED]; + mV[VGREEN] = vec[VGREEN]; + mV[VBLUE] = vec[VBLUE]; + mV[VALPHA] = vec[VALPHA]; return (*this); } inline const LLColor4U& LLColor4U::setAlpha(U8 a) { - mV[VW] = a; + mV[VALPHA] = a; return (*this); } @@ -290,159 +289,159 @@ inline const LLColor4U& LLColor4U::setAlpha(U8 a) inline F32 LLColor4U::length(void) const { - return (F32) sqrt( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] ); + return (F32) sqrt( ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE] ); } inline F32 LLColor4U::lengthSquared(void) const { - return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ]; + return ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE]; } // deprecated inline F32 LLColor4U::magVec(void) const { - return (F32) sqrt( ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ] ); + return (F32) sqrt( ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE] ); } // deprecated inline F32 LLColor4U::magVecSquared(void) const { - return ((F32)mV[VX]) * mV[VX] + ((F32)mV[VY]) * mV[VY] + ((F32)mV[VZ]) * mV[VZ]; + return ((F32)mV[VRED]) * mV[VRED] + ((F32)mV[VGREEN]) * mV[VGREEN] + ((F32)mV[VBLUE]) * mV[VBLUE]; } inline LLColor4U operator+(const LLColor4U &a, const LLColor4U &b) { return LLColor4U( - a.mV[VX] + b.mV[VX], - a.mV[VY] + b.mV[VY], - a.mV[VZ] + b.mV[VZ], - a.mV[VW] + b.mV[VW]); + a.mV[VRED] + b.mV[VRED], + a.mV[VGREEN] + b.mV[VGREEN], + a.mV[VBLUE] + b.mV[VBLUE], + a.mV[VALPHA] + b.mV[VALPHA]); } inline LLColor4U operator-(const LLColor4U &a, const LLColor4U &b) { return LLColor4U( - a.mV[VX] - b.mV[VX], - a.mV[VY] - b.mV[VY], - a.mV[VZ] - b.mV[VZ], - a.mV[VW] - b.mV[VW]); + a.mV[VRED] - b.mV[VRED], + a.mV[VGREEN] - b.mV[VGREEN], + a.mV[VBLUE] - b.mV[VBLUE], + a.mV[VALPHA] - b.mV[VALPHA]); } inline LLColor4U operator*(const LLColor4U &a, const LLColor4U &b) { return LLColor4U( - a.mV[VX] * b.mV[VX], - a.mV[VY] * b.mV[VY], - a.mV[VZ] * b.mV[VZ], - a.mV[VW] * b.mV[VW]); + a.mV[VRED] * b.mV[VRED], + a.mV[VGREEN] * b.mV[VGREEN], + a.mV[VBLUE] * b.mV[VBLUE], + a.mV[VALPHA] * b.mV[VALPHA]); } inline LLColor4U LLColor4U::addClampMax(const LLColor4U &color) { - return LLColor4U(llmin((S32)mV[VX] + color.mV[VX], 255), - llmin((S32)mV[VY] + color.mV[VY], 255), - llmin((S32)mV[VZ] + color.mV[VZ], 255), - llmin((S32)mV[VW] + color.mV[VW], 255)); + return LLColor4U(llmin((S32)mV[VRED] + color.mV[VRED], 255), + llmin((S32)mV[VGREEN] + color.mV[VGREEN], 255), + llmin((S32)mV[VBLUE] + color.mV[VBLUE], 255), + llmin((S32)mV[VALPHA] + color.mV[VALPHA], 255)); } inline LLColor4U LLColor4U::multAll(const F32 k) { // Round to nearest return LLColor4U( - (U8)ll_round(mV[VX] * k), - (U8)ll_round(mV[VY] * k), - (U8)ll_round(mV[VZ] * k), - (U8)ll_round(mV[VW] * k)); + (U8)ll_round(mV[VRED] * k), + (U8)ll_round(mV[VGREEN] * k), + (U8)ll_round(mV[VBLUE] * k), + (U8)ll_round(mV[VALPHA] * k)); } /* inline LLColor4U operator*(const LLColor4U &a, U8 k) { // only affects rgb (not a!) return LLColor4U( - a.mV[VX] * k, - a.mV[VY] * k, - a.mV[VZ] * k, - a.mV[VW]); + a.mV[VRED] * k, + a.mV[VGREEN] * k, + a.mV[VBLUE] * k, + a.mV[VALPHA]); } inline LLColor4U operator*(U8 k, const LLColor4U &a) { // only affects rgb (not a!) return LLColor4U( - a.mV[VX] * k, - a.mV[VY] * k, - a.mV[VZ] * k, - a.mV[VW]); + a.mV[VRED] * k, + a.mV[VGREEN] * k, + a.mV[VBLUE] * k, + a.mV[VALPHA]); } inline LLColor4U operator%(U8 k, const LLColor4U &a) { // only affects alpha (not rgb!) return LLColor4U( - a.mV[VX], - a.mV[VY], - a.mV[VZ], - a.mV[VW] * k ); + a.mV[VRED], + a.mV[VGREEN], + a.mV[VBLUE], + a.mV[VALPHA] * k ); } inline LLColor4U operator%(const LLColor4U &a, U8 k) { // only affects alpha (not rgb!) return LLColor4U( - a.mV[VX], - a.mV[VY], - a.mV[VZ], - a.mV[VW] * k ); + a.mV[VRED], + a.mV[VGREEN], + a.mV[VBLUE], + a.mV[VALPHA] * k ); } */ inline bool operator==(const LLColor4U &a, const LLColor4U &b) { - return ( (a.mV[VX] == b.mV[VX]) - &&(a.mV[VY] == b.mV[VY]) - &&(a.mV[VZ] == b.mV[VZ]) - &&(a.mV[VW] == b.mV[VW])); + return ( (a.mV[VRED] == b.mV[VRED]) + &&(a.mV[VGREEN] == b.mV[VGREEN]) + &&(a.mV[VBLUE] == b.mV[VBLUE]) + &&(a.mV[VALPHA] == b.mV[VALPHA])); } inline bool operator!=(const LLColor4U &a, const LLColor4U &b) { - return ( (a.mV[VX] != b.mV[VX]) - ||(a.mV[VY] != b.mV[VY]) - ||(a.mV[VZ] != b.mV[VZ]) - ||(a.mV[VW] != b.mV[VW])); + return ( (a.mV[VRED] != b.mV[VRED]) + ||(a.mV[VGREEN] != b.mV[VGREEN]) + ||(a.mV[VBLUE] != b.mV[VBLUE]) + ||(a.mV[VALPHA] != b.mV[VALPHA])); } inline const LLColor4U& operator+=(LLColor4U &a, const LLColor4U &b) { - a.mV[VX] += b.mV[VX]; - a.mV[VY] += b.mV[VY]; - a.mV[VZ] += b.mV[VZ]; - a.mV[VW] += b.mV[VW]; + a.mV[VRED] += b.mV[VRED]; + a.mV[VGREEN] += b.mV[VGREEN]; + a.mV[VBLUE] += b.mV[VBLUE]; + a.mV[VALPHA] += b.mV[VALPHA]; return a; } inline const LLColor4U& operator-=(LLColor4U &a, const LLColor4U &b) { - a.mV[VX] -= b.mV[VX]; - a.mV[VY] -= b.mV[VY]; - a.mV[VZ] -= b.mV[VZ]; - a.mV[VW] -= b.mV[VW]; + a.mV[VRED] -= b.mV[VRED]; + a.mV[VGREEN] -= b.mV[VGREEN]; + a.mV[VBLUE] -= b.mV[VBLUE]; + a.mV[VALPHA] -= b.mV[VALPHA]; return a; } inline const LLColor4U& operator*=(LLColor4U &a, U8 k) { // only affects rgb (not a!) - a.mV[VX] *= k; - a.mV[VY] *= k; - a.mV[VZ] *= k; + a.mV[VRED] *= k; + a.mV[VGREEN] *= k; + a.mV[VBLUE] *= k; return a; } inline const LLColor4U& operator%=(LLColor4U &a, U8 k) { // only affects alpha (not rgb!) - a.mV[VW] *= k; + a.mV[VALPHA] *= k; return a; } diff --git a/indra/llmath/v4math.cpp b/indra/llmath/v4math.cpp index 8955145527..0aa6eb09c3 100644 --- a/indra/llmath/v4math.cpp +++ b/indra/llmath/v4math.cpp @@ -36,28 +36,6 @@ // LLVector4 // Axis-Angle rotations - -/* -const LLVector4& LLVector4::rotVec(F32 angle, const LLVector4 &vec) -{ - if ( !vec.isExactlyZero() && angle ) - { - *this = *this * LLMatrix4(angle, vec); - } - return *this; -} - -const LLVector4& LLVector4::rotVec(F32 angle, F32 x, F32 y, F32 z) -{ - LLVector3 vec(x, y, z); - if ( !vec.isExactlyZero() && angle ) - { - *this = *this * LLMatrix4(angle, vec); - } - return *this; -} -*/ - const LLVector4& LLVector4::rotVec(const LLMatrix4 &mat) { *this = *this * mat; @@ -81,15 +59,15 @@ const LLVector4& LLVector4::scaleVec(const LLVector4& vec) } // Sets all values to absolute value of their original values -// Returns TRUE if data changed -BOOL LLVector4::abs() +// Returns true if data changed +bool LLVector4::abs() { - BOOL ret = FALSE; + bool ret{ false }; - if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = TRUE; } - if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = TRUE; } - if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = TRUE; } - if (mV[3] < 0.f) { mV[3] = -mV[3]; ret = TRUE; } + if (mV[0] < 0.f) { mV[0] = -mV[0]; ret = true; } + if (mV[1] < 0.f) { mV[1] = -mV[1]; ret = true; } + if (mV[2] < 0.f) { mV[2] = -mV[2]; ret = true; } + if (mV[3] < 0.f) { mV[3] = -mV[3]; ret = true; } return ret; } @@ -117,7 +95,7 @@ F32 angle_between( const LLVector4& a, const LLVector4& b ) return angle; } -BOOL are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon) +bool are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon) { LLVector4 an = a; LLVector4 bn = b; @@ -125,8 +103,8 @@ BOOL are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon) bn.normalize(); F32 dot = an * bn; if ( (1.0f - fabs(dot)) < epsilon) - return TRUE; - return FALSE; + return true; + return false; } diff --git a/indra/llmath/v4math.h b/indra/llmath/v4math.h index 7f0020af6b..7ed22212d3 100644 --- a/indra/llmath/v4math.h +++ b/indra/llmath/v4math.h @@ -74,7 +74,7 @@ class LLVector4 } - inline BOOL isFinite() const; // checks to see if all values of LLVector3 are finite + inline bool isFinite() const; // checks to see if all values of LLVector3 are finite inline void clear(); // Clears LLVector4 to (0, 0, 0, 1) inline void clearVec(); // deprecated @@ -101,14 +101,12 @@ class LLVector4 F32 normVec(); // deprecated // Sets all values to absolute value of their original values - // Returns TRUE if data changed - BOOL abs(); + // Returns true if data changed + bool abs(); - BOOL isExactlyClear() const { return (mV[VW] == 1.0f) && !mV[VX] && !mV[VY] && !mV[VZ]; } - BOOL isExactlyZero() const { return !mV[VW] && !mV[VX] && !mV[VY] && !mV[VZ]; } + bool isExactlyClear() const { return (mV[VW] == 1.0f) && !mV[VX] && !mV[VY] && !mV[VZ]; } + bool isExactlyZero() const { return !mV[VW] && !mV[VX] && !mV[VY] && !mV[VZ]; } - const LLVector4& rotVec(F32 angle, const LLVector4 &vec); // Rotates about vec by angle radians - const LLVector4& rotVec(F32 angle, F32 x, F32 y, F32 z); // Rotates about x,y,z by angle radians const LLVector4& rotVec(const LLMatrix4 &mat); // Rotates by MAT4 mat const LLVector4& rotVec(const LLQuaternion &q); // Rotates by QUAT q @@ -139,7 +137,7 @@ class LLVector4 // Non-member functions F32 angle_between(const LLVector4 &a, const LLVector4 &b); // Returns angle (radians) between a and b -BOOL are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon=F_APPROXIMATELY_ZERO); // Returns TRUE if a and b are very close to parallel +bool are_parallel(const LLVector4 &a, const LLVector4 &b, F32 epsilon = F_APPROXIMATELY_ZERO); // Returns true if a and b are very close to parallel F32 dist_vec(const LLVector4 &a, const LLVector4 &b); // Returns distance between a and b F32 dist_vec_squared(const LLVector4 &a, const LLVector4 &b); // Returns distance squared between a and b LLVector3 vec4to3(const LLVector4 &vec); @@ -226,7 +224,7 @@ inline LLVector4::LLVector4(const LLSD &sd) } -inline BOOL LLVector4::isFinite() const +inline bool LLVector4::isFinite() const { return (llfinite(mV[VX]) && llfinite(mV[VY]) && llfinite(mV[VZ]) && llfinite(mV[VW])); } diff --git a/indra/llmath/xform.cpp b/indra/llmath/xform.cpp index 6edad9664f..39bbb94c9f 100644 --- a/indra/llmath/xform.cpp +++ b/indra/llmath/xform.cpp @@ -52,12 +52,12 @@ LLXform* LLXform::getRoot() const return (LLXform*)root; } -BOOL LLXform::isRoot() const +bool LLXform::isRoot() const { return (!mParent); } -BOOL LLXform::isRootEdit() const +bool LLXform::isRootEdit() const { return (!mParent); } @@ -86,7 +86,7 @@ void LLXformMatrix::update() } } -void LLXformMatrix::updateMatrix(BOOL update_bounds) +void LLXformMatrix::updateMatrix(bool update_bounds) { update(); diff --git a/indra/llmath/xform.h b/indra/llmath/xform.h index 06ca526f4f..7434301670 100644 --- a/indra/llmath/xform.h +++ b/indra/llmath/xform.h @@ -30,12 +30,12 @@ #include "m4math.h" #include "llquaternion.h" -const F32 MAX_OBJECT_Z = 4096.f; // should match REGION_HEIGHT_METERS, Pre-havok4: 768.f -const F32 MIN_OBJECT_Z = -256.f; -const F32 DEFAULT_MAX_PRIM_SCALE = 64.f; -const F32 DEFAULT_MAX_PRIM_SCALE_NO_MESH = 10.f; -const F32 MIN_PRIM_SCALE = 0.01f; -const F32 MAX_PRIM_SCALE = 65536.f; // something very high but not near FLT_MAX +constexpr F32 MAX_OBJECT_Z = 4096.f; // should match REGION_HEIGHT_METERS, Pre-havok4: 768.f +constexpr F32 MIN_OBJECT_Z = -256.f; +constexpr F32 DEFAULT_MAX_PRIM_SCALE = 64.f; +constexpr F32 DEFAULT_MAX_PRIM_SCALE_NO_MESH = 10.f; +constexpr F32 MIN_PRIM_SCALE = 0.01f; +constexpr F32 MAX_PRIM_SCALE = 65536.f; // something very high but not near FLT_MAX class LLXform { @@ -52,7 +52,7 @@ protected: LLXform* mParent; U32 mChanged; - BOOL mScaleChildOffset; + bool mScaleChildOffset; public: typedef enum e_changed_flags @@ -78,7 +78,7 @@ public: mScale. setVec(1,1,1); mWorldPosition.clearVec(); mWorldRotation.loadIdentity(); - mScaleChildOffset = FALSE; + mScaleChildOffset = false; } LLXform(); @@ -86,7 +86,7 @@ public: void getLocalMat4(LLMatrix4 &mat) const { mat.initAll(mScale, mRotation, mPosition); } - inline BOOL setParent(LLXform *parent); + inline bool setParent(LLXform *parent); inline void setPosition(const LLVector3& pos); inline void setPosition(const F32 x, const F32 y, const F32 z); @@ -109,18 +109,18 @@ public: void warn(const char* const msg); void setChanged(const U32 bits) { mChanged |= bits; } - BOOL isChanged() const { return mChanged; } - BOOL isChanged(const U32 bits) const { return mChanged & bits; } + bool isChanged() const { return mChanged; } + bool isChanged(const U32 bits) const { return mChanged & bits; } void clearChanged() { mChanged = 0; } void clearChanged(U32 bits) { mChanged &= ~bits; } - void setScaleChildOffset(BOOL scale) { mScaleChildOffset = scale; } - BOOL getScaleChildOffset() { return mScaleChildOffset; } + void setScaleChildOffset(bool scale) { mScaleChildOffset = scale; } + bool getScaleChildOffset() { return mScaleChildOffset; } LLXform* getParent() const { return mParent; } LLXform* getRoot() const; - virtual BOOL isRoot() const; - virtual BOOL isRootEdit() const; + virtual bool isRoot() const; + virtual bool isRootEdit() const; const LLVector3& getPosition() const { return mPosition; } const LLVector3& getScale() const { return mScale; } @@ -149,7 +149,7 @@ public: } void update(); - void updateMatrix(BOOL update_bounds = TRUE); + void updateMatrix(bool update_bounds = true); void getMinMax(LLVector3& min,LLVector3& max) const; protected: @@ -159,12 +159,12 @@ protected: }; -BOOL LLXform::setParent(LLXform* parent) +bool LLXform::setParent(LLXform* parent) { // Validate and make sure we're not creating a loop if (parent == mParent) { - return TRUE; + return true; } if (parent) { @@ -174,13 +174,13 @@ BOOL LLXform::setParent(LLXform* parent) if (cur_par == this) { //warn("LLXform::setParent Creating loop when setting parent!"); - return FALSE; + return false; } cur_par = cur_par->mParent; } } mParent = parent; - return TRUE; + return true; } void LLXform::setPosition(const LLVector3& pos) |