mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Rename all member variables to follow the style guidelines (prefixed with the 'm') - class TSMesh
This commit is contained in:
parent
1778a8d7f2
commit
e2545c359c
12 changed files with 406 additions and 406 deletions
|
|
@ -1228,9 +1228,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 )
|
||||||
|
|
|
||||||
|
|
@ -147,22 +147,22 @@ TSMesh* AppMesh::constructTSMesh()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy mesh elements
|
// Copy mesh elements
|
||||||
tsmesh->verts = mPoints;
|
tsmesh->mVerts = mPoints;
|
||||||
tsmesh->norms = mNormals;
|
tsmesh->mNorms = mNormals;
|
||||||
tsmesh->tverts = mUVs;
|
tsmesh->mTVerts = mUVs;
|
||||||
tsmesh->primitives = mPrimitives;
|
tsmesh->mPrimitives = mPrimitives;
|
||||||
tsmesh->indices = mIndices;
|
tsmesh->mIndices = mIndices;
|
||||||
tsmesh->colors = mColors;
|
tsmesh->mColors = mColors;
|
||||||
tsmesh->tverts2 = mUV2s;
|
tsmesh->mTVerts2 = mUV2s;
|
||||||
|
|
||||||
// Finish initializing the shape
|
// Finish initializing the shape
|
||||||
tsmesh->setFlags(mFlags);
|
tsmesh->setFlags(mFlags);
|
||||||
tsmesh->computeBounds();
|
tsmesh->computeBounds();
|
||||||
tsmesh->numFrames = mNumFrames;
|
tsmesh->mNumFrames = mNumFrames;
|
||||||
tsmesh->numMatFrames = mNumMatFrames;
|
tsmesh->mNumMatFrames = mNumMatFrames;
|
||||||
tsmesh->vertsPerFrame = mVertsPerFrame;
|
tsmesh->mVertsPerFrame = mVertsPerFrame;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1157,7 +1157,7 @@ void TSShapeLoader::install()
|
||||||
{
|
{
|
||||||
TSMesh *mesh = mShape->meshes[obj.startMeshIndex + iMesh];
|
TSMesh *mesh = mShape->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);
|
||||||
|
|
|
||||||
|
|
@ -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)" );
|
||||||
|
|
@ -1377,16 +1377,16 @@ void TSMesh::prepOpcodeCollision()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Have to walk the tristrip to get a count... may have degenerates
|
// Have to walk the tristrip to get a count... may have degenerates
|
||||||
U32 idx0 = base + indices[start + 0];
|
U32 idx0 = base + mIndices[start + 0];
|
||||||
U32 idx1;
|
U32 idx1;
|
||||||
U32 idx2 = base + indices[start + 1];
|
U32 idx2 = base + mIndices[start + 1];
|
||||||
U32 * nextIdx = &idx1;
|
U32 * nextIdx = &idx1;
|
||||||
for ( S32 j = 2; j < draw.numElements; j++ )
|
for ( S32 j = 2; j < draw.numElements; j++ )
|
||||||
{
|
{
|
||||||
*nextIdx = idx2;
|
*nextIdx = idx2;
|
||||||
// nextIdx = (j%2)==0 ? &idx0 : &idx1;
|
// nextIdx = (j%2)==0 ? &idx0 : &idx1;
|
||||||
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
||||||
idx2 = base + indices[start + j];
|
idx2 = base + mIndices[start + j];
|
||||||
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -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)" );
|
||||||
|
|
@ -1421,9 +1421,9 @@ void TSMesh::prepOpcodeCollision()
|
||||||
{
|
{
|
||||||
for ( S32 j = 0; j < draw.numElements; )
|
for ( S32 j = 0; j < draw.numElements; )
|
||||||
{
|
{
|
||||||
curIts->mVRef[2] = base + indices[start + j + 0];
|
curIts->mVRef[2] = base + mIndices[start + j + 0];
|
||||||
curIts->mVRef[1] = base + indices[start + j + 1];
|
curIts->mVRef[1] = base + mIndices[start + j + 1];
|
||||||
curIts->mVRef[0] = base + indices[start + j + 2];
|
curIts->mVRef[0] = base + mIndices[start + j + 2];
|
||||||
curIts->mMatIdx = matIndex;
|
curIts->mMatIdx = matIndex;
|
||||||
curIts++;
|
curIts++;
|
||||||
|
|
||||||
|
|
@ -1434,16 +1434,16 @@ void TSMesh::prepOpcodeCollision()
|
||||||
{
|
{
|
||||||
AssertFatal( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip,"TSMesh::buildPolyList (2)" );
|
AssertFatal( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Strip,"TSMesh::buildPolyList (2)" );
|
||||||
|
|
||||||
U32 idx0 = base + indices[start + 0];
|
U32 idx0 = base + mIndices[start + 0];
|
||||||
U32 idx1;
|
U32 idx1;
|
||||||
U32 idx2 = base + indices[start + 1];
|
U32 idx2 = base + mIndices[start + 1];
|
||||||
U32 * nextIdx = &idx1;
|
U32 * nextIdx = &idx1;
|
||||||
for ( S32 j = 2; j < draw.numElements; j++ )
|
for ( S32 j = 2; j < draw.numElements; j++ )
|
||||||
{
|
{
|
||||||
*nextIdx = idx2;
|
*nextIdx = idx2;
|
||||||
// nextIdx = (j%2)==0 ? &idx0 : &idx1;
|
// nextIdx = (j%2)==0 ? &idx0 : &idx1;
|
||||||
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
||||||
idx2 = base + indices[start + j];
|
idx2 = base + mIndices[start + j];
|
||||||
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -1462,7 +1462,7 @@ void TSMesh::prepOpcodeCollision()
|
||||||
if( mVertexData.isReady() )
|
if( mVertexData.isReady() )
|
||||||
pts[i].Set( mVertexData[i].vert().x, mVertexData[i].vert().y, mVertexData[i].vert().z );
|
pts[i].Set( mVertexData[i].vert().x, mVertexData[i].vert().y, mVertexData[i].vert().z );
|
||||||
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 );
|
||||||
|
|
||||||
mi->SetPointers( its, pts );
|
mi->SetPointers( its, pts );
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -105,7 +105,7 @@ class TSMesh
|
||||||
struct TSMeshVertexArray;
|
struct TSMeshVertexArray;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
U32 meshType;
|
U32 mMeshType;
|
||||||
Box3F mBounds;
|
Box3F mBounds;
|
||||||
Point3F mCenter;
|
Point3F mCenter;
|
||||||
F32 mRadius;
|
F32 mRadius;
|
||||||
|
|
@ -140,17 +140,17 @@ class TSMesh
|
||||||
FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals
|
FlagMask = Billboard|BillboardZAxis|HasDetailTexture|UseEncodedNormals
|
||||||
};
|
};
|
||||||
|
|
||||||
U32 getMeshType() const { return meshType & TypeMask; }
|
U32 getMeshType() const { return mMeshType & TypeMask; }
|
||||||
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 );
|
||||||
|
|
||||||
S32 parentMesh; ///< index into shapes mesh list
|
S32 mParentMesh; ///< index into shapes mesh list
|
||||||
S32 numFrames;
|
S32 mNumFrames;
|
||||||
S32 numMatFrames;
|
S32 mNumMatFrames;
|
||||||
S32 vertsPerFrame;
|
S32 mVertsPerFrame;
|
||||||
|
|
||||||
/// @name Aligned Vertex Data
|
/// @name Aligned Vertex Data
|
||||||
/// @{
|
/// @{
|
||||||
|
|
@ -244,34 +244,34 @@ class TSMesh
|
||||||
FreeableVector<T>& operator=(const FreeableVector<T>& p) { Vector<T>::operator=(p); return *this; }
|
FreeableVector<T>& operator=(const FreeableVector<T>& p) { Vector<T>::operator=(p); return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
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> indices;
|
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
|
||||||
|
|
|
||||||
|
|
@ -246,24 +246,24 @@ 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->indices[draw.start], draw.numElements );
|
mIndices.merge( &mesh->mIndices[draw.start], draw.numElements );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
U32 idx0 = mesh->indices[draw.start + 0];
|
U32 idx0 = mesh->mIndices[draw.start + 0];
|
||||||
U32 idx1;
|
U32 idx1;
|
||||||
U32 idx2 = mesh->indices[draw.start + 1];
|
U32 idx2 = mesh->mIndices[draw.start + 1];
|
||||||
U32 *nextIdx = &idx1;
|
U32 *nextIdx = &idx1;
|
||||||
for ( S32 j = 2; j < draw.numElements; j++ )
|
for ( S32 j = 2; j < draw.numElements; j++ )
|
||||||
{
|
{
|
||||||
*nextIdx = idx2;
|
*nextIdx = idx2;
|
||||||
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
||||||
idx2 = mesh->indices[draw.start + j];
|
idx2 = mesh->mIndices[draw.start + j];
|
||||||
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -323,69 +323,69 @@ TSMesh* MeshFit::initMeshFromFile( const String& filename ) const
|
||||||
TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numTris ) const
|
TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numTris ) const
|
||||||
{
|
{
|
||||||
TSMesh* mesh = mShape->copyMesh( NULL );
|
TSMesh* mesh = mShape->copyMesh( NULL );
|
||||||
mesh->numFrames = 1;
|
mesh->mNumFrames = 1;
|
||||||
mesh->numMatFrames = 1;
|
mesh->mNumMatFrames = 1;
|
||||||
mesh->vertsPerFrame = numVerts;
|
mesh->mVertsPerFrame = numVerts;
|
||||||
mesh->setFlags(0);
|
mesh->setFlags(0);
|
||||||
mesh->mHasColor = false;
|
mesh->mHasColor = false;
|
||||||
mesh->mHasTVert2 = false;
|
mesh->mHasTVert2 = false;
|
||||||
mesh->mNumVerts = numVerts;
|
mesh->mNumVerts = numVerts;
|
||||||
|
|
||||||
mesh->indices.reserve( numTris * 3 );
|
mesh->mIndices.reserve( numTris * 3 );
|
||||||
for ( S32 i = 0; i < numTris; i++ )
|
for ( S32 i = 0; i < numTris; i++ )
|
||||||
{
|
{
|
||||||
mesh->indices.push_back( indices[i*3 + 0] );
|
mesh->mIndices.push_back( indices[i*3 + 0] );
|
||||||
mesh->indices.push_back( indices[i*3 + 2] );
|
mesh->mIndices.push_back( indices[i*3 + 2] );
|
||||||
mesh->indices.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->indices.size(); iInd += 3)
|
for (S32 iInd = 0; iInd < mesh->mIndices.size(); iInd += 3)
|
||||||
{
|
{
|
||||||
// Compute the normal for this triangle
|
// Compute the normal for this triangle
|
||||||
S32 idx0 = mesh->indices[iInd + 0];
|
S32 idx0 = mesh->mIndices[iInd + 0];
|
||||||
S32 idx1 = mesh->indices[iInd + 1];
|
S32 idx1 = mesh->mIndices[iInd + 1];
|
||||||
S32 idx2 = mesh->indices[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->indices.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;
|
||||||
}
|
}
|
||||||
|
|
@ -792,10 +792,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] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -569,8 +569,8 @@ void TSShape::initVertexFeatures()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hasColors |= !mesh->colors.empty();
|
hasColors |= !mesh->mColors.empty();
|
||||||
hasTexcoord2 |= !mesh->tverts2.empty();
|
hasTexcoord2 |= !mesh->mTVerts2.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -676,11 +676,11 @@ void TSShape::initMaterialList()
|
||||||
|
|
||||||
mHasSkinMesh |= mesh->getMeshType() == TSMesh::SkinMeshType;
|
mHasSkinMesh |= mesh->getMeshType() == TSMesh::SkinMeshType;
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -690,7 +690,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)
|
||||||
|
|
@ -1175,15 +1175,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)
|
||||||
{
|
{
|
||||||
|
|
@ -1271,9 +1271,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();
|
||||||
|
|
@ -1448,15 +1448,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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1326,7 +1326,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
|
||||||
|
|
@ -1363,10 +1363,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();
|
||||||
|
|
|
||||||
|
|
@ -900,11 +900,11 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
|
||||||
return mesh; // return an empty mesh
|
return mesh; // return an empty mesh
|
||||||
|
|
||||||
// Copy mesh elements
|
// Copy mesh elements
|
||||||
mesh->indices = srcMesh->indices;
|
mesh->mIndices = srcMesh->mIndices;
|
||||||
mesh->primitives = srcMesh->primitives;
|
mesh->mPrimitives = srcMesh->mPrimitives;
|
||||||
mesh->numFrames = srcMesh->numFrames;
|
mesh->mNumFrames = srcMesh->mNumFrames;
|
||||||
mesh->numMatFrames = srcMesh->numMatFrames;
|
mesh->mNumMatFrames = srcMesh->mNumMatFrames;
|
||||||
mesh->vertsPerFrame = srcMesh->vertsPerFrame;
|
mesh->mVertsPerFrame = srcMesh->mVertsPerFrame;
|
||||||
mesh->setFlags(srcMesh->getFlags());
|
mesh->setFlags(srcMesh->getFlags());
|
||||||
mesh->mHasColor = srcMesh->mHasColor;
|
mesh->mHasColor = srcMesh->mHasColor;
|
||||||
mesh->mHasTVert2 = srcMesh->mHasTVert2;
|
mesh->mHasTVert2 = srcMesh->mHasTVert2;
|
||||||
|
|
@ -936,14 +936,14 @@ TSMesh* TSShape::copyMesh( const TSMesh* srcMesh ) const
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mesh->verts = srcMesh->verts;
|
mesh->mVerts = srcMesh->mVerts;
|
||||||
mesh->tverts = srcMesh->tverts;
|
mesh->mTVerts = srcMesh->mTVerts;
|
||||||
mesh->tverts2 = srcMesh->tverts2;
|
mesh->mTVerts2 = srcMesh->mTVerts2;
|
||||||
mesh->colors = srcMesh->colors;
|
mesh->mColors = srcMesh->mColors;
|
||||||
mesh->norms = srcMesh->norms;
|
mesh->mNorms = srcMesh->mNorms;
|
||||||
|
|
||||||
mesh->createTangents(mesh->verts, mesh->norms);
|
mesh->createTangents(mesh->mVerts, mesh->mNorms);
|
||||||
mesh->encodedNorms.set(NULL,0);
|
mesh->mEncodedNorms.set(NULL,0);
|
||||||
|
|
||||||
mesh->convertToAlignedMeshData();
|
mesh->convertToAlignedMeshData();
|
||||||
}
|
}
|
||||||
|
|
@ -1103,12 +1103,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
|
||||||
|
|
@ -1119,7 +1119,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ public:
|
||||||
void disassemble();
|
void disassemble();
|
||||||
|
|
||||||
TSSortedMesh() {
|
TSSortedMesh() {
|
||||||
meshType = SortedMeshType;
|
mMeshType = SortedMeshType;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue