Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
output path overrride
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Oct 30, 2023
1 parent b2f7bbb commit 08e7e89
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion externals/cage
Submodule cage updated 40 files
+1 −1 externals/assimp/assimp
+1 −1 externals/cubeb/cubeb
+1 −1 externals/fastnoise/fastnoise
+1 −1 externals/freetype/freetype
+1 −1 externals/gamenetworkingsockets/GameNetworkingSockets
+1 −1 externals/jpeg/jpeg
+1 −1 externals/msdfgen/msdfgen
+1 −1 externals/openxr-sdk/OpenXR-SDK
+1 −1 externals/plf/plf_colony
+1 −1 externals/plf/plf_list
+1 −1 externals/pmp/pmp
+1 −1 externals/png/png
+1 −1 externals/stb/stb
+1 −1 externals/tiff/tiff
+1 −1 externals/unordered_dense/unordered_dense
+1 −1 externals/utfcpp/utfcpp
+1 −1 externals/zlib-ng/zlib-ng
+1 −1 sources/include/cage-core/camera.h
+23 −23 sources/include/cage-core/collider.h
+9 −9 sources/include/cage-core/collisionStructure.h
+8 −0 sources/include/cage-core/core.h
+153 −153 sources/include/cage-core/geometry.h
+2 −2 sources/include/cage-core/mat3x4.h
+220 −256 sources/include/cage-core/math.h
+13 −13 sources/include/cage-core/spatialStructure.h
+65 −65 sources/libcore/geometry/aabbCone.cpp
+50 −57 sources/libcore/geometry/collider.cpp
+15 −15 sources/libcore/geometry/collisionStructure.cpp
+91 −93 sources/libcore/geometry/geometry.cpp
+3 −3 sources/libcore/geometry/linesDistances.cpp
+5 −5 sources/libcore/geometry/minimumBoundingSphere.cpp
+26 −26 sources/libcore/geometry/shapes.cpp
+33 −33 sources/libcore/geometry/spatialStructure.cpp
+8 −8 sources/libcore/geometry/triangleBox.cpp
+2 −2 sources/libcore/geometry/triangleTriangle.cpp
+1 −1 sources/libcore/math/camera.cpp
+64 −50 sources/libcore/math/matrices.cpp
+28 −18 sources/libcore/math/scalars.cpp
+15 −10 sources/libcore/math/transform.cpp
+63 −31 sources/libcore/math/vectors.cpp
36 changes: 20 additions & 16 deletions sources/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@
namespace unnatural
{
void terrainPreseed();
void writeConfigurationDescription(File *f);
void writeConfigurationDescription(File* f);
String configOverrideOutputPath;

namespace
{
String findOutputDirectory(const String &planetName)
String findOutputDirectory(String name)
{
String root;
try
{
root = pathSearchTowardsRoot("output", PathTypeFlags::Directory);
}
catch (const Exception &)
catch (const Exception&)
{
root = "output";
}

{
String name = pathReplaceInvalidCharacters(planetName);
if (!configOverrideOutputPath.empty())
name = configOverrideOutputPath;
else
name = pathReplaceInvalidCharacters(name);
name = replace(name, " ", "_");
#ifdef CAGE_DEBUG
name += "_debug";
Expand Down Expand Up @@ -132,7 +136,7 @@ namespace unnatural

f->writeLine("[packages]");
f->writeLine("unnatural/base/base.pack");
for (const String &s : assetPackages)
for (const String& s : assetPackages)
f->writeLine(s);

f->writeLine("[camera]");
Expand All @@ -158,7 +162,7 @@ namespace unnatural
{ // object file
Holder<File> f = writeFile(pathJoin(assetsDirectory, "planet.object"));
f->writeLine("[]");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
f->writeLine(c.mesh);
f->close();
}
Expand All @@ -173,7 +177,7 @@ namespace unnatural
{ // generate asset configuration
Holder<File> f = writeFile(pathJoin(assetsDirectory, "planet.assets"));
uint32 textureCounts[4] = {}; // opaque albedo, transparent albedo, special, normal
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
{
if (!c.albedo.empty())
textureCounts[c.transparency]++;
Expand All @@ -187,7 +191,7 @@ namespace unnatural
f->writeLine("[]");
f->writeLine("scheme = texture");
f->writeLine("srgb = true");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
if (!c.albedo.empty() && !c.transparency)
f->writeLine(c.albedo);
}
Expand All @@ -197,7 +201,7 @@ namespace unnatural
f->writeLine("scheme = texture");
f->writeLine("srgb = true");
f->writeLine("premultiplyAlpha = true");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
if (!c.albedo.empty() && c.transparency)
f->writeLine(c.albedo);
}
Expand All @@ -206,7 +210,7 @@ namespace unnatural
f->writeLine("[]");
f->writeLine("scheme = texture");
f->writeLine("convert = gltfToSpecial");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
if (!c.pbr.empty())
f->writeLine(c.pbr);
}
Expand All @@ -215,13 +219,13 @@ namespace unnatural
f->writeLine("[]");
f->writeLine("scheme = texture");
f->writeLine("normal = true");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
if (!c.normal.empty())
f->writeLine(c.normal);
}
f->writeLine("[]");
f->writeLine("scheme = model");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
f->writeLine(c.mesh);
f->writeLine("[]");
f->writeLine("scheme = model");
Expand All @@ -248,7 +252,7 @@ def loadChunk(meshname):
bpy.ops.import_scene.gltf(filepath = meshname)
)Python");
for (const Chunk &c : chunks)
for (const Chunk& c : chunks)
f->writeLine(Stringizer() + "loadChunk('" + c.mesh + "')");
f->write(R"Python(
for a in bpy.data.window_managers[0].windows[0].screen.areas:
Expand Down Expand Up @@ -318,7 +322,7 @@ bpy.ops.object.select_all(action='DESELECT')
c.albedo = Stringizer() + "land-" + index + "-albedo.png";
c.pbr = Stringizer() + "land-" + index + "-pbr.png";
c.normal = Stringizer() + "land-" + index + "-normal.png";
const auto &msh = split[index];
const auto& msh = split[index];
const uint32 resolution = meshUnwrap(msh);
meshSaveRender(pathJoin(assetsDirectory, c.mesh), msh, c.transparency);
Holder<Image> albedo, special, heightMap;
Expand Down Expand Up @@ -369,7 +373,7 @@ bpy.ops.object.select_all(action='DESELECT')
c.pbr = Stringizer() + "water-" + index + "-pbr.png";
c.normal = Stringizer() + "water-" + index + "-normal.png";
c.transparency = true;
const auto &msh = split[index];
const auto& msh = split[index];
const uint32 resolution = meshUnwrap(msh);
meshSaveRender(pathJoin(assetsDirectory, c.mesh), msh, c.transparency);
Holder<Image> albedo, special, heightMap;
Expand Down Expand Up @@ -447,7 +451,7 @@ bpy.ops.object.select_all(action='DESELECT')
CAGE_LOG(SeverityEnum::Note, "blender", p->readLine());
}
}
catch (const ProcessPipeEof &)
catch (const ProcessPipeEof&)
{
// nothing
}
Expand Down
9 changes: 7 additions & 2 deletions sources/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
namespace unnatural
{
void terrainApplyConfig();
extern String configOverrideOutputPath;

namespace
{
void applyConfiguration(const Holder<Ini> &cmd)
void applyConfiguration(const Holder<Ini>& cmd)
{
ConfigString configShapeMode("unnatural-planets/shape/mode", "random");
configShapeMode = cmd->cmdString('s', "shape", configShapeMode);
Expand Down Expand Up @@ -44,11 +45,15 @@ namespace unnatural
ConfigBool configPreviewEnable("unnatural-planets/preview/enable", false);
configPreviewEnable = cmd->cmdBool('r', "preview", configPreviewEnable);
CAGE_LOG(SeverityEnum::Info, "configuration", Stringizer() + "enable preview: " + !!configPreviewEnable);

// configOverrideOutputPath should not be stored in the ini file
configOverrideOutputPath = cmd->cmdString('v', "outputPathOverride", "");
CAGE_LOG(SeverityEnum::Info, "configuration", Stringizer() + "override output path: " + configOverrideOutputPath);
}
}
}

int main(int argc, const char *args[])
int main(int argc, const char* args[])
{
using namespace unnatural;

Expand Down

0 comments on commit 08e7e89

Please sign in to comment.