Переглянути джерело

Fix a bug in the GLTF importer

Panagiotis Christopoulos Charitos 5 роки тому
батько
коміт
cc8fbe998e

+ 11 - 3
src/anki/importer/GltfImporter.cpp

@@ -217,6 +217,12 @@ Error GltfImporter::writeAll()
 	}
 	}
 
 
 	// Check error
 	// Check error
+	if(err)
+	{
+		ANKI_GLTF_LOGE("Error happened in main thread");
+		return err;
+	}
+
 	const Error threadErr = m_errorInThread.load();
 	const Error threadErr = m_errorInThread.load();
 	if(threadErr)
 	if(threadErr)
 	{
 	{
@@ -764,10 +770,12 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh, CString skinName)
 		ANKI_CHECK(file.writeText("\t\t\t<mesh2>%s%s.ankimesh</mesh2>\n", m_rpath.cstr(), name.cstr()));
 		ANKI_CHECK(file.writeText("\t\t\t<mesh2>%s%s.ankimesh</mesh2>\n", m_rpath.cstr(), name.cstr()));
 	}
 	}
 
 
-	auto mtlOverride = extras.find("material_override");
-	if(mtlOverride != extras.getEnd())
+	HashMapAuto<CString, StringAuto> materialExtras(m_alloc);
+	ANKI_CHECK(getExtras(mesh.primitives[0].material->extras, materialExtras));
+	auto mtlOverride = materialExtras.find("material_override");
+	if(mtlOverride != materialExtras.getEnd())
 	{
 	{
-		ANKI_CHECK(file.writeText("\t\t\t<material>%s%s</material>\n", m_rpath.cstr(), mtlOverride->cstr()));
+		ANKI_CHECK(file.writeText("\t\t\t<material>%s</material>\n", mtlOverride->cstr()));
 	}
 	}
 	else
 	else
 	{
 	{

+ 1 - 1
src/anki/importer/GltfImporterMesh.cpp

@@ -368,7 +368,7 @@ Error GltfImporter::writeMesh(const cgltf_mesh& mesh, CString nameOverride, F32
 
 
 		aabbMin = aabbMin.min(submesh.m_aabbMin);
 		aabbMin = aabbMin.min(submesh.m_aabbMin);
 		// Bump aabbMax a bit
 		// Bump aabbMax a bit
-		submesh.m_aabbMax += EPSILON + 10.0f;
+		submesh.m_aabbMax += EPSILON * 10.0f;
 		aabbMax = aabbMax.max(submesh.m_aabbMax);
 		aabbMax = aabbMax.max(submesh.m_aabbMax);
 
 
 		//
 		//