mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Revert recent style cleanup changes.
This commit is contained in:
parent
a73850a4bb
commit
84e8cbb4ee
62 changed files with 3380 additions and 3380 deletions
|
|
@ -204,18 +204,18 @@ void MeshFit::initSourceGeometry( const String& target )
|
|||
{
|
||||
// Add all geometry in the highest detail level
|
||||
S32 dl = 0;
|
||||
S32 ss = mShape->mDetails[dl].subShapeNum;
|
||||
S32 ss = mShape->details[dl].subShapeNum;
|
||||
if ( ss < 0 )
|
||||
return;
|
||||
|
||||
S32 od = mShape->mDetails[dl].objectDetailNum;
|
||||
S32 start = mShape->mSubShapeFirstObject[ss];
|
||||
S32 end = start + mShape->mSubShapeNumObjects[ss];
|
||||
S32 od = mShape->details[dl].objectDetailNum;
|
||||
S32 start = mShape->subShapeFirstObject[ss];
|
||||
S32 end = start + mShape->subShapeNumObjects[ss];
|
||||
|
||||
for ( S32 i = start; i < end; i++ )
|
||||
{
|
||||
const TSShape::Object &obj = mShape->mObjects[i];
|
||||
const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->mMeshes[obj.startMeshIndex + od] : NULL;
|
||||
const TSShape::Object &obj = mShape->objects[i];
|
||||
const TSMesh* mesh = ( od < obj.numMeshes ) ? mShape->meshes[obj.startMeshIndex + od] : NULL;
|
||||
if ( mesh )
|
||||
addSourceMesh( obj, mesh );
|
||||
}
|
||||
|
|
@ -227,10 +227,10 @@ void MeshFit::initSourceGeometry( const String& target )
|
|||
if ( objIndex == -1 )
|
||||
return;
|
||||
|
||||
const TSShape::Object &obj = mShape->mObjects[objIndex];
|
||||
const TSShape::Object &obj = mShape->objects[objIndex];
|
||||
for ( S32 i = 0; i < obj.numMeshes; i++ )
|
||||
{
|
||||
const TSMesh* mesh = mShape->mMeshes[obj.startMeshIndex + i];
|
||||
const TSMesh* mesh = mShape->meshes[obj.startMeshIndex + i];
|
||||
if ( mesh )
|
||||
{
|
||||
addSourceMesh( obj, mesh );
|
||||
|
|
@ -246,24 +246,24 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
|
|||
{
|
||||
// Add indices
|
||||
S32 indicesBase = mIndices.size();
|
||||
for ( S32 i = 0; i < mesh->mPrimitives.size(); i++ )
|
||||
for ( S32 i = 0; i < mesh->primitives.size(); i++ )
|
||||
{
|
||||
const TSDrawPrimitive& draw = mesh->mPrimitives[i];
|
||||
const TSDrawPrimitive& draw = mesh->primitives[i];
|
||||
if ( (draw.matIndex & TSDrawPrimitive::TypeMask) == TSDrawPrimitive::Triangles )
|
||||
{
|
||||
mIndices.merge( &mesh->mIndices[draw.start], draw.numElements );
|
||||
mIndices.merge( &mesh->indices[draw.start], draw.numElements );
|
||||
}
|
||||
else
|
||||
{
|
||||
U32 idx0 = mesh->mIndices[draw.start + 0];
|
||||
U32 idx0 = mesh->indices[draw.start + 0];
|
||||
U32 idx1;
|
||||
U32 idx2 = mesh->mIndices[draw.start + 1];
|
||||
U32 idx2 = mesh->indices[draw.start + 1];
|
||||
U32 *nextIdx = &idx1;
|
||||
for ( S32 j = 2; j < draw.numElements; j++ )
|
||||
{
|
||||
*nextIdx = idx2;
|
||||
nextIdx = (U32*) ( (dsize_t)nextIdx ^ (dsize_t)&idx0 ^ (dsize_t)&idx1);
|
||||
idx2 = mesh->mIndices[draw.start + j];
|
||||
idx2 = mesh->indices[draw.start + j];
|
||||
if ( idx0 == idx1 || idx0 == idx2 || idx1 == idx2 )
|
||||
continue;
|
||||
|
||||
|
|
@ -290,9 +290,9 @@ void MeshFit::addSourceMesh( const TSShape::Object& obj, const TSMesh* mesh )
|
|||
}
|
||||
else
|
||||
{
|
||||
count = mesh->mVerts.size();
|
||||
count = mesh->verts.size();
|
||||
stride = sizeof(Point3F);
|
||||
pVert = (U8*)mesh->mVerts.address();
|
||||
pVert = (U8*)mesh->verts.address();
|
||||
}
|
||||
|
||||
MatrixF objMat;
|
||||
|
|
@ -310,82 +310,82 @@ TSMesh* MeshFit::initMeshFromFile( const String& filename ) const
|
|||
{
|
||||
// Open the source shape file and make a copy of the mesh
|
||||
Resource<TSShape> hShape = ResourceManager::get().load(filename);
|
||||
if (!bool(hShape) || !((TSShape*)hShape)->mMeshes.size())
|
||||
if (!bool(hShape) || !((TSShape*)hShape)->meshes.size())
|
||||
{
|
||||
Con::errorf("TSShape::createMesh: Could not load source mesh from %s", filename.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TSMesh* srcMesh = ((TSShape*)hShape)->mMeshes[0];
|
||||
TSMesh* srcMesh = ((TSShape*)hShape)->meshes[0];
|
||||
return mShape->copyMesh( srcMesh );
|
||||
}
|
||||
|
||||
TSMesh* MeshFit::createTriMesh( F32* verts, S32 numVerts, U32* indices, S32 numTris ) const
|
||||
{
|
||||
TSMesh* mesh = mShape->copyMesh( NULL );
|
||||
mesh->mNumFrames = 1;
|
||||
mesh->mNumMatFrames = 1;
|
||||
mesh->mVertsPerFrame = numVerts;
|
||||
mesh->numFrames = 1;
|
||||
mesh->numMatFrames = 1;
|
||||
mesh->vertsPerFrame = numVerts;
|
||||
mesh->setFlags(0);
|
||||
mesh->mHasColor = false;
|
||||
mesh->mHasTVert2 = false;
|
||||
mesh->mNumVerts = numVerts;
|
||||
|
||||
mesh->mIndices.reserve( numTris * 3 );
|
||||
mesh->indices.reserve( numTris * 3 );
|
||||
for ( S32 i = 0; i < numTris; i++ )
|
||||
{
|
||||
mesh->mIndices.push_back( indices[i*3 + 0] );
|
||||
mesh->mIndices.push_back( indices[i*3 + 2] );
|
||||
mesh->mIndices.push_back( indices[i*3 + 1] );
|
||||
mesh->indices.push_back( indices[i*3 + 0] );
|
||||
mesh->indices.push_back( indices[i*3 + 2] );
|
||||
mesh->indices.push_back( indices[i*3 + 1] );
|
||||
}
|
||||
|
||||
mesh->mVerts.set( verts, numVerts );
|
||||
mesh->verts.set( verts, numVerts );
|
||||
|
||||
// Compute mesh normals
|
||||
mesh->mNorms.setSize( mesh->mVerts.size() );
|
||||
for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
|
||||
mesh->mNorms[iNorm] = Point3F::Zero;
|
||||
mesh->norms.setSize( mesh->verts.size() );
|
||||
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++)
|
||||
mesh->norms[iNorm] = Point3F::Zero;
|
||||
|
||||
// Sum triangle normals for each vertex
|
||||
for (S32 iInd = 0; iInd < mesh->mIndices.size(); iInd += 3)
|
||||
for (S32 iInd = 0; iInd < mesh->indices.size(); iInd += 3)
|
||||
{
|
||||
// Compute the normal for this triangle
|
||||
S32 idx0 = mesh->mIndices[iInd + 0];
|
||||
S32 idx1 = mesh->mIndices[iInd + 1];
|
||||
S32 idx2 = mesh->mIndices[iInd + 2];
|
||||
S32 idx0 = mesh->indices[iInd + 0];
|
||||
S32 idx1 = mesh->indices[iInd + 1];
|
||||
S32 idx2 = mesh->indices[iInd + 2];
|
||||
|
||||
const Point3F& v0 = mesh->mVerts[idx0];
|
||||
const Point3F& v1 = mesh->mVerts[idx1];
|
||||
const Point3F& v2 = mesh->mVerts[idx2];
|
||||
const Point3F& v0 = mesh->verts[idx0];
|
||||
const Point3F& v1 = mesh->verts[idx1];
|
||||
const Point3F& v2 = mesh->verts[idx2];
|
||||
|
||||
Point3F n;
|
||||
mCross(v2 - v0, v1 - v0, &n);
|
||||
n.normalize(); // remove this to use 'weighted' normals (large triangles will have more effect)
|
||||
|
||||
mesh->mNorms[idx0] += n;
|
||||
mesh->mNorms[idx1] += n;
|
||||
mesh->mNorms[idx2] += n;
|
||||
mesh->norms[idx0] += n;
|
||||
mesh->norms[idx1] += n;
|
||||
mesh->norms[idx2] += n;
|
||||
}
|
||||
|
||||
// Normalize the vertex normals (this takes care of averaging the triangle normals)
|
||||
for (S32 iNorm = 0; iNorm < mesh->mNorms.size(); iNorm++)
|
||||
mesh->mNorms[iNorm].normalize();
|
||||
for (S32 iNorm = 0; iNorm < mesh->norms.size(); iNorm++)
|
||||
mesh->norms[iNorm].normalize();
|
||||
|
||||
// Set some dummy UVs
|
||||
mesh->mTVerts.setSize( numVerts );
|
||||
for ( S32 j = 0; j < mesh->mTVerts.size(); j++ )
|
||||
mesh->mTVerts[j].set( 0, 0 );
|
||||
mesh->tverts.setSize( numVerts );
|
||||
for ( S32 j = 0; j < mesh->tverts.size(); j++ )
|
||||
mesh->tverts[j].set( 0, 0 );
|
||||
|
||||
// Add a single triangle-list primitive
|
||||
mesh->mPrimitives.increment();
|
||||
mesh->mPrimitives.last().start = 0;
|
||||
mesh->mPrimitives.last().numElements = mesh->mIndices.size();
|
||||
mesh->mPrimitives.last().matIndex = TSDrawPrimitive::Triangles |
|
||||
mesh->primitives.increment();
|
||||
mesh->primitives.last().start = 0;
|
||||
mesh->primitives.last().numElements = mesh->indices.size();
|
||||
mesh->primitives.last().matIndex = TSDrawPrimitive::Triangles |
|
||||
TSDrawPrimitive::Indexed |
|
||||
TSDrawPrimitive::NoMaterial;
|
||||
|
||||
mesh->createTangents( mesh->mVerts, mesh->mNorms );
|
||||
mesh->mEncodedNorms.set( NULL,0 );
|
||||
mesh->createTangents( mesh->verts, mesh->norms );
|
||||
mesh->encodedNorms.set( NULL,0 );
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
|
@ -792,10 +792,10 @@ DefineTSShapeConstructorMethod( addPrimitive, bool, ( const char* meshName, cons
|
|||
}
|
||||
else
|
||||
{
|
||||
for (S32 i = 0; i < mesh->mVerts.size(); i++)
|
||||
for (S32 i = 0; i < mesh->verts.size(); i++)
|
||||
{
|
||||
Point3F v(mesh->mVerts[i]);
|
||||
mat.mulP( v, &mesh->mVerts[i] );
|
||||
Point3F v(mesh->verts[i]);
|
||||
mat.mulP( v, &mesh->verts[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue