summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-04-06 16:21:40 -0500
committerDave Parks <davep@lindenlab.com>2011-04-06 16:21:40 -0500
commitf17997e274a426086e20e1743f79748ccfadcbac (patch)
tree33add07ae83d1293914c7204782a8bff6d21f3da
parent09dd619612c4ff6cb8e4db991f156679f60fac06 (diff)
merge cleanup
-rw-r--r--indra/newview/llpolymesh.cpp122
1 files changed, 48 insertions, 74 deletions
diff --git a/indra/newview/llpolymesh.cpp b/indra/newview/llpolymesh.cpp
index b512a867ba..90e835cda8 100644
--- a/indra/newview/llpolymesh.cpp
+++ b/indra/newview/llpolymesh.cpp
@@ -738,43 +738,40 @@ const LLVector2 &LLPolyMeshSharedData::getUVs(U32 index)
//-----------------------------------------------------------------------------
LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_mesh)
{
- LLMemType mt(LLMemType::MTYPE_AVATAR_MESH);
-
- llassert(shared_data);
-
- mSharedData = shared_data;
- mReferenceMesh = reference_mesh;
- mAvatarp = NULL;
- mVertexData = NULL;
-
- mCurVertexCount = 0;
- mFaceIndexCount = 0;
- mFaceIndexOffset = 0;
- mFaceVertexCount = 0;
- mFaceVertexOffset = 0;
-
- if (shared_data->isLOD() && reference_mesh)
- {
- mCoords = reference_mesh->mCoords;
- mNormals = reference_mesh->mNormals;
- mScaledNormals = reference_mesh->mScaledNormals;
- mBinormals = reference_mesh->mBinormals;
- mScaledBinormals = reference_mesh->mScaledBinormals;
- mTexCoords = reference_mesh->mTexCoords;
- mClothingWeights = reference_mesh->mClothingWeights;
- }
- else
- {
-#if 1 // Allocate memory without initializing every vector
- // NOTE: This makes asusmptions about the size of LLVector[234]
- int nverts = mSharedData->mNumVertices;
- int nfloats = nverts * (3*5 + 2 + 4);
- mVertexData = new F32[nfloats];
+ LLMemType mt(LLMemType::MTYPE_AVATAR_MESH);
+
+ llassert(shared_data);
+
+ mSharedData = shared_data;
+ mReferenceMesh = reference_mesh;
+ mAvatarp = NULL;
+ mVertexData = NULL;
+
+ mCurVertexCount = 0;
+ mFaceIndexCount = 0;
+ mFaceIndexOffset = 0;
+ mFaceVertexCount = 0;
+ mFaceVertexOffset = 0;
+
+ if (shared_data->isLOD() && reference_mesh)
+ {
+ mCoords = reference_mesh->mCoords;
+ mNormals = reference_mesh->mNormals;
+ mScaledNormals = reference_mesh->mScaledNormals;
+ mBinormals = reference_mesh->mBinormals;
+ mScaledBinormals = reference_mesh->mScaledBinormals;
+ mTexCoords = reference_mesh->mTexCoords;
+ mClothingWeights = reference_mesh->mClothingWeights;
+ }
+ else
+ {
+ // Allocate memory without initializing every vector
+ // NOTE: This makes asusmptions about the size of LLVector[234]
+ int nverts = mSharedData->mNumVertices;
+ int nfloats = nverts * (3*5 + 2 + 4);
//use 16 byte aligned vertex data to make LLPolyMesh SSE friendly
- mVertexData = (F32*) malloc(nfloats*4);
- int offset = 0;
- mCoords = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
- mNormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
+ mVertexData = new F32[nfloats];
+ int offset = 0;
mCoords = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
mNormals = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
mClothingWeights = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
@@ -782,23 +779,11 @@ LLPolyMesh::LLPolyMesh(LLPolyMeshSharedData *shared_data, LLPolyMesh *reference_
// these members don't need to be 16-byte aligned, but the first one might be
// read during an aligned memcpy of mTexCoords
- mScaledNormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
- mBinormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
- mScaledBinormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
- mTexCoords = (LLVector2*)(mVertexData + offset); offset += 2*nverts;
- mClothingWeights = (LLVector4*)(mVertexData + offset); offset += 4*nverts;
-#else
- mCoords = new LLVector3[mSharedData->mNumVertices];
- mNormals = new LLVector3[mSharedData->mNumVertices];
- mScaledNormals = new LLVector3[mSharedData->mNumVertices];
- mBinormals = new LLVector3[mSharedData->mNumVertices];
- mScaledBinormals = new LLVector3[mSharedData->mNumVertices];
- mTexCoords = new LLVector2[mSharedData->mNumVertices];
- mClothingWeights = new LLVector4[mSharedData->mNumVertices];
- memset(mClothingWeights, 0, sizeof(LLVector4) * mSharedData->mNumVertices);
-#endif
- initializeForMorph();
- }
+ mScaledNormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
+ mBinormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
+ mScaledBinormals = (LLVector3*)(mVertexData + offset); offset += 3*nverts;
+ initializeForMorph();
+ }
}
@@ -813,17 +798,9 @@ LLPolyMesh::~LLPolyMesh()
delete mJointRenderData[i];
mJointRenderData[i] = NULL;
}
-#if 0 // These are now allocated as one big uninitialized chunk
- delete [] mCoords;
- delete [] mNormals;
- delete [] mScaledNormals;
- delete [] mBinormals;
- delete [] mScaledBinormals;
- delete [] mClothingWeights;
- delete [] mTexCoords;
-#else
- delete [] mVertexData;
-#endif
+
+ delete [] mVertexData;
+
}
@@ -989,20 +966,17 @@ LLVector3 *LLPolyMesh::getScaledBinormals()
//-----------------------------------------------------------------------------
void LLPolyMesh::initializeForMorph()
{
- if (!mSharedData)
- return;
-
- memcpy(mCoords, mSharedData->mBaseCoords, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
- memcpy(mNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
+ for (U32 i = 0; i < mSharedData->mNumVertices; ++i)
+ {
mCoords[i] = LLVector4(mSharedData->mBaseCoords[i]);
mNormals[i] = LLVector4(mSharedData->mBaseNormals[i]);
}
- memcpy(mScaledNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
- memcpy(mBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
- memcpy(mScaledBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
- memcpy(mTexCoords, mSharedData->mTexCoords, sizeof(LLVector2) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
- memset(mClothingWeights, 0, sizeof(LLVector4) * mSharedData->mNumVertices);
+ memcpy(mScaledNormals, mSharedData->mBaseNormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
+ memcpy(mBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
+ memcpy(mScaledBinormals, mSharedData->mBaseBinormals, sizeof(LLVector3) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
+ memcpy(mTexCoords, mSharedData->mTexCoords, sizeof(LLVector2) * mSharedData->mNumVertices); /*Flawfinder: ignore*/
+ memset(mClothingWeights, 0, sizeof(LLVector4) * mSharedData->mNumVertices);
}
//-----------------------------------------------------------------------------