summaryrefslogtreecommitdiff
path: root/indra/llmath
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmath')
-rw-r--r--indra/llmath/lloctree.h2
-rw-r--r--indra/llmath/llvolume.cpp34
-rw-r--r--indra/llmath/llvolumemgr.cpp11
-rw-r--r--indra/llmath/llvolumemgr.h2
4 files changed, 27 insertions, 22 deletions
diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h
index fab8070259..998d19d58b 100644
--- a/indra/llmath/lloctree.h
+++ b/indra/llmath/lloctree.h
@@ -567,8 +567,6 @@ public:
{
}
- bool isLeaf() { return false; }
-
bool balance()
{
if (this->getChildCount() == 1 &&
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index 984c13e0d8..0c711cabcd 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2075,6 +2075,14 @@ void LLVolume::sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components,
}
mSculptLevel = sculpt_level;
+
+ // Delete any existing faces so that they get regenerated
+ if (mVolumeFaces)
+ {
+ delete[] mVolumeFaces;
+ mVolumeFaces = NULL;
+ }
+
createVolumeFaces();
}
@@ -4817,29 +4825,33 @@ BOOL LLVolumeFace::createSide(BOOL partial_build)
}
}
- //generate normals
- for (U32 i = 0; i < mIndices.size()/3; i++) { //for each triangle
- const VertexData& v0 = mVertices[mIndices[i*3+0]];
- const VertexData& v1 = mVertices[mIndices[i*3+1]];
- const VertexData& v2 = mVertices[mIndices[i*3+2]];
+ //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];
//calculate triangle normal
- LLVector3 norm = (v0.mPosition-v1.mPosition)%
- (v0.mPosition-v2.mPosition);
+ LLVector3 norm = (v0.mPosition-v1.mPosition) % (v0.mPosition-v2.mPosition);
for (U32 j = 0; j < 3; j++)
{ //add triangle normal to vertices
- mVertices[mIndices[i*3+j]].mNormal += norm; // * (weight_sum - d[j])/weight_sum;
+ const S32 idx = mIndices[i*3+j];
+ mVertices[idx].mNormal += norm; // * (weight_sum - d[j])/weight_sum;
}
//even out quad contributions
- if (i % 2 == 0)
+ if ((i & 1) == 0)
{
- mVertices[mIndices[i*3+2]].mNormal += norm;
+ mVertices[i2].mNormal += norm;
}
else
{
- mVertices[mIndices[i*3+1]].mNormal += norm;
+ mVertices[i1].mNormal += norm;
}
}
diff --git a/indra/llmath/llvolumemgr.cpp b/indra/llmath/llvolumemgr.cpp
index 945d74f7c1..1a448ed8e0 100644
--- a/indra/llmath/llvolumemgr.cpp
+++ b/indra/llmath/llvolumemgr.cpp
@@ -229,12 +229,6 @@ LLVolumeLODGroup::LLVolumeLODGroup(const LLVolumeParams &params)
LLVolumeLODGroup::~LLVolumeLODGroup()
{
- S32 i;
- for (i = 0; i < NUM_LODS; i++)
- {
- delete mVolumeLODs[i];
- mVolumeLODs[i] = NULL;
- }
}
@@ -242,11 +236,12 @@ LLVolume * LLVolumeLODGroup::getLOD(const S32 detail)
{
llassert(detail >=0 && detail < NUM_LODS);
mAccessCount[detail]++;
- mLODRefs[detail]++;
- if (!mVolumeLODs[detail])
+
+ if (!mLODRefs[detail])
{
mVolumeLODs[detail] = new LLVolume(mParams, mDetailScales[detail]);
}
+ mLODRefs[detail]++;
return mVolumeLODs[detail];
}
diff --git a/indra/llmath/llvolumemgr.h b/indra/llmath/llvolumemgr.h
index 3d7b663670..f3d4b5ee6b 100644
--- a/indra/llmath/llvolumemgr.h
+++ b/indra/llmath/llvolumemgr.h
@@ -69,7 +69,7 @@ protected:
LLVolumeParams mParams;
S32 mLODRefs[NUM_LODS];
- LLVolume *mVolumeLODs[NUM_LODS];
+ LLPointer<LLVolume> mVolumeLODs[NUM_LODS];
static F32 mDetailThresholds[NUM_LODS];
static F32 mDetailScales[NUM_LODS];
S32 mAccessCount[NUM_LODS];