diff options
Diffstat (limited to 'indra/llmath')
-rw-r--r-- | indra/llmath/llvolume.cpp | 93 | ||||
-rw-r--r-- | indra/llmath/tests/llmodularmath_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/llquaternion_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/m3math_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/mathmisc_test.cpp | 6 | ||||
-rw-r--r-- | indra/llmath/tests/v2math_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/v3color_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/v3dmath_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/v3math_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/v4color_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/v4coloru_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/v4math_test.cpp | 2 | ||||
-rw-r--r-- | indra/llmath/tests/xform_test.cpp | 2 |
13 files changed, 69 insertions, 52 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 39b7453ffc..14e1ca8d43 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -80,6 +80,8 @@ const F32 SKEW_MAX = 0.95f; const F32 SCULPT_MIN_AREA = 0.002f; const S32 SCULPT_MIN_AREA_DETAIL = 1; +#define GEN_TRI_STRIP 0 + BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) { LLVector3 test = (pt2-pt1)%(pt3-pt2); @@ -1682,7 +1684,7 @@ LLVolume::LLVolume(const LLVolumeParams ¶ms, const F32 detail, const BOOL ge mGenerateSingleFace = generate_single_face; generate(); - if (mParams.getSculptID().isNull()) + if (mParams.getSculptID().isNull() && params.getSculptType() == LL_SCULPT_TYPE_NONE) { createVolumeFaces(); } @@ -1858,6 +1860,11 @@ void LLVolume::createVolumeFaces() LLProfile::Face& face = mProfilep->mFaces[i]; vf.mBeginS = face.mIndex; vf.mNumS = face.mCount; + if (vf.mNumS < 0) + { + llerrs << "Volume face corruption detected." << llendl; + } + vf.mBeginT = 0; vf.mNumT= getPath().mPath.size(); vf.mID = i; @@ -1901,6 +1908,10 @@ void LLVolume::createVolumeFaces() if (face.mFlat && vf.mNumS > 2) { //flat inner faces have to copy vert normals vf.mNumS = vf.mNumS*2; + if (vf.mNumS < 0) + { + llerrs << "Volume face corruption detected." << llendl; + } } } else @@ -4515,7 +4526,9 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) if (!partial_build) { +#if GEN_TRI_STRIP mTriStrip.clear(); +#endif S32 idxs[] = {0,1,(grid_size+1)+1,(grid_size+1)+1,(grid_size+1),0}; for(S32 gx = 0;gx<grid_size;gx++) { @@ -4529,6 +4542,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]); } +#if GEN_TRI_STRIP if (gy == 0) { mTriStrip.push_back((gx+1)*(grid_size+1)); @@ -4544,6 +4558,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { mTriStrip.push_back(gy+1+gx*(grid_size+1)); } +#endif } else { @@ -4552,6 +4567,7 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) mIndices.push_back(vtop+(gy*(grid_size+1))+gx+idxs[i]); } +#if GEN_TRI_STRIP if (gy == 0) { mTriStrip.push_back(gx*(grid_size+1)); @@ -4566,15 +4582,18 @@ BOOL LLVolumeFace::createUnCutCubeCap(LLVolume* volume, BOOL partial_build) { mTriStrip.push_back(gy+1+(gx+1)*(grid_size+1)); } +#endif } } } +#if GEN_TRI_STRIP if (mTriStrip.size()%2 == 1) { mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]); } +#endif } return TRUE; @@ -4944,6 +4963,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) mIndices[3*i+v2] = i + 1; } +#if GEN_TRI_STRIP //make tri strip if (mTypeMask & OPEN_MASK) { @@ -4986,6 +5006,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]); } } +#endif } return TRUE; @@ -4993,6 +5014,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build) void LLVolumeFace::makeTriStrip() { +#if GEN_TRI_STRIP for (U32 i = 0; i < mIndices.size(); i+=3) { U16 i0 = mIndices[i]; @@ -5021,6 +5043,7 @@ void LLVolumeFace::makeTriStrip() { mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]); } +#endif } void LLVolumeFace::createBinormals() @@ -5106,12 +5129,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) mHasBinormals = FALSE; } - - LLVector3& face_min = mExtents[0]; - LLVector3& face_max = mExtents[1]; - - mCenter.clearVec(); - S32 begin_stex = llfloor( profile[mBeginS].mV[2] ); S32 num_s = ((mTypeMask & INNER_MASK) && (mTypeMask & FLAT_MASK) && mNumS > 2) ? mNumS/2 : mNumS; @@ -5167,15 +5184,6 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) mVertices[cur_vertex].mNormal = LLVector3(0,0,0); mVertices[cur_vertex].mBinormal = LLVector3(0,0,0); - - if (cur_vertex == 0) - { - face_min = face_max = mesh[i].mPos; - } - else - { - update_min_max(face_min, face_max, mesh[i].mPos); - } cur_vertex++; @@ -5209,12 +5217,22 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) mVertices[cur_vertex].mNormal = LLVector3(0,0,0); mVertices[cur_vertex].mBinormal = LLVector3(0,0,0); - update_min_max(face_min,face_max,mesh[i].mPos); - cur_vertex++; } } + + //get bounding box for this side + LLVector3& face_min = mExtents[0]; + LLVector3& face_max = mExtents[1]; + mCenter.clearVec(); + + face_min = face_max = mVertices[0].mPosition; + for (U32 i = 1; i < mVertices.size(); ++i) + { + update_min_max(face_min, face_max, mVertices[i].mPosition); + } + mCenter = (face_min + face_max) * 0.5f; S32 cur_index = 0; @@ -5223,13 +5241,17 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) if (!partial_build) { +#if GEN_TRI_STRIP mTriStrip.clear(); +#endif // Now we generate the indices. for (t = 0; t < (mNumT-1); t++) { +#if GEN_TRI_STRIP //prepend terminating index to strip mTriStrip.push_back(mNumS*t); +#endif for (s = 0; s < (mNumS-1); s++) { @@ -5240,6 +5262,7 @@ 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 +#if GEN_TRI_STRIP if (s == 0) { mTriStrip.push_back(s+mNumS*t); @@ -5247,6 +5270,7 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } mTriStrip.push_back(s+1+mNumS*t); mTriStrip.push_back(s+1+mNumS*(t+1)); +#endif 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 @@ -5288,44 +5312,37 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } mEdge[cur_edge++] = (mNumS-1)*2*t+s*2; //top right/bottom left neighbor face } +#if GEN_TRI_STRIP //append terminating vertex to strip mTriStrip.push_back(mNumS-1+mNumS*(t+1)); +#endif } +#if GEN_TRI_STRIP if (mTriStrip.size()%2 == 1) { mTriStrip.push_back(mTriStrip[mTriStrip.size()-1]); } +#endif } //generate normals for (U32 i = 0; i < mIndices.size()/3; i++) //for each triangle { - const S32 i0 = mIndices[i*3+0]; - const S32 i1 = mIndices[i*3+1]; - const S32 i2 = mIndices[i*3+2]; - const VertexData& v0 = mVertices[i0]; - const VertexData& v1 = mVertices[i1]; - const VertexData& v2 = mVertices[i2]; + const U16* idx = &(mIndices[i*3]); + + VertexData* v[] = + { &mVertices[idx[0]], &mVertices[idx[1]], &mVertices[idx[2]] }; //calculate triangle normal - LLVector3 norm = (v0.mPosition-v1.mPosition) % (v0.mPosition-v2.mPosition); + LLVector3 norm = (v[0]->mPosition-v[1]->mPosition) % (v[0]->mPosition-v[2]->mPosition); - for (U32 j = 0; j < 3; j++) - { //add triangle normal to vertices - const S32 idx = mIndices[i*3+j]; - mVertices[idx].mNormal += norm; // * (weight_sum - d[j])/weight_sum; - } + v[0]->mNormal += norm; + v[1]->mNormal += norm; + v[2]->mNormal += norm; //even out quad contributions - if ((i & 1) == 0) - { - mVertices[i2].mNormal += norm; - } - else - { - mVertices[i1].mNormal += norm; - } + v[i%2+1]->mNormal += norm; } // adjust normals based on wrapping and stitching diff --git a/indra/llmath/tests/llmodularmath_test.cpp b/indra/llmath/tests/llmodularmath_test.cpp index e6525542f1..063d3ef79f 100644 --- a/indra/llmath/tests/llmodularmath_test.cpp +++ b/indra/llmath/tests/llmodularmath_test.cpp @@ -39,7 +39,7 @@ namespace tut }; typedef test_group<modularmath_data> modularmath_test; typedef modularmath_test::object modularmath_object; - tut::modularmath_test modularmath_testcase("modularmath"); + tut::modularmath_test modularmath_testcase("LLModularMath"); template<> template<> void modularmath_object::test<1>() diff --git a/indra/llmath/tests/llquaternion_test.cpp b/indra/llmath/tests/llquaternion_test.cpp index 29e7793d49..9e79b299ff 100644 --- a/indra/llmath/tests/llquaternion_test.cpp +++ b/indra/llmath/tests/llquaternion_test.cpp @@ -43,7 +43,7 @@ namespace tut }; typedef test_group<llquat_test> llquat_test_t; typedef llquat_test_t::object llquat_test_object_t; - tut::llquat_test_t tut_llquat_test("llquat"); + tut::llquat_test_t tut_llquat_test("LLQuaternion"); //test case for LLQuaternion::LLQuaternion(void) fn. template<> template<> diff --git a/indra/llmath/tests/m3math_test.cpp b/indra/llmath/tests/m3math_test.cpp index 3b424f79c6..8abf61b740 100644 --- a/indra/llmath/tests/m3math_test.cpp +++ b/indra/llmath/tests/m3math_test.cpp @@ -44,7 +44,7 @@ namespace tut }; typedef test_group<m3math_test> m3math_test_t; typedef m3math_test_t::object m3math_test_object_t; - tut::m3math_test_t tut_m3math_test("m3math_test"); + tut::m3math_test_t tut_m3math_test("m3math_h"); //test case for setIdentity() fn. template<> template<> diff --git a/indra/llmath/tests/mathmisc_test.cpp b/indra/llmath/tests/mathmisc_test.cpp index 58b78cd491..91a2e6c009 100644 --- a/indra/llmath/tests/mathmisc_test.cpp +++ b/indra/llmath/tests/mathmisc_test.cpp @@ -45,7 +45,7 @@ namespace tut }; typedef test_group<math_data> math_test; typedef math_test::object math_object; - tut::math_test tm("basic_linden_math"); + tut::math_test tm("BasicLindenMath"); template<> template<> void math_object::test<1>() @@ -178,7 +178,7 @@ namespace tut }; typedef test_group<uuid_data> uuid_test; typedef uuid_test::object uuid_object; - tut::uuid_test tu("uuid"); + tut::uuid_test tu("LLUUID"); template<> template<> void uuid_object::test<1>() @@ -233,7 +233,7 @@ namespace tut }; typedef test_group<crc_data> crc_test; typedef crc_test::object crc_object; - tut::crc_test tc("crc"); + tut::crc_test tc("LLCrc"); template<> template<> void crc_object::test<1>() diff --git a/indra/llmath/tests/v2math_test.cpp b/indra/llmath/tests/v2math_test.cpp index e112892c49..9747996b25 100644 --- a/indra/llmath/tests/v2math_test.cpp +++ b/indra/llmath/tests/v2math_test.cpp @@ -39,7 +39,7 @@ namespace tut }; typedef test_group<v2math_data> v2math_test; typedef v2math_test::object v2math_object; - tut::v2math_test v2math_testcase("v2math"); + tut::v2math_test v2math_testcase("v2math_h"); template<> template<> void v2math_object::test<1>() diff --git a/indra/llmath/tests/v3color_test.cpp b/indra/llmath/tests/v3color_test.cpp index 4a05a84123..2c00f00ab3 100644 --- a/indra/llmath/tests/v3color_test.cpp +++ b/indra/llmath/tests/v3color_test.cpp @@ -39,7 +39,7 @@ namespace tut }; typedef test_group<v3color_data> v3color_test; typedef v3color_test::object v3color_object; - tut::v3color_test v3color_testcase("v3color"); + tut::v3color_test v3color_testcase("v3color_h"); template<> template<> void v3color_object::test<1>() diff --git a/indra/llmath/tests/v3dmath_test.cpp b/indra/llmath/tests/v3dmath_test.cpp index 68bcbd124f..b67346f4e5 100644 --- a/indra/llmath/tests/v3dmath_test.cpp +++ b/indra/llmath/tests/v3dmath_test.cpp @@ -43,7 +43,7 @@ namespace tut }; typedef test_group<v3dmath_data> v3dmath_test; typedef v3dmath_test::object v3dmath_object; - tut::v3dmath_test v3dmath_testcase("v3dmath"); + tut::v3dmath_test v3dmath_testcase("v3dmath_h"); template<> template<> void v3dmath_object::test<1>() diff --git a/indra/llmath/tests/v3math_test.cpp b/indra/llmath/tests/v3math_test.cpp index e6ef5d5012..e4732bf861 100644 --- a/indra/llmath/tests/v3math_test.cpp +++ b/indra/llmath/tests/v3math_test.cpp @@ -45,7 +45,7 @@ namespace tut }; typedef test_group<v3math_data> v3math_test; typedef v3math_test::object v3math_object; - tut::v3math_test v3math_testcase("v3math"); + tut::v3math_test v3math_testcase("v3math_h"); template<> template<> void v3math_object::test<1>() diff --git a/indra/llmath/tests/v4color_test.cpp b/indra/llmath/tests/v4color_test.cpp index dde5f9069b..fbd43625d1 100644 --- a/indra/llmath/tests/v4color_test.cpp +++ b/indra/llmath/tests/v4color_test.cpp @@ -43,7 +43,7 @@ namespace tut }; typedef test_group<v4color_data> v4color_test; typedef v4color_test::object v4color_object; - tut::v4color_test v4color_testcase("v4color"); + tut::v4color_test v4color_testcase("v4color_h"); template<> template<> void v4color_object::test<1>() diff --git a/indra/llmath/tests/v4coloru_test.cpp b/indra/llmath/tests/v4coloru_test.cpp index 1408d05b81..6d84ba41ef 100644 --- a/indra/llmath/tests/v4coloru_test.cpp +++ b/indra/llmath/tests/v4coloru_test.cpp @@ -42,7 +42,7 @@ namespace tut }; typedef test_group<v4coloru_data> v4coloru_test; typedef v4coloru_test::object v4coloru_object; - tut::v4coloru_test v4coloru_testcase("v4coloru"); + tut::v4coloru_test v4coloru_testcase("v4coloru_h"); template<> template<> void v4coloru_object::test<1>() diff --git a/indra/llmath/tests/v4math_test.cpp b/indra/llmath/tests/v4math_test.cpp index 24c1af5e61..b1f934e555 100644 --- a/indra/llmath/tests/v4math_test.cpp +++ b/indra/llmath/tests/v4math_test.cpp @@ -41,7 +41,7 @@ namespace tut }; typedef test_group<v4math_data> v4math_test; typedef v4math_test::object v4math_object; - tut::v4math_test v4math_testcase("v4math"); + tut::v4math_test v4math_testcase("v4math_h"); template<> template<> void v4math_object::test<1>() diff --git a/indra/llmath/tests/xform_test.cpp b/indra/llmath/tests/xform_test.cpp index 1337daa50a..49870eef3c 100644 --- a/indra/llmath/tests/xform_test.cpp +++ b/indra/llmath/tests/xform_test.cpp @@ -38,7 +38,7 @@ namespace tut }; typedef test_group<xform_test> xform_test_t; typedef xform_test_t::object xform_test_object_t; - tut::xform_test_t tut_xform_test("xform_test"); + tut::xform_test_t tut_xform_test("LLXForm"); //test case for init(), getParent(), getRotation(), getPositionW(), getWorldRotation() fns. template<> template<> |