diff options
Diffstat (limited to 'indra/llmath')
-rw-r--r-- | indra/llmath/llvolume.cpp | 48 | ||||
-rw-r--r-- | indra/llmath/llvolumeoctree.cpp | 7 | ||||
-rw-r--r-- | indra/llmath/llvolumeoctree.h | 12 |
3 files changed, 38 insertions, 29 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp index 6dd5c8e5c8..c0b50b606e 100644 --- a/indra/llmath/llvolume.cpp +++ b/indra/llmath/llvolume.cpp @@ -93,11 +93,13 @@ extern BOOL gDebugGL; void assert_aligned(void* ptr, uintptr_t alignment) { +#if 0 uintptr_t t = (uintptr_t) ptr; if (t%alignment != 0) { llerrs << "WTF?" << llendl; } +#endif } BOOL check_same_clock_dir( const LLVector3& pt1, const LLVector3& pt2, const LLVector3& pt3, const LLVector3& norm) @@ -2319,12 +2321,6 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) pos_range.setSub(max_pos, min_pos); LLVector2 tc_range = max_tc - min_tc; - LLVector4a& min = face.mExtents[0]; - LLVector4a& max = face.mExtents[1]; - - min.clear(); - max.clear(); - LLVector4a* pos_out = face.mPositions; LLVector4a* norm_out = face.mNormals; LLVector2* tc_out = face.mTexCoords; @@ -2338,17 +2334,6 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) pos_out->mul(pos_range); pos_out->add(min_pos); - if (j == 0) - { - min = *pos_out; - max = min; - } - else - { - min.setMin(min, *pos_out); - max.setMax(max, *pos_out); - } - pos_out++; U16* n = (U16*) &(norm[j*3*2]); @@ -2425,6 +2410,19 @@ bool LLVolume::unpackVolumeFaces(std::istream& is, S32 size) } } + //calculate bounding box + LLVector4a& min = face.mExtents[0]; + LLVector4a& max = face.mExtents[1]; + + min.clear(); + max.clear(); + min = max = face.mPositions[0]; + + for (S32 i = 1; i < face.mNumVertices; ++i) + { + min.setMin(min, face.mPositions[i]); + max.setMax(max, face.mPositions[i]); + } } } @@ -5525,7 +5523,7 @@ void LLVolumeFace::createOctree(F32 scaler, const LLVector4a& center, const LLVe center.setAdd(min, max); center.mul(0.5f); - *tri->mPositionGroup = center; + tri->mPositionGroup = center; //compute "radius" LLVector4a size; @@ -6140,6 +6138,14 @@ void LLVolumeFace::createBinormals() LLVector2* tc = (LLVector2*) mTexCoords; LLVector4a* binorm = (LLVector4a*) mBinormals; + LLVector4a* end = mBinormals+mNumVertices; + while (binorm < end) + { + (*binorm++).clear(); + } + + binorm = mBinormals; + for (U32 i = 0; i < mNumIndices/3; i++) { //for each triangle const U16& i0 = mIndices[i*3+0]; @@ -6593,6 +6599,12 @@ BOOL LLVolumeFace::createSide(LLVolume* volume, BOOL partial_build) } } + //clear normals + for (U32 i = 0; i < mNumVertices; i++) + { + mNormals[i].clear(); + } + //generate normals for (U32 i = 0; i < mNumIndices/3; i++) //for each triangle { diff --git a/indra/llmath/llvolumeoctree.cpp b/indra/llmath/llvolumeoctree.cpp index 3a7cb4940a..b5a935c2b5 100644 --- a/indra/llmath/llvolumeoctree.cpp +++ b/indra/llmath/llvolumeoctree.cpp @@ -78,14 +78,11 @@ BOOL LLLineSegmentBoxIntersect(const LLVector4a& start, const LLVector4a& end, c LLVolumeOctreeListener::LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node) { node->addListener(this); - - mBounds = (LLVector4a*) ll_aligned_malloc_16(sizeof(LLVector4a)*4); - mExtents = mBounds+2; } LLVolumeOctreeListener::~LLVolumeOctreeListener() { - ll_aligned_free_16(mBounds); + } void LLVolumeOctreeListener::handleChildAddition(const LLOctreeNode<LLVolumeTriangle>* parent, @@ -191,7 +188,7 @@ void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle>* n const LLVector4a& LLVolumeTriangle::getPositionGroup() const { - return *mPositionGroup; + return mPositionGroup; } const F32& LLVolumeTriangle::getBinRadius() const diff --git a/indra/llmath/llvolumeoctree.h b/indra/llmath/llvolumeoctree.h index 1f5a78b137..f696cbd976 100644 --- a/indra/llmath/llvolumeoctree.h +++ b/indra/llmath/llvolumeoctree.h @@ -64,8 +64,8 @@ public: public: - LLVector4a* mBounds; // bounding box (center, size) of this node and all its children (tight fit to objects) - LLVector4a* mExtents; // extents (min, max) of this node and all its children + LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects) + LLVector4a mExtents[2]; // extents (min, max) of this node and all its children }; class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle> @@ -96,7 +96,7 @@ class LLVolumeTriangle : public LLRefCount public: LLVolumeTriangle() { - mPositionGroup = (LLVector4a*) ll_aligned_malloc_16(16); + } LLVolumeTriangle(const LLVolumeTriangle& rhs) @@ -112,14 +112,14 @@ public: ~LLVolumeTriangle() { - ll_aligned_free_16(mPositionGroup); + } + LLVector4a mPositionGroup; + const LLVector4a* mV[3]; U16 mIndex[3]; - LLVector4a* mPositionGroup; - F32 mRadius; virtual const LLVector4a& getPositionGroup() const; |