more compiler compliant cleanups plus a full set of tsMesh::foo to tsmesh::mFoo class var conversions for consistency

This commit is contained in:
Azaezel 2018-03-13 14:53:23 -05:00
parent b55db9a143
commit 4615bd6db8
13 changed files with 293 additions and 293 deletions

View file

@ -424,10 +424,10 @@ bool VolumetricFog::LoadShape()
for (U32 k = 0; k < mesh->mIndices.size(); k++) for (U32 k = 0; k < mesh->mIndices.size(); k++)
det_size[i].indices->push_back(mesh->mIndices[k]); det_size[i].indices->push_back(mesh->mIndices[k]);
U32 primitivesSize = mesh->primitives.size(); U32 primitivesSize = mesh->mPrimitives.size();
for (U32 k = 0; k < primitivesSize; k++) for (U32 k = 0; k < primitivesSize; k++)
{ {
const TSDrawPrimitive & draw = mesh->primitives[k]; const TSDrawPrimitive & draw = mesh->mPrimitives[k];
GFXPrimitiveType drawType = GFXdrawTypes[draw.matIndex >> 30]; GFXPrimitiveType drawType = GFXdrawTypes[draw.matIndex >> 30];
switch (drawType) switch (drawType)
{ {

View file

@ -1244,9 +1244,9 @@ void GuiShapeEdPreview::updateDetailLevel(const SceneRenderState* state)
continue; continue;
// Count the number of draw calls and materials // Count the number of draw calls and materials
mNumDrawCalls += mesh->primitives.size(); mNumDrawCalls += mesh->mPrimitives.size();
for ( S32 iPrim = 0; iPrim < mesh->primitives.size(); iPrim++ ) for ( S32 iPrim = 0; iPrim < mesh->mPrimitives.size(); iPrim++ )
usedMaterials.push_back_unique( mesh->primitives[iPrim].matIndex & TSDrawPrimitive::MaterialMask ); usedMaterials.push_back_unique( mesh->mPrimitives[iPrim].matIndex & TSDrawPrimitive::MaterialMask );
// For skinned meshes, count the number of bones and weights // For skinned meshes, count the number of bones and weights
if ( mesh->getMeshType() == TSMesh::SkinMeshType ) if ( mesh->getMeshType() == TSMesh::SkinMeshType )

View file

@ -147,13 +147,13 @@ TSMesh* AppMesh::constructTSMesh()
} }
// Copy mesh elements // Copy mesh elements
tsmesh->verts = points; tsmesh->mVerts = points;
tsmesh->norms = normals; tsmesh->mNorms = normals;
tsmesh->tverts = uvs; tsmesh->mTverts = uvs;
tsmesh->primitives = primitives; tsmesh->mPrimitives = primitives;
tsmesh->mIndices = indices; tsmesh->mIndices = indices;
tsmesh->colors = colors; tsmesh->mColors = colors;
tsmesh->tverts2 = uv2s; tsmesh->mTverts2 = uv2s;
// Finish initializing the shape // Finish initializing the shape
tsmesh->setFlags(flags); tsmesh->setFlags(flags);
@ -162,8 +162,8 @@ TSMesh* AppMesh::constructTSMesh()
tsmesh->numFrames = numFrames; tsmesh->numFrames = numFrames;
tsmesh->numMatFrames = numMatFrames; tsmesh->numMatFrames = numMatFrames;
tsmesh->vertsPerFrame = vertsPerFrame; tsmesh->vertsPerFrame = vertsPerFrame;
tsmesh->createTangents(tsmesh->verts, tsmesh->norms); tsmesh->createTangents(tsmesh->mVerts, tsmesh->mNorms);
tsmesh->encodedNorms.set(NULL,0); tsmesh->mEncodedNorms.set(NULL,0);
return tsmesh; return tsmesh;
} }

View file

