|
|
@@ -136,7 +136,7 @@ static Error getNodeTransform(const cgltf_node& node, Transform& trf)
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
-static Bool stringsExist(const HashMapAuto<CString, StringAuto>& map, const std::initializer_list<CString>& list)
|
|
|
+static Bool stringsExist(const HashMapAuto<CString, StringRaii>& map, const std::initializer_list<CString>& list)
|
|
|
{
|
|
|
for(CString item : list)
|
|
|
{
|
|
|
@@ -221,7 +221,7 @@ Error GltfImporter::writeAll()
|
|
|
{
|
|
|
populateNodePtrToIdx();
|
|
|
|
|
|
- StringAuto sceneFname(m_alloc);
|
|
|
+ StringRaii sceneFname(m_alloc);
|
|
|
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()));
|
|
|
@@ -233,7 +233,7 @@ Error GltfImporter::writeAll()
|
|
|
{
|
|
|
for(cgltf_node* const* node = scene->nodes; node < scene->nodes + scene->nodes_count && !err; ++node)
|
|
|
{
|
|
|
- err = visitNode(*(*node), Transform::getIdentity(), HashMapAuto<CString, StringAuto>(m_alloc));
|
|
|
+ err = visitNode(*(*node), Transform::getIdentity(), HashMapAuto<CString, StringRaii>(m_alloc));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -264,7 +264,7 @@ Error GltfImporter::writeAll()
|
|
|
return err;
|
|
|
}
|
|
|
|
|
|
-Error GltfImporter::getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out)
|
|
|
+Error GltfImporter::getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringRaii>& out)
|
|
|
{
|
|
|
cgltf_size extrasSize;
|
|
|
cgltf_copy_extras_json(m_gltf, &extras, nullptr, &extrasSize);
|
|
|
@@ -273,7 +273,7 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, HashMapAuto<CString, S
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
- DynamicArrayAuto<char, PtrSize> json(m_alloc);
|
|
|
+ DynamicArrayRaii<char, PtrSize> json(m_alloc);
|
|
|
json.create(extrasSize + 1);
|
|
|
cgltf_result res = cgltf_copy_extras_json(m_gltf, &extras, &json[0], &extrasSize);
|
|
|
if(res != cgltf_result_success)
|
|
|
@@ -294,14 +294,14 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, HashMapAuto<CString, S
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
- DynamicArrayAuto<jsmntok_t> tokens(m_alloc);
|
|
|
+ DynamicArrayRaii<jsmntok_t> tokens(m_alloc);
|
|
|
tokens.create(U32(tokenCount));
|
|
|
|
|
|
// Get tokens
|
|
|
jsmn_init(&parser);
|
|
|
jsmn_parse(&parser, jsonTxt.cstr(), jsonTxt.getLength(), &tokens[0], tokens.getSize());
|
|
|
|
|
|
- StringListAuto tokenStrings(m_alloc);
|
|
|
+ StringListRaii tokenStrings(m_alloc);
|
|
|
for(const jsmntok_t& token : tokens)
|
|
|
{
|
|
|
if(token.type != JSMN_STRING && token.type != JSMN_PRIMITIVE)
|
|
|
@@ -309,7 +309,7 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, HashMapAuto<CString, S
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- StringAuto tokenStr(m_alloc);
|
|
|
+ StringRaii tokenStr(m_alloc);
|
|
|
tokenStr.create(&jsonTxt[token.start], &jsonTxt[token.end]);
|
|
|
tokenStrings.pushBack(tokenStr.toCString());
|
|
|
}
|
|
|
@@ -327,7 +327,7 @@ Error GltfImporter::getExtras(const cgltf_extras& extras, HashMapAuto<CString, S
|
|
|
auto it2 = it;
|
|
|
++it2;
|
|
|
|
|
|
- out.emplace(it->toCString(), StringAuto(m_alloc, it2->toCString()));
|
|
|
+ out.emplace(it->toCString(), StringRaii(m_alloc, it2->toCString()));
|
|
|
++it;
|
|
|
++it;
|
|
|
}
|
|
|
@@ -358,9 +358,9 @@ void GltfImporter::populateNodePtrToIdx()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-StringAuto GltfImporter::getNodeName(const cgltf_node& node)
|
|
|
+StringRaii GltfImporter::getNodeName(const cgltf_node& node)
|
|
|
{
|
|
|
- StringAuto out(m_alloc);
|
|
|
+ StringRaii out(m_alloc);
|
|
|
|
|
|
if(node.name)
|
|
|
{
|
|
|
@@ -376,9 +376,9 @@ StringAuto GltfImporter::getNodeName(const cgltf_node& node)
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-Error GltfImporter::parseArrayOfNumbers(CString str, DynamicArrayAuto<F64>& out, const U32* expectedArraySize)
|
|
|
+Error GltfImporter::parseArrayOfNumbers(CString str, DynamicArrayRaii<F64>& out, const U32* expectedArraySize)
|
|
|
{
|
|
|
- StringListAuto list(m_alloc);
|
|
|
+ StringListRaii list(m_alloc);
|
|
|
list.splitString(str, ' ');
|
|
|
|
|
|
out.create(U32(list.getSize()));
|
|
|
@@ -408,7 +408,7 @@ Error GltfImporter::parseArrayOfNumbers(CString str, DynamicArrayAuto<F64>& out,
|
|
|
}
|
|
|
|
|
|
Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf,
|
|
|
- const HashMapAuto<CString, StringAuto>& parentExtras)
|
|
|
+ const HashMapAuto<CString, StringRaii>& parentExtras)
|
|
|
{
|
|
|
// Check error from a thread
|
|
|
const Error threadErr = m_errorInThread.load();
|
|
|
@@ -418,7 +418,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
return threadErr;
|
|
|
}
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto> outExtras(m_alloc);
|
|
|
+ HashMapAuto<CString, StringRaii> outExtras(m_alloc);
|
|
|
if(node.light)
|
|
|
{
|
|
|
ANKI_CHECK(writeLight(node, parentExtras));
|
|
|
@@ -440,17 +440,17 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
else if(node.mesh)
|
|
|
{
|
|
|
// Handle special nodes
|
|
|
- HashMapAuto<CString, StringAuto> extras(parentExtras);
|
|
|
+ HashMapAuto<CString, StringRaii> extras(parentExtras);
|
|
|
ANKI_CHECK(getExtras(node.mesh->extras, extras));
|
|
|
ANKI_CHECK(getExtras(node.extras, extras));
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto>::Iterator it;
|
|
|
+ HashMapAuto<CString, StringRaii>::Iterator it;
|
|
|
|
|
|
const Bool skipRt = (it = extras.find("no_rt")) != extras.getEnd() && (*it == "true" || *it == "1");
|
|
|
|
|
|
if((it = extras.find("particles")) != extras.getEnd())
|
|
|
{
|
|
|
- const StringAuto& fname = *it;
|
|
|
+ const StringRaii& fname = *it;
|
|
|
|
|
|
Bool gpuParticles = false;
|
|
|
if((it = extras.find("gpu_particles")) != extras.getEnd() && *it == "true")
|
|
|
@@ -479,7 +479,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
|
|
|
if((it = extras.find("skybox_solid_color")) != extras.getEnd())
|
|
|
{
|
|
|
- StringListAuto tokens(m_alloc);
|
|
|
+ StringListRaii tokens(m_alloc);
|
|
|
tokens.splitString(*it, ' ');
|
|
|
if(tokens.getSize() != 3)
|
|
|
{
|
|
|
@@ -548,7 +548,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
m_sceneFile.writeTextf("\nnode = scene:newStaticCollisionNode(\"%s\")\n", getNodeName(node).cstr()));
|
|
|
|
|
|
ANKI_CHECK(m_sceneFile.writeText("comp = scene:getSceneNodeBase():getBodyComponent()\n"));
|
|
|
- const StringAuto meshFname = computeMeshResourceFilename(*node.mesh);
|
|
|
+ const StringRaii meshFname = computeMeshResourceFilename(*node.mesh);
|
|
|
ANKI_CHECK(m_sceneFile.writeTextf("comp:loadMeshResource(\"%s%s\")\n", m_rpath.cstr(), meshFname.cstr()));
|
|
|
|
|
|
Transform localTrf;
|
|
|
@@ -616,13 +616,13 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
}
|
|
|
else if((it = extras.find("decal")) != extras.getEnd() && (*it == "true" || *it == "1"))
|
|
|
{
|
|
|
- StringAuto diffuseAtlas(m_alloc);
|
|
|
+ StringRaii diffuseAtlas(m_alloc);
|
|
|
if((it = extras.find("decal_diffuse_atlas")) != extras.getEnd())
|
|
|
{
|
|
|
diffuseAtlas.create(it->toCString());
|
|
|
}
|
|
|
|
|
|
- StringAuto diffuseSubtexture(m_alloc);
|
|
|
+ StringRaii diffuseSubtexture(m_alloc);
|
|
|
if((it = extras.find("decal_diffuse_sub_texture")) != extras.getEnd())
|
|
|
{
|
|
|
diffuseSubtexture.create(it->toCString());
|
|
|
@@ -634,13 +634,13 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
ANKI_CHECK(it->toNumber(diffuseFactor));
|
|
|
}
|
|
|
|
|
|
- StringAuto specularRougnessMetallicAtlas(m_alloc);
|
|
|
+ StringRaii specularRougnessMetallicAtlas(m_alloc);
|
|
|
if((it = extras.find("decal_specular_roughness_metallic_atlas")) != extras.getEnd())
|
|
|
{
|
|
|
specularRougnessMetallicAtlas.create(it->toCString());
|
|
|
}
|
|
|
|
|
|
- StringAuto specularRougnessMetallicSubtexture(m_alloc);
|
|
|
+ StringRaii specularRougnessMetallicSubtexture(m_alloc);
|
|
|
if((it = extras.find("decal_specular_roughness_metallic_sub_texture")) != extras.getEnd())
|
|
|
{
|
|
|
specularRougnessMetallicSubtexture.create(it->toCString());
|
|
|
@@ -698,7 +698,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
ctx->m_skin = node.skin;
|
|
|
ctx->m_rayTracing = !skipRt;
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto>::Iterator it2;
|
|
|
+ HashMapAuto<CString, StringRaii>::Iterator it2;
|
|
|
const Bool selfCollision = (it2 = extras.find("collision_mesh")) != extras.getEnd() && *it2 == "self";
|
|
|
|
|
|
U32 maxLod = 0;
|
|
|
@@ -781,7 +781,7 @@ Error GltfImporter::visitNode(const cgltf_node& node, const Transform& parentTrf
|
|
|
|
|
|
ANKI_CHECK(m_sceneFile.writeText("comp = node2:getSceneNodeBase():getBodyComponent()\n"));
|
|
|
|
|
|
- const StringAuto meshFname = computeMeshResourceFilename(*node.mesh, maxLod);
|
|
|
+ const StringRaii meshFname = computeMeshResourceFilename(*node.mesh, maxLod);
|
|
|
|
|
|
ANKI_CHECK(
|
|
|
m_sceneFile.writeTextf("comp:loadMeshResource(\"%s%s\")\n", m_rpath.cstr(), meshFname.cstr()));
|
|
|
@@ -835,14 +835,14 @@ Error GltfImporter::writeTransform(const Transform& trf)
|
|
|
|
|
|
Error GltfImporter::writeModel(const cgltf_mesh& mesh)
|
|
|
{
|
|
|
- const StringAuto modelFname = computeModelResourceFilename(mesh);
|
|
|
+ const StringRaii modelFname = computeModelResourceFilename(mesh);
|
|
|
ANKI_IMPORTER_LOGV("Importing model %s", modelFname.cstr());
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto> extras(m_alloc);
|
|
|
+ HashMapAuto<CString, StringRaii> extras(m_alloc);
|
|
|
ANKI_CHECK(getExtras(mesh.extras, extras));
|
|
|
|
|
|
File file;
|
|
|
- StringAuto modelFullFname(m_alloc);
|
|
|
+ StringRaii modelFullFname(m_alloc);
|
|
|
modelFullFname.sprintf("%s/%s", m_outDir.cstr(), modelFname.cstr());
|
|
|
ANKI_CHECK(file.open(modelFullFname, FileOpenFlag::kWrite));
|
|
|
|
|
|
@@ -861,23 +861,23 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh)
|
|
|
}
|
|
|
|
|
|
{
|
|
|
- const StringAuto meshFname = computeMeshResourceFilename(mesh);
|
|
|
+ const StringRaii meshFname = computeMeshResourceFilename(mesh);
|
|
|
ANKI_CHECK(file.writeTextf("\t\t\t<mesh>%s%s</mesh>\n", m_rpath.cstr(), meshFname.cstr()));
|
|
|
}
|
|
|
|
|
|
if(m_lodCount > 1 && !skipMeshLod(mesh, 1))
|
|
|
{
|
|
|
- const StringAuto meshFname = computeMeshResourceFilename(mesh, 1);
|
|
|
+ const StringRaii meshFname = computeMeshResourceFilename(mesh, 1);
|
|
|
ANKI_CHECK(file.writeTextf("\t\t\t<mesh1>%s%s</mesh1>\n", m_rpath.cstr(), meshFname.cstr()));
|
|
|
}
|
|
|
|
|
|
if(m_lodCount > 2 && !skipMeshLod(mesh, 2))
|
|
|
{
|
|
|
- const StringAuto meshFname = computeMeshResourceFilename(mesh, 2);
|
|
|
+ const StringRaii meshFname = computeMeshResourceFilename(mesh, 2);
|
|
|
ANKI_CHECK(file.writeTextf("\t\t\t<mesh2>%s%s</mesh2>\n", m_rpath.cstr(), meshFname.cstr()));
|
|
|
}
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto> materialExtras(m_alloc);
|
|
|
+ HashMapAuto<CString, StringRaii> materialExtras(m_alloc);
|
|
|
ANKI_CHECK(getExtras(mesh.primitives[primIdx].material->extras, materialExtras));
|
|
|
auto mtlOverride = materialExtras.find("material_override");
|
|
|
if(mtlOverride != materialExtras.getEnd())
|
|
|
@@ -886,7 +886,7 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- const StringAuto mtlFname = computeMaterialResourceFilename(*mesh.primitives[primIdx].material);
|
|
|
+ const StringRaii mtlFname = computeMaterialResourceFilename(*mesh.primitives[primIdx].material);
|
|
|
ANKI_CHECK(file.writeTextf("\t\t\t<material>%s%s</material>\n", m_rpath.cstr(), mtlFname.cstr()));
|
|
|
}
|
|
|
|
|
|
@@ -902,12 +902,12 @@ Error GltfImporter::writeModel(const cgltf_mesh& mesh)
|
|
|
|
|
|
Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
|
|
|
{
|
|
|
- StringAuto fname(m_alloc);
|
|
|
+ StringRaii fname(m_alloc);
|
|
|
fname.sprintf("%s%s", m_outDir.cstr(), computeSkeletonResourceFilename(skin).cstr());
|
|
|
ANKI_IMPORTER_LOGV("Importing skeleton %s", fname.cstr());
|
|
|
|
|
|
// Get matrices
|
|
|
- DynamicArrayAuto<Mat4> boneMats(m_alloc);
|
|
|
+ DynamicArrayRaii<Mat4> boneMats(m_alloc);
|
|
|
readAccessor(*skin.inverse_bind_matrices, boneMats);
|
|
|
if(boneMats.getSize() != skin.joints_count)
|
|
|
{
|
|
|
@@ -926,7 +926,7 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
|
|
|
{
|
|
|
const cgltf_node& boneNode = *skin.joints[i];
|
|
|
|
|
|
- StringAuto parent(m_alloc);
|
|
|
+ StringRaii parent(m_alloc);
|
|
|
|
|
|
// Name & parent
|
|
|
ANKI_CHECK(file.writeTextf("\t\t<bone name=\"%s\" ", getNodeName(boneNode).cstr()));
|
|
|
@@ -965,13 +965,13 @@ Error GltfImporter::writeSkeleton(const cgltf_skin& skin)
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
-Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras)
|
|
|
+Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString, StringRaii>& parentExtras)
|
|
|
{
|
|
|
const cgltf_light& light = *node.light;
|
|
|
- StringAuto nodeName = getNodeName(node);
|
|
|
+ StringRaii nodeName = getNodeName(node);
|
|
|
ANKI_IMPORTER_LOGV("Importing light %s", nodeName.cstr());
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto> extras(parentExtras);
|
|
|
+ HashMapAuto<CString, StringRaii> extras(parentExtras);
|
|
|
ANKI_CHECK(getExtras(light.extras, extras));
|
|
|
ANKI_CHECK(getExtras(node.extras, extras));
|
|
|
|
|
|
@@ -1059,7 +1059,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
|
|
|
|
|
|
if(lsSpriteSize != extras.getEnd())
|
|
|
{
|
|
|
- DynamicArrayAuto<F64> numbers(m_alloc);
|
|
|
+ DynamicArrayRaii<F64> numbers(m_alloc);
|
|
|
const U32 count = 2;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lsSpriteSize->toCString(), numbers, &count));
|
|
|
|
|
|
@@ -1068,7 +1068,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
|
|
|
|
|
|
if(lsColor != extras.getEnd())
|
|
|
{
|
|
|
- DynamicArrayAuto<F64> numbers(m_alloc);
|
|
|
+ DynamicArrayRaii<F64> numbers(m_alloc);
|
|
|
const U32 count = 4;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lsColor->toCString(), numbers, &count));
|
|
|
|
|
|
@@ -1085,7 +1085,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
|
|
|
|
|
|
if(lightEventIntensity != extras.getEnd())
|
|
|
{
|
|
|
- DynamicArrayAuto<F64> numbers(m_alloc);
|
|
|
+ DynamicArrayRaii<F64> numbers(m_alloc);
|
|
|
const U32 count = 4;
|
|
|
ANKI_CHECK(parseArrayOfNumbers(lightEventIntensity->toCString(), numbers, &count));
|
|
|
ANKI_CHECK(m_sceneFile.writeTextf("event:setIntensityMultiplier(Vec4.new(%f, %f, %f, %f))\n", numbers[0],
|
|
|
@@ -1094,7 +1094,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
|
|
|
|
|
|
if(lightEventFrequency != extras.getEnd())
|
|
|
{
|
|
|
- DynamicArrayAuto<F64> numbers(m_alloc);
|
|
|
+ DynamicArrayRaii<F64> numbers(m_alloc);
|
|
|
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]));
|
|
|
@@ -1105,7 +1105,7 @@ Error GltfImporter::writeLight(const cgltf_node& node, const HashMapAuto<CString
|
|
|
}
|
|
|
|
|
|
Error GltfImporter::writeCamera(const cgltf_node& node,
|
|
|
- [[maybe_unused]] const HashMapAuto<CString, StringAuto>& parentExtras)
|
|
|
+ [[maybe_unused]] const HashMapAuto<CString, StringRaii>& parentExtras)
|
|
|
{
|
|
|
if(node.camera->type != cgltf_camera_type_perspective)
|
|
|
{
|
|
|
@@ -1128,14 +1128,14 @@ Error GltfImporter::writeCamera(const cgltf_node& node,
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
-Error GltfImporter::writeModelNode(const cgltf_node& node, const HashMapAuto<CString, StringAuto>& parentExtras)
|
|
|
+Error GltfImporter::writeModelNode(const cgltf_node& node, const HashMapAuto<CString, StringRaii>& parentExtras)
|
|
|
{
|
|
|
ANKI_IMPORTER_LOGV("Importing model node %s", getNodeName(node).cstr());
|
|
|
|
|
|
- HashMapAuto<CString, StringAuto> extras(parentExtras);
|
|
|
+ HashMapAuto<CString, StringRaii> extras(parentExtras);
|
|
|
ANKI_CHECK(getExtras(node.extras, extras));
|
|
|
|
|
|
- const StringAuto modelFname = computeModelResourceFilename(*node.mesh);
|
|
|
+ const StringRaii modelFname = computeModelResourceFilename(*node.mesh);
|
|
|
|
|
|
ANKI_CHECK(m_sceneFile.writeTextf("\nnode = scene:newModelNode(\"%s\")\n", getNodeName(node).cstr()));
|
|
|
ANKI_CHECK(m_sceneFile.writeTextf("node:getSceneNodeBase():getModelComponent():loadModelResource(\"%s%s\")\n",
|
|
|
@@ -1150,9 +1150,9 @@ Error GltfImporter::writeModelNode(const cgltf_node& node, const HashMapAuto<CSt
|
|
|
return Error::kNone;
|
|
|
}
|
|
|
|
|
|
-StringAuto GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh) const
|
|
|
+StringRaii GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh) const
|
|
|
{
|
|
|
- StringListAuto list(m_alloc);
|
|
|
+ StringListRaii list(m_alloc);
|
|
|
|
|
|
list.pushBack(mesh.name);
|
|
|
|
|
|
@@ -1162,55 +1162,55 @@ StringAuto GltfImporter::computeModelResourceFilename(const cgltf_mesh& mesh) co
|
|
|
list.pushBackSprintf("_%s", mtlName);
|
|
|
}
|
|
|
|
|
|
- StringAuto joined(m_alloc);
|
|
|
+ StringRaii joined(m_alloc);
|
|
|
list.join("", joined);
|
|
|
|
|
|
const U64 hash = computeHash(joined.getBegin(), joined.getLength());
|
|
|
|
|
|
- StringAuto out(m_alloc);
|
|
|
+ StringRaii out(m_alloc);
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankimdl", joined.cstr(), hash); // Limit the filename size
|
|
|
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-StringAuto GltfImporter::computeMeshResourceFilename(const cgltf_mesh& mesh, U32 lod) const
|
|
|
+StringRaii GltfImporter::computeMeshResourceFilename(const cgltf_mesh& mesh, U32 lod) const
|
|
|
{
|
|
|
const U64 hash = computeHash(mesh.name, strlen(mesh.name));
|
|
|
|
|
|
- StringAuto out(m_alloc);
|
|
|
+ StringRaii out(m_alloc);
|
|
|
|
|
|
out.sprintf("%.64s_lod%u_%" PRIx64 ".ankimesh", mesh.name, lod, hash); // Limit the filename size
|
|
|
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-StringAuto GltfImporter::computeMaterialResourceFilename(const cgltf_material& mtl) const
|
|
|
+StringRaii GltfImporter::computeMaterialResourceFilename(const cgltf_material& mtl) const
|
|
|
{
|
|
|
const U64 hash = computeHash(mtl.name, strlen(mtl.name));
|
|
|
|
|
|
- StringAuto out(m_alloc);
|
|
|
+ StringRaii out(m_alloc);
|
|
|
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankimtl", mtl.name, hash); // Limit the filename size
|
|
|
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-StringAuto GltfImporter::computeAnimationResourceFilename(const cgltf_animation& anim) const
|
|
|
+StringRaii GltfImporter::computeAnimationResourceFilename(const cgltf_animation& anim) const
|
|
|
{
|
|
|
const U64 hash = computeHash(anim.name, strlen(anim.name));
|
|
|
|
|
|
- StringAuto out(m_alloc);
|
|
|
+ StringRaii out(m_alloc);
|
|
|
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankianim", anim.name, hash); // Limit the filename size
|
|
|
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
-StringAuto GltfImporter::computeSkeletonResourceFilename(const cgltf_skin& skin) const
|
|
|
+StringRaii GltfImporter::computeSkeletonResourceFilename(const cgltf_skin& skin) const
|
|
|
{
|
|
|
const U64 hash = computeHash(skin.name, strlen(skin.name));
|
|
|
|
|
|
- StringAuto out(m_alloc);
|
|
|
+ StringRaii out(m_alloc);
|
|
|
|
|
|
out.sprintf("%.64s_%" PRIx64 ".ankiskel", skin.name, hash); // Limit the filename size
|
|
|
|