diff options
Diffstat (limited to 'indra/llmath')
| -rw-r--r-- | indra/llmath/CMakeLists.txt | 48 | ||||
| -rw-r--r-- | indra/llmath/llcamera.cpp | 7 | ||||
| -rw-r--r-- | indra/llmath/llinterp.h | 10 | ||||
| -rw-r--r-- | indra/llmath/llmath.h | 2 | ||||
| -rw-r--r-- | indra/llmath/lloctree.h | 1 | ||||
| -rw-r--r-- | indra/llmath/llvolume.cpp | 3 | ||||
| -rw-r--r-- | indra/llmath/xform.cpp | 5 | ||||
| -rw-r--r-- | indra/llmath/xform.h | 30 |
8 files changed, 64 insertions, 42 deletions
diff --git a/indra/llmath/CMakeLists.txt b/indra/llmath/CMakeLists.txt index 7957c32be2..e93fe90650 100644 --- a/indra/llmath/CMakeLists.txt +++ b/indra/llmath/CMakeLists.txt @@ -86,27 +86,29 @@ list(APPEND llmath_SOURCE_FILES ${llmath_HEADER_FILES}) add_library (llmath ${llmath_SOURCE_FILES}) # Add tests -include(LLAddBuildTest) -# UNIT TESTS -SET(llmath_TEST_SOURCE_FILES - llbboxlocal.cpp - llmodularmath.cpp - llrect.cpp - v2math.cpp - v3color.cpp - v4color.cpp - v4coloru.cpp - ) -LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}") +if (LL_TESTS) + include(LLAddBuildTest) + # UNIT TESTS + SET(llmath_TEST_SOURCE_FILES + llbboxlocal.cpp + llmodularmath.cpp + llrect.cpp + v2math.cpp + v3color.cpp + v4color.cpp + v4coloru.cpp + ) + LL_ADD_PROJECT_UNIT_TESTS(llmath "${llmath_TEST_SOURCE_FILES}") -# INTEGRATION TESTS -set(test_libs llmath llcommon ${LLCOMMON_LIBRARIES} ${WINDOWS_LIBRARIES}) -# TODO: Some of these need refactoring to be proper Unit tests rather than Integration tests. -LL_ADD_INTEGRATION_TEST(llbbox llbbox.cpp "${test_libs}") -LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}") -LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}") -LL_ADD_INTEGRATION_TEST(m3math "" "${test_libs}") -LL_ADD_INTEGRATION_TEST(v3dmath v3dmath.cpp "${test_libs}") -LL_ADD_INTEGRATION_TEST(v3math v3math.cpp "${test_libs}") -LL_ADD_INTEGRATION_TEST(v4math v4math.cpp "${test_libs}") -LL_ADD_INTEGRATION_TEST(xform xform.cpp "${test_libs}") + # INTEGRATION TESTS + set(test_libs llmath llcommon ${LLCOMMON_LIBRARIES} ${WINDOWS_LIBRARIES}) + # TODO: Some of these need refactoring to be proper Unit tests rather than Integration tests. + LL_ADD_INTEGRATION_TEST(llbbox llbbox.cpp "${test_libs}") + LL_ADD_INTEGRATION_TEST(llquaternion llquaternion.cpp "${test_libs}") + LL_ADD_INTEGRATION_TEST(mathmisc "" "${test_libs}") + LL_ADD_INTEGRATION_TEST(m3math "" "${test_libs}") + LL_ADD_INTEGRATION_TEST(v3dmath v3dmath.cpp "${test_libs}") + LL_ADD_INTEGRATION_TEST(v3math v3math.cpp "${test_libs}") + LL_ADD_INTEGRATION_TEST(v4math v4math.cpp "${test_libs}") + LL_ADD_INTEGRATION_TEST(xform xform.cpp "${test_libs}") +endif (LL_TESTS) diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp index 21ea4b2e7c..487ed6451f 100644 --- a/indra/llmath/llcamera.cpp +++ b/indra/llmath/llcamera.cpp @@ -45,7 +45,8 @@ LLCamera::LLCamera() : mNearPlane(DEFAULT_NEAR_PLANE), mFarPlane(DEFAULT_FAR_PLANE), mFixedDistance(-1.f), - mPlaneCount(6) + mPlaneCount(6), + mFrustumCornerDist(0.f) { calculateFrustumPlanes(); } @@ -55,7 +56,8 @@ LLCamera::LLCamera(F32 vertical_fov_rads, F32 aspect_ratio, S32 view_height_in_p LLCoordFrame(), mViewHeightInPixels(view_height_in_pixels), mFixedDistance(-1.f), - mPlaneCount(6) + mPlaneCount(6), + mFrustumCornerDist(0.f) { mAspect = llclamp(aspect_ratio, MIN_ASPECT_RATIO, MAX_ASPECT_RATIO); mNearPlane = llclamp(near_plane, MIN_NEAR_PLANE, MAX_NEAR_PLANE); @@ -648,7 +650,6 @@ void LLCamera::ignoreAgentFrustumPlane(S32 idx) void LLCamera::calcAgentFrustumPlanes(LLVector3* frust) { - for (int i = 0; i < 8; i++) { mAgentFrustum[i] = frust[i]; diff --git a/indra/llmath/llinterp.h b/indra/llmath/llinterp.h index 8beeef480b..88af004170 100644 --- a/indra/llmath/llinterp.h +++ b/indra/llmath/llinterp.h @@ -32,6 +32,13 @@ #ifndef LL_LLINTERP_H #define LL_LLINTERP_H +#if defined(LL_WINDOWS) +// macro definitions for common math constants (e.g. M_PI) are declared under the _USE_MATH_DEFINES +// on Windows system. +// So, let's define _USE_MATH_DEFINES before including math.h + #define _USE_MATH_DEFINES +#endif + #include "math.h" // Class from which different types of interpolators can be derived @@ -47,7 +54,7 @@ template <typename Type> class LLInterp { public: - LLInterp(); + LLInterp(); virtual ~LLInterp() {} virtual void start(); @@ -144,6 +151,7 @@ protected: template <typename Type> LLInterp<Type>::LLInterp() +: mStartVal(Type()), mEndVal(Type()), mCurVal(Type()) { mStartTime = 0.f; mEndTime = 1.f; diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h index 7a5d51ff76..209b506c30 100644 --- a/indra/llmath/llmath.h +++ b/indra/llmath/llmath.h @@ -203,7 +203,7 @@ inline S32 llfloor( F32 f ) } return result; #else - return (S32)floor(f); + return (S32)floorf(f); #endif } diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index ba8776690a..2f34fb1bb0 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -183,7 +183,6 @@ public: { mMax.mdV[i] = mCenter.mdV[i] + mSize.mdV[i]; mMin.mdV[i] = mCenter.mdV[i] - mSize.mdV[i]; - mCenter.mdV[i] = mCenter.mdV[i]; } } diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index b8ef92f9a9..192c6157a8 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -3582,7 +3582,7 @@ S32 LLVolume::lineSegmentIntersect(const LLVector3& start, const LLVector3& end, if (face == -1) // ALL_SIDES { start_face = 0; - end_face = getNumFaces() - 1; + end_face = getNumVolumeFaces() - 1; } else { @@ -3822,6 +3822,7 @@ BOOL LLVolume::cleanupTriangleData( const S32 num_input_vertices, // Generate the vertex mapping and the list of vertices without // duplicates. This will crash if there are no vertices. + llassert(num_input_vertices > 0); // check for no vertices! S32 *vertex_mapping = new S32[num_input_vertices]; LLVector3 *new_vertices = new LLVector3[num_input_vertices]; LLVertexIndexPair *prev_pairp = NULL; diff --git a/indra/llmath/xform.cpp b/indra/llmath/xform.cpp index ce6f756ab9..7a8b0cf6a3 100644 --- a/indra/llmath/xform.cpp +++ b/indra/llmath/xform.cpp @@ -42,6 +42,11 @@ LLXform::~LLXform() { } +// Link optimization - don't inline these llwarns +void LLXform::warn(const char* const msg) +{ + llwarns << msg << llendl; +} LLXform* LLXform::getRoot() const { diff --git a/indra/llmath/xform.h b/indra/llmath/xform.h index 5b7b1900bc..c4edd46279 100644 --- a/indra/llmath/xform.h +++ b/indra/llmath/xform.h @@ -107,6 +107,12 @@ public: inline void setRotation(const LLQuaternion& rot); inline void setRotation(const F32 x, const F32 y, const F32 z); inline void setRotation(const F32 x, const F32 y, const F32 z, const F32 s); + + // Above functions must be inline for speed, but also + // need to emit warnings. llwarns causes inline LLError::CallSite + // static objects that make more work for the linker. + // Avoid inline llwarns by calling this function. + void warn(const char* const msg); void setChanged(const U32 bits) { mChanged |= bits; } BOOL isChanged() const { return mChanged; } @@ -173,7 +179,7 @@ BOOL LLXform::setParent(LLXform* parent) { if (cur_par == this) { - //llwarns << "LLXform::setParent Creating loop when setting parent!" << llendl; + //warn("LLXform::setParent Creating loop when setting parent!"); return FALSE; } cur_par = cur_par->mParent; @@ -191,7 +197,7 @@ void LLXform::setPosition(const LLVector3& pos) else { mPosition.clearVec(); - llwarns << "Non Finite in LLXform::setPosition(LLVector3)" << llendl; + warn("Non Finite in LLXform::setPosition(LLVector3)"); } } @@ -203,7 +209,7 @@ void LLXform::setPosition(const F32 x, const F32 y, const F32 z) else { mPosition.clearVec(); - llwarns << "Non Finite in LLXform::setPosition(F32,F32,F32)" << llendl; + warn("Non Finite in LLXform::setPosition(F32,F32,F32)"); } } @@ -215,7 +221,7 @@ void LLXform::setPositionX(const F32 x) else { mPosition.mV[VX] = 0.f; - llwarns << "Non Finite in LLXform::setPositionX" << llendl; + warn("Non Finite in LLXform::setPositionX"); } } @@ -227,7 +233,7 @@ void LLXform::setPositionY(const F32 y) else { mPosition.mV[VY] = 0.f; - llwarns << "Non Finite in LLXform::setPositionY" << llendl; + warn("Non Finite in LLXform::setPositionY"); } } @@ -239,7 +245,7 @@ void LLXform::setPositionZ(const F32 z) else { mPosition.mV[VZ] = 0.f; - llwarns << "Non Finite in LLXform::setPositionZ" << llendl; + warn("Non Finite in LLXform::setPositionZ"); } } @@ -249,7 +255,7 @@ void LLXform::addPosition(const LLVector3& pos) if (pos.isFinite()) mPosition += pos; else - llwarns << "Non Finite in LLXform::addPosition" << llendl; + warn("Non Finite in LLXform::addPosition"); } void LLXform::setScale(const LLVector3& scale) @@ -260,7 +266,7 @@ void LLXform::setScale(const LLVector3& scale) else { mScale.setVec(1.f, 1.f, 1.f); - llwarns << "Non Finite in LLXform::setScale" << llendl; + warn("Non Finite in LLXform::setScale"); } } void LLXform::setScale(const F32 x, const F32 y, const F32 z) @@ -271,7 +277,7 @@ void LLXform::setScale(const F32 x, const F32 y, const F32 z) else { mScale.setVec(1.f, 1.f, 1.f); - llwarns << "Non Finite in LLXform::setScale" << llendl; + warn("Non Finite in LLXform::setScale"); } } void LLXform::setRotation(const LLQuaternion& rot) @@ -282,7 +288,7 @@ void LLXform::setRotation(const LLQuaternion& rot) else { mRotation.loadIdentity(); - llwarns << "Non Finite in LLXform::setRotation" << llendl; + warn("Non Finite in LLXform::setRotation"); } } void LLXform::setRotation(const F32 x, const F32 y, const F32 z) @@ -295,7 +301,7 @@ void LLXform::setRotation(const F32 x, const F32 y, const F32 z) else { mRotation.loadIdentity(); - llwarns << "Non Finite in LLXform::setRotation" << llendl; + warn("Non Finite in LLXform::setRotation"); } } void LLXform::setRotation(const F32 x, const F32 y, const F32 z, const F32 s) @@ -308,7 +314,7 @@ void LLXform::setRotation(const F32 x, const F32 y, const F32 z, const F32 s) else { mRotation.loadIdentity(); - llwarns << "Non Finite in LLXform::setRotation" << llendl; + warn("Non Finite in LLXform::setRotation"); } } |