@ -1172,7 +1172,7 @@ void TSShapeLoader::install()
{ {
TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh]; TSMesh *mesh = shape->meshes[obj.startMeshIndex + iMesh];
if (mesh && !mesh->primitives.size()) if (mesh && !mesh->mPrimitives.size())
{ {
S32 oldMeshCount = obj.numMeshes; S32 oldMeshCount = obj.numMeshes;
destructInPlace(mesh); destructInPlace(mesh);

View file

@ -1364,9 +1364,9 @@ void TSMesh::prepOpcodeCollision()
// Figure out how many triangles we have... // Figure out how many triangles we have...
U32 triCount = 0; U32 triCount = 0;
const U32 base = 0; const U32 base = 0;
for ( U32 i = 0; i < primitives.size(); i++ ) for ( U32 i = 0; i < mPrimitives.size(); i++ )
{ {
TSDrawPrimitive & draw = primitives[i]; TSDrawPrimitive & draw = mPrimitives[i];
const U32 start = draw.start; const U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" ); AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );
@ -1396,7 +1396,7 @@ void TSMesh::prepOpcodeCollision()
} }
// Just do the first trilist for now. // Just do the first trilist for now.
mi->SetNbVertices( mVertexData.isReady() ? mNumVerts : verts.size() ); mi->SetNbVertices( mVertexData.isReady() ? mNumVerts : mVerts.size() );
mi->SetNbTriangles( triCount ); mi->SetNbTriangles( triCount );
// Stuff everything into appropriate arrays. // Stuff everything into appropriate arrays.
@ -1407,9 +1407,9 @@ void TSMesh::prepOpcodeCollision()
mOpPoints = pts; mOpPoints = pts;
// add the polys... // add the polys...
for ( U32 i = 0; i < primitives.size(); i++ ) for ( U32 i = 0; i < mPrimitives.size(); i++ )
{ {
TSDrawPrimitive & draw = primitives[i]; TSDrawPrimitive & draw = mPrimitives[i];
const U32 start = draw.start; const U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" ); AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );
@ -1467,7 +1467,7 @@ void TSMesh::prepOpcodeCollision()
} }
else else
{ {
pts[i].Set( verts[i].x, verts[i].y, verts[i].z ); pts[i].Set( mVerts[i].x, mVerts[i].y, mVerts[i].z );
} }
} }

View file

@ -122,7 +122,7 @@ void TSMesh::innerRender( TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb
GFX->setVertexBuffer( vb ); GFX->setVertexBuffer( vb );
GFX->setPrimitiveBuffer( pb ); GFX->setPrimitiveBuffer( pb );
for( U32 p = 0; p < primitives.size(); p++ ) for( U32 p = 0; p < mPrimitives.size(); p++ )
GFX->drawPrimitive( p ); GFX->drawPrimitive( p );
} }
@ -223,9 +223,9 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata,
// NOTICE: SFXBB is removed and refraction is disabled! // NOTICE: SFXBB is removed and refraction is disabled!
//coreRI->backBuffTex = GFX->getSfxBackBuffer(); //coreRI->backBuffTex = GFX->getSfxBackBuffer();
for ( S32 i = 0; i < primitives.size(); i++ ) for ( S32 i = 0; i < mPrimitives.size(); i++ )
{ {
const TSDrawPrimitive &draw = primitives[i]; const TSDrawPrimitive &draw = mPrimitives[i];
// We need to have a material. // We need to have a material.
if ( draw.matIndex & TSDrawPrimitive::NoMaterial ) if ( draw.matIndex & TSDrawPrimitive::NoMaterial )
@ -253,7 +253,7 @@ void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata,
#ifndef TORQUE_OS_MAC #ifndef TORQUE_OS_MAC
// Get the instancing material if this mesh qualifies. // Get the instancing material if this mesh qualifies.
if ( meshType != SkinMeshType && pb->mPrimitiveArray[i].numVertices < smMaxInstancingVerts ) if (mMeshType != SkinMeshType && pb->mPrimitiveArray[i].numVertices < smMaxInstancingVerts )
if (matInst && !matInst->getFeatures().hasFeature(MFT_HardwareSkinning)) if (matInst && !matInst->getFeatures().hasFeature(MFT_HardwareSkinning))
matInst = InstancingMaterialHook::getInstancingMat( matInst ); matInst = InstancingMaterialHook::getInstancingMat( matInst );
@ -293,13 +293,13 @@ const Point3F * TSMesh::getNormals( S32 firstVert )
if ( getFlags( UseEncodedNormals ) ) if ( getFlags( UseEncodedNormals ) )
{ {
gNormalStore.setSize( vertsPerFrame ); gNormalStore.setSize( vertsPerFrame );
for ( S32 i = 0; i < encodedNorms.size(); i++ ) for ( S32 i = 0; i < mEncodedNorms.size(); i++ )
gNormalStore[i] = decodeNormal( encodedNorms[ i + firstVert ] ); gNormalStore[i] = decodeNormal(mEncodedNorms[ i + firstVert ] );
return gNormalStore.address(); return gNormalStore.address();
} }
return &norms[firstVert]; return &mNorms[firstVert];
} }
//----------------------------------------------------- //-----------------------------------------------------
@ -352,28 +352,28 @@ bool TSMesh::buildPolyList( S32 frame, AbstractPolyList *polyList, U32 &surfaceK
{ {
// Don't use vertex() method as we want to retain the original indices // Don't use vertex() method as we want to retain the original indices
OptimizedPolyList::VertIndex vert; OptimizedPolyList::VertIndex vert;
vert.vertIdx = opList->insertPoint( verts[ i + firstVert ] ); vert.vertIdx = opList->insertPoint( mVerts[ i + firstVert ] );
vert.normalIdx = opList->insertNormal( norms[ i + firstVert ] ); vert.normalIdx = opList->insertNormal( mNorms[ i + firstVert ] );
vert.uv0Idx = opList->insertUV0( tverts[ i + firstVert ] ); vert.uv0Idx = opList->insertUV0( mTverts[ i + firstVert ] );
if ( hasTVert2 ) if ( hasTVert2 )
vert.uv1Idx = opList->insertUV1( tverts2[ i + firstVert ] ); vert.uv1Idx = opList->insertUV1(mTverts[ i + firstVert ] );
opList->mVertexList.push_back( vert ); opList->mVertexList.push_back( vert );
} }
} }
else else
{ {
base = polyList->addPointAndNormal( verts[firstVert], norms[firstVert] ); base = polyList->addPointAndNormal( mVerts[firstVert], mNorms[firstVert] );
for ( i = 1; i < vertsPerFrame; i++ ) for ( i = 1; i < vertsPerFrame; i++ )
polyList->addPointAndNormal( verts[ i + firstVert ], norms[ i + firstVert ] ); polyList->addPointAndNormal(mVerts[ i + firstVert ], mNorms[ i + firstVert ] );
} }
} }
} }
// add the polys... // add the polys...
for ( i = 0; i < primitives.size(); i++ ) for ( i = 0; i < mPrimitives.size(); i++ )
{ {
TSDrawPrimitive & draw = primitives[i]; TSDrawPrimitive & draw = mPrimitives[i];
U32 start = draw.start; U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" ); AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );
@ -440,9 +440,9 @@ bool TSMesh::getFeatures( S32 frame, const MatrixF& mat, const VectorF&, ConvexF
} }
// add the polys... // add the polys...
for ( i = 0; i < primitives.size(); i++ ) for ( i = 0; i < mPrimitives.size(); i++ )
{ {
TSDrawPrimitive & draw = primitives[i]; TSDrawPrimitive & draw = mPrimitives[i];
U32 start = draw.start; U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" ); AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildPolyList (1)" );
@ -627,7 +627,7 @@ void TSMesh::support( S32 frame, const Point3F &v, F32 *currMaxDP, Point3F *curr
bool TSMesh::castRay( S32 frame, const Point3F & start, const Point3F & end, RayInfo * rayInfo, TSMaterialList* materials ) bool TSMesh::castRay( S32 frame, const Point3F & start, const Point3F & end, RayInfo * rayInfo, TSMaterialList* materials )
{ {
if ( planeNormals.empty() ) if ( mPlaneNormals.empty() )
buildConvexHull(); // if haven't done it yet... buildConvexHull(); // if haven't done it yet...
// Keep track of startTime and endTime. They start out at just under 0 and just over 1, respectively. // Keep track of startTime and endTime. They start out at just under 0 and just over 1, respectively.
@ -657,15 +657,15 @@ bool TSMesh::castRay( S32 frame, const Point3F & start, const Point3F & end, Ray
S32 * pplane = &curPlane; S32 * pplane = &curPlane;
bool * pfound = &found; bool * pfound = &found;
S32 startPlane = frame * planesPerFrame; S32 startPlane = frame * mPlanesPerFrame;
for ( S32 i = startPlane; i < startPlane + planesPerFrame; i++ ) for ( S32 i = startPlane; i < startPlane + mPlanesPerFrame; i++ )
{ {
// if start & end outside, no collision // if start & end outside, no collision
// if start & end inside, continue // if start & end inside, continue
// if start outside, end inside, or visa versa, find intersection of line with plane // if start outside, end inside, or visa versa, find intersection of line with plane
// then update intersection of line with hull (using startTime and endTime) // then update intersection of line with hull (using startTime and endTime)
F32 dot1 = mDot( planeNormals[i], start ) - planeConstants[i]; F32 dot1 = mDot(mPlaneNormals[i], start ) - mPlaneConstants[i];
F32 dot2 = mDot( planeNormals[i], end) - planeConstants[i]; F32 dot2 = mDot(mPlaneNormals[i], end) - mPlaneConstants[i];
if ( dot1 * dot2 > 0.0f ) if ( dot1 * dot2 > 0.0f )
{ {
// same side of the plane...which side -- dot==0 considered inside // same side of the plane...which side -- dot==0 considered inside
@ -747,10 +747,10 @@ bool TSMesh::castRay( S32 frame, const Point3F & start, const Point3F & end, Ray
// setup rayInfo // setup rayInfo
if ( found && rayInfo ) if ( found && rayInfo )
{ {
curMaterial = planeMaterials[ curPlane - startPlane ]; curMaterial = mPlaneMaterials[ curPlane - startPlane ];
rayInfo->t = (F32)startNum/(F32)startDen; // finally divide... rayInfo->t = (F32)startNum/(F32)startDen; // finally divide...
rayInfo->normal = planeNormals[curPlane]; rayInfo->normal = mPlaneNormals[curPlane];
if (materials && materials->size() > 0) if (materials && materials->size() > 0)
rayInfo->material = materials->getMaterialInst( curMaterial ); rayInfo->material = materials->getMaterialInst( curMaterial );
@ -785,9 +785,9 @@ bool TSMesh::castRayRendered( S32 frame, const Point3F & start, const Point3F &
BaseMatInstance* bestMaterial = NULL; BaseMatInstance* bestMaterial = NULL;
Point3F dir = end - start; Point3F dir = end - start;
for ( S32 i = 0; i < primitives.size(); i++ ) for ( S32 i = 0; i < mPrimitives.size(); i++ )
{ {
TSDrawPrimitive & draw = primitives[i]; TSDrawPrimitive & draw = mPrimitives[i];
U32 drawStart = draw.start; U32 drawStart = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::castRayRendered (1)" ); AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::castRayRendered (1)" );
@ -927,35 +927,35 @@ bool TSMesh::addToHull( U32 idx0, U32 idx1, U32 idx2 )
normal.normalize(); normal.normalize();
F32 k = mDot( normal, mVertexData.getBase(idx0).vert() ); F32 k = mDot( normal, mVertexData.getBase(idx0).vert() );
for ( S32 i = 0; i < planeNormals.size(); i++ ) for ( S32 i = 0; i < mPlaneNormals.size(); i++ )
{ {
if ( mDot( planeNormals[i], normal ) > 0.99f && mFabs( k-planeConstants[i] ) < 0.01f ) if ( mDot(mPlaneNormals[i], normal ) > 0.99f && mFabs( k- mPlaneConstants[i] ) < 0.01f )
return false; // this is a repeat... return false; // this is a repeat...
} }
// new plane, add it to the list... // new plane, add it to the list...
planeNormals.push_back( normal ); mPlaneNormals.push_back( normal );
planeConstants.push_back( k ); mPlaneConstants.push_back( k );
return true; return true;
} }
bool TSMesh::buildConvexHull() bool TSMesh::buildConvexHull()
{ {
// already done, return without error // already done, return without error
if ( planeNormals.size() ) if (mPlaneNormals.size() )
return true; return true;
bool error = false; bool error = false;
// should probably only have 1 frame, but just in case... // should probably only have 1 frame, but just in case...
planesPerFrame = 0; mPlanesPerFrame = 0;
S32 frame, i, j; S32 frame, i, j;
for ( frame = 0; frame < numFrames; frame++ ) for ( frame = 0; frame < numFrames; frame++ )
{ {
S32 firstVert = vertsPerFrame * frame; S32 firstVert = vertsPerFrame * frame;
S32 firstPlane = planeNormals.size(); S32 firstPlane = mPlaneNormals.size();
for ( i = 0; i < primitives.size(); i++ ) for ( i = 0; i < mPrimitives.size(); i++ )
{ {
TSDrawPrimitive & draw = primitives[i]; TSDrawPrimitive & draw = mPrimitives[i];
U32 start = draw.start; U32 start = draw.start;
AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildConvexHull (1)" ); AssertFatal( draw.matIndex & TSDrawPrimitive::Indexed,"TSMesh::buildConvexHull (1)" );
@ -967,7 +967,7 @@ bool TSMesh::buildConvexHull()
if ( addToHull( mIndices[start + j + 0] + firstVert, if ( addToHull( mIndices[start + j + 0] + firstVert,
mIndices[start + j + 1] + firstVert, mIndices[start + j + 1] + firstVert,
mIndices[start + j + 2] + firstVert ) && frame == 0 ) mIndices[start + j + 2] + firstVert ) && frame == 0 )
planeMaterials.push_back( draw.matIndex & TSDrawPrimitive::MaterialMask ); mPlaneMaterials.push_back( draw.matIndex & TSDrawPrimitive::MaterialMask );
} }
else else
{ {
@ -984,51 +984,51 @@ bool TSMesh::buildConvexHull()
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1 ); nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1 );
idx2 = mIndices[start + j] + firstVert; idx2 = mIndices[start + j] + firstVert;
if ( addToHull( idx0, idx1, idx2 ) && frame == 0 ) if ( addToHull( idx0, idx1, idx2 ) && frame == 0 )
planeMaterials.push_back( draw.matIndex & TSDrawPrimitive::MaterialMask ); mPlaneMaterials.push_back( draw.matIndex & TSDrawPrimitive::MaterialMask );
} }
} }
} }
// make sure all the verts on this frame are inside all the planes // make sure all the verts on this frame are inside all the planes
for ( i = 0; i < vertsPerFrame; i++ ) for ( i = 0; i < vertsPerFrame; i++ )
for ( j = firstPlane; j < planeNormals.size(); j++ ) for ( j = firstPlane; j < mPlaneNormals.size(); j++ )
if ( mDot( mVertexData.getBase(firstVert + i).vert(), planeNormals[j] ) - planeConstants[j] < 0.01 ) // .01 == a little slack if ( mDot( mVertexData.getBase(firstVert + i).vert(), mPlaneNormals[j] ) - mPlaneConstants[j] < 0.01 ) // .01 == a little slack
error = true; error = true;
if ( frame == 0 ) if ( frame == 0 )
planesPerFrame = planeNormals.size(); mPlanesPerFrame = mPlaneNormals.size();
if ( (frame + 1) * planesPerFrame != planeNormals.size() ) if ( (frame + 1) * mPlanesPerFrame != mPlaneNormals.size() )
{ {
// eek, not all frames have same number of planes... // eek, not all frames have same number of planes...
while ( (frame + 1) * planesPerFrame > planeNormals.size() ) while ( (frame + 1) * mPlanesPerFrame > mPlaneNormals.size() )
{ {
// we're short, duplicate last plane till we match // we're short, duplicate last plane till we match
U32 sz = planeNormals.size(); U32 sz = mPlaneNormals.size();
planeNormals.increment(); mPlaneNormals.increment();
planeNormals.last() = planeNormals[sz-1]; mPlaneNormals.last() = mPlaneNormals[sz-1];
planeConstants.increment(); mPlaneConstants.increment();
planeConstants.last() = planeConstants[sz-1]; mPlaneConstants.last() = mPlaneConstants[sz-1];
} }
while ( (frame + 1) * planesPerFrame < planeNormals.size() ) while ( (frame + 1) * mPlanesPerFrame < mPlaneNormals.size() )
{ {
// harsh -- last frame has more than other frames // harsh -- last frame has more than other frames
// duplicate last plane in each frame // duplicate last plane in each frame
for ( S32 k = frame - 1; k >= 0; k-- ) for ( S32 k = frame - 1; k >= 0; k-- )
{ {
planeNormals.insert( k * planesPerFrame + planesPerFrame ); mPlaneNormals.insert( k * mPlanesPerFrame + mPlanesPerFrame );
planeNormals[k * planesPerFrame + planesPerFrame] = planeNormals[k * planesPerFrame + planesPerFrame - 1]; mPlaneNormals[k * mPlanesPerFrame + mPlanesPerFrame] = mPlaneNormals[k * mPlanesPerFrame + mPlanesPerFrame - 1];
planeConstants.insert( k * planesPerFrame + planesPerFrame ); mPlaneConstants.insert( k * mPlanesPerFrame + mPlanesPerFrame );
planeConstants[k * planesPerFrame + planesPerFrame] = planeConstants[k * planesPerFrame + planesPerFrame - 1]; mPlaneConstants[k * mPlanesPerFrame + mPlanesPerFrame] = mPlaneConstants[k * mPlanesPerFrame + mPlanesPerFrame - 1];
if ( k == 0 ) if ( k == 0 )
{ {
planeMaterials.increment(); mPlaneMaterials.increment();
planeMaterials.last() = planeMaterials[planeMaterials.size() - 2]; mPlaneMaterials.last() = mPlaneMaterials[mPlaneMaterials.size() - 2];
} }
} }
planesPerFrame++; mPlanesPerFrame++;
} }
} }
AssertFatal( (frame + 1) * planesPerFrame == planeNormals.size(),"TSMesh::buildConvexHull (3)" ); AssertFatal( (frame + 1) * mPlanesPerFrame == mPlaneNormals.size(),"TSMesh::buildConvexHull (3)" );
} }
return !error; return !error;
} }
@ -1051,7 +1051,7 @@ void TSMesh::computeBounds( const MatrixF &transform, Box3F &bounds, S32 frame,
AssertFatal(!mVertexData.isReady() || (mVertexData.isReady() && mNumVerts == mVertexData.size() && mNumVerts == vertsPerFrame), "vertex number mismatch"); AssertFatal(!mVertexData.isReady() || (mVertexData.isReady() && mNumVerts == mVertexData.size() && mNumVerts == vertsPerFrame), "vertex number mismatch");
if(verts.size() == 0 && mVertexData.isReady() && mVertexData.size() > 0) if(mVerts.size() == 0 && mVertexData.isReady() && mVertexData.size() > 0)
{ {
baseVert = &mVertexData.getBase(0).vert(); baseVert = &mVertexData.getBase(0).vert();
stride = mVertexData.vertSize(); stride = mVertexData.vertSize();
@ -1066,11 +1066,11 @@ void TSMesh::computeBounds( const MatrixF &transform, Box3F &bounds, S32 frame,
} }
else else
{ {
baseVert = verts.address(); baseVert = mVerts.address();
stride = sizeof(Point3F); stride = sizeof(Point3F);
if ( frame < 0 ) if ( frame < 0 )
numVerts = verts.size(); numVerts = mVerts.size();
else else
{ {
baseVert += frame * vertsPerFrame; baseVert += frame * vertsPerFrame;
@ -1131,22 +1131,22 @@ void TSMesh::computeBounds( const Point3F *v, S32 numVerts, S32 stride, const Ma
S32 TSMesh::getNumPolys() const S32 TSMesh::getNumPolys() const
{ {
S32 count = 0; S32 count = 0;
for ( S32 i = 0; i < primitives.size(); i++ ) for ( S32 i = 0; i < mPrimitives.size(); i++ )
{ {
switch (primitives[i].matIndex & TSDrawPrimitive::TypeMask) switch (mPrimitives[i].matIndex & TSDrawPrimitive::TypeMask)
{ {
case TSDrawPrimitive::Triangles: case TSDrawPrimitive::Triangles:
count += primitives[i].numElements / 3; count += mPrimitives[i].numElements / 3;
break; break;
case TSDrawPrimitive::Fan: case TSDrawPrimitive::Fan:
count += primitives[i].numElements - 2; count += mPrimitives[i].numElements - 2;
break; break;
case TSDrawPrimitive::Strip: case TSDrawPrimitive::Strip:
// Don't count degenerate triangles // Don't count degenerate triangles
for ( S32 j = primitives[i].start; for ( S32 j = mPrimitives[i].start;
j < primitives[i].start+primitives[i].numElements-2; j < mPrimitives[i].start+ mPrimitives[i].numElements-2;
j++ ) j++ )
{ {
if ((mIndices[j] != mIndices[j+1]) && if ((mIndices[j] != mIndices[j+1]) &&
@ -1162,11 +1162,11 @@ S32 TSMesh::getNumPolys() const
//----------------------------------------------------- //-----------------------------------------------------
TSMesh::TSMesh() : meshType( StandardMeshType ) TSMesh::TSMesh() : mMeshType( StandardMeshType )
{ {
VECTOR_SET_ASSOCIATION( planeNormals ); VECTOR_SET_ASSOCIATION(mPlaneNormals );
VECTOR_SET_ASSOCIATION( planeConstants ); VECTOR_SET_ASSOCIATION(mPlaneConstants );
VECTOR_SET_ASSOCIATION( planeMaterials ); VECTOR_SET_ASSOCIATION(mPlaneMaterials );
mParentMesh = -1; mParentMesh = -1;
mOptTree = NULL; mOptTree = NULL;
@ -1181,7 +1181,7 @@ TSMesh::TSMesh() : meshType( StandardMeshType )
mVertSize = 0; mVertSize = 0;
mVertOffset = 0; mVertOffset = 0;
parentMeshObject = NULL; mParentMeshObject = NULL;
} }
//----------------------------------------------------- //-----------------------------------------------------
@ -1326,8 +1326,8 @@ void TSSkinMesh::createSkinBatchData()
} }
else else
{ {
batchData.initialNorms = norms; batchData.initialNorms = mNorms;
batchData.initialVerts = verts; batchData.initialVerts = mVerts;
} }
// Build the batch operations // Build the batch operations
@ -1546,10 +1546,10 @@ void TSSkinMesh::computeBounds( const MatrixF &transform, Box3F &bounds, S32 fra
{ {
TORQUE_UNUSED(frame); TORQUE_UNUSED(frame);
if (verts.size() != 0) if (mVerts.size() != 0)
{ {
// Use unskinned verts // Use unskinned verts
TSMesh::computeBounds( verts.address(), verts.size(), sizeof(Point3F), transform, bounds, center, radius ); TSMesh::computeBounds(mVerts.address(), mVerts.size(), sizeof(Point3F), transform, bounds, center, radius );
} }
else if (frame <= 0 && batchData.initialVerts.size() > 0) else if (frame <= 0 && batchData.initialVerts.size() > 0)
{ {
@ -2368,10 +2368,10 @@ void TSMesh::dumpPrimitives(U32 startVertex, U32 startIndex, GFXPrimitive *piArr
// go through and create PrimitiveInfo array // go through and create PrimitiveInfo array
GFXPrimitive pInfo; GFXPrimitive pInfo;
U32 primitivesSize = primitives.size(); U32 primitivesSize = mPrimitives.size();
for (U32 i = 0; i < primitivesSize; i++) for (U32 i = 0; i < primitivesSize; i++)
{ {
const TSDrawPrimitive & draw = primitives[i]; const TSDrawPrimitive & draw = mPrimitives[i];
GFXPrimitiveType drawType = getDrawType(draw.matIndex >> 30); GFXPrimitiveType drawType = getDrawType(draw.matIndex >> 30);
@ -2436,21 +2436,21 @@ void TSMesh::assemble( bool skip )
S32 numVerts = tsalloc.get32(); S32 numVerts = tsalloc.get32();
S32 *ptr32 = getSharedData32(mParentMesh, 3 * numVerts, (S32**)smVertsList.address(), skip ); S32 *ptr32 = getSharedData32(mParentMesh, 3 * numVerts, (S32**)smVertsList.address(), skip );
verts.set( (Point3F*)ptr32, numVerts ); mVerts.set( (Point3F*)ptr32, numVerts );
S32 numTVerts = tsalloc.get32(); S32 numTVerts = tsalloc.get32();
ptr32 = getSharedData32(mParentMesh, 2 * numTVerts, (S32**)smTVertsList.address(), skip ); ptr32 = getSharedData32(mParentMesh, 2 * numTVerts, (S32**)smTVertsList.address(), skip );
tverts.set( (Point2F*)ptr32, numTVerts ); mTverts.set( (Point2F*)ptr32, numTVerts );
if ( TSShape::smReadVersion > 25 ) if ( TSShape::smReadVersion > 25 )
{ {
numTVerts = tsalloc.get32(); numTVerts = tsalloc.get32();
ptr32 = getSharedData32(mParentMesh, 2 * numTVerts, (S32**)smTVerts2List.address(), skip ); ptr32 = getSharedData32(mParentMesh, 2 * numTVerts, (S32**)smTVerts2List.address(), skip );
tverts2.set( (Point2F*)ptr32, numTVerts ); mTverts2.set( (Point2F*)ptr32, numTVerts );
S32 numVColors = tsalloc.get32(); S32 numVColors = tsalloc.get32();
ptr32 = getSharedData32(mParentMesh, numVColors, (S32**)smColorsList.address(), skip ); ptr32 = getSharedData32(mParentMesh, numVColors, (S32**)smColorsList.address(), skip );
colors.set( (ColorI*)ptr32, numVColors ); mColors.set( (ColorI*)ptr32, numVColors );
} }
S8 *ptr8; S8 *ptr8;
@ -2459,27 +2459,27 @@ void TSMesh::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 ); // adva nce past norms, don't use tsalloc.getPointer32( numVerts * 3 ); // adva nce past norms, don't use
norms.set( NULL, 0 ); mNorms.set( NULL, 0 );
ptr8 = getSharedData8(mParentMesh, numVerts, (S8**)smEncodedNormsList.address(), skip ); ptr8 = getSharedData8(mParentMesh, numVerts, (S8**)smEncodedNormsList.address(), skip );
encodedNorms.set( ptr8, numVerts ); mEncodedNorms.set( ptr8, numVerts );
} }
else if ( TSShape::smReadVersion > 21 ) else if ( TSShape::smReadVersion > 21 )
{ {
// 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 );
norms.set( (Point3F*)ptr32, numVerts ); mNorms.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
encodedNorms.set( NULL, 0 ); mEncodedNorms.set( NULL, 0 );
} }
else else
{ {
// no encoded normals... // no encoded normals...
ptr32 = getSharedData32(mParentMesh, 3 * numVerts, (S32**)smNormsList.address(), skip ); ptr32 = getSharedData32(mParentMesh, 3 * numVerts, (S32**)smNormsList.address(), skip );
norms.set( (Point3F*)ptr32, numVerts ); mNorms.set( (Point3F*)ptr32, numVerts );
encodedNorms.set( NULL, 0 ); mEncodedNorms.set( NULL, 0 );
} }
// copy the primitives and indices...how we do this depends on what // copy the primitives and indices...how we do this depends on what
@ -2553,7 +2553,7 @@ void TSMesh::assemble( bool skip )
AssertFatal(chkPrim==szPrimOut && chkInd==szIndOut,"TSMesh::primitive conversion"); AssertFatal(chkPrim==szPrimOut && chkInd==szIndOut,"TSMesh::primitive conversion");
// store output // store output
primitives.set(primOut, szPrimOut); mPrimitives.set(primOut, szPrimOut);
mIndices.set(indOut, szIndOut); mIndices.set(indOut, szIndOut);
// delete temporary arrays if necessary // delete temporary arrays if necessary
@ -2569,7 +2569,7 @@ void TSMesh::assemble( bool skip )
vertsPerFrame = tsalloc.get32(); vertsPerFrame = tsalloc.get32();
U32 flags = (U32)tsalloc.get32(); U32 flags = (U32)tsalloc.get32();
if ( encodedNorms.size() ) if ( mEncodedNorms.size() )
flags |= UseEncodedNormals; flags |= UseEncodedNormals;
setFlags( flags ); setFlags( flags );
@ -2577,9 +2577,9 @@ void TSMesh::assemble( bool skip )
// Set color & tvert2 flags if we have an old version // Set color & tvert2 flags if we have an old version
if (TSShape::smReadVersion < 27) if (TSShape::smReadVersion < 27)
{ {
if (colors.size() > 0) setFlags(HasColor); if (mColors.size() > 0) setFlags(HasColor);
if (tverts2.size() > 0) setFlags(HasTVert2); if (mTverts2.size() > 0) setFlags(HasTVert2);
mNumVerts = verts.size(); mNumVerts = mVerts.size();
} }
tsalloc.checkGuard(); tsalloc.checkGuard();
@ -2587,7 +2587,7 @@ void TSMesh::assemble( bool skip )
if ( tsalloc.allocShape32( 0 ) && TSShape::smReadVersion < 19 ) if ( tsalloc.allocShape32( 0 ) && TSShape::smReadVersion < 19 )
computeBounds(); // only do this if we copied the data... computeBounds(); // only do this if we copied the data...
createTangents(verts, norms); createTangents(mVerts, mNorms);
} }
void TSMesh::disassemble() void TSMesh::disassemble()
@ -2636,39 +2636,39 @@ void TSMesh::disassemble()
else else
{ {
// verts... // verts...
tsalloc.set32(verts.size()); tsalloc.set32(mVerts.size());
if (mParentMesh < 0) if (mParentMesh < 0)
tsalloc.copyToBuffer32((S32*)verts.address(), 3 * verts.size()); // if no parent mesh, then save off our verts tsalloc.copyToBuffer32((S32*)mVerts.address(), 3 * mVerts.size()); // if no parent mesh, then save off our verts
// tverts... // tverts...
tsalloc.set32(tverts.size()); tsalloc.set32(mTverts.size());
if (mParentMesh < 0) if (mParentMesh < 0)
tsalloc.copyToBuffer32((S32*)tverts.address(), 2 * tverts.size()); // if no parent mesh, then save off our tverts tsalloc.copyToBuffer32((S32*)mTverts.address(), 2 * mTverts.size()); // if no parent mesh, then save off our tverts
if (TSShape::smVersion > 25) if (TSShape::smVersion > 25)
{ {
// tverts2... // tverts2...
tsalloc.set32(tverts2.size()); tsalloc.set32(mTverts2.size());
if (mParentMesh < 0) if (mParentMesh < 0)
tsalloc.copyToBuffer32((S32*)tverts2.address(), 2 * tverts2.size()); // if no parent mesh, then save off our tverts tsalloc.copyToBuffer32((S32*)mTverts2.address(), 2 * mTverts2.size()); // if no parent mesh, then save off our tverts
// colors // colors
tsalloc.set32(colors.size()); tsalloc.set32(mColors.size());
if (mParentMesh < 0) if (mParentMesh < 0)
tsalloc.copyToBuffer32((S32*)colors.address(), colors.size()); // if no parent mesh, then save off our tverts tsalloc.copyToBuffer32((S32*)mColors.address(), mColors.size()); // if no parent mesh, then save off our tverts
} }
// norms... // norms...
if (mParentMesh < 0) // if no parent mesh, then save off our norms if (mParentMesh < 0) // if no parent mesh, then save off our norms
tsalloc.copyToBuffer32((S32*)norms.address(), 3 * norms.size()); // norms.size()==verts.size() or error... tsalloc.copyToBuffer32((S32*)mNorms.address(), 3 * mNorms.size()); // norms.size()==verts.size() or error...
// encoded norms... // encoded norms...
if (mParentMesh < 0) if (mParentMesh < 0)
{ {
// 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 < norms.size(); i++) for (S32 i = 0; i < mNorms.size(); i++)
{ {
U8 normIdx = encodedNorms.size() ? encodedNorms[i] : encodeNormal(norms[i]); U8 normIdx = mEncodedNorms.size() ? mEncodedNorms[i] : encodeNormal(mNorms[i]);
tsalloc.copyToBuffer8((S8*)&normIdx, 1); tsalloc.copyToBuffer8((S8*)&normIdx, 1);
} }
} }
@ -2677,14 +2677,14 @@ void TSMesh::disassemble()
// optimize triangle draw order during disassemble // optimize triangle draw order during disassemble
{ {
FrameTemp<TriListOpt::IndexType> tmpIdxs(mIndices.size()); FrameTemp<TriListOpt::IndexType> tmpIdxs(mIndices.size());
for ( S32 i = 0; i < primitives.size(); i++ ) for ( S32 i = 0; i < mPrimitives.size(); i++ )
{ {
const TSDrawPrimitive& prim = primitives[i]; const TSDrawPrimitive& prim = mPrimitives[i];
// only optimize triangle lists (strips and fans are assumed to be already optimized) // only optimize triangle lists (strips and fans are assumed to be already optimized)
if ( (prim.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles ) if ( (prim.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles )
{ {
TriListOpt::OptimizeTriangleOrdering(verts.size(), prim.numElements, TriListOpt::OptimizeTriangleOrdering(mVerts.size(), prim.numElements,
mIndices.address() + prim.start, tmpIdxs.address()); mIndices.address() + prim.start, tmpIdxs.address());
dCopyArray(mIndices.address() + prim.start, tmpIdxs.address(), dCopyArray(mIndices.address() + prim.start, tmpIdxs.address(),
prim.numElements); prim.numElements);
@ -2695,8 +2695,8 @@ void TSMesh::disassemble()
if (TSShape::smVersion > 25) if (TSShape::smVersion > 25)
{ {
// primitives... // primitives...
tsalloc.set32( primitives.size() ); tsalloc.set32(mPrimitives.size() );
tsalloc.copyToBuffer32((S32*)primitives.address(),3*primitives.size()); tsalloc.copyToBuffer32((S32*)mPrimitives.address(),3* mPrimitives.size());
// indices... // indices...
tsalloc.set32(mIndices.size()); tsalloc.set32(mIndices.size());
@ -2705,15 +2705,15 @@ void TSMesh::disassemble()
else else
{ {
// primitives // primitives
tsalloc.set32( primitives.size() ); tsalloc.set32(mPrimitives.size() );
for (S32 i=0; i<primitives.size(); i++) for (S32 i=0; i<mPrimitives.size(); i++)
{ {
S16 start = (S16)primitives[i].start; S16 start = (S16)mPrimitives[i].start;
S16 numElements = (S16)primitives[i].numElements; S16 numElements = (S16)mPrimitives[i].numElements;
tsalloc.copyToBuffer16(&start, 1); tsalloc.copyToBuffer16(&start, 1);
tsalloc.copyToBuffer16(&numElements, 1); tsalloc.copyToBuffer16(&numElements, 1);
tsalloc.copyToBuffer32(&(primitives[i].matIndex), 1); tsalloc.copyToBuffer32(&(mPrimitives[i].matIndex), 1);
} }
// indices // indices
@ -2772,7 +2772,7 @@ void TSSkinMesh::assemble( bool skip )
batchData.initialNorms.set(NULL, 0); batchData.initialNorms.set(NULL, 0);
ptr8 = getSharedData8(mParentMesh, numVerts, (S8**)smEncodedNormsList.address(), skip); ptr8 = getSharedData8(mParentMesh, numVerts, (S8**)smEncodedNormsList.address(), skip);
encodedNorms.set(ptr8, numVerts); mEncodedNorms.set(ptr8, numVerts);
// Note: we don't set the encoded normals flag because we handle them in updateSkin and // Note: we don't set the encoded normals flag because we handle them in updateSkin and
// hide the fact that we are using them from base class (TSMesh) // hide the fact that we are using them from base class (TSMesh)
} }
@ -2785,33 +2785,33 @@ void TSSkinMesh::assemble( bool skip )
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
encodedNorms.set(NULL, 0); mEncodedNorms.set(NULL, 0);
} }
else else
{ {
// 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); batchData.initialNorms.set((Point3F*)ptr32, numVerts);
encodedNorms.set(NULL, 0); mEncodedNorms.set(NULL, 0);
} }
// Sometimes we'll have a mesh with 0 verts but initialVerts is set, // Sometimes we'll have a mesh with 0 verts but initialVerts is set,
// so set these accordingly // so set these accordingly
if (verts.size() == 0) if (mVerts.size() == 0)
{ {
verts = batchData.initialVerts; mVerts = batchData.initialVerts;
} }
if (norms.size() == 0) if (mNorms.size() == 0)
{ {
norms = batchData.initialNorms; mNorms = batchData.initialNorms;
} }
} }
else else
{ {
// Set from the mesh data // Set from the mesh data
batchData.initialVerts = verts; batchData.initialVerts = mVerts;
batchData.initialNorms = norms; batchData.initialNorms = mNorms;
} }
sz = tsalloc.get32(); sz = tsalloc.get32();
@ -2885,15 +2885,15 @@ void TSSkinMesh::disassemble()
// 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*)verts.address(), 3 * verts.size()); tsalloc.copyToBuffer32((S32*)mVerts.address(), 3 * mVerts.size());
// no longer do this here...let tsmesh handle this // no longer do this here...let tsmesh handle this
tsalloc.copyToBuffer32((S32*)norms.address(), 3 * norms.size()); tsalloc.copyToBuffer32((S32*)mNorms.address(), 3 * mNorms.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 < norms.size(); i++) for (S32 i = 0; i < mNorms.size(); i++)
{ {
U8 normIdx = encodedNorms.size() ? encodedNorms[i] : encodeNormal(norms[i]); U8 normIdx = mEncodedNorms.size() ? mEncodedNorms[i] : encodeNormal(mNorms[i]);
tsalloc.copyToBuffer8((S8*)&normIdx, 1); tsalloc.copyToBuffer8((S8*)&normIdx, 1);
} }
} }
@ -2939,7 +2939,7 @@ void TSSkinMesh::disassemble()
TSSkinMesh::TSSkinMesh() TSSkinMesh::TSSkinMesh()
{ {
meshType = SkinMeshType; mMeshType = SkinMeshType;
batchData.initialized = false; batchData.initialized = false;
maxBones = -1; maxBones = -1;
} }
@ -2958,9 +2958,9 @@ inline void TSMesh::findTangent( U32 index1,
const Point3F &v2 = _verts[index2]; const Point3F &v2 = _verts[index2];
const Point3F &v3 = _verts[index3]; const Point3F &v3 = _verts[index3];
const Point2F &w1 = tverts[index1]; const Point2F &w1 = mTverts[index1];
const Point2F &w2 = tverts[index2]; const Point2F &w2 = mTverts[index2];
const Point2F &w3 = tverts[index3]; const Point2F &w3 = mTverts[index3];
F32 x1 = v2.x - v1.x; F32 x1 = v2.x - v1.x;
F32 x2 = v3.x - v1.x; F32 x2 = v3.x - v1.x;
@ -3025,11 +3025,11 @@ void TSMesh::createTangents(const Vector<Point3F> &_verts, const Vector<Point3F>
Point3F *tan1 = tan0.address() + numVerts; Point3F *tan1 = tan0.address() + numVerts;
dMemset( tan0.address(), 0, sizeof(Point3F) * 2 * numVerts ); dMemset( tan0.address(), 0, sizeof(Point3F) * 2 * numVerts );
U32 numPrimatives = primitives.size(); U32 numPrimatives = mPrimitives.size();
for (S32 i = 0; i < numPrimatives; i++ ) for (S32 i = 0; i < numPrimatives; i++ )
{ {
const TSDrawPrimitive & draw = primitives[i]; const TSDrawPrimitive & draw = mPrimitives[i];
GFXPrimitiveType drawType = getDrawType( draw.matIndex >> 30 ); GFXPrimitiveType drawType = getDrawType( draw.matIndex >> 30 );
U32 p1Index = 0; U32 p1Index = 0;
@ -3066,7 +3066,7 @@ void TSMesh::createTangents(const Vector<Point3F> &_verts, const Vector<Point3F>
} }
} }
tangents.setSize( numVerts ); mTangents.setSize( numVerts );
// fill out final info from accumulated basis data // fill out final info from accumulated basis data
for( U32 i = 0; i < numVerts; i++ ) for( U32 i = 0; i < numVerts; i++ )
@ -3077,12 +3077,12 @@ void TSMesh::createTangents(const Vector<Point3F> &_verts, const Vector<Point3F>
Point3F tempPt = t - n * mDot( n, t ); Point3F tempPt = t - n * mDot( n, t );
tempPt.normalize(); tempPt.normalize();
tangents[i] = tempPt; mTangents[i] = tempPt;
Point3F cp; Point3F cp;
mCross( n, t, &cp ); mCross( n, t, &cp );
tangents[i].w = (mDot( cp, b ) < 0.0f) ? -1.0f : 1.0f; mTangents[i].w = (mDot( cp, b ) < 0.0f) ? -1.0f : 1.0f;
} }
} }
@ -3090,7 +3090,7 @@ void TSMesh::convertToVertexData()
{ {
if (!mVertexData.isReady()) if (!mVertexData.isReady())
{ {
_convertToVertexData(mVertexData, verts, norms); _convertToVertexData(mVertexData, mVerts, mNorms);
} }
} }
@ -3111,39 +3111,39 @@ void TSSkinMesh::convertToVertexData()
void TSMesh::copySourceVertexDataFrom(const TSMesh* srcMesh) void TSMesh::copySourceVertexDataFrom(const TSMesh* srcMesh)
{ {
verts = srcMesh->verts; mVerts = srcMesh->mVerts;
tverts = srcMesh->tverts; mTverts = srcMesh->mTverts;
norms = srcMesh->norms; mNorms = srcMesh->mNorms;
colors = srcMesh->colors; mColors = srcMesh->mColors;
tverts2 = srcMesh->tverts2; mTverts2 = srcMesh->mTverts2;
if (verts.size() == 0) if (mVerts.size() == 0)
{ {
bool hasTVert2 = srcMesh->getHasTVert2(); bool hasTVert2 = srcMesh->getHasTVert2();
bool hasColor = srcMesh->getHasColor(); bool hasColor = srcMesh->getHasColor();
verts.setSize(srcMesh->mNumVerts); mVerts.setSize(srcMesh->mNumVerts);
tverts.setSize(srcMesh->mNumVerts); mTverts.setSize(srcMesh->mNumVerts);
norms.setSize(srcMesh->mNumVerts); mNorms.setSize(srcMesh->mNumVerts);
if (hasColor) if (hasColor)
colors.setSize(mNumVerts); mColors.setSize(mNumVerts);
if (hasTVert2) if (hasTVert2)
tverts2.setSize(mNumVerts); mTverts2.setSize(mNumVerts);
// Fill arrays // Fill arrays
for (U32 i = 0; i < mNumVerts; i++) for (U32 i = 0; i < mNumVerts; i++)
{ {
const __TSMeshVertexBase &cv = srcMesh->mVertexData.getBase(i); const __TSMeshVertexBase &cv = srcMesh->mVertexData.getBase(i);
const __TSMeshVertex_3xUVColor &cvc = srcMesh->mVertexData.getColor(i); const __TSMeshVertex_3xUVColor &cvc = srcMesh->mVertexData.getColor(i);
verts[i] = cv.vert(); mVerts[i] = cv.vert();
tverts[i] = cv.tvert(); mTverts[i] = cv.tvert();
norms[i] = cv.normal(); mNorms[i] = cv.normal();
if (hasColor) if (hasColor)
cvc.color().getColor(&colors[i]); cvc.color().getColor(&mColors[i]);
if (hasTVert2) if (hasTVert2)
tverts2[i] = cvc.tvert2(); mTverts2[i] = cvc.tvert2();
} }
} }
} }
@ -3173,21 +3173,21 @@ void TSSkinMesh::copySourceVertexDataFrom(const TSMesh* srcMesh)
U32 TSMesh::getNumVerts() U32 TSMesh::getNumVerts()
{ {
return mVertexData.isReady() ? mNumVerts : verts.size(); return mVertexData.isReady() ? mNumVerts : mVerts.size();
} }
void TSMesh::_convertToVertexData(TSMeshVertexArray &outArray, const Vector<Point3F> &_verts, const Vector<Point3F> &_norms) void TSMesh::_convertToVertexData(TSMeshVertexArray &outArray, const Vector<Point3F> &_verts, const Vector<Point3F> &_norms)
{ {
// Update tangents list // Update tangents list
createTangents(verts, norms); createTangents(mVerts, mNorms);
AssertFatal(_verts.size() == mNumVerts, "vert count mismatch"); AssertFatal(_verts.size() == mNumVerts, "vert count mismatch");
AssertFatal(!getHasColor() || colors.size() == _verts.size(), "Vector of color elements should be the same size as other vectors"); AssertFatal(!getHasColor() || mColors.size() == _verts.size(), "Vector of color elements should be the same size as other vectors");
AssertFatal(!getHasTVert2() || tverts2.size() == _verts.size(), "Vector of tvert2 elements should be the same size as other vectors"); AssertFatal(!getHasTVert2() || mTverts2.size() == _verts.size(), "Vector of tvert2 elements should be the same size as other vectors");
AssertFatal(!outArray.isReady(), "Mesh already converted to aligned data! Re-check code!"); AssertFatal(!outArray.isReady(), "Mesh already converted to aligned data! Re-check code!");
AssertFatal(_verts.size() == _norms.size() && AssertFatal(_verts.size() == _norms.size() &&
_verts.size() == tangents.size(), _verts.size() == mTangents.size(),
"Vectors: verts, norms, tangents must all be the same size"); "Vectors: verts, norms, tangents must all be the same size");
AssertFatal(mVertSize == outArray.vertSize(), "Size inconsistency"); AssertFatal(mVertSize == outArray.vertSize(), "Size inconsistency");
@ -3206,18 +3206,18 @@ void TSMesh::_convertToVertexData(TSMeshVertexArray &outArray, const Vector<Poin
__TSMeshVertexBase &v = outArray.getBase(i); __TSMeshVertexBase &v = outArray.getBase(i);
v.vert(_verts[i]); v.vert(_verts[i]);
v.normal(_norms[i]); v.normal(_norms[i]);
v.tangent(tangents[i]); v.tangent(mTangents[i]);
if (i < tverts.size()) if (i < mTverts.size())
v.tvert(tverts[i]); v.tvert(mTverts[i]);
if (hasTVert2 || hasColor) if (hasTVert2 || hasColor)
{ {
__TSMeshVertex_3xUVColor &vc = outArray.getColor(i); __TSMeshVertex_3xUVColor &vc = outArray.getColor(i);
if (hasTVert2 && i < tverts2.size()) if (hasTVert2 && i < mTverts2.size())
vc.tvert2(tverts2[i]); vc.tvert2(mTverts2[i]);
if (hasColor && i < colors.size()) if (hasColor && i < mColors.size())
vc.color(colors[i]); vc.color(mColors[i]);
} }
// NOTE: skin verts are set later on for the skinned mesh, otherwise we'll set the default (i.e. 0) if we need one for a rigid mesh // NOTE: skin verts are set later on for the skinned mesh, otherwise we'll set the default (i.e. 0) if we need one for a rigid mesh
@ -3231,7 +3231,7 @@ void TSMesh::_convertToVertexData(TSMeshVertexArray &outArray, const Vector<Poin
void TSMesh::makeEditable() void TSMesh::makeEditable()
{ {
bool hasVerts = verts.size() != 0; bool hasVerts = mVerts.size() != 0;
if(mVertexData.isReady() && !hasVerts) if(mVertexData.isReady() && !hasVerts)
{ {
@ -3282,7 +3282,7 @@ void TSSkinMesh::addWeightsFromVertexBuffer()
void TSSkinMesh::makeEditable() void TSSkinMesh::makeEditable()
{ {
bool hasVerts = verts.size() != 0; bool hasVerts = mVerts.size() != 0;
// Reconstruct bone mapping // Reconstruct bone mapping
if (mVertexData.isReady() && !hasVerts) if (mVertexData.isReady() && !hasVerts)
@ -3307,36 +3307,36 @@ void TSSkinMesh::makeEditable()
void TSMesh::clearEditable() void TSMesh::clearEditable()
{ {
if (verts.size() == 0) if (mVerts.size() == 0)
return; return;
if (colors.empty()) if (mColors.empty())
clearFlags(HasColor); clearFlags(HasColor);
else else
setFlags(HasColor); setFlags(HasColor);
if (tverts2.empty()) if (mTverts2.empty())
clearFlags(HasTVert2); clearFlags(HasTVert2);
else else
setFlags(HasTVert2); setFlags(HasTVert2);
verts.free_memory(); mVerts.free_memory();
norms.free_memory(); mNorms.free_memory();
tangents.free_memory(); mTangents.free_memory();
tverts.free_memory(); mTverts.free_memory();
tverts2.free_memory(); mTverts2.free_memory();
colors.free_memory(); mColors.free_memory();
} }
void TSMesh::updateMeshFlags() void TSMesh::updateMeshFlags()
{ {
// Make sure flags are correct // Make sure flags are correct
if (colors.empty()) if (mColors.empty())
clearFlags(HasColor); clearFlags(HasColor);
else else
setFlags(HasColor); setFlags(HasColor);
if (tverts2.empty()) if (mTverts2.empty())
clearFlags(HasTVert2); clearFlags(HasTVert2);
else else
setFlags(HasTVert2); setFlags(HasTVert2);

View file

@ -251,7 +251,7 @@ public:
protected: protected:
U32 meshType; U32 mMeshType;
Box3F mBounds; Box3F mBounds;
Point3F mCenter; Point3F mCenter;
F32 mRadius; F32 mRadius;
@ -259,7 +259,7 @@ protected:
const GFXVertexFormat *mVertexFormat; const GFXVertexFormat *mVertexFormat;
TSMesh *parentMeshObject; ///< Current parent object instance TSMesh *mParentMeshObject; ///< Current parent object instance
U32 mPrimBufferOffset; U32 mPrimBufferOffset;
@ -299,12 +299,12 @@ protected:
FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals|HasColor|HasTVert2 FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals|HasColor|HasTVert2
}; };
U32 getMeshType() const { return meshType & TypeMask; } U32 getMeshType() const { return mMeshType & TypeMask; }
U32 getHasColor() const { return colors.size() > 0 || meshType & HasColor; } U32 getHasColor() const { return mColors.size() > 0 || mMeshType & HasColor; }
U32 getHasTVert2() const { return tverts2.size() > 0 || meshType & HasTVert2; } U32 getHasTVert2() const { return mTverts2.size() > 0 || mMeshType & HasTVert2; }
void setFlags(U32 flag) { meshType |= flag; } void setFlags(U32 flag) { mMeshType |= flag; }
void clearFlags(U32 flag) { meshType &= ~flag; } void clearFlags(U32 flag) { mMeshType &= ~flag; }
U32 getFlags( U32 flag = 0xFFFFFFFF ) const { return meshType & flag; } U32 getFlags( U32 flag = 0xFFFFFFFF ) const { return mMeshType & flag; }
const Point3F* getNormals( S32 firstVert ); const Point3F* getNormals( S32 firstVert );
@ -319,34 +319,34 @@ protected:
/// @name Vertex data /// @name Vertex data
/// @{ /// @{
FreeableVector<Point3F> verts; FreeableVector<Point3F> mVerts;
FreeableVector<Point3F> norms; FreeableVector<Point3F> mNorms;
FreeableVector<Point2F> tverts; FreeableVector<Point2F> mTverts;
FreeableVector<Point4F> tangents; FreeableVector<Point4F> mTangents;
// Optional second texture uvs. // Optional second texture uvs.
FreeableVector<Point2F> tverts2; FreeableVector<Point2F> mTverts2;
// Optional vertex colors data. // Optional vertex colors data.
FreeableVector<ColorI> colors; FreeableVector<ColorI> mColors;
/// @} /// @}
Vector<TSDrawPrimitive> primitives; Vector<TSDrawPrimitive> mPrimitives;
Vector<U8> encodedNorms; Vector<U8> mEncodedNorms;
Vector<U32> mIndices; Vector<U32> mIndices;
/// billboard data /// billboard data
Point3F billboardAxis; Point3F mBillboardAxis;
/// @name Convex Hull Data /// @name Convex Hull Data
/// Convex hulls are convex (no angles >= 180º) meshes used for collision /// Convex hulls are convex (no angles >= 180º) meshes used for collision
/// @{ /// @{
Vector<Point3F> planeNormals; Vector<Point3F> mPlaneNormals;
Vector<F32> planeConstants; Vector<F32> mPlaneConstants;
Vector<U32> planeMaterials; Vector<U32> mPlaneMaterials;
S32 planesPerFrame; S32 mPlanesPerFrame;
U32 mergeBufferStart; U32 mMergeBufferStart;
/// @} /// @}
/// @name Render Methods /// @name Render Methods

View file

@ -246,9 +246,9 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
{ {
// Add indices // Add indices
S32 indicesBase = mIndices.size(); S32 indicesBase = mIndices.size();
for ( S32 i = 0; i < mesh->primitives.size(); i++ ) for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ )
{ {
const TSDrawPrimitive& draw = mesh->primitives[i]; const TSDrawPrimitive& draw = mesh->mPrimitives[i];
if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles ) if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles )
{ {
mIndices.merge( &mesh->mIndices[draw.start], draw.numElements ); mIndices.merge( &mesh->mIndices[draw.start], draw.numElements );
@ -282,7 +282,7 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
S32 count, stride; S32 count, stride;
U8* pVert; U8* pVert;
if ( mesh->mVertexData.isReady() && mesh->verts.size() == 0 ) if ( mesh->mVertexData.isReady() && mesh->mVerts.size() == 0 )
{ {
count = mesh->mVertexData.size(); count = mesh->mVertexData.size();
stride = mesh->mVertexData.vertSize(); stride = mesh->mVertexData.vertSize();
@ -290,9 +290,9 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
} }
else else
{ {
count = mesh->verts.size(); count = mesh->mVerts.size();
stride = sizeof(Point3F); stride = sizeof(Point3F);
pVert = (U8*)mesh->verts.address(); pVert = (U8*)mesh->mVerts.address();
} }
MatrixF objMat; MatrixF objMat;
@ -337,12 +337,12 @@ TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numT
mesh->mIndices.push_back( indices[i*3 + 1] ); mesh->mIndices.push_back( indices[i*3 + 1] );
} }
mesh->verts.set( verts, numVerts ); mesh->mVerts.set( verts, numVerts );
// Compute mesh normals // Compute mesh normals
mesh->norms.setSize( mesh->verts.size() ); mesh->mNorms.setSize( mesh->mVerts.size() );
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++) for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
mesh->norms[iNorm] = Point3F::Zero; mesh->mNorms[iNorm] = Point3F::Zero;
// Sum triangle normals for each vertex // Sum triangle normals for each vertex
for (S32 iInd = 0; iInd < mesh->mIndices.size(); iInd += 3) for (S32 iInd = 0; iInd < mesh->mIndices.size(); iInd += 3)
@ -352,38 +352,38 @@ TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numT
S32 idx1 = mesh->mIndices[iInd + 1]; S32 idx1 = mesh->mIndices[iInd + 1];
S32 idx2 = mesh->mIndices[iInd + 2]; S32 idx2 = mesh->mIndices[iInd + 2];
const Point3F& v0 = mesh->verts[idx0]; const Point3F& v0 = mesh->mVerts[idx0];
const Point3F& v1 = mesh->verts[idx1]; const Point3F& v1 = mesh->mVerts[idx1];
const Point3F& v2 = mesh->verts[idx2]; const Point3F& v2 = mesh->mVerts[idx2];
Point3F n; Point3F n;
mCross(v2 - v0, v1 - v0, &n); mCross(v2 - v0, v1 - v0, &n);
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect) n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
mesh->norms[idx0] += n; mesh->mNorms[idx0] += n;
mesh->norms[idx1] += n; mesh->mNorms[idx1] += n;
mesh->norms[idx2] += n; mesh->mNorms[idx2] += n;
} }
// Normalize the vertex normals (this takes care of averaging the triangle normals) // Normalize the vertex normals (this takes care of averaging the triangle normals)
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++) for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
mesh->norms[iNorm].normalize(); mesh->mNorms[iNorm].normalize();
// Set some dummy UVs // Set some dummy UVs
mesh->tverts.setSize( numVerts ); mesh->mTverts.setSize( numVerts );
for ( S32 j = 0; j < mesh->tverts.size(); j++ ) for ( S32 j = 0; j < mesh->mTverts.size(); j++ )
mesh->tverts[j].set( 0, 0 ); mesh->mTverts[j].set( 0, 0 );
// Add a single triangle-list primitive // Add a single triangle-list primitive
mesh->primitives.increment(); mesh->mPrimitives.increment();
mesh->primitives.last().start = 0; mesh->mPrimitives.last().start = 0;
mesh->primitives.last().numElements = mesh->mIndices.size(); mesh->mPrimitives.last().numElements = mesh->mIndices.size();
mesh->primitives.last().matIndex = TSDrawPrimitive::Triangles | mesh->mPrimitives.last().matIndex = TSDrawPrimitive::Triangles |
TSDrawPrimitive::Indexed | TSDrawPrimitive::Indexed |
TSDrawPrimitive::NoMaterial; TSDrawPrimitive::NoMaterial;
mesh->createTangents( mesh->verts, mesh->norms ); mesh->createTangents( mesh->mVerts, mesh->mNorms);
mesh->encodedNorms.set( NULL,0 ); mesh->mEncodedNorms.set( NULL,0 );
return mesh; return mesh;
} }
@ -404,13 +404,13 @@ void MeshFit::addBox( const Point3F& sides, const MatrixF& mat )
if ( !mesh ) if ( !mesh )
return; return;
if (mesh->verts.size() > 0) if (mesh->mVerts.size() > 0)
{ {
for (S32 i = 0; i < mesh->verts.size(); i++) for (S32 i = 0; i < mesh->mVerts.size(); i++)
{ {
Point3F v = mesh->verts[i]; Point3F v = mesh->mVerts[i];
v.convolve(sides); v.convolve(sides);
mesh->verts[i] = v; mesh->mVerts[i] = v;
} }
mesh->mVertexData.setReady(false); mesh->mVertexData.setReady(false);
@ -799,7 +799,7 @@ DefineTSShapeConstructorMethod( addPrimitive, bool, ( const char* meshName, cons
MatrixF mat( txfm.getMatrix() ); MatrixF mat( txfm.getMatrix() );
// Transform the mesh vertices // Transform the mesh vertices
if ( mesh->mVertexData.isReady() && mesh->verts.size() == 0 ) if ( mesh->mVertexData.isReady() && mesh->mVerts.size() == 0 )
{ {
for (S32 i = 0; i < mesh->mVertexData.size(); i++) for (S32 i = 0; i < mesh->mVertexData.size(); i++)
{ {
@ -811,10 +811,10 @@ DefineTSShapeConstructorMethod( addPrimitive, bool, ( const char* meshName, cons
} }
else else
{ {
for (S32 i = 0; i < mesh->verts.size(); i++) for (S32 i = 0; i < mesh->mVerts.size(); i++)
{ {
Point3F v(mesh->verts[i]); Point3F v(mesh->mVerts[i]);
mat.mulP( v, &mesh->verts[i] ); mat.mulP( v, &mesh->mVerts[i] );
} }
} }

View file

@ -592,11 +592,11 @@ void TSShape::initObjects()
if (mesh->mParentMesh >= 0 && mesh->mParentMesh < meshes.size()) if (mesh->mParentMesh >= 0 && mesh->mParentMesh < meshes.size())
{ {
mesh->parentMeshObject = meshes[mesh->mParentMesh]; mesh->mParentMeshObject = meshes[mesh->mParentMesh];
} }
else else
{ {
mesh->parentMeshObject = NULL; mesh->mParentMeshObject = NULL;
} }
mesh->mVertexFormat = &mVertexFormat; mesh->mVertexFormat = &mVertexFormat;
@ -623,7 +623,7 @@ void TSShape::initVertexBuffers()
continue; continue;
destIndices += mesh->mIndices.size(); destIndices += mesh->mIndices.size();
destPrims += mesh->primitives.size(); destPrims += mesh->mPrimitives.size();
} }
// For HW skinning we can just use the static buffer // For HW skinning we can just use the static buffer
@ -660,14 +660,14 @@ void TSShape::initVertexBuffers()
AssertFatal(mesh->mVertOffset / mVertexSize == vertStart, "offset mismatch"); AssertFatal(mesh->mVertOffset / mVertexSize == vertStart, "offset mismatch");
vertStart += mesh->mNumVerts; vertStart += mesh->mNumVerts;
primStart += mesh->primitives.size(); primStart += mesh->mPrimitives.size();
indStart += mesh->mIndices.size(); indStart += mesh->mIndices.size();
mesh->mVB = mShapeVertexBuffer; mesh->mVB = mShapeVertexBuffer;
mesh->mPB = mShapeVertexIndices; mesh->mPB = mShapeVertexIndices;
// Advance // Advance
piInput += mesh->primitives.size(); piInput += mesh->mPrimitives.size();
ibIndices += mesh->mIndices.size(); ibIndices += mesh->mIndices.size();
if (TSSkinMesh::smDebugSkinVerts && mesh->getMeshType() == TSMesh::SkinMeshType) if (TSSkinMesh::smDebugSkinVerts && mesh->getMeshType() == TSMesh::SkinMeshType)
@ -906,12 +906,12 @@ void TSShape::initVertexFeatures()
mesh->mVertexData.setReady(true); mesh->mVertexData.setReady(true);
#ifdef TORQUE_DEBUG #ifdef TORQUE_DEBUG
AssertFatal(mesh->mNumVerts == mesh->verts.size(), "vert mismatch"); AssertFatal(mesh->mNumVerts == mesh->mVerts.size(), "vert mismatch");
for (U32 i = 0; i < mesh->mNumVerts; i++) for (U32 i = 0; i < mesh->mNumVerts; i++)
{ {
Point3F v1 = mesh->verts[i]; Point3F v1 = mesh->mVerts[i];
Point3F v2 = mesh->mVertexData.getBase(i).vert(); Point3F v2 = mesh->mVertexData.getBase(i).vert();
AssertFatal(mesh->verts[i] == mesh->mVertexData.getBase(i).vert(), "vert data mismatch"); AssertFatal(mesh->mVerts[i] == mesh->mVertexData.getBase(i).vert(), "vert data mismatch");
} }
if (mesh->getMeshType() == TSMesh::SkinMeshType) if (mesh->getMeshType() == TSMesh::SkinMeshType)
@ -987,11 +987,11 @@ void TSShape::initMaterialList()
if (!mesh) if (!mesh)
continue; continue;
for (k=0; k<mesh->primitives.size(); k++) for (k=0; k<mesh->mPrimitives.size(); k++)
{ {
if (mesh->primitives[k].matIndex & TSDrawPrimitive::NoMaterial) if (mesh->mPrimitives[k].matIndex & TSDrawPrimitive::NoMaterial)
continue; continue;
S32 flags = materialList->getFlags(mesh->primitives[k].matIndex & TSDrawPrimitive::MaterialMask); S32 flags = materialList->getFlags(mesh->mPrimitives[k].matIndex & TSDrawPrimitive::MaterialMask);
if (flags & TSMaterialList::AuxiliaryMap) if (flags & TSMaterialList::AuxiliaryMap)
continue; continue;
if (flags & TSMaterialList::Translucent) if (flags & TSMaterialList::Translucent)
@ -1001,7 +1001,7 @@ void TSShape::initMaterialList()
break; break;
} }
} }
if (k!=mesh->primitives.size()) if (k!=mesh->mPrimitives.size())
break; break;
} }
if (j!=obj.numMeshes) if (j!=obj.numMeshes)
@ -1521,15 +1521,15 @@ void TSShape::assembleShape()
// fill in location of verts, tverts, and normals for detail levels // fill in location of verts, tverts, and normals for detail levels
if (mesh && meshType!=TSMesh::DecalMeshType) if (mesh && meshType!=TSMesh::DecalMeshType)
{ {
TSMesh::smVertsList[i] = mesh->verts.address(); TSMesh::smVertsList[i] = mesh->mVerts.address();
TSMesh::smTVertsList[i] = mesh->tverts.address(); TSMesh::smTVertsList[i] = mesh->mTverts.address();
if (smReadVersion >= 26) if (smReadVersion >= 26)
{ {
TSMesh::smTVerts2List[i] = mesh->tverts2.address(); TSMesh::smTVerts2List[i] = mesh->mTverts2.address();
TSMesh::smColorsList[i] = mesh->colors.address(); TSMesh::smColorsList[i] = mesh->mColors.address();
} }
TSMesh::smNormsList[i] = mesh->norms.address(); TSMesh::smNormsList[i] = mesh->mNorms.address();
TSMesh::smEncodedNormsList[i] = mesh->encodedNorms.address(); TSMesh::smEncodedNormsList[i] = mesh->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
if (meshType==TSMesh::SkinMeshType) if (meshType==TSMesh::SkinMeshType)
{ {
@ -1617,9 +1617,9 @@ void TSShape::assembleShape()
if (skin) if (skin)
{ {
TSMesh::smVertsList[i] = skin->batchData.initialVerts.address(); TSMesh::smVertsList[i] = skin->batchData.initialVerts.address();
TSMesh::smTVertsList[i] = skin->tverts.address(); TSMesh::smTVertsList[i] = skin->mTverts.address();
TSMesh::smNormsList[i] = skin->batchData.initialNorms.address(); TSMesh::smNormsList[i] = skin->batchData.initialNorms.address();
TSMesh::smEncodedNormsList[i] = skin->encodedNorms.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->batchData.initialTransforms.address();
TSSkinMesh::smVertexIndexList[i] = skin->vertexIndex.address(); TSSkinMesh::smVertexIndexList[i] = skin->vertexIndex.address();
@ -1805,15 +1805,15 @@ bool TSShape::canWriteOldFormat() const
continue; continue;
// Cannot use old format if using the new functionality (COLORs, 2nd UV set) // Cannot use old format if using the new functionality (COLORs, 2nd UV set)
if (meshes[i]->tverts2.size() || meshes[i]->colors.size()) if (meshes[i]->mTverts2.size() || meshes[i]->mColors.size())
return false; return false;
// Cannot use old format if any primitive has too many triangles // Cannot use old format if any primitive has too many triangles
// (ie. cannot fit in a S16) // (ie. cannot fit in a S16)
for (S32 j = 0; j < meshes[i]->primitives.size(); j++) for (S32 j = 0; j < meshes[i]->mPrimitives.size(); j++)
{ {
if ((meshes[i]->primitives[j].start + if ((meshes[i]->mPrimitives[j].start +
meshes[i]->primitives[j].numElements) >= (1 << 15)) meshes[i]->mPrimitives[j].numElements) >= (1 << 15))
{ {
return false; return false;
} }

View file

@ -1340,7 +1340,7 @@ DefineTSShapeConstructorMethod( getMeshMaterial, const char*, ( const char* name
GET_MESH( getMeshMaterial, mesh, name, "" ); GET_MESH( getMeshMaterial, mesh, name, "" );
// Return the name of the first material attached to this mesh // Return the name of the first material attached to this mesh
S32 matIndex = mesh->primitives[0].matIndex & TSDrawPrimitive::MaterialMask; S32 matIndex = mesh->mPrimitives[0].matIndex & TSDrawPrimitive::MaterialMask;
if ((matIndex >= 0) && (matIndex < mShape->materialList->size())) if ((matIndex >= 0) && (matIndex < mShape->materialList->size()))
return mShape->materialList->getMaterialName( matIndex ); return mShape->materialList->getMaterialName( matIndex );
else else
@ -1377,10 +1377,10 @@ DefineTSShapeConstructorMethod( setMeshMaterial, bool, ( const char* meshName, c
} }
// Set this material for all primitives in the mesh // Set this material for all primitives in the mesh
for ( S32 i = 0; i < mesh->primitives.size(); i++ ) for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ )
{ {
U32 matType = mesh->primitives[i].matIndex & ( TSDrawPrimitive::TypeMask | TSDrawPrimitive::Indexed ); U32 matType = mesh->mPrimitives[i].matIndex & ( TSDrawPrimitive::TypeMask | TSDrawPrimitive::Indexed );
mesh->primitives[i].matIndex = ( matType | matIndex ); mesh->mPrimitives[i].matIndex = ( matType | matIndex );
} }
ADD_TO_CHANGE_SET(); ADD_TO_CHANGE_SET();

View file

@ -938,7 +938,7 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
// Copy mesh elements // Copy mesh elements
mesh->mIndices = srcMesh->mIndices; mesh->mIndices = srcMesh->mIndices;
mesh->primitives = srcMesh->primitives; mesh->mPrimitives = srcMesh->mPrimitives;
mesh->numFrames = srcMesh->numFrames; mesh->numFrames = srcMesh->numFrames;
mesh->numMatFrames = srcMesh->numMatFrames; mesh->numMatFrames = srcMesh->numMatFrames;
mesh->vertsPerFrame = srcMesh->vertsPerFrame; mesh->vertsPerFrame = srcMesh->vertsPerFrame;
@ -948,8 +948,8 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
// Copy vertex data in an *unpacked* form // Copy vertex data in an *unpacked* form
mesh->copySourceVertexDataFrom(srcMesh); mesh->copySourceVertexDataFrom(srcMesh);
mesh->createTangents(mesh->verts, mesh->norms); mesh->createTangents(mesh->mVerts, mesh->mNorms);
mesh->encodedNorms.set(NULL, 0); mesh->mEncodedNorms.set(NULL, 0);
mesh->computeBounds(); mesh->computeBounds();
@ -1108,12 +1108,12 @@ bool TSShape::addMesh(TSShape* srcShape, const String& srcMeshName, const String
// Copy materials used by the source mesh (only if from a different shape) // Copy materials used by the source mesh (only if from a different shape)
if (srcShape != this) if (srcShape != this)
{ {
for (S32 i = 0; i < mesh->primitives.size(); i++) for (S32 i = 0; i < mesh->mPrimitives.size(); i++)
{ {
if (!(mesh->primitives[i].matIndex & TSDrawPrimitive::NoMaterial)) if (!(mesh->mPrimitives[i].matIndex & TSDrawPrimitive::NoMaterial))
{ {
S32 drawType = (mesh->primitives[i].matIndex & (~TSDrawPrimitive::MaterialMask)); S32 drawType = (mesh->mPrimitives[i].matIndex & (~TSDrawPrimitive::MaterialMask));
S32 srcMatIndex = mesh->primitives[i].matIndex & TSDrawPrimitive::MaterialMask; S32 srcMatIndex = mesh->mPrimitives[i].matIndex & TSDrawPrimitive::MaterialMask;
const String& matName = srcShape->materialList->getMaterialName(srcMatIndex); const String& matName = srcShape->materialList->getMaterialName(srcMatIndex);
// Add the material if it does not already exist // Add the material if it does not already exist
@ -1124,7 +1124,7 @@ bool TSShape::addMesh(TSShape* srcShape, const String& srcMeshName, const String
materialList->push_back(matName, srcShape->materialList->getFlags(srcMatIndex)); materialList->push_back(matName, srcShape->materialList->getFlags(srcMatIndex));
} }
mesh->primitives[i].matIndex = drawType | destMatIndex; mesh->mPrimitives[i].matIndex = drawType | destMatIndex;
} }
} }
} }

View file

@ -86,10 +86,10 @@ S32 TSSortedMesh::getNumPolys()
Cluster & cluster = clusters[cIdx]; Cluster & cluster = clusters[cIdx];
for (S32 i=cluster.startPrimitive; i<cluster.endPrimitive; i++) for (S32 i=cluster.startPrimitive; i<cluster.endPrimitive; i++)
{ {
if (primitives[i].matIndex & TSDrawPrimitive::Triangles) if (mPrimitives[i].matIndex & TSDrawPrimitive::Triangles)
count += primitives[i].numElements / 3; count += mPrimitives[i].numElements / 3;
else else
count += primitives[i].numElements - 2; count += mPrimitives[i].numElements - 2;
} }
cIdx = cluster.frontCluster; // always use frontCluster...we assume about the same no matter what cIdx = cluster.frontCluster; // always use frontCluster...we assume about the same no matter what
} }

View file

@ -71,7 +71,7 @@ public:
void disassemble(); void disassemble();
TSSortedMesh() { TSSortedMesh() {
meshType = SortedMeshType; mMeshType = SortedMeshType;
} }
}; };