|
|
@@ -149,8 +149,7 @@ static Bool stringsExist(const ImporterHashMap<CString, ImporterString>& map, co
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-GltfImporter::GltfImporter(BaseMemoryPool* pool)
|
|
|
- : m_pool(pool)
|
|
|
+GltfImporter::GltfImporter()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -162,7 +161,7 @@ GltfImporter::~GltfImporter()
|
|
|
m_gltf = nullptr;
|
|
|
}
|
|
|
|
|
|
- deleteInstance(*m_pool, m_jobManager);
|
|
|
+ deleteInstance(ImporterMemoryPool::getSingleton(), m_jobManager);
|
|
|
}
|
|
|
|
|
|
Error GltfImporter::init(const GltfImporterInitInfo& initInfo)
|
|
|
@@ -211,7 +210,7 @@ Error GltfImporter::init(const GltfImporterInitInfo& initInfo)
|
|
|
if(initInfo.m_threadCount > 0)
|
|
|
{
|
|
|
const U32 threadCount = min(getCpuCoresCount(), initInfo.m_threadCount);
|
|
|
- m_jobManager = newInstance<ThreadJobManager>(*m_pool, threadCount, true);
|
|
|
+ m_jobManager = newInstance<ThreadJobManager>(ImporterMemoryPool::getSingleton(), threadCount, true);
|
|
|
}
|
|
|
|
|
|
m_importTextures = initInfo.m_importTextures;
|
|
|
@@ -223,7 +222,7 @@ Error GltfImporter::writeAll()
|
|
|
{
|
|
|
populateNodePtrToIdx();
|
|
|
|
|
|
- ImporterString sceneFname(m_pool);
|
|
|
+ ImporterString sceneFname;
|
|
|
sceneFname.sprintf("%sScene.lua", m_outDir.cstr());
|
|
|
ANKI_CHECK(m_sceneFile.open(sceneFname.toCString(), FileOpenFlag::kWrite));
|
|
|
ANKI_CHECK(m_sceneFile.writeTextf("-- Generated by: %s\n", m_comment.cstr()));
|
|
|
@@ -234,7 +233,7 @@ Error GltfImporter::writeAll()
|
|
|
{
|
|
|
for(cgltf_node* const* node = scene->nodes; node < scene->nodes + scene->nodes_count; ++node)
|
|
|
{
|
|
|
- ANKI_CHECK(visitNode(*(*node), Transform::getIdentity(), ImporterHashMap<CString, ImporterString>(m_pool)));
|
|
|
+ ANKI_CHECK(visitNode(*(*node), Transform::getIdentity(), ImporterHashMap<CString, ImporterString>()));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -357,7 +356,7 @@ Error GltfImporter::writeAll()
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
-Error GltfImporter::getExtras(const cgltf_extras& extras, ImporterHashMap<CString, ImporterString>& out) const
|
|
|
+Error GltfImporter::appendExtras(const cgltf_extras& extras, ImporterHashMap<CString, ImporterString>& out) const
|
|
|
{
|
|
|
cgltf_size extrasSize;
|
|
|
cgltf_copy_extras_json(m_gltf, &extras, nullptr, &extrasSize);
|
|
|
@@ -366,7 +365,7 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, ImporterHashMap<CStrin
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
- ImporterDynamicArrayLarge<char> json(m_pool);
|
|
|
+ ImporterDynamicArrayLarge<char> json;
|
|
|
json.resize(extrasSize + 1);
|
|
|
cgltf_result res = cgltf_copy_extras_json(m_gltf, &extras, &json[0], &extrasSize);
|
|
|
if(res != cgltf_result_success)
|
|
|
@@ -387,14 +386,14 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, ImporterHashMap<CStrin
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
- ImporterDynamicArray<jsmntok_t> tokens(m_pool);
|
|
|
+ ImporterDynamicArray<jsmntok_t> tokens;
|
|
|
tokens.resize(U32(tokenCount));
|
|
|
|
|
|
// Get tokens
|
|
|
jsmn_init(&parser);
|
|
|
jsmn_parse(&parser, jsonTxt.cstr(), jsonTxt.getLength(), &tokens[0], tokens.getSize());
|
|
|
|
|
|
- ImporterStringList tokenStrings(m_pool);
|
|
|
+ ImporterStringList tokenStrings;
|
|
|
for(const jsmntok_t& token : tokens)
|
|
|
{
|
|
|
if(token.type != JSMN_STRING && token.type != JSMN_PRIMITIVE)
|
|
|
@@ -402,14 +401,14 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, ImporterHashMap<CStrin
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- ImporterString tokenStr(&jsonTxt[token.start], &jsonTxt[token.end], m_pool);
|
|
|
+ ImporterString tokenStr(&jsonTxt[token.start], &jsonTxt[token.end]);
|
|
|
tokenStrings.pushBack(tokenStr.toCString());
|
|
|
}
|
|
|
|
|
|
if((tokenStrings.getSize() % 2) != 0)
|
|
|
{
|
|
|
- ANKI_IMPORTER_LOGE("Unable to parse: %s", jsonTxt.cstr());
|
|
|
- return Error::kFunctionFailed;
|
|
|
+ ANKI_IMPORTER_LOGV("Ignoring: %s", jsonTxt.cstr());
|
|
|
+ return Error::kNone;
|
|
|
}
|
|
|
|
|
|
// Write them to the map
|
|
|
@@ -419,7 +418,7 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, ImporterHashMap<CStrin
|
|
|
auto it2 = it;
|
|
|
++it2;
|
|
|
|
|
|
- out.emplace(it->toCString(), ImporterString(it2->toCString(), m_pool));
|
|
|
+ out.emplace(it->toCString(), ImporterString(it2->toCString()));
|
|
|
++it;
|
|
|
++it;
|
|
|
}
|
|
|
@@ -427,6 +426,15 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, ImporterHashMap<CStrin
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
+static void appendExtrasMap(const ImporterHashMap<CString, ImporterString>& in, ImporterHashMap<CString, ImporterString>& out)
|
|
|
+{
|
|
|
+ auto& outs = out.getSparseArray();
|
|
|
+ for(auto it = in.getBegin(); it != in.getEnd(); ++it)
|
|
|
+ {
|
|
|
+ outs.emplace(it.getKey(), *it);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
void GltfImporter::populateNodePtrToIdxInternal(const cgltf_node& node, U32& idx)
|
|
|
{
|
|
|
m_nodePtrToIdx.emplace(&node, idx++);
|
|
|
@@ -452,7 +460,7 @@ void GltfImporter::populateNodePtrToIdx()
|
|
|
|
|
|
ImporterString GltfImporter::getNodeName(const cgltf_node& node) const
|
|
|
{
|
|
|
- ImporterString out(m_pool);
|
|
|
+ ImporterString out;
|
|
|
|
|
|
if(node.name)
|
|
|
{
|
|
|
@@ -470,7 +478,7 @@ ImporterString GltfImporter::getNodeName(const cgltf_node& node) const
|
|
|
|
|
|
Error GltfImporter::parseArrayOfNumbers(CString str, ImporterDynamicArray<F64>& out, const U32* expectedArraySize)
|
|
|
{
|
|
|
- ImporterStringList list(m_pool);
|
|
|
+ ImporterStringList list;
|
|
|
list.splitString(str, ' ');
|
|
|
|
|
|
out.resize(U32(list.getSize()));
|
|
|
@@ -508,10 +516,15 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
return threadErr;
|
|
|
}
|
|
|
|
|
|
- ImporterHashMap<CString, ImporterString> outExtras(m_pool);
|
|
|
+ ImporterHashMap<CString, ImporterString> outExtras;
|
|
|
if(node.light)
|
|
|
{
|
|
|
- ANKI_CHECK(writeLight(node, parentExtras));
|
|
|
+ ImporterHashMap<CString, ImporterString> extras;
|
|
|
+ ANKI_CHECK(appendExtras(node.light->extras, extras));
|
|
|
+ ANKI_CHECK(appendExtras(node.extras, extras));
|
|
|
+ appendExtrasMap(parentExtras, extras);
|
|
|
+
|
|
|
+ ANKI_CHECK(writeLight(node, extras));
|
|
|
|
|
|
Transform localTrf;
|
|
|
ANKI_CHECK(getNodeTransform(node, localTrf));
|
|
|
@@ -520,7 +533,12 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
}
|
|
|
else if(node.camera)
|
|
|
{
|
|
|
- ANKI_CHECK(writeCamera(node, parentExtras));
|
|
|
+ ImporterHashMap<CString, ImporterString> extras;
|
|
|
+ ANKI_CHECK(appendExtras(node.camera->extras, extras));
|
|
|
+ ANKI_CHECK(appendExtras(node.extras, extras));
|
|
|
+ appendExtrasMap(parentExtras, extras);
|
|
|
+
|
|
|
+ ANKI_CHECK(writeCamera(node, extras));
|
|
|
|
|
|
Transform localTrf;
|
|
|
ANKI_CHECK(getNodeTransform(node, localTrf));
|
|
|
@@ -530,9 +548,10 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
else if(node.mesh)
|
|
|
{
|
|
|
// Handle special nodes
|
|
|
- ImporterHashMap<CString, ImporterString> extras(parentExtras);
|
|
|
- ANKI_CHECK(getExtras(node.mesh->extras, extras));
|
|
|
- ANKI_CHECK(getExtras(node.extras, extras));
|
|
|
+ ImporterHashMap<CString, ImporterString> extras;
|
|
|
+ ANKI_CHECK(appendExtras(node.mesh->extras, extras));
|
|
|
+ ANKI_CHECK(appendExtras(node.extras, extras));
|
|
|
+ appendExtrasMap(parentExtras, extras);
|
|
|
|
|
|
ImporterHashMap<CString, ImporterString>::Iterator it;
|
|
|
|
|
|
@@ -568,7 +587,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
|
|
|
if((it = extras.find("skybox_solid_color")) != extras.getEnd())
|
|
|
{
|
|
|
- ImporterStringList tokens(m_pool);
|
|
|
+ ImporterStringList tokens;
|
|
|
tokens.splitString(*it, ' ');
|
|
|
if(tokens.getSize() != 3)
|
|
|
{
|
|
|
@@ -699,13 +718,13 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
}
|
|
|
else if((it = extras.find("decal")) != extras.getEnd() && (*it == "true" || *it == "1"))
|
|
|
{
|
|
|
- ImporterString diffuseAtlas(m_pool);
|
|
|
+ ImporterString diffuseAtlas;
|
|
|
if((it = extras.find("decal_diffuse_atlas")) != extras.getEnd())
|
|
|
{
|
|
|
diffuseAtlas = *it;
|
|
|
}
|
|
|
|
|
|
- ImporterString diffuseSubtexture(m_pool);
|
|
|
+ ImporterString diffuseSubtexture;
|
|
|
if((it = extras.find("decal_diffuse_sub_texture")) != extras.getEnd())
|
|
|
{
|
|
|
diffuseSubtexture = *it;
|
|
|
@@ -717,13 +736,13 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
ANKI_CHECK(it->toNumber(diffuseFactor));
|
|
|
}
|
|
|
|
|
|
- ImporterString specularRougnessMetallicAtlas(m_pool);
|
|
|
+ ImporterString specularRougnessMetallicAtlas;
|
|
|
if((it = extras.find("decal_specular_roughness_metallic_atlas")) != extras.getEnd())
|
|
|
{
|
|
|
specularRougnessMetallicAtlas = *it;
|
|
|
}
|
|
|
|
|
|
- ImporterString specularRougnessMetallicSubtexture(m_pool);
|
|
|
+ ImporterString specularRougnessMetallicSubtexture;
|
|
|
if((it = extras.find("decal_specular_roughness_metallic_sub_texture")) != extras.getEnd())
|
|
|
{
|
|
|
specularRougnessMetallicSubtexture = *it;
|
|
|
@@ -761,44 +780,52 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
|
|
|
const Bool skipRt = (it = extras.find("no_rt")) != extras.getEnd() && (*it == "true" || *it == "1");
|
|
|
|
|
|
- addRequest<const cgltf_mesh*>(node.mesh, m_meshImportRequests);
|
|
|
- for(U32 i = 0; i < node.mesh->primitives_count; ++i)
|
|
|
- {
|
|
|
- const MaterialImportRequest req = {node.mesh->primitives[i].material, !skipRt};
|
|
|
- addRequest<MaterialImportRequest>(req, m_materialImportRequests);
|
|
|
- }
|
|
|
+ Transform localTrf;
|
|
|
+ const Error err = getNodeTransform(node, localTrf);
|
|
|
|
|
|
- if(node.skin)
|
|
|
+ if(err)
|
|
|
{
|
|
|
- addRequest<const cgltf_skin*>(node.skin, m_skinImportRequests);
|
|
|
+ ANKI_IMPORTER_LOGE("Will skip node: %s", getNodeName(node).cstr());
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ addRequest<const cgltf_mesh*>(node.mesh, m_meshImportRequests);
|
|
|
+ for(U32 i = 0; i < node.mesh->primitives_count; ++i)
|
|
|
+ {
|
|
|
+ const MaterialImportRequest req = {node.mesh->primitives[i].material, !skipRt};
|
|
|
+ addRequest<MaterialImportRequest>(req, m_materialImportRequests);
|
|
|
+ }
|
|
|
|
|
|
- addRequest<const cgltf_mesh*>(node.mesh, m_modelImportRequests);
|
|
|
+ if(node.skin)
|
|
|
+ {
|
|
|
+ addRequest<const cgltf_skin*>(node.skin, m_skinImportRequests);
|
|
|
+ }
|
|
|
|
|
|
- ImporterHashMap<CString, ImporterString>::Iterator it2;
|
|
|
- const Bool selfCollision = (it2 = extras.find("collision_mesh")) != extras.getEnd() && *it2 == "self";
|
|
|
+ addRequest<const cgltf_mesh*>(node.mesh, m_modelImportRequests);
|
|
|
|
|
|
- ANKI_CHECK(writeModelNode(node, parentExtras));
|
|
|
+ ImporterHashMap<CString, ImporterString>::Iterator it2;
|
|
|
+ const Bool selfCollision = (it2 = extras.find("collision_mesh")) != extras.getEnd() && *it2 == "self";
|
|
|
|
|
|
- Transform localTrf;
|
|
|
- ANKI_CHECK(getNodeTransform(node, localTrf));
|
|
|
- ANKI_CHECK(writeTransform(parentTrf.combineTransformations(localTrf)));
|
|
|
+ ANKI_CHECK(writeModelNode(node, parentExtras));
|
|
|
|
|
|
- if(selfCollision)
|
|
|
- {
|
|
|
- ANKI_CHECK(m_sceneFile.writeText("comp = node:newBodyComponent()\n"));
|
|
|
+ ANKI_CHECK(writeTransform(parentTrf.combineTransformations(localTrf)));
|
|
|
|
|
|
- const ImporterString meshFname = computeMeshResourceFilename(*node.mesh);
|
|
|
+ if(selfCollision)
|
|
|
+ {
|
|
|
+ ANKI_CHECK(m_sceneFile.writeText("comp = node:newBodyComponent()\n"));
|
|
|
+
|
|
|
+ const ImporterString meshFname = computeMeshResourceFilename(*node.mesh);
|
|
|
|
|
|
- ANKI_CHECK(m_sceneFile.writeText("comp:setMeshFromModelComponent()\n"));
|
|
|
- ANKI_CHECK(m_sceneFile.writeText("comp:teleportTo(trf)\n"));
|
|
|
+ ANKI_CHECK(m_sceneFile.writeText("comp:setMeshFromModelComponent()\n"));
|
|
|
+ ANKI_CHECK(m_sceneFile.writeText("comp:teleportTo(trf)\n"));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ANKI_IMPORTER_LOGV("Ignoring node %s. Assuming transform node", getNodeName(node).cstr());
|
|
|
- ANKI_CHECK(getExtras(node.extras, outExtras));
|
|
|
+ ANKI_CHECK(appendExtras(node.extras, outExtras));
|
|
|
}
|
|
|
|
|
|
// Visit children
|
|
|
@@ -843,11 +870,11 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh) const
|
|
|
const ImporterString modelFname = computeModelResourceFilename(mesh);
|
|
|
ANKI_IMPORTER_LOGV("Importing model %s", modelFname.cstr());
|
|
|
|
|
|
- ImporterHashMap<CString, ImporterString> extras(m_pool);
|
|
|
- ANKI_CHECK(getExtras(mesh.extras, extras));
|
|
|
+ ImporterHashMap<CString, ImporterString> extras;
|
|
|
+ ANKI_CHECK(appendExtras(mesh.extras, extras));
|
|
|
|
|
|
File file;
|
|
|
- ImporterString modelFullFname(m_pool);
|
|
|
+ ImporterString modelFullFname;
|
|
|
modelFullFname.sprintf("%s/%s", m_outDir.cstr(), modelFname.cstr());
|
|
|
ANKI_CHECK(file.open(modelFullFname, FileOpenFlag::kWrite));
|
|
|
|
|
|
@@ -868,8 +895,8 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh) const
|
|
|
ANKI_CHECK(file.writeTextf("\t\t\t<mesh subMeshIndex=\"%u\">%s%s</mesh>\n", primIdx, m_rpath.cstr(), meshFname.cstr()));
|
|
|
}
|
|
|
|
|
|
- ImporterHashMap<CString, ImporterString> materialExtras(m_pool);
|
|
|
- ANKI_CHECK(getExtras(mesh.primitives[primIdx].material->extras, materialExtras));
|
|
|
+ ImporterHashMap<CString, ImporterString> materialExtras;
|
|
|
+ ANKI_CHECK(appendExtras(mesh.primitives[primIdx].material->extras, materialExtras));
|
|
|
auto mtlOverride = materialExtras.find("material_override");
|
|
|
if(mtlOverride != materialExtras.getEnd())
|
|
|
{
|
|
|
@@ -893,12 +920,12 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh) const
|
|
|
|
|
|
Error GltfImporter::writeSkeleton(const cgltf_skin& skin) const
|
|
|
{
|
|
|
- ImporterString fname(m_pool);
|
|
|
+ ImporterString fname;
|
|
|
fname.sprintf("%s%s", m_outDir.cstr(), computeSkeletonResourceFilename(skin).cstr());
|
|
|
ANKI_IMPORTER_LOGV("Importing skeleton %s", fname.cstr());
|
|
|
|
|
|
// Get matrices
|
|
|
- ImporterDynamicArray<Mat4> boneMats(m_pool);
|
|
|
+ ImporterDynamicArray<Mat4> boneMats;
|
|
|
readAccessor(*skin.inverse_bind_matrices, boneMats);
|
|
|
if(boneMats.getSize() != skin.joints_count)
|
|
|
{
|
|
|
@@ -917,7 +944,7 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin) const
|
|
|
{
|
|
|
const cgltf_node& boneNode = *skin.joints[i];
|
|
|
|
|
|
- ImporterString parent(m_pool);
|
|
|
+ ImporterString parent;
|
|
|
|
|
|
// Name & parent
|
|
|
ANKI_CHECK(file.writeTextf("\t\t<bone name=\"%s\" ", getNodeName(boneNode).cstr()));
|
|
|
@@ -964,8 +991,8 @@ Error GltfImporter::writeLight(const cgltf_node& node, const ImporterHashMap<CSt
|
|
|
ANKI_IMPORTER_LOGV("Importing light %s", nodeName.cstr());
|
|
|
|
|
|
ImporterHashMap<CString, ImporterString> extras(parentExtras);
|
|
|
- ANKI_CHECK(getExtras(light.extras, extras));
|
|
|
- ANKI_CHECK(getExtras(node.extras, extras));
|
|
|
+ ANKI_CHECK(appendExtras(light.extras, extras));
|
|
|
+ ANKI_CHECK(appendExtras(node.extras, extras));
|
|
|
|
|
|
CString lightTypeStr;
|
|
|
switch(light.type)
|
|
|
@@ -1049,7 +1076,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const ImporterHashMap<CSt
|
|
|
|
|
|
if(lsSpriteSize != extras.getEnd())
|
|
|
{
|
|
|
- ImporterDynamicArray<F64> numbers(m_pool);
|
|
|
+ ImporterDynamicArray<F64> numbers;
|
|
|
const U32 count = 2;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lsSpriteSize->toCString(), numbers, &count));
|
|
|
|
|
|
@@ -1058,7 +1085,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const ImporterHashMap<CSt
|
|
|
|
|
|
if(lsColor != extras.getEnd())
|
|
|
{
|
|
|
- ImporterDynamicArray<F64> numbers(m_pool);
|
|
|
+ ImporterDynamicArray<F64> numbers;
|
|
|
const U32 count = 4;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
|
|
|
|
|
|
@@ -1075,7 +1102,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const ImporterHashMap<CSt
|
|
|
|
|
|
if(lightEventIntensity != extras.getEnd())
|
|
|
{
|
|
|
- ImporterDynamicArray<F64> numbers(m_pool);
|
|
|
+ ImporterDynamicArray<F64> numbers;
|
|
|
const U32 count = 4;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
|
|
|
ANKI_CHECK(
|
|
|
@@ -1084,7 +1111,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const ImporterHashMap<CSt
|
|
|
|
|
|
if(lightEventFrequency != extras.getEnd())
|
|
|
{
|
|
|
- ImporterDynamicArray<F64> numbers(m_pool);
|
|
|
+ ImporterDynamicArray<F64> numbers;
|
|
|
const U32 count = 2;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lightEventFrequency->toCString(), numbers, &count));
|
|
|
ANKI_CHECK(m_sceneFile.writeTextf("event:setFrequency(%f, %f)\n", numbers[0], numbers[1]));
|
|
|
@@ -1120,7 +1147,7 @@ Error GltfImporter::writeModelNode(const cgltf_node& node, const ImporterHashMap
|
|
|
ANKI_IMPORTER_LOGV("Importing model node %s", getNodeName(node).cstr());
|
|
|
|
|
|
ImporterHashMap<CString, ImporterString> extras(parentExtras);
|
|
|
- ANKI_CHECK(getExtras(node.extras, extras));
|
|
|
+ ANKI_CHECK(appendExtras(node.extras, extras));
|
|
|
|
|
|
const ImporterString modelFname = computeModelResourceFilename(*node.mesh);
|
|
|
|
|
|
@@ -1138,7 +1165,7 @@ Error GltfImporter::writeModelNode(const cgltf_node& node, const ImporterHashMap
|
|
|
|
|
|
ImporterString GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh) const
|
|
|
{
|
|
|
- ImporterStringList list(m_pool);
|
|
|
+ ImporterStringList list;
|
|
|
|
|
|
list.pushBack(mesh.name);
|
|
|
|
|
|
@@ -1148,12 +1175,12 @@ ImporterString GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh
|
|
|
list.pushBackSprintf("_%s", mtlName);
|
|
|
}
|
|
|
|
|
|
- ImporterString joined(m_pool);
|
|
|
+ ImporterString joined;
|
|
|
list.join("", joined);
|
|
|
|
|
|
const U64 hash = computeHash(joined.getBegin(), joined.getLength());
|
|
|
|
|
|
- ImporterString out(m_pool);
|
|
|
+ ImporterString out;
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankimdl", joined.cstr(), hash); // Limit the filename size
|
|
|
|
|
|
return out;
|
|
|
@@ -1162,7 +1189,7 @@ ImporterString GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh
|
|
|
ImporterString GltfImporter::computeMeshResourceFilename(const cgltf_mesh& mesh) const
|
|
|
{
|
|
|
const U64 hash = computeHash(mesh.name, strlen(mesh.name));
|
|
|
- ImporterString out(m_pool);
|
|
|
+ ImporterString out;
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankimesh", mesh.name, hash); // Limit the filename size
|
|
|
return out;
|
|
|
}
|
|
|
@@ -1171,7 +1198,7 @@ ImporterString GltfImporter::computeMaterialResourceFilename(const cgltf_materia
|
|
|
{
|
|
|
const U64 hash = computeHash(mtl.name, strlen(mtl.name));
|
|
|
|
|
|
- ImporterString out(m_pool);
|
|
|
+ ImporterString out;
|
|
|
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankimtl", mtl.name, hash); // Limit the filename size
|
|
|
|
|
|
@@ -1182,7 +1209,7 @@ ImporterString GltfImporter::computeAnimationResourceFilename(const cgltf_animat
|
|
|
{
|
|
|
const U64 hash = computeHash(anim.name, strlen(anim.name));
|
|
|
|
|
|
- ImporterString out(m_pool);
|
|
|
+ ImporterString out;
|
|
|
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankianim", anim.name, hash); // Limit the filename size
|
|
|
|
|
|
@@ -1193,7 +1220,7 @@ ImporterString GltfImporter::computeSkeletonResourceFilename(const cgltf_skin& s
|
|
|
{
|
|
|
const U64 hash = computeHash(skin.name, strlen(skin.name));
|
|
|
|
|
|
- ImporterString out(m_pool);
|
|
|
+ ImporterString out;
|
|
|
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankiskel", skin.name, hash); // Limit the filename size
|
|
|
|