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

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

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