Fix .x material slot parsing

Co-authored-by: hecktest <>
This commit is contained in:
hecks 2021-07-29 05:05:34 +02:00 committed by GitHub
parent ae81dbd942
commit 6c78f181b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 12 deletions

View File

@ -89,7 +89,6 @@ IAnimatedMesh* CXMeshFileLoader::createMesh(io::IReadFile* file)
P=0;
End=0;
CurFrame=0;
TemplateMaterials.clear();
delete [] Buffer;
Buffer = 0;
@ -519,6 +518,11 @@ bool CXMeshFileLoader::parseDataObject()
return parseDataObjectAnimationTicksPerSecond();
}
else
if (objectName == "Material")
{
return parseUnknownDataObject();
}
else
if (objectName == "}")
{
os::Printer::log("} found in dataObject", ELL_WARNING);
@ -1455,12 +1459,17 @@ bool CXMeshFileLoader::parseDataObjectMeshMaterialList(SXMesh &mesh)
{
// template materials now available thanks to joeWright
objectName = getNextToken();
for (u32 i=0; i<TemplateMaterials.size(); ++i)
if (TemplateMaterials[i].Name == objectName)
mesh.Materials.push_back(TemplateMaterials[i].Material);
mesh.Materials.push_back(video::SMaterial());
getNextToken(); // skip }
}
else
if (objectName == "Material")
{
mesh.Materials.push_back(video::SMaterial());
if (!parseUnknownDataObject())
return false;
}
else
if (objectName == ";")
{
// ignore

View File

@ -39,12 +39,6 @@ public:
//! See IReferenceCounted::drop() for more information.
virtual IAnimatedMesh* createMesh(io::IReadFile* file) _IRR_OVERRIDE_;
struct SXTemplateMaterial
{
core::stringc Name; // template name from Xfile
video::SMaterial Material; // material
};
struct SXMesh
{
SXMesh() : MaxSkinWeightsPerVertex(0), MaxSkinWeightsPerFace(0), BoneCount(0),AttachedJointID(-1),HasSkinning(false), HasVertexColors(false) {}
@ -182,8 +176,6 @@ private:
core::array<SXMesh*> Meshes;
core::array<SXTemplateMaterial> TemplateMaterials;
u32 MajorVersion;
u32 MinorVersion;
bool BinaryFormat;