Fixes primitive assignment. AppMesh::primitives in this case is a purely collada/dts concept and is not indices or faces. Any mesh with more than 2^16 vertices should be split into multiple primitives to avoid indexing across a 16 bit boundary. Mesh division into primitives has not been implemented for assimp yet.

This commit is contained in:
OTHGMars 2019-03-28 04:16:22 -04:00
parent 2658debeb0
commit 08431347ea

View file

@ -132,7 +132,7 @@ void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
}
U32 numFaces = mMeshData->mNumFaces;
primitives.reserve(numFaces);
//primitives.reserve(numFaces);
//Fetch the number of indices
U32 indicesCount = 0;
@ -143,19 +143,18 @@ void AssimpAppMesh::lockMesh(F32 t, const MatrixF& objOffset)
indices.reserve(indicesCount);
// Create TSMesh primitive
primitives.increment();
TSDrawPrimitive& primitive = primitives.last();
primitive.start = 0;
primitive.matIndex = (TSDrawPrimitive::Triangles | TSDrawPrimitive::Indexed) | (S32)mMeshData->mMaterialIndex;
primitive.numElements = indicesCount;
for ( U32 n = 0; n < mMeshData->mNumFaces; ++n)
{
const struct aiFace* face = &mMeshData->mFaces[n];
if ( face->mNumIndices == 3 )
{
// Create TSMesh primitive
primitives.increment();
TSDrawPrimitive& primitive = primitives.last();
primitive.start = indices.size();
primitive.matIndex = (TSDrawPrimitive::Triangles | TSDrawPrimitive::Indexed) | (S32)mMeshData->mMaterialIndex;
//primitive.numElements = face->mNumIndices;//3;
primitive.numElements = 3;
if (Con::getBoolVariable("$Assimp::FlipNormals", true))
{
U32 indexCount = face->mNumIndices;