PE: Support normal generation when using assimp importer.
This commit is contained in:
@@ -248,18 +248,6 @@ bool ProcessMesh(ImportedModelData& result, AssimpImporterData& data, const aiMe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normals
|
|
||||||
if (aMesh->mNormals)
|
|
||||||
{
|
|
||||||
mesh.Normals.Set((const Float3*)aMesh->mNormals, aMesh->mNumVertices);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tangents
|
|
||||||
if (aMesh->mTangents)
|
|
||||||
{
|
|
||||||
mesh.Tangents.Set((const Float3*)aMesh->mTangents, aMesh->mNumVertices);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indices
|
// Indices
|
||||||
const int32 indicesCount = aMesh->mNumFaces * 3;
|
const int32 indicesCount = aMesh->mNumFaces * 3;
|
||||||
mesh.Indices.Resize(indicesCount, false);
|
mesh.Indices.Resize(indicesCount, false);
|
||||||
@@ -277,6 +265,27 @@ bool ProcessMesh(ImportedModelData& result, AssimpImporterData& data, const aiMe
|
|||||||
mesh.Indices[i++] = face->mIndices[2];
|
mesh.Indices[i++] = face->mIndices[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normals
|
||||||
|
if (data.Options.CalculateNormals || !aMesh->mNormals)
|
||||||
|
{
|
||||||
|
// Support generation of normals when using assimp.
|
||||||
|
if (mesh.GenerateNormals(data.Options.SmoothingNormalsAngle))
|
||||||
|
{
|
||||||
|
errorMsg = TEXT("Failed to generate normals.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (aMesh->mNormals)
|
||||||
|
{
|
||||||
|
mesh.Normals.Set((const Float3*)aMesh->mNormals, aMesh->mNumVertices);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tangents
|
||||||
|
if (aMesh->mTangents)
|
||||||
|
{
|
||||||
|
mesh.Tangents.Set((const Float3*)aMesh->mTangents, aMesh->mNumVertices);
|
||||||
|
}
|
||||||
|
|
||||||
// Lightmap UVs
|
// Lightmap UVs
|
||||||
if (data.Options.LightmapUVsSource == ModelLightmapUVsSource::Disable)
|
if (data.Options.LightmapUVsSource == ModelLightmapUVsSource::Disable)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user