diff --git a/CMakeLists.txt b/CMakeLists.txt index 39550f5..c4847b8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.13) project(UDIMTextureImporter) -set(DLL_VERSION 2.1.3) +set(DLL_VERSION 2.1.4) set(SOURCE_FILES ../UDIMTextureImporterData/src/udimTextureImporter.cpp diff --git a/UDIMTextureImporterData/src/goz.cpp b/UDIMTextureImporterData/src/goz.cpp index 4346197..9f0d140 100755 --- a/UDIMTextureImporterData/src/goz.cpp +++ b/UDIMTextureImporterData/src/goz.cpp @@ -3,6 +3,8 @@ #include "goz.hpp" #include "util.hpp" +#include "timer.hpp" + GoZ::GoZ() {}; @@ -26,6 +28,9 @@ void GoZ::write(std::string outPath) void GoZ::computeVertexNormals() { + Timer timer; + timer.start(); + this->normals.resize(this->vertices.size()); Vector3f zeroVec(0, 0, 0); std::fill(normals.begin(), normals.end(), zeroVec); @@ -76,6 +81,9 @@ void GoZ::computeVertexNormals() for (auto& n : this->normals) { n.normalize(); } + + timer.showDuration("Vertex normal calculated in "); + } // https://stackoverflow.com/questions/5255806/how-to-calculate-tangent-and-binorma @@ -117,6 +125,10 @@ void GoZ::computeTangentBasis(const Vector3f& A, std::vector GoZ::initTextures(std::vector& texture_paths) { + + Timer timer; + timer.start(); + // Find out the last number of the UDIM images int max_udim = 0; for (auto& path : texture_paths) { @@ -136,13 +148,19 @@ std::vector GoZ::initTextures(std::vector& texture_paths) int udim = stoi(texture_udim) - 1000; textures[static_cast(udim - 1)] = img; } - std::cout << "Finished loading textures" << std::endl; + + timer.showDuration("Finished loading textures in "); + return textures; } void GoZ::importVectorDisplacement(std::vector& texture_paths) { + + Timer timer; + timer.start(); + std::vector textures = initTextures(texture_paths); // Vector Displacement @@ -235,11 +253,16 @@ void GoZ::importVectorDisplacement(std::vector& texture_paths) } } this->vertices = outVertices; + + timer.showDuration("Finished Vector Displacement in "); } void GoZ::importNormalDisplacement(std::vector& texture_paths) { + Timer timer; + timer.start(); + std::vector textures = initTextures(texture_paths); std::vector> outVertices = this->vertices; @@ -293,11 +316,16 @@ void GoZ::importNormalDisplacement(std::vector& texture_paths) } } this->vertices = outVertices; + + timer.showDuration("Finished Normal Displacement in "); } void GoZ::importVertexColor(std::vector& texture_paths, double gamma) { + Timer timer; + timer.start(); + std::vector textures = initTextures(texture_paths); size_t numFaces = this->faces.size(); @@ -350,11 +378,16 @@ void GoZ::importVertexColor(std::vector& texture_paths, double gamm } } } + + timer.showDuration("Finished color to polypaint in "); } void GoZ::importMask(std::vector& texture_paths) { + Timer timer; + timer.start(); + std::vector textures = initTextures(texture_paths); // Init mask value array with 0.0 @@ -408,4 +441,6 @@ void GoZ::importMask(std::vector& texture_paths) } } this->mask = outMask; + + timer.showDuration("Finished mask import in "); } diff --git a/UDIMTextureImporterData/src/udimTextureImporter.cpp b/UDIMTextureImporterData/src/udimTextureImporter.cpp index 949bcbf..61e8bfe 100755 --- a/UDIMTextureImporterData/src/udimTextureImporter.cpp +++ b/UDIMTextureImporterData/src/udimTextureImporter.cpp @@ -37,21 +37,6 @@ int EXPORT ImportUDIM(char* GoZFilePath, return 1; } - // Create a path for the log file - std::filesystem::path logPath = gozPath.string(); - logPath.replace_extension("log"); - - std::ofstream logOfs(logPath, std::ios::out); - if (!logOfs) { - strcpy(pOptBuffer2, "Failed to open the log file."); - return 1; - } - - // Redirect all cout to log file - // https://www.quora.com/How-do-I-output-all-my-cout-s-to-a-text-file-in-C - auto cout_buff = std::cout.rdbuf(); - std::cout.rdbuf(logOfs.rdbuf()); - // Split/Convert the long texture path string to vector // pOptBuffer1 comes in this format: // "1#C:/path/image.1001.tif#C:/path/image.1002.tif#C:/path.image.1003.tif .... @@ -98,10 +83,6 @@ int EXPORT ImportUDIM(char* GoZFilePath, std::cout << "GoZ output path: " << gozPath.string() << std::endl; obj.write(gozPath.string()); - logOfs << "End dll" << std::endl; - logOfs.close(); - std::cout.rdbuf(cout_buff); - return 0; }