Cleaned up polymesh (mesh vectors/normals size match VBO vectors/normals size to allow memcpy). Prep for vbo testing.

This commit is contained in:
Shyotl
2011-08-04 01:38:56 -05:00
parent 4f8186b17e
commit 2c489d7741
10 changed files with 235 additions and 277 deletions

View File

@@ -282,16 +282,16 @@ BOOL LLPolyMorphData::saveOBJ(LLFILE *fp)
LLPolyMesh mesh(mMesh, NULL);
LLVector3 *coords = mesh.getWritableCoords();
LLVector3 *normals = mesh.getWritableNormals();
LLVector4 *coords = mesh.getWritableCoords();
LLVector4 *normals = mesh.getWritableNormals();
LLVector2 *tex_coords = mesh.getWritableTexCoords();
for(U32 vert_index_morph = 0; vert_index_morph < mNumIndices; vert_index_morph++)
{
S32 vert_index_mesh = mVertexIndices[vert_index_morph];
coords[vert_index_mesh] += mCoords[vert_index_morph];
normals[vert_index_mesh] += mNormals[vert_index_morph];
coords[vert_index_mesh] += LLVector4(mCoords[vert_index_morph]);
normals[vert_index_mesh] += LLVector4(mNormals[vert_index_morph]);
normals[vert_index_mesh].normVec();
tex_coords[vert_index_mesh] += mTexCoords[vert_index_morph];
}
@@ -307,8 +307,8 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
if (!morph)
return FALSE;
LLVector3 *morph_coords = morph->getWritableCoords();
LLVector3 *morph_normals = morph->getWritableNormals();
LLVector4 *morph_coords = morph->getWritableCoords();
LLVector4 *morph_normals = morph->getWritableNormals();
LLVector3 *morph_binormals = morph->getWritableBinormals();
LLVector2 *morph_tex_coords = morph->getWritableTexCoords();
@@ -318,8 +318,8 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
LLPolyMesh delta(mMesh, NULL);
U32 nverts = delta.getNumVertices();
LLVector3 *delta_coords = delta.getWritableCoords();
LLVector3 *delta_normals = delta.getWritableNormals();
LLVector4 *delta_coords = delta.getWritableCoords();
LLVector4 *delta_normals = delta.getWritableNormals();
LLVector3 *delta_binormals = delta.getWritableBinormals();
LLVector2 *delta_tex_coords = delta.getWritableTexCoords();
@@ -380,8 +380,8 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
{
new_vertex_indices[morph_index] = vert_index;
new_coords[morph_index] = delta_coords[vert_index];
new_normals[morph_index] = delta_normals[vert_index];
new_coords[morph_index] = LLVector3(delta_coords[vert_index]);
new_normals[morph_index] = LLVector3(delta_normals[vert_index]);
new_binormals[morph_index] = delta_binormals[vert_index];
new_tex_coords[morph_index] = delta_tex_coords[vert_index];
@@ -417,8 +417,8 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
{
vert_index = mVertexIndices[morph_index];
delta_coords[vert_index] -= mCoords[morph_index];
delta_normals[vert_index] -= mNormals[morph_index];
delta_coords[vert_index] -= LLVector4(mCoords[morph_index]);
delta_normals[vert_index] -= LLVector4(mNormals[morph_index]);
delta_binormals[vert_index] -= mBinormals[morph_index];
delta_tex_coords[vert_index] -= mTexCoords[morph_index];
}
@@ -456,8 +456,8 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
continue;
}
LLVector3 *mesh_coords = mesh->getWritableCoords();
LLVector3 *mesh_normals = mesh->getWritableNormals();
LLVector4 *mesh_coords = mesh->getWritableCoords();
LLVector4 *mesh_normals = mesh->getWritableNormals();
LLVector3 *mesh_binormals = mesh->getWritableBinormals();
LLVector2 *mesh_tex_coords = mesh->getWritableTexCoords();
LLVector3 *mesh_scaled_normals = mesh->getScaledNormals();
@@ -468,10 +468,10 @@ BOOL LLPolyMorphData::setMorphFromMesh(LLPolyMesh *morph)
mesh_coords[vert_index] += delta_coords[vert_index] * weight;
mesh_tex_coords[vert_index] += delta_tex_coords[vert_index] * weight;
mesh_scaled_normals[vert_index] += delta_normals[vert_index] * weight * NORMAL_SOFTEN_FACTOR;
mesh_scaled_normals[vert_index] += LLVector3(delta_normals[vert_index] * weight * NORMAL_SOFTEN_FACTOR);
LLVector3 normalized_normal = mesh_scaled_normals[vert_index];
normalized_normal.normVec();
mesh_normals[vert_index] = normalized_normal;
mesh_normals[vert_index] = LLVector4(normalized_normal);
mesh_scaled_binormals[vert_index] += delta_binormals[vert_index] * weight * NORMAL_SOFTEN_FACTOR;
LLVector3 tangent = mesh_scaled_binormals[vert_index] % normalized_normal;
@@ -797,10 +797,10 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
if (delta_weight != 0.f)
{
llassert(!mMesh->isLOD());
LLVector3 *coords = mMesh->getWritableCoords();
LLVector4 *coords = mMesh->getWritableCoords();
LLVector3 *scaled_normals = mMesh->getScaledNormals();
LLVector3 *normals = mMesh->getWritableNormals();
LLVector4 *normals = mMesh->getWritableNormals();
LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
LLVector3 *binormals = mMesh->getWritableBinormals();
@@ -820,7 +820,8 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
maskWeight = maskWeightArray[vert_index_morph];
}
coords[vert_index_mesh] += mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight;
coords[vert_index_mesh] += LLVector4(mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight);
if (getInfo()->mIsClothingMorph && clothing_weights)
{
LLVector3 clothing_offset = mMorphData->mCoords[vert_index_morph] * delta_weight * maskWeight;
@@ -835,7 +836,7 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
scaled_normals[vert_index_mesh] += mMorphData->mNormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
LLVector3 normalized_normal = scaled_normals[vert_index_mesh];
normalized_normal.normVec();
normals[vert_index_mesh] = normalized_normal;
normals[vert_index_mesh] = LLVector4(normalized_normal);
// calculate new binormals
scaled_binormals[vert_index_mesh] += mMorphData->mBinormals[vert_index_morph] * delta_weight * maskWeight * NORMAL_SOFTEN_FACTOR;
@@ -906,31 +907,31 @@ BOOL LLPolyMorphTarget::undoMask(BOOL delete_mask)
F32 *mask_weights = mVertMask->getMorphMaskWeights();
LLVector3 *coords = mMesh->getWritableCoords();
LLVector4 *coords = mMesh->getWritableCoords();
LLVector3 *scaled_normals = mMesh->getScaledNormals();
LLVector3 *scaled_binormals = mMesh->getScaledBinormals();
LLVector2 *tex_coords = mMesh->getWritableTexCoords();
for(U32 vert = 0; vert < mMorphData->mNumIndices; vert++)
{
F32 mask_weight = 1.f;
if (mask_weights)
{
mask_weight = mask_weights[vert];
}
F32 mask_weight = 1.f;
if (mask_weights)
{
mask_weight = mask_weights[vert];
}
F32 last_mask_weight = mLastWeight * mask_weight;
F32 lastMaskWeight = mLastWeight * mask_weights[vert];
S32 out_vert = mMorphData->mVertexIndices[vert];
// remove effect of existing masked morph
coords[out_vert] -= mMorphData->mCoords[vert] * last_mask_weight;
scaled_normals[out_vert] -= mMorphData->mNormals[vert] * last_mask_weight * NORMAL_SOFTEN_FACTOR;
scaled_binormals[out_vert] -= mMorphData->mBinormals[vert] * last_mask_weight * NORMAL_SOFTEN_FACTOR;
tex_coords[out_vert] -= mMorphData->mTexCoords[vert] * last_mask_weight;
coords[out_vert] -= LLVector4(mMorphData->mCoords[vert]) * lastMaskWeight;
scaled_normals[out_vert] -= mMorphData->mNormals[vert] * lastMaskWeight * NORMAL_SOFTEN_FACTOR;
scaled_binormals[out_vert] -= mMorphData->mBinormals[vert] * lastMaskWeight * NORMAL_SOFTEN_FACTOR;
tex_coords[out_vert] -= mMorphData->mTexCoords[vert] * lastMaskWeight;
if (clothing_weights)
{
LLVector3 clothing_offset = mMorphData->mCoords[vert] * last_mask_weight;
LLVector3 clothing_offset = mMorphData->mCoords[vert] * lastMaskWeight;
LLVector4* clothing_weight = &clothing_weights[out_vert];
clothing_weight->mV[VX] -= clothing_offset.mV[VX];
clothing_weight->mV[VY] -= clothing_offset.mV[VY];