Quellcode durchsuchen

Minor additions

Panagiotis Christopoulos Charitos vor 5 Jahren
Ursprung
Commit
896e15bc36
3 geänderte Dateien mit 21 neuen und 4 gelöschten Zeilen
  1. 4 1
      src/anki/importer/GltfImporter.cpp
  2. 3 1
      src/anki/importer/GltfImporter.h
  3. 14 2
      tools/gltf_importer/Main.cpp

+ 4 - 1
src/anki/importer/GltfImporter.cpp

@@ -162,13 +162,15 @@ Error GltfImporter::init(CString inputFname,
 	F32 lodFactor,
 	F32 lodFactor,
 	U32 lodCount,
 	U32 lodCount,
 	F32 lightIntensityScale,
 	F32 lightIntensityScale,
-	U32 threadCount)
+	U32 threadCount,
+	CString comment)
 {
 {
 	m_inputFname.create(inputFname);
 	m_inputFname.create(inputFname);
 	m_outDir.create(outDir);
 	m_outDir.create(outDir);
 	m_rpath.create(rpath);
 	m_rpath.create(rpath);
 	m_texrpath.create(texrpath);
 	m_texrpath.create(texrpath);
 	m_optimizeMeshes = optimizeMeshes;
 	m_optimizeMeshes = optimizeMeshes;
+	m_comment.create(comment);
 
 
 	m_lightIntensityScale = clamp(lightIntensityScale, 0.1f, 1.0f);
 	m_lightIntensityScale = clamp(lightIntensityScale, 0.1f, 1.0f);
 
 
@@ -224,6 +226,7 @@ Error GltfImporter::writeAll()
 	StringAuto sceneFname(m_alloc);
 	StringAuto sceneFname(m_alloc);
 	sceneFname.sprintf("%sscene.lua", m_outDir.cstr());
 	sceneFname.sprintf("%sscene.lua", m_outDir.cstr());
 	ANKI_CHECK(m_sceneFile.open(sceneFname.toCString(), FileOpenFlag::WRITE));
 	ANKI_CHECK(m_sceneFile.open(sceneFname.toCString(), FileOpenFlag::WRITE));
+	ANKI_CHECK(m_sceneFile.writeText("-- Generated by: %s\n", m_comment.cstr()));
 	ANKI_CHECK(m_sceneFile.writeText("local scene = getSceneGraph()\nlocal events = getEventManager()\n"));
 	ANKI_CHECK(m_sceneFile.writeText("local scene = getSceneGraph()\nlocal events = getEventManager()\n"));
 
 
 	// Nodes
 	// Nodes

+ 3 - 1
src/anki/importer/GltfImporter.h

@@ -38,7 +38,8 @@ public:
 		F32 lodFactor,
 		F32 lodFactor,
 		U32 lodCount,
 		U32 lodCount,
 		F32 lightIntensityScale,
 		F32 lightIntensityScale,
-		U32 threadCount);
+		U32 threadCount,
+		CString comment);
 
 
 	ANKI_USE_RESULT Error writeAll();
 	ANKI_USE_RESULT Error writeAll();
 
 
@@ -78,6 +79,7 @@ private:
 	U32 m_lodCount = 1;
 	U32 m_lodCount = 1;
 	F32 m_lightIntensityScale = 1.0f;
 	F32 m_lightIntensityScale = 1.0f;
 	Bool m_optimizeMeshes = false;
 	Bool m_optimizeMeshes = false;
+	StringAuto m_comment{m_alloc};
 
 
 	// Misc
 	// Misc
 	ANKI_USE_RESULT Error getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out);
 	ANKI_USE_RESULT Error getExtras(const cgltf_extras& extras, HashMapAuto<CString, StringAuto>& out);

+ 14 - 2
tools/gltf_importer/Main.cpp

@@ -187,7 +187,18 @@ int main(int argc, char** argv)
 		return 1;
 		return 1;
 	}
 	}
 
 
-	HeapAllocator<U8> alloc{allocAligned, nullptr};
+	HeapAllocator<U8> alloc(allocAligned, nullptr);
+	StringAuto comment(alloc);
+	for(I32 i = 0; i < argc; ++i)
+	{
+		if(i != 0)
+		{
+			comment.append(" ");
+		}
+
+		comment.append(argv[i]);
+	}
+
 	GltfImporter importer{alloc};
 	GltfImporter importer{alloc};
 	if(importer.init(info.m_inputFname.toCString(),
 	if(importer.init(info.m_inputFname.toCString(),
 		   info.m_outDir.toCString(),
 		   info.m_outDir.toCString(),
@@ -197,7 +208,8 @@ int main(int argc, char** argv)
 		   info.m_lodFactor,
 		   info.m_lodFactor,
 		   info.m_lodCount,
 		   info.m_lodCount,
 		   info.m_lightIntensityScale,
 		   info.m_lightIntensityScale,
-		   info.m_threadCount))
+		   info.m_threadCount,
+		   comment))
 	{
 	{
 		return 1;
 		return 1;
 	}
 	}