diff --git a/code/nel/tools/pipeline/plugin_nel/process_texture_dds.cpp b/code/nel/tools/pipeline/plugin_nel/process_texture_dds.cpp index 7c4e7e0ec..2aea236b0 100644 --- a/code/nel/tools/pipeline/plugin_nel/process_texture_dds.cpp +++ b/code/nel/tools/pipeline/plugin_nel/process_texture_dds.cpp @@ -33,6 +33,7 @@ // NeL includes #include +#include // Project includes @@ -41,10 +42,92 @@ using namespace std; namespace PIPELINE { +void CProcessTextureDDS::buildDDS(const std::string &dependLog, const std::string &errorLog, const std::string &srcFile, const std::string &dstFile, const std::string &algorithm, bool createMipMap, uint reduceFactor, bool checkUserColor) +{ + nldebug("Build: DDS '%s'", dstFile.c_str()); + std::vector arguments; + arguments.push_back(srcFile); + arguments.push_back("-o"); + arguments.push_back(dstFile); + if (!algorithm.empty()) + { + arguments.push_back("-a"); + arguments.push_back(algorithm); + } + if (createMipMap) + arguments.push_back("-m"); + if (reduceFactor) + { + std::stringstream ss; + ss << "-r" << reduceFactor; + arguments.push_back(ss.str()); + } + if (!checkUserColor) + arguments.push_back("-nousercolor"); + arguments.push_back("-f"); + arguments.push_back("-d"); + arguments.push_back(dependLog); + arguments.push_back("-e"); + arguments.push_back(errorLog); + m_PipelineProcess->runConsoleTool(m_PipelineProcess->getConfig("ToolTga2Dds"), arguments); +} + void CProcessTextureDDS::build() { nldebug("Build process plugin: CProcessTextureDDS"); - m_PipelineProcess->setExit(FINISH_ERROR, "Not implemented"); + + std::string tempDir = m_PipelineProcess->getTempDirectory(); + std::string dependLog = tempDir + "depend.log"; + std::string errorLog = tempDir + "error.log"; + + { + uint nb; + if (m_PipelineProcess->getValueNb(nb, "Texture.DDS")) + { + for (uint i = 0; i < nb; ++i) + { + std::string root; + { + std::stringstream ss; + ss << "Texture.DDS[" << i << "]."; + root = ss.str(); + } + std::vector srcDirectories; + if (!m_PipelineProcess->getValues(srcDirectories, root + "SrcDirectories")) break; + std::string dstDirectory; + if (!m_PipelineProcess->getValue(dstDirectory, root + "DstDirectory")) break; + std::string algorithm; + if (!m_PipelineProcess->getValue(algorithm, root + "Algorithm")) algorithm = ""; + bool createMipMap; + if (!m_PipelineProcess->getValue(createMipMap, root + "CreateMipMap")) createMipMap = false; + uint reduceFactor; + if (!m_PipelineProcess->getValue(reduceFactor, root + "ReduceFactor")) reduceFactor = 0; + bool checkUserColor; + if (!m_PipelineProcess->getValue(checkUserColor, root + "CheckUserColor")) checkUserColor = false; + for (std::vector::iterator it = srcDirectories.begin(), end = srcDirectories.end(); it != end; ++it) + { + std::vector srcFiles; + NLMISC::CPath::getPathContent(*it, false, false, true, srcFiles); + for (std::vector::iterator itf = srcFiles.begin(), endf = srcFiles.end(); itf != endf; ++itf) + { + const std::string &srcFile = *itf; + std::string dstFile = dstDirectory + NLMISC::CFile::getFilenameWithoutExtension(NLMISC::CFile::getFilename(srcFile)) + ".dds"; + // TODO: PARAMETER inputDepends = checkUserColor (because there can be additional inputs depending on the input & depend file of the existing output) (expected input that is waited for must be in the depend log even if it doesn't exist yet!) + if (m_PipelineProcess->needsToBeRebuilt(srcFile, dstFile)) + { + m_PipelineProcess->makePaths(dstFile); + buildDDS(dependLog, errorLog, srcFile, dstFile, algorithm, createMipMap, reduceFactor, checkUserColor); + if (m_PipelineProcess->needsExit()) return; + m_PipelineProcess->parseToolLog(dependLog, errorLog, false); + } + if (m_PipelineProcess->needsExit()) return; + } + } + } + } + } + + m_PipelineProcess->deleteDirectoryIfEmpty(tempDir); } void CProcessTextureDDSInfo::getDependentDirectories(std::vector &resultAppend) diff --git a/code/nel/tools/pipeline/plugin_nel/process_texture_dds.h b/code/nel/tools/pipeline/plugin_nel/process_texture_dds.h index 0c2d61c1e..dc9d8fe94 100644 --- a/code/nel/tools/pipeline/plugin_nel/process_texture_dds.h +++ b/code/nel/tools/pipeline/plugin_nel/process_texture_dds.h @@ -51,7 +51,7 @@ public: CProcessTextureDDS() { } virtual ~CProcessTextureDDS() { } - void buildAtlas(const std::string &dependLog, const std::string &errorLog, const std::vector &srcDirectories, const std::string &dstFile); + void buildDDS(const std::string &dependLog, const std::string &errorLog, const std::string &srcFile, const std::string &dstFile, const std::string &algorithm, bool createMipMap, uint reduceFactor, bool checkUserColor); virtual void build(); @@ -69,7 +69,7 @@ class CProcessTextureDDSInfo : public IProcessInfo public: CProcessTextureDDSInfo() { } virtual ~CProcessTextureDDSInfo() { } - + virtual void getDependentDirectories(std::vector &resultAppend); virtual void getDependentFiles(std::vector &resultAppend); diff --git a/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg index 961c3802b..7d786b11f 100644 --- a/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg +++ b/code/nel/tools/pipeline/service/example_cfg/pipeline_service_default.cfg @@ -41,6 +41,7 @@ PrimitivesDirectory = SharedLeveldesign + "/primitives"; // ToolSuffix = ".exe"; ToolBuildInterface = "build_interface"; +ToolTga2Dds = "tga2dds"; // Ignored process plugins, like CProcessMaxShape, which should be completely ignored by the master service, even if they are configured to be used inside the process sheets. // MasterIgnoreProcessPlugins = { }; // Only used by the master service. NOT USED, USE WORKSPACE INTEAD! diff --git a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp index 0400b8440..36b7af1c5 100644 --- a/code/nel/tools/pipeline/service/module_pipeline_slave.cpp +++ b/code/nel/tools/pipeline/service/module_pipeline_slave.cpp @@ -636,7 +636,7 @@ public: CInfoFlags::getInstance()->removeFlag(PIPELINE_INFO_BUILD_TASK); } - void finishedTask(TProcessResult errorLevel, const std::string &errorMessage) + void finishedTask(TProcessResult errorLevel, std::string errorMessage) { nlinfo("errorLevel: %i, errorMessage: %s", (uint32)errorLevel, errorMessage.c_str()); clearActiveProcess(); diff --git a/code/nel/tools/pipeline/service/pipeline_project.cpp b/code/nel/tools/pipeline/service/pipeline_project.cpp index 7311996f9..e1efde897 100644 --- a/code/nel/tools/pipeline/service/pipeline_project.cpp +++ b/code/nel/tools/pipeline/service/pipeline_project.cpp @@ -66,6 +66,11 @@ bool CPipelineProject::getValue(std::string &result, const std::string &name) nlwarning("Node '%s' not found in '%s'", name.c_str(), m_Form->getFilename().c_str()); return false; } + if (!valueElm) + { + nlwarning("Node '%s' not found in '%s', valueElm returned NULL, probably using default value", name.c_str(), m_Form->getFilename().c_str()); + return false; + } std::string value; if (!valueElm->getValue(value)) { diff --git a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project index dccf6f057..6f1741f8b 100644 --- a/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project +++ b/code/ryzom/common/data_leveldesign/leveldesign/pipeline/common_interface.pipeline_project @@ -71,7 +71,7 @@ - +