From ed20555235c2854574344c2c999334ea4b67c116 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Fri, 21 Sep 2018 16:47:12 +0300 Subject: [PATCH 01/13] Added button for material saving --- BaikalStandalone/Application/application.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BaikalStandalone/Application/application.cpp b/BaikalStandalone/Application/application.cpp index c0f7ef91..afaa4eed 100644 --- a/BaikalStandalone/Application/application.cpp +++ b/BaikalStandalone/Application/application.cpp @@ -918,6 +918,13 @@ namespace Baikal } } + if (ImGui::Button("Save materials")) + { + auto material_io = Baikal::MaterialIo::CreateMaterialIoXML(); + material_io->SaveMaterialsFromScene(m_settings.path + "/materials.xml", *m_cl->GetScene()); + material_io->SaveIdentityMapping(m_settings.path + "/mapping.xml", *m_cl->GetScene()); + } + if (m_settings.time_benchmark && m_settings.samplecount > 511) { m_settings.time_benchmark = false; From f513ab1a21843b6121e9f0b6f23f879c7967f447 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Fri, 21 Sep 2018 20:10:39 +0300 Subject: [PATCH 02/13] Fixed load/save texture for material saving --- BaikalIO/CMakeLists.txt | 2 +- BaikalIO/material_io.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index a5ac46f0..4b3eb967 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -25,7 +25,7 @@ endif (BAIKAL_ENABLE_FBX) add_library(BaikalIO SHARED ${SOURCES}) target_compile_definitions(BaikalIO PRIVATE BAIKAL_EXPORT_API) -target_compile_features(BaikalIO PRIVATE cxx_std_14) +target_compile_features(BaikalIO PRIVATE cxx_std_17) target_link_libraries(BaikalIO PUBLIC Baikal OpenImageIO::OpenImageIO) if (UNIX AND NOT APPLE) diff --git a/BaikalIO/material_io.cpp b/BaikalIO/material_io.cpp index 0261299e..7ee467ce 100644 --- a/BaikalIO/material_io.cpp +++ b/BaikalIO/material_io.cpp @@ -13,6 +13,7 @@ #include "XML/tinyxml2.h" #include +#include #include #include #include @@ -486,18 +487,18 @@ namespace Baikal } else { - std::string texture_name = texture->GetName(); + std::filesystem::path texture_name = texture->GetName(); if (texture_name.empty()) { std::ostringstream oss; oss << (std::uint64_t)texture.get() << ".jpg"; texture_name = oss.str(); - io.SaveImage(m_base_path + texture_name, texture); + io.SaveImage(m_base_path + texture_name.string(), texture); } - m_tex2name[texture] = texture_name; + m_tex2name[texture] = texture_name.filename().string(); - printer.PushAttribute("value", texture_name.c_str()); + printer.PushAttribute("value", m_tex2name[texture].c_str()); } printer.CloseElement(); break; From fd7d9c55e529069d791e31e880697ac79a5d2b06 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Mon, 24 Sep 2018 13:10:41 +0300 Subject: [PATCH 03/13] Fix linux build --- BaikalIO/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index 4b3eb967..e9315935 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -32,6 +32,10 @@ if (UNIX AND NOT APPLE) target_link_libraries(BaikalIO PUBLIC stdc++fs) endif () +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental") +endif() + target_include_directories(BaikalIO PUBLIC "${Baikal_SOURCE_DIR}/BaikalIO" "${Baikal_SOURCE_DIR}/3rdparty/tinyobjloader/include") if (BAIKAL_ENABLE_FBX) From a26efceb4f7e7f923666e2c079aaf37a9d05a232 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Tue, 25 Sep 2018 14:55:58 +0300 Subject: [PATCH 04/13] Fix for old GNU compiler --- BaikalIO/material_io.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BaikalIO/material_io.cpp b/BaikalIO/material_io.cpp index 7ee467ce..fb8dde4a 100644 --- a/BaikalIO/material_io.cpp +++ b/BaikalIO/material_io.cpp @@ -13,12 +13,17 @@ #include "XML/tinyxml2.h" #include -#include #include #include #include #include +#if (defined(__GNUC__) && (__GNUC__ < 8)) +#include +#else +#include +#endif + namespace Baikal { using namespace tinyxml2; From 2bf5f7dc5153faf139b6ef1520ff9ea7039b8951 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Tue, 25 Sep 2018 16:10:48 +0300 Subject: [PATCH 05/13] Yet another fix for old compilers --- BaikalIO/material_io.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BaikalIO/material_io.cpp b/BaikalIO/material_io.cpp index fb8dde4a..f2cc2cb9 100644 --- a/BaikalIO/material_io.cpp +++ b/BaikalIO/material_io.cpp @@ -492,7 +492,12 @@ namespace Baikal } else { +#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__GNUC__) && (__GNUC__ < 8)) + std::experimental::filesystem::v1::path = texture_name = texture->GetName(); +#else std::filesystem::path texture_name = texture->GetName(); +#endif + if (texture_name.empty()) { std::ostringstream oss; From b1abedb4c5867bf1e4eb4bc95757a6703873c465 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Tue, 25 Sep 2018 18:00:01 +0300 Subject: [PATCH 06/13] YAF for ubuntu --- BaikalIO/material_io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaikalIO/material_io.cpp b/BaikalIO/material_io.cpp index f2cc2cb9..bdf9c78d 100644 --- a/BaikalIO/material_io.cpp +++ b/BaikalIO/material_io.cpp @@ -493,7 +493,7 @@ namespace Baikal else { #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__GNUC__) && (__GNUC__ < 8)) - std::experimental::filesystem::v1::path = texture_name = texture->GetName(); + std::experimental::filesystem::v1::path texture_name = texture->GetName(); #else std::filesystem::path texture_name = texture->GetName(); #endif From 15a4724e0fb501b440efed087c5da1ad7b1514d8 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Tue, 25 Sep 2018 19:30:02 +0300 Subject: [PATCH 07/13] YEF ios --- BaikalIO/material_io.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/BaikalIO/material_io.cpp b/BaikalIO/material_io.cpp index bdf9c78d..9f65620a 100644 --- a/BaikalIO/material_io.cpp +++ b/BaikalIO/material_io.cpp @@ -24,6 +24,18 @@ #include #endif +// Visual Studio 2015 and GCC 7 work-around ... +// std::filesystem was incorporated into C++-17 (which is obviously after VS +// 2015 was released). However, Microsoft implemented the draft standard in +// the std::exerimental namespace. To avoid nasty ripple effects when the +// compiler is updated, make it look like the standard here +#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__GNUC__) && (__GNUC__ < 8)) +namespace std +{ + namespace filesystem = experimental::filesystem::v1; +} +#endif + namespace Baikal { using namespace tinyxml2; @@ -492,12 +504,7 @@ namespace Baikal } else { -#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__GNUC__) && (__GNUC__ < 8)) - std::experimental::filesystem::v1::path texture_name = texture->GetName(); -#else std::filesystem::path texture_name = texture->GetName(); -#endif - if (texture_name.empty()) { std::ostringstream oss; From 80fea173bd9b6211f2d5c16ece8bfb0a9d9ebe57 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Thu, 27 Sep 2018 17:56:52 +0300 Subject: [PATCH 08/13] filesystem moved from DataGenerator itno BaikalIO --- BaikalDataGenerator/CMakeLists.txt | 1 - BaikalIO/CMakeLists.txt | 3 ++- .../Source => BaikalIO}/filesystem.h | 0 BaikalIO/material_io.cpp | 19 +------------------ 4 files changed, 3 insertions(+), 20 deletions(-) rename {BaikalDataGenerator/Source => BaikalIO}/filesystem.h (100%) diff --git a/BaikalDataGenerator/CMakeLists.txt b/BaikalDataGenerator/CMakeLists.txt index da25701e..ec47fcb2 100644 --- a/BaikalDataGenerator/CMakeLists.txt +++ b/BaikalDataGenerator/CMakeLists.txt @@ -1,6 +1,5 @@ set(DATAGENERATOR_SOURCES Source/main.cpp - Source/filesystem.h Source/cmd_line_parser.h Source/cmd_line_parser.cpp Source/render.h diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index e9315935..14755496 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -9,6 +9,7 @@ set(SOURCES scene_io.h scene_test_io.cpp scene_obj_io.cpp + filesystem.h ) if (UNIX AND NOT APPLE) @@ -32,7 +33,7 @@ if (UNIX AND NOT APPLE) target_link_libraries(BaikalIO PUBLIC stdc++fs) endif () -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR APPLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental") endif() diff --git a/BaikalDataGenerator/Source/filesystem.h b/BaikalIO/filesystem.h similarity index 100% rename from BaikalDataGenerator/Source/filesystem.h rename to BaikalIO/filesystem.h diff --git a/BaikalIO/material_io.cpp b/BaikalIO/material_io.cpp index 9f65620a..6901b463 100644 --- a/BaikalIO/material_io.cpp +++ b/BaikalIO/material_io.cpp @@ -8,6 +8,7 @@ #include "SceneGraph/uberv2material.h" #include "SceneGraph/inputmaps.h" +#include "filesystem.h" #include "image_io.h" #include "XML/tinyxml2.h" @@ -18,24 +19,6 @@ #include #include -#if (defined(__GNUC__) && (__GNUC__ < 8)) -#include -#else -#include -#endif - -// Visual Studio 2015 and GCC 7 work-around ... -// std::filesystem was incorporated into C++-17 (which is obviously after VS -// 2015 was released). However, Microsoft implemented the draft standard in -// the std::exerimental namespace. To avoid nasty ripple effects when the -// compiler is updated, make it look like the standard here -#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__GNUC__) && (__GNUC__ < 8)) -namespace std -{ - namespace filesystem = experimental::filesystem::v1; -} -#endif - namespace Baikal { using namespace tinyxml2; From 74a8d65dfe26bcdf8126133f5bb0303527096651 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Thu, 27 Sep 2018 19:26:28 +0300 Subject: [PATCH 09/13] yet another try to launch this on OSX --- BaikalIO/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index 14755496..377ddb93 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -33,10 +33,14 @@ if (UNIX AND NOT APPLE) target_link_libraries(BaikalIO PUBLIC stdc++fs) endif () -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR APPLE) +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental") endif() +if (APPLE) + target_compile_options(BaikalIO PUBLIC -stdlib=libc++) +endif (APPLE) + target_include_directories(BaikalIO PUBLIC "${Baikal_SOURCE_DIR}/BaikalIO" "${Baikal_SOURCE_DIR}/3rdparty/tinyobjloader/include") if (BAIKAL_ENABLE_FBX) From db476fb21230d5610f0857a459cbc6c10559eea0 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Thu, 27 Sep 2018 20:01:29 +0300 Subject: [PATCH 10/13] YEAF for apple --- BaikalIO/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index 377ddb93..5f97a4e1 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -35,12 +35,9 @@ endif () if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental") + target_compile_options(BaikalIO PUBLIC -stdlib=libc++) endif() -if (APPLE) - target_compile_options(BaikalIO PUBLIC -stdlib=libc++) -endif (APPLE) - target_include_directories(BaikalIO PUBLIC "${Baikal_SOURCE_DIR}/BaikalIO" "${Baikal_SOURCE_DIR}/3rdparty/tinyobjloader/include") if (BAIKAL_ENABLE_FBX) From b08d11d182ed39f4062882959596d7367701ad4f Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Fri, 28 Sep 2018 14:25:21 +0300 Subject: [PATCH 11/13] YEAF for apple, added macors for clang in filesystem --- BaikalIO/filesystem.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/BaikalIO/filesystem.h b/BaikalIO/filesystem.h index 5a3612df..3355f6bc 100644 --- a/BaikalIO/filesystem.h +++ b/BaikalIO/filesystem.h @@ -1,6 +1,6 @@ #pragma once -#if (defined(__GNUC__) && (__GNUC__ < 8)) +#if (defined(__GNUC__) && (__GNUC__ < 8)) || (defined(__clang__) && (__clang_major__ < 7)) #include #else #include @@ -16,4 +16,9 @@ namespace std { namespace filesystem = experimental::filesystem::v1; } +#elif (defined(__clang__)) +namespace std +{ + namespace filesystem = experimental::filesystem; +} #endif \ No newline at end of file From ee6fb12fa9c1b2cb0c0716561a3536cfe252dfcf Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Fri, 28 Sep 2018 16:15:27 +0300 Subject: [PATCH 12/13] added stdc++fs for clang --- BaikalIO/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index 5f97a4e1..6f6c60f6 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -29,7 +29,7 @@ target_compile_definitions(BaikalIO PRIVATE BAIKAL_EXPORT_API) target_compile_features(BaikalIO PRIVATE cxx_std_17) target_link_libraries(BaikalIO PUBLIC Baikal OpenImageIO::OpenImageIO) -if (UNIX AND NOT APPLE) +if (UNIX OR APPLE) target_link_libraries(BaikalIO PUBLIC stdc++fs) endif () From 684860aebfed6e79e88e8dd734aca95e11657569 Mon Sep 17 00:00:00 2001 From: Alexander Khokhlov Date: Fri, 28 Sep 2018 17:17:41 +0300 Subject: [PATCH 13/13] one more try --- BaikalIO/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaikalIO/CMakeLists.txt b/BaikalIO/CMakeLists.txt index 6f6c60f6..942fe237 100644 --- a/BaikalIO/CMakeLists.txt +++ b/BaikalIO/CMakeLists.txt @@ -34,7 +34,7 @@ if (UNIX OR APPLE) endif () if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lc++experimental") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++fs -lc++experimental") target_compile_options(BaikalIO PUBLIC -stdlib=libc++) endif()