develop
kaetemi 4 years ago
parent c6f8baa058
commit bb03f80d84
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -775,9 +775,8 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM)
{ {
uint maxVertices = meshSkinManager->getMaxVertices(); uint maxVertices = meshSkinManager->getMaxVertices();
uint vertexSize = meshSkinManager->getVertexSize(); uint vertexSize = meshSkinManager->getVertexSize();
nlassert(vertexSize == 32);
if (_OriginalSkinVertices.size() <= maxVertices) if (maxVertices >= _OriginalSkinVertices.size() && vertexSize == 32)
{ {
// apply the skinning // apply the skinning
uint8 *dstVb = meshSkinManager->lock(); uint8 *dstVb = meshSkinManager->lock();
@ -787,7 +786,7 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM)
else else
{ {
supportVertexStream = false; supportVertexStream = false;
nlwarning("Unable to animate skinned model, too many vertices"); nlwarning("Unable to animate skinned model, too many vertices, or stream format unsupported");
} }
} }
else else
@ -795,9 +794,6 @@ void CMeshGeom::renderSkin(CTransformShape *trans, float alphaMRM)
nlwarning("Unable to animate skinned model, unsupported vertex format"); nlwarning("Unable to animate skinned model, unsupported vertex format");
} }
// apply the skinning: _VBuffer is modified.
// applySkin(skeleton);
// Setup meshVertexProgram // Setup meshVertexProgram
//=========== //===========
@ -1837,26 +1833,13 @@ void CMeshGeom::applySkin(void *dstVb, CSkeletonModel *skeleton)
return; return;
// Use correct skinning // Use correct skinning
TSkinType skinType; nlassert(!_OriginalSkinNormals.empty());
if( _OriginalSkinNormals.empty() ) nlassert(_OriginalTGSpace.empty());
skinType= SkinPosOnly;
else if( _OriginalTGSpace.empty() )
skinType= SkinWithNormal;
else
skinType= SkinWithTgSpace;
nlassert(skinType == SkinWithNormal); // Only support the streamable vertex buffer format
// Get VB src/dst info/ptrs. // Get VB src/dst info/ptrs.
uint numVertices= (uint)_OriginalSkinVertices.size(); uint numVertices= (uint)_OriginalSkinVertices.size();
static const uint dstStride = 32; // _VBuffer.getVertexSize(); static const uint dstStride = 32; // _VBuffer.getVertexSize();
uint srcStride = _VBuffer.getVertexSize(); uint srcStride = _VBuffer.getVertexSize();
// Get dst TgSpace.
uint tgSpaceStage = 0;
if( skinType>= SkinWithTgSpace)
{
nlassert(_VBuffer.getNumTexCoordUsed() > 0);
tgSpaceStage= _VBuffer.getNumTexCoordUsed() - 1;
}
// Mark all vertices flag to not computed. // Mark all vertices flag to not computed.
static vector<uint8> skinFlags; static vector<uint8> skinFlags;
@ -1887,24 +1870,10 @@ void CMeshGeom::applySkin(void *dstVb, CSkeletonModel *skeleton)
CVector *srcVector= &_OriginalSkinVertices[0]; CVector *srcVector= &_OriginalSkinVertices[0];
uint8 *srcPal= (uint8*)vba.getPaletteSkinPointer(0); uint8 *srcPal= (uint8*)vba.getPaletteSkinPointer(0);
uint8 *srcWgt= (uint8*)vba.getWeightPointer(0); uint8 *srcWgt= (uint8*)vba.getWeightPointer(0);
uint8 *dstVector = dstVbPos; // (uint8 *)vba.getVertexCoordPointer(0); uint8 *dstVector = dstVbPos;
// Normal. // Normal.
CVector *srcNormal= NULL; CVector *srcNormal= &_OriginalSkinNormals[0];
uint8 *dstNormal= NULL; uint8 *dstNormal = dstVbNormal;
if(skinType>=SkinWithNormal)
{
srcNormal= &_OriginalSkinNormals[0];
dstNormal = dstVbNormal; // (uint8 *)vba.getNormalCoordPointer(0);
}
// TgSpace.
CVector *srcTgSpace= NULL;
uint8 *dstTgSpace= NULL;
if(skinType>=SkinWithTgSpace)
{
nlassert(false);
srcTgSpace= &_OriginalTGSpace[0];
dstTgSpace = (uint8 *)vba.getTexCoordPointer(0, tgSpaceStage);
}
// For all vertices that need to be computed. // For all vertices that need to be computed.
uint size= numVertices; uint size= numVertices;
@ -1928,12 +1897,7 @@ void CMeshGeom::applySkin(void *dstVb, CSkeletonModel *skeleton)
computeSoftwarePointSkinning(matrixes, srcVector, psPal, (float*)srcWgt, (CVector*)dstVector); computeSoftwarePointSkinning(matrixes, srcVector, psPal, (float*)srcWgt, (CVector*)dstVector);
// compute normal part. // compute normal part.
if(skinType>=SkinWithNormal)
computeSoftwareVectorSkinning(matrixes, srcNormal, psPal, (float*)srcWgt, (CVector*)dstNormal); computeSoftwareVectorSkinning(matrixes, srcNormal, psPal, (float*)srcWgt, (CVector*)dstNormal);
// compute tg part.
if(skinType>=SkinWithTgSpace)
computeSoftwareVectorSkinning(matrixes, srcTgSpace, psPal, (float*)srcWgt, (CVector*)dstTgSpace);
} }
// inc flags. // inc flags.
@ -1941,13 +1905,11 @@ void CMeshGeom::applySkin(void *dstVb, CSkeletonModel *skeleton)
// inc src (all whatever skin type used...) // inc src (all whatever skin type used...)
srcVector++; srcVector++;
srcNormal++; srcNormal++;
srcTgSpace++;
// inc paletteSkin and dst (all whatever skin type used...) // inc paletteSkin and dst (all whatever skin type used...)
srcPal+= srcStride; srcPal+= srcStride;
srcWgt+= srcStride; srcWgt+= srcStride;
dstVector+= dstStride; dstVector+= dstStride;
dstNormal+= dstStride; dstNormal+= dstStride;
dstTgSpace+= dstStride;
} }
} }
@ -1983,9 +1945,6 @@ void CMeshGeom::applySkin(void *dstVb, CSkeletonModel *skeleton)
dstUV += dstStride; dstUV += dstStride;
} }
} }
// dirt
_OriginalSkinRestored= false;
} }

Loading…
Cancel
Save