mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Fix for Issue #130 for Decals and Smoothing Groups
This commit is contained in:
parent
9a76293991
commit
a803398eb0
|
|
@ -827,6 +827,8 @@ bool TSStatic::buildPolyList(PolyListContext context, AbstractPolyList* polyList
|
|||
return false;
|
||||
else if ( meshType == Bounds )
|
||||
polyList->addBox( mObjBox );
|
||||
else if ( meshType == VisibleMesh )
|
||||
mShapeInstance->buildPolyList( polyList, 0 );
|
||||
else
|
||||
{
|
||||
// Everything else is done from the collision meshes
|
||||
|
|
|
|||
|
|
@ -157,6 +157,11 @@ public:
|
|||
/// an ID number for that point.
|
||||
virtual U32 addPoint(const Point3F& p) = 0;
|
||||
|
||||
/// Adds a point and normal to the poly list, and returns
|
||||
/// an ID number for them. Normals are ignored for polylists
|
||||
/// that do not support them.
|
||||
virtual U32 addPointAndNormal(const Point3F& p, const Point3F& normal) { return addPoint( p ); }
|
||||
|
||||
/// Adds a plane to the poly list, and returns
|
||||
/// an ID number for that point.
|
||||
virtual U32 addPlane(const PlaneF& plane) = 0;
|
||||
|
|
|
|||
|
|
@ -74,6 +74,11 @@ bool ClippedPolyList::isEmpty() const
|
|||
//----------------------------------------------------------------------------
|
||||
|
||||
U32 ClippedPolyList::addPoint(const Point3F& p)
|
||||
{
|
||||
return addPointAndNormal( p, Point3F::Zero );
|
||||
}
|
||||
|
||||
U32 ClippedPolyList::addPointAndNormal(const Point3F& p, const Point3F& normal)
|
||||
{
|
||||
mVertexList.increment();
|
||||
Vertex& v = mVertexList.last();
|
||||
|
|
@ -82,6 +87,14 @@ U32 ClippedPolyList::addPoint(const Point3F& p)
|
|||
v.point.z = p.z * mScale.z;
|
||||
mMatrix.mulP(v.point);
|
||||
|
||||
mNormalList.increment();
|
||||
VectorF& n = mNormalList.last();
|
||||
n = normal;
|
||||
if ( !n.isZero() )
|
||||
mMatrix.mulV(n);
|
||||
|
||||
AssertFatal(mNormalList.size() == mVertexList.size(), "Normals count does not match vertex count!");
|
||||
|
||||
// Build the plane mask
|
||||
register U32 mask = 1;
|
||||
register S32 count = mPlaneList.size();
|
||||
|
|
@ -242,6 +255,13 @@ void ClippedPolyList::end()
|
|||
VectorF vv = v2 - v1;
|
||||
F32 t = -mPlaneList[p].distToPlane(v1) / mDot(mPlaneList[p],vv);
|
||||
|
||||
mNormalList.increment();
|
||||
VectorF& n1 = mNormalList[mIndexList[i1]];
|
||||
VectorF& n2 = mNormalList[mIndexList[i1]];
|
||||
VectorF nn = mLerp( n1, n2, t );
|
||||
nn.normalizeSafe();
|
||||
mNormalList.last() = nn;
|
||||
|
||||
mIndexList.push_back/*_noresize*/(mVertexList.size() - 1);
|
||||
Vertex& iv = mVertexList.last();
|
||||
iv.point.x = v1.x + vv.x * t;
|
||||
|
|
@ -343,12 +363,14 @@ void ClippedPolyList::cullUnusedVerts()
|
|||
if ( !result )
|
||||
{
|
||||
mVertexList.setSize( i );
|
||||
mNormalList.setSize( i );
|
||||
break;
|
||||
}
|
||||
|
||||
// Erase unused verts.
|
||||
numDeleted = (k-1) - i + 1;
|
||||
mVertexList.erase( i, numDeleted );
|
||||
mNormalList.erase( i, numDeleted );
|
||||
|
||||
// Find any references to vertices after those deleted
|
||||
// in the mIndexList and correct with an offset
|
||||
|
|
@ -407,7 +429,7 @@ void ClippedPolyList::generateNormals()
|
|||
{
|
||||
PROFILE_SCOPE( ClippedPolyList_GenerateNormals );
|
||||
|
||||
mNormalList.setSize( mVertexList.size() );
|
||||
AssertFatal(mNormalList.size() == mVertexList.size(), "Normals count does not match vertex count!");
|
||||
|
||||
U32 i, polyCount;
|
||||
VectorF normal;
|
||||
|
|
@ -418,6 +440,10 @@ void ClippedPolyList::generateNormals()
|
|||
U32 n = 0;
|
||||
for ( ; normalIter != mNormalList.end(); normalIter++, n++ )
|
||||
{
|
||||
// Skip normals that already have values.
|
||||
if ( !normalIter->isZero() )
|
||||
continue;
|
||||
|
||||
// Average all the face normals which
|
||||
// share this vertex index.
|
||||
indexIter = mIndexList.begin();
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ public:
|
|||
// AbstractPolyList
|
||||
bool isEmpty() const;
|
||||
U32 addPoint(const Point3F& p);
|
||||
U32 addPointAndNormal(const Point3F& p, const Point3F& normal);
|
||||
U32 addPlane(const PlaneF& plane);
|
||||
void begin(BaseMatInstance* material,U32 surfaceKey);
|
||||
void plane(U32 v1,U32 v2,U32 v3);
|
||||
|
|
|
|||
|
|
@ -322,9 +322,11 @@ bool TSMesh::buildPolyList( S32 frame, AbstractPolyList *polyList, U32 &surfaceK
|
|||
}
|
||||
else
|
||||
{
|
||||
base = polyList->addPoint( mVertexData[firstVert].vert() );
|
||||
base = polyList->addPointAndNormal( mVertexData[firstVert].vert(), mVertexData[firstVert].normal() );
|
||||
for ( i = 1; i < vertsPerFrame; i++ )
|
||||
polyList->addPoint( mVertexData[ i + firstVert ].vert() );
|
||||
{
|
||||
polyList->addPointAndNormal( mVertexData[ i + firstVert ].vert(), mVertexData[ i + firstVert ].normal() );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -348,9 +350,9 @@ bool TSMesh::buildPolyList( S32 frame, AbstractPolyList *polyList, U32 &surfaceK
|
|||
}
|
||||
else
|
||||
{
|
||||
base = polyList->addPoint( verts[firstVert] );
|
||||
base = polyList->addPointAndNormal( verts[firstVert], norms[firstVert] );
|
||||
for ( i = 1; i < vertsPerFrame; i++ )
|
||||
polyList->addPoint( verts[ i + firstVert ] );
|
||||
polyList->addPointAndNormal( verts[ i + firstVert ], norms[ i + firstVert ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue