Rename all member variables to follow the style guidelines (prefixed with the 'm') - class TSSkinMesh

This commit is contained in:
bank 2014-05-13 12:45:42 +04:00
parent e2545c359c
commit 2112c81446
6 changed files with 110 additions and 110 deletions

View file

@ -1236,8 +1236,8 @@ void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
if ( mesh->getMeshType() == TSMesh::SkinMeshType ) if ( mesh->getMeshType() == TSMesh::SkinMeshType )
{ {
const TSSkinMesh* skin = dynamic_cast<const TSSkinMesh*>(mesh); const TSSkinMesh* skin = dynamic_cast<const TSSkinMesh*>(mesh);
mNumBones += skin->batchData.initialTransforms.size(); mNumBones += skin->mBatchData.initialTransforms.size();
mNumWeights += skin->weight.size(); mNumWeights += skin->mWeight.size();
} }
} }

View file

@ -133,13 +133,13 @@ TSMesh* AppMesh::constructTSMesh()
tsmesh = tsskin; tsmesh = tsskin;
// Copy skin elements // Copy skin elements
tsskin->weight = mWeight; tsskin->mWeight = mWeight;
tsskin->boneIndex = mBoneIndex; tsskin->mBoneIndex = mBoneIndex;
tsskin->vertexIndex = mVertexIndex; tsskin->mVertexIndex = mVertexIndex;
tsskin->batchData.nodeIndex = mNodeIndex; tsskin->mBatchData.nodeIndex = mNodeIndex;
tsskin->batchData.initialTransforms = mInitialTransforms; tsskin->mBatchData.initialTransforms = mInitialTransforms;
tsskin->batchData.initialVerts = mInitialVerts; tsskin->mBatchData.initialVerts = mInitialVerts;
tsskin->batchData.initialNorms = mInitialNorms; tsskin->mBatchData.initialNorms = mInitialNorms;
} }
else else
{ {

View file

@ -1180,53 +1180,53 @@ void TSSkinMesh::updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHa
{ {
PROFILE_SCOPE( TSSkinMesh_UpdateSkin ); PROFILE_SCOPE( TSSkinMesh_UpdateSkin );
AssertFatal(batchDataInitialized, "Batch data not initialized. Call createBatchData() before any skin update is called."); AssertFatal(mBatchDataInitialized, "Batch data not initialized. Call createBatchData() before any skin update is called.");
// set arrays // set arrays
#if defined(TORQUE_MAX_LIB) #if defined(TORQUE_MAX_LIB)
mVerts.setSize(batchData.initialVerts.size()); mVerts.setSize(mBatchData.initialVerts.size());
mNorms.setSize(batchData.initialNorms.size()); mNorms.setSize(mBatchData.initialNorms.size());
#else #else
if ( !batchDataInitialized && mEncodedNorms.size() ) if ( !mBatchDataInitialized && mEncodedNorms.size() )
{ {
// we co-opt responsibility for updating encoded normals from mesh // we co-opt responsibility for updating encoded normals from mesh
gNormalStore.setSize( mVertsPerFrame ); gNormalStore.setSize( mVertsPerFrame );
for ( S32 i = 0; i < mVertsPerFrame; i++ ) for ( S32 i = 0; i < mVertsPerFrame; i++ )
gNormalStore[i] = decodeNormal( mEncodedNorms[i] ); gNormalStore[i] = decodeNormal( mEncodedNorms[i] );
batchData.initialNorms.set( gNormalStore.address(), mVertsPerFrame ); mBatchData.initialNorms.set( gNormalStore.address(), mVertsPerFrame );
} }
#endif #endif
static Vector<MatrixF> sBoneTransforms; static Vector<MatrixF> sBoneTransforms;
sBoneTransforms.setSize( batchData.nodeIndex.size() ); sBoneTransforms.setSize( mBatchData.nodeIndex.size() );
// set up bone transforms // set up bone transforms
PROFILE_START(TSSkinMesh_UpdateTransforms); PROFILE_START(TSSkinMesh_UpdateTransforms);
for( S32 i=0; i<batchData.nodeIndex.size(); i++ ) for( S32 i=0; i<mBatchData.nodeIndex.size(); i++ )
{ {
S32 node = batchData.nodeIndex[i]; S32 node = mBatchData.nodeIndex[i];
sBoneTransforms[i].mul( transforms[node], batchData.initialTransforms[i] ); sBoneTransforms[i].mul( transforms[node], mBatchData.initialTransforms[i] );
} }
const MatrixF * matrices = &sBoneTransforms[0]; const MatrixF * matrices = &sBoneTransforms[0];
PROFILE_END(); PROFILE_END();
// Perform skinning // Perform skinning
const bool bBatchByVert = !batchData.vertexBatchOperations.empty(); const bool bBatchByVert = !mBatchData.vertexBatchOperations.empty();
if(bBatchByVert) if(bBatchByVert)
{ {
const Point3F *inVerts = &batchData.initialVerts[0]; const Point3F *inVerts = &mBatchData.initialVerts[0];
const Point3F *inNorms = &batchData.initialNorms[0]; const Point3F *inNorms = &mBatchData.initialNorms[0];
Point3F srcVtx, srcNrm; Point3F srcVtx, srcNrm;
AssertFatal( batchData.vertexBatchOperations.size() == batchData.initialVerts.size(), "Assumption failed!" ); AssertFatal( mBatchData.vertexBatchOperations.size() == mBatchData.initialVerts.size(), "Assumption failed!" );
register Point3F skinnedVert; register Point3F skinnedVert;
register Point3F skinnedNorm; register Point3F skinnedNorm;
for( Vector<BatchData::BatchedVertex>::const_iterator itr = batchData.vertexBatchOperations.begin(); for( Vector<BatchData::BatchedVertex>::const_iterator itr = mBatchData.vertexBatchOperations.begin();
itr != batchData.vertexBatchOperations.end(); itr++ ) itr != mBatchData.vertexBatchOperations.end(); itr++ )
{ {
const BatchData::BatchedVertex &curVert = *itr; const BatchData::BatchedVertex &curVert = *itr;
@ -1275,11 +1275,11 @@ void TSSkinMesh::updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHa
zero_vert_normal_bulk(mNumVerts, outPtr, outStride); zero_vert_normal_bulk(mNumVerts, outPtr, outStride);
// Iterate over transforms, and perform batch transform x skin_vert // Iterate over transforms, and perform batch transform x skin_vert
for(Vector<S32>::const_iterator itr = batchData.transformKeys.begin(); for(Vector<S32>::const_iterator itr = mBatchData.transformKeys.begin();
itr != batchData.transformKeys.end(); itr++) itr != mBatchData.transformKeys.end(); itr++)
{ {
const S32 boneXfmIdx = *itr; const S32 boneXfmIdx = *itr;
const BatchData::BatchedTransform &curTransform = *batchData.transformBatchOperations.retreive(boneXfmIdx); const BatchData::BatchedTransform &curTransform = *mBatchData.transformBatchOperations.retreive(boneXfmIdx);
const MatrixF &curBoneMat = matrices[boneXfmIdx]; const MatrixF &curBoneMat = matrices[boneXfmIdx];
const S32 numVerts = curTransform.numElements; const S32 numVerts = curTransform.numElements;
@ -1307,14 +1307,14 @@ S32 QSORT_CALLBACK _sort_BatchedVertWeight( const void *a, const void *b )
void TSSkinMesh::createBatchData() void TSSkinMesh::createBatchData()
{ {
if(batchDataInitialized) if(mBatchDataInitialized)
return; return;
batchDataInitialized = true; mBatchDataInitialized = true;
S32 * curVtx = vertexIndex.begin(); S32 * curVtx = mVertexIndex.begin();
S32 * curBone = boneIndex.begin(); S32 * curBone = mBoneIndex.begin();
F32 * curWeight = weight.begin(); F32 * curWeight = mWeight.begin();
const S32 * endVtx = vertexIndex.end(); const S32 * endVtx = mVertexIndex.end();
// Temp vector to build batch operations // Temp vector to build batch operations
Vector<BatchData::BatchedVertex> batchOperations; Vector<BatchData::BatchedVertex> batchOperations;
@ -1408,7 +1408,7 @@ void TSSkinMesh::createBatchData()
#ifdef _BATCH_BY_VERTEX #ifdef _BATCH_BY_VERTEX
// Copy data to member, and be done // Copy data to member, and be done
batchData.vertexBatchOperations.set(batchOperations.address(), batchOperations.size()); mBatchData.vertexBatchOperations.set(batchOperations.address(), batchOperations.size());
// Convert to batch-by-transform, which is better for CPU skinning, // Convert to batch-by-transform, which is better for CPU skinning,
// where-as GPU skinning would data for batch-by-vertex operation // where-as GPU skinning would data for batch-by-vertex operation
@ -1424,18 +1424,18 @@ void TSSkinMesh::createBatchData()
// Find the proper batched transform, and add this vertex/weight to the // Find the proper batched transform, and add this vertex/weight to the
// list of verts affected by the transform // list of verts affected by the transform
BatchData::BatchedTransform *bt = batchData.transformBatchOperations.retreive(transformOp.transformIndex); BatchData::BatchedTransform *bt = mBatchData.transformBatchOperations.retreive(transformOp.transformIndex);
if(!bt) if(!bt)
{ {
bt = new BatchData::BatchedTransform; bt = new BatchData::BatchedTransform;
batchData.transformBatchOperations.insert(bt, transformOp.transformIndex); mBatchData.transformBatchOperations.insert(bt, transformOp.transformIndex);
bt->_tmpVec = new Vector<BatchData::BatchedVertWeight>; bt->_tmpVec = new Vector<BatchData::BatchedVertWeight>;
batchData.transformKeys.push_back(transformOp.transformIndex); mBatchData.transformKeys.push_back(transformOp.transformIndex);
} }
bt->_tmpVec->increment(); bt->_tmpVec->increment();
bt->_tmpVec->last().vert = batchData.initialVerts[curTransform.vertexIndex]; bt->_tmpVec->last().vert = mBatchData.initialVerts[curTransform.vertexIndex];
bt->_tmpVec->last().normal = batchData.initialNorms[curTransform.vertexIndex]; bt->_tmpVec->last().normal = mBatchData.initialNorms[curTransform.vertexIndex];
bt->_tmpVec->last().weight = transformOp.weight; bt->_tmpVec->last().weight = transformOp.weight;
bt->_tmpVec->last().vidx = curTransform.vertexIndex; bt->_tmpVec->last().vidx = curTransform.vertexIndex;
} }
@ -1443,10 +1443,10 @@ void TSSkinMesh::createBatchData()
// Now iterate the resulting operations and convert the vectors to aligned // Now iterate the resulting operations and convert the vectors to aligned
// memory locations // memory locations
const S32 numBatchOps = batchData.transformKeys.size(); const S32 numBatchOps = mBatchData.transformKeys.size();
for(S32 i = 0; i < numBatchOps; i++) for(S32 i = 0; i < numBatchOps; i++)
{ {
BatchData::BatchedTransform &curTransform = *batchData.transformBatchOperations.retreive(batchData.transformKeys[i]); BatchData::BatchedTransform &curTransform = *mBatchData.transformBatchOperations.retreive(mBatchData.transformKeys[i]);
const S32 numVerts = curTransform._tmpVec->size(); const S32 numVerts = curTransform._tmpVec->size();
// Allocate a chunk of aligned memory and copy in values // Allocate a chunk of aligned memory and copy in values
@ -1464,7 +1464,7 @@ void TSSkinMesh::createBatchData()
// Now sort the batch data so that the skin function writes close to linear output // Now sort the batch data so that the skin function writes close to linear output
for(S32 i = 0; i < numBatchOps; i++) for(S32 i = 0; i < numBatchOps; i++)
{ {
BatchData::BatchedTransform &curTransform = *batchData.transformBatchOperations.retreive(batchData.transformKeys[i]); BatchData::BatchedTransform &curTransform = *mBatchData.transformBatchOperations.retreive(mBatchData.transformKeys[i]);
dQsort(curTransform.alignedMem, curTransform.numElements, sizeof(BatchData::BatchedVertWeight), _sort_BatchedVertWeight); dQsort(curTransform.alignedMem, curTransform.numElements, sizeof(BatchData::BatchedVertWeight), _sort_BatchedVertWeight);
} }
#endif #endif
@ -1489,11 +1489,11 @@ void TSSkinMesh::render( TSMaterialList *materials,
// Initialize the vertex data if it needs it // Initialize the vertex data if it needs it
if(!mVertexData.isReady() ) if(!mVertexData.isReady() )
_convertToAlignedMeshData(mVertexData, batchData.initialVerts, batchData.initialNorms); _convertToAlignedMeshData(mVertexData, mBatchData.initialVerts, mBatchData.initialNorms);
AssertFatal(mVertexData.size() == mNumVerts, "Vert # mismatch"); AssertFatal(mVertexData.size() == mNumVerts, "Vert # mismatch");
// Initialize the skin batch if that isn't ready // Initialize the skin batch if that isn't ready
if(!batchDataInitialized) if(!mBatchDataInitialized)
createBatchData(); createBatchData();
const bool vertsChanged = vertexBuffer.isNull() || vertexBuffer->mNumVerts != mNumVerts; const bool vertsChanged = vertexBuffer.isNull() || vertexBuffer->mNumVerts != mNumVerts;
@ -1550,7 +1550,7 @@ void TSSkinMesh::computeBounds( const MatrixF &transform, Box3F &bounds, S32 fra
if (frame < 0) if (frame < 0)
{ {
// Use unskinned verts // Use unskinned verts
TSMesh::computeBounds( batchData.initialVerts.address(), batchData.initialVerts.size(), sizeof(Point3F), transform, bounds, center, radius ); TSMesh::computeBounds( mBatchData.initialVerts.address(), mBatchData.initialVerts.size(), sizeof(Point3F), transform, bounds, center, radius );
} }
else else
{ {
@ -2765,14 +2765,14 @@ void TSMesh::disassemble()
void TSSkinMesh::assemble( bool skip ) void TSSkinMesh::assemble( bool skip )
{ {
// avoid a crash on computeBounds... // avoid a crash on computeBounds...
batchData.initialVerts.set( NULL, 0 ); mBatchData.initialVerts.set( NULL, 0 );
TSMesh::assemble( skip ); TSMesh::assemble( skip );
S32 sz = tsalloc.get32(); S32 sz = tsalloc.get32();
S32 numVerts = sz; S32 numVerts = sz;
S32 * ptr32 = getSharedData32( mParentMesh, 3 * numVerts, (S32**)smVertsList.address(), skip ); S32 * ptr32 = getSharedData32( mParentMesh, 3 * numVerts, (S32**)smVertsList.address(), skip );
batchData.initialVerts.set( (Point3F*)ptr32, sz ); mBatchData.initialVerts.set( (Point3F*)ptr32, sz );
S8 * ptr8; S8 * ptr8;
if ( TSShape::smReadVersion>21 && TSMesh::smUseEncodedNormals ) if ( TSShape::smReadVersion>21 && TSMesh::smUseEncodedNormals )
@ -2780,7 +2780,7 @@ void TSSkinMesh::assemble( bool skip )
// we have encoded normals and we want to use them... // we have encoded normals and we want to use them...
if ( mParentMesh < 0 ) if ( mParentMesh < 0 )
tsalloc.getPointer32( numVerts * 3 ); // advance past norms, don't use tsalloc.getPointer32( numVerts * 3 ); // advance past norms, don't use
batchData.initialNorms.set( NULL, 0 ); mBatchData.initialNorms.set( NULL, 0 );
ptr8 = getSharedData8( mParentMesh, numVerts, (S8**)smEncodedNormsList.address(), skip ); ptr8 = getSharedData8( mParentMesh, numVerts, (S8**)smEncodedNormsList.address(), skip );
mEncodedNorms.set( ptr8, numVerts ); mEncodedNorms.set( ptr8, numVerts );
@ -2791,7 +2791,7 @@ void TSSkinMesh::assemble( bool skip )
{ {
// we have encoded normals but we don't want to use them... // we have encoded normals but we don't want to use them...
ptr32 = getSharedData32( mParentMesh, 3 * numVerts, (S32**)smNormsList.address(), skip ); ptr32 = getSharedData32( mParentMesh, 3 * numVerts, (S32**)smNormsList.address(), skip );
batchData.initialNorms.set( (Point3F*)ptr32, numVerts ); mBatchData.initialNorms.set( (Point3F*)ptr32, numVerts );
if ( mParentMesh < 0 ) if ( mParentMesh < 0 )
tsalloc.getPointer8( numVerts ); // advance past encoded normls, don't use tsalloc.getPointer8( numVerts ); // advance past encoded normls, don't use
@ -2802,34 +2802,34 @@ void TSSkinMesh::assemble( bool skip )
{ {
// no encoded normals... // no encoded normals...
ptr32 = getSharedData32( mParentMesh, 3 * numVerts, (S32**)smNormsList.address(), skip ); ptr32 = getSharedData32( mParentMesh, 3 * numVerts, (S32**)smNormsList.address(), skip );
batchData.initialNorms.set( (Point3F*)ptr32, numVerts ); mBatchData.initialNorms.set( (Point3F*)ptr32, numVerts );
mEncodedNorms.set( NULL, 0 ); mEncodedNorms.set( NULL, 0 );
} }
sz = tsalloc.get32(); sz = tsalloc.get32();
ptr32 = getSharedData32( mParentMesh, 16 * sz, (S32**)smInitTransformList.address(), skip ); ptr32 = getSharedData32( mParentMesh, 16 * sz, (S32**)smInitTransformList.address(), skip );
batchData.initialTransforms.set( ptr32, sz ); mBatchData.initialTransforms.set( ptr32, sz );
sz = tsalloc.get32(); sz = tsalloc.get32();
ptr32 = getSharedData32( mParentMesh, sz, (S32**)smVertexIndexList.address(), skip ); ptr32 = getSharedData32( mParentMesh, sz, (S32**)smVertexIndexList.address(), skip );
vertexIndex.set( ptr32, sz ); mVertexIndex.set( ptr32, sz );
ptr32 = getSharedData32( mParentMesh, sz, (S32**)smBoneIndexList.address(), skip ); ptr32 = getSharedData32( mParentMesh, sz, (S32**)smBoneIndexList.address(), skip );
boneIndex.set( ptr32, sz ); mBoneIndex.set( ptr32, sz );
ptr32 = getSharedData32( mParentMesh, sz, (S32**)smWeightList.address(), skip ); ptr32 = getSharedData32( mParentMesh, sz, (S32**)smWeightList.address(), skip );
weight.set( (F32*)ptr32, sz ); mWeight.set( (F32*)ptr32, sz );
sz = tsalloc.get32(); sz = tsalloc.get32();
ptr32 = getSharedData32( mParentMesh, sz, (S32**)smNodeIndexList.address(), skip ); ptr32 = getSharedData32( mParentMesh, sz, (S32**)smNodeIndexList.address(), skip );
batchData.nodeIndex.set( ptr32, sz ); mBatchData.nodeIndex.set( ptr32, sz );
tsalloc.checkGuard(); tsalloc.checkGuard();
if ( tsalloc.allocShape32( 0 ) && TSShape::smReadVersion < 19 ) if ( tsalloc.allocShape32( 0 ) && TSShape::smReadVersion < 19 )
TSMesh::computeBounds(); // only do this if we copied the data... TSMesh::computeBounds(); // only do this if we copied the data...
createTangents(batchData.initialVerts, batchData.initialNorms); createTangents(mBatchData.initialVerts, mBatchData.initialNorms);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -2839,40 +2839,40 @@ void TSSkinMesh::disassemble()
{ {
TSMesh::disassemble(); TSMesh::disassemble();
tsalloc.set32( batchData.initialVerts.size() ); tsalloc.set32( mBatchData.initialVerts.size() );
// if we have no parent mesh, then save off our verts & norms // if we have no parent mesh, then save off our verts & norms
if ( mParentMesh < 0 ) if ( mParentMesh < 0 )
{ {
tsalloc.copyToBuffer32( (S32*)batchData.initialVerts.address(), 3 * batchData.initialVerts.size() ); tsalloc.copyToBuffer32( (S32*)mBatchData.initialVerts.address(), 3 * mBatchData.initialVerts.size() );
// no longer do this here...let tsmesh handle this // no longer do this here...let tsmesh handle this
tsalloc.copyToBuffer32( (S32*)batchData.initialNorms.address(), 3 * batchData.initialNorms.size() ); tsalloc.copyToBuffer32( (S32*)mBatchData.initialNorms.address(), 3 * mBatchData.initialNorms.size() );
// if no parent mesh, compute encoded normals and copy over // if no parent mesh, compute encoded normals and copy over
for ( S32 i = 0; i < batchData.initialNorms.size(); i++ ) for ( S32 i = 0; i < mBatchData.initialNorms.size(); i++ )
{ {
U8 normIdx = mEncodedNorms.size() ? mEncodedNorms[i] : encodeNormal( batchData.initialNorms[i] ); U8 normIdx = mEncodedNorms.size() ? mEncodedNorms[i] : encodeNormal( mBatchData.initialNorms[i] );
tsalloc.copyToBuffer8( (S8*)&normIdx, 1 ); tsalloc.copyToBuffer8( (S8*)&normIdx, 1 );
} }
} }
tsalloc.set32( batchData.initialTransforms.size() ); tsalloc.set32( mBatchData.initialTransforms.size() );
if ( mParentMesh < 0 ) if ( mParentMesh < 0 )
tsalloc.copyToBuffer32( (S32*)batchData.initialTransforms.address(), batchData.initialTransforms.size() * 16 ); tsalloc.copyToBuffer32( (S32*)mBatchData.initialTransforms.address(), mBatchData.initialTransforms.size() * 16 );
tsalloc.set32( vertexIndex.size() ); tsalloc.set32( mVertexIndex.size() );
if ( mParentMesh < 0 ) if ( mParentMesh < 0 )
{ {
tsalloc.copyToBuffer32( (S32*)vertexIndex.address(), vertexIndex.size() ); tsalloc.copyToBuffer32( (S32*)mVertexIndex.address(), mVertexIndex.size() );
tsalloc.copyToBuffer32( (S32*)boneIndex.address(), boneIndex.size() ); tsalloc.copyToBuffer32( (S32*)mBoneIndex.address(), mBoneIndex.size() );
tsalloc.copyToBuffer32( (S32*)weight.address(), weight.size() ); tsalloc.copyToBuffer32( (S32*)mWeight.address(), mWeight.size() );
} }
tsalloc.set32( batchData.nodeIndex.size() ); tsalloc.set32( mBatchData.nodeIndex.size() );
if ( mParentMesh < 0 ) if ( mParentMesh < 0 )
tsalloc.copyToBuffer32( (S32*)batchData.nodeIndex.address(), batchData.nodeIndex.size() ); tsalloc.copyToBuffer32( (S32*)mBatchData.nodeIndex.address(), mBatchData.nodeIndex.size() );
tsalloc.setGuard(); tsalloc.setGuard();
} }
@ -2881,7 +2881,7 @@ TSSkinMesh::TSSkinMesh()
{ {
mMeshType = SkinMeshType; mMeshType = SkinMeshType;
mDynamic = true; mDynamic = true;
batchDataInitialized = false; mBatchDataInitialized = false;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -3040,7 +3040,7 @@ void TSMesh::convertToAlignedMeshData()
void TSSkinMesh::convertToAlignedMeshData() void TSSkinMesh::convertToAlignedMeshData()
{ {
if(!mVertexData.isReady()) if(!mVertexData.isReady())
_convertToAlignedMeshData(mVertexData, batchData.initialVerts, batchData.initialNorms); _convertToAlignedMeshData(mVertexData, mBatchData.initialVerts, mBatchData.initialNorms);
} }
void TSMesh::_convertToAlignedMeshData( TSMeshVertexArray &vertexData, const Vector<Point3F> &_verts, const Vector<Point3F> &_norms ) void TSMesh::_convertToAlignedMeshData( TSMeshVertexArray &vertexData, const Vector<Point3F> &_verts, const Vector<Point3F> &_norms )

View file

@ -501,13 +501,13 @@ public:
typedef TSMesh Parent; typedef TSMesh Parent;
/// Structure containing data needed to batch skinning /// Structure containing data needed to batch skinning
BatchData batchData; BatchData mBatchData;
bool batchDataInitialized; bool mBatchDataInitialized;
/// vectors that define the vertex, weight, bone tuples /// vectors that define the vertex, weight, bone tuples
Vector<F32> weight; Vector<F32> mWeight;
Vector<S32> boneIndex; Vector<S32> mBoneIndex;
Vector<S32> vertexIndex; Vector<S32> mVertexIndex;
/// set verts and normals... /// set verts and normals...
void updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHandle &instanceVB, GFXPrimitiveBufferHandle &instancePB ); void updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHandle &instanceVB, GFXPrimitiveBufferHandle &instancePB );

View file

@ -1188,13 +1188,13 @@ void TSShape::assembleShape()
if (meshType==TSMesh::SkinMeshType) if (meshType==TSMesh::SkinMeshType)
{ {
TSSkinMesh * skin = (TSSkinMesh*)mesh; TSSkinMesh * skin = (TSSkinMesh*)mesh;
TSMesh::smVertsList[i] = skin->batchData.initialVerts.address(); TSMesh::smVertsList[i] = skin->mBatchData.initialVerts.address();
TSMesh::smNormsList[i] = skin->batchData.initialNorms.address(); TSMesh::smNormsList[i] = skin->mBatchData.initialNorms.address();
TSSkinMesh::smInitTransformList[i] = skin->batchData.initialTransforms.address(); TSSkinMesh::smInitTransformList[i] = skin->mBatchData.initialTransforms.address();
TSSkinMesh::smVertexIndexList[i] = skin->vertexIndex.address(); TSSkinMesh::smVertexIndexList[i] = skin->mVertexIndex.address();
TSSkinMesh::smBoneIndexList[i] = skin->boneIndex.address(); TSSkinMesh::smBoneIndexList[i] = skin->mBoneIndex.address();
TSSkinMesh::smWeightList[i] = skin->weight.address(); TSSkinMesh::smWeightList[i] = skin->mWeight.address();
TSSkinMesh::smNodeIndexList[i] = skin->batchData.nodeIndex.address(); TSSkinMesh::smNodeIndexList[i] = skin->mBatchData.nodeIndex.address();
} }
} }
} }
@ -1270,16 +1270,16 @@ void TSShape::assembleShape()
// fill in location of verts, tverts, and normals for shared detail levels // fill in location of verts, tverts, and normals for shared detail levels
if (skin) if (skin)
{ {
TSMesh::smVertsList[i] = skin->batchData.initialVerts.address(); TSMesh::smVertsList[i] = skin->mBatchData.initialVerts.address();
TSMesh::smTVertsList[i] = skin->mTVerts.address(); TSMesh::smTVertsList[i] = skin->mTVerts.address();
TSMesh::smNormsList[i] = skin->batchData.initialNorms.address(); TSMesh::smNormsList[i] = skin->mBatchData.initialNorms.address();
TSMesh::smEncodedNormsList[i] = skin->mEncodedNorms.address(); TSMesh::smEncodedNormsList[i] = skin->mEncodedNorms.address();
TSMesh::smDataCopied[i] = !skip; // as long as we didn't skip this mesh, the data should be in shape now TSMesh::smDataCopied[i] = !skip; // as long as we didn't skip this mesh, the data should be in shape now
TSSkinMesh::smInitTransformList[i] = skin->batchData.initialTransforms.address(); TSSkinMesh::smInitTransformList[i] = skin->mBatchData.initialTransforms.address();
TSSkinMesh::smVertexIndexList[i] = skin->vertexIndex.address(); TSSkinMesh::smVertexIndexList[i] = skin->mVertexIndex.address();
TSSkinMesh::smBoneIndexList[i] = skin->boneIndex.address(); TSSkinMesh::smBoneIndexList[i] = skin->mBoneIndex.address();
TSSkinMesh::smWeightList[i] = skin->weight.address(); TSSkinMesh::smWeightList[i] = skin->mWeight.address();
TSSkinMesh::smNodeIndexList[i] = skin->batchData.nodeIndex.address(); TSSkinMesh::smNodeIndexList[i] = skin->mBatchData.nodeIndex.address();
} }
} }

View file

@ -485,10 +485,10 @@ bool TSShape::addNode(const String& name, const String& parentName, const Point3
if (meshes[i] && (meshes[i]->getMeshType() == TSMesh::SkinMeshType)) if (meshes[i] && (meshes[i]->getMeshType() == TSMesh::SkinMeshType))
{ {
TSSkinMesh* skin = dynamic_cast<TSSkinMesh*>(meshes[i]); TSSkinMesh* skin = dynamic_cast<TSSkinMesh*>(meshes[i]);
for (S32 j = 0; j < skin->batchData.nodeIndex.size(); j++) for (S32 j = 0; j < skin->mBatchData.nodeIndex.size(); j++)
{ {
if (skin->batchData.nodeIndex[j] >= nodeIndex) if (skin->mBatchData.nodeIndex[j] >= nodeIndex)
skin->batchData.nodeIndex[j]++; skin->mBatchData.nodeIndex[j]++;
} }
} }
} }
@ -613,12 +613,12 @@ bool TSShape::removeNode(const String& name)
if (meshes[i] && (meshes[i]->getMeshType() == TSMesh::SkinMeshType)) if (meshes[i] && (meshes[i]->getMeshType() == TSMesh::SkinMeshType))
{ {
TSSkinMesh* skin = dynamic_cast<TSSkinMesh*>(meshes[i]); TSSkinMesh* skin = dynamic_cast<TSSkinMesh*>(meshes[i]);
for (S32 j = 0; j < skin->batchData.nodeIndex.size(); j++) for (S32 j = 0; j < skin->mBatchData.nodeIndex.size(); j++)
{ {
if (skin->batchData.nodeIndex[j] == nodeIndex) if (skin->mBatchData.nodeIndex[j] == nodeIndex)
skin->batchData.nodeIndex[j] = nodeParentIndex; skin->mBatchData.nodeIndex[j] = nodeParentIndex;
if (skin->batchData.nodeIndex[j] > nodeIndex) if (skin->mBatchData.nodeIndex[j] > nodeIndex)
skin->batchData.nodeIndex[j]--; skin->mBatchData.nodeIndex[j]--;
} }
} }
} }
@ -876,14 +876,14 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
// Copy skin elements // Copy skin elements
const TSSkinMesh *srcSkin = dynamic_cast<const TSSkinMesh*>(srcMesh); const TSSkinMesh *srcSkin = dynamic_cast<const TSSkinMesh*>(srcMesh);
skin->weight = srcSkin->weight; skin->mWeight = srcSkin->mWeight;
skin->vertexIndex = srcSkin->vertexIndex; skin->mVertexIndex = srcSkin->mVertexIndex;
skin->boneIndex = srcSkin->boneIndex; skin->mBoneIndex = srcSkin->mBoneIndex;
skin->batchData.nodeIndex = srcSkin->batchData.nodeIndex; skin->mBatchData.nodeIndex = srcSkin->mBatchData.nodeIndex;
skin->batchData.initialTransforms = srcSkin->batchData.initialTransforms; skin->mBatchData.initialTransforms = srcSkin->mBatchData.initialTransforms;
skin->batchData.initialVerts = srcSkin->batchData.initialVerts; skin->mBatchData.initialVerts = srcSkin->mBatchData.initialVerts;
skin->batchData.initialNorms = srcSkin->batchData.initialNorms; skin->mBatchData.initialNorms = srcSkin->mBatchData.initialNorms;
mesh = static_cast<TSMesh*>(skin); mesh = static_cast<TSMesh*>(skin);
} }
@ -1073,9 +1073,9 @@ bool TSShape::addMesh(TSShape* srcShape, const String& srcMeshName, const String
for (S32 i = 0; i < srcShape->nodes.size(); i++) for (S32 i = 0; i < srcShape->nodes.size(); i++)
nodeMap.push_back( findNode( srcShape->getName(srcShape->nodes[i].nameIndex) ) ); nodeMap.push_back( findNode( srcShape->getName(srcShape->nodes[i].nameIndex) ) );
for (S32 i = 0; i < srcSkin->boneIndex.size(); i++) for (S32 i = 0; i < srcSkin->mBoneIndex.size(); i++)
{ {
S32 srcNode = srcSkin->boneIndex[i]; S32 srcNode = srcSkin->mBoneIndex[i];
if (nodeMap[srcNode] == -1) if (nodeMap[srcNode] == -1)
{ {
const char* name = srcShape->getName(srcShape->nodes[srcNode].nameIndex).c_str(); const char* name = srcShape->getName(srcShape->nodes[srcNode].nameIndex).c_str();
@ -1088,9 +1088,9 @@ bool TSShape::addMesh(TSShape* srcShape, const String& srcMeshName, const String
TSSkinMesh *skin = dynamic_cast<TSSkinMesh*>(mesh); TSSkinMesh *skin = dynamic_cast<TSSkinMesh*>(mesh);
// Remap node indices // Remap node indices
skin->batchData.nodeIndex = srcSkin->batchData.nodeIndex; skin->mBatchData.nodeIndex = srcSkin->mBatchData.nodeIndex;
for (S32 i = 0; i < skin->batchData.nodeIndex.size(); i++) for (S32 i = 0; i < skin->mBatchData.nodeIndex.size(); i++)
skin->batchData.nodeIndex[i] = nodeMap[skin->batchData.nodeIndex[i]]; skin->mBatchData.nodeIndex[i] = nodeMap[skin->mBatchData.nodeIndex[i]];
} }
// Add the copied mesh to the shape // Add the copied mesh to the shape