diff --git a/components/detournavigator/asyncnavmeshupdater.cpp b/components/detournavigator/asyncnavmeshupdater.cpp index 5c88d0cfa2..966e07bc5a 100644 --- a/components/detournavigator/asyncnavmeshupdater.cpp +++ b/components/detournavigator/asyncnavmeshupdater.cpp @@ -409,7 +409,7 @@ namespace DetourNavigator } if (recastMesh && mSettings.get().mEnableWriteRecastMeshToFile) writeToFile(*recastMesh, mSettings.get().mRecastMeshPathPrefix + std::to_string(job.mChangedTile.x()) - + "_" + std::to_string(job.mChangedTile.y()) + "_", recastMeshRevision); + + "_" + std::to_string(job.mChangedTile.y()) + "_", recastMeshRevision, mSettings); if (mSettings.get().mEnableWriteNavMeshToFile) if (const auto shared = job.mNavMeshCacheItem.lock()) writeToFile(shared->lockConst()->getImpl(), mSettings.get().mNavMeshPathPrefix, navMeshRevision); diff --git a/components/detournavigator/debug.cpp b/components/detournavigator/debug.cpp index 4cb5b248b0..07832d748f 100644 --- a/components/detournavigator/debug.cpp +++ b/components/detournavigator/debug.cpp @@ -1,6 +1,8 @@ #include "debug.hpp" #include "exceptions.hpp" #include "recastmesh.hpp" +#include "settings.hpp" +#include "settingsutils.hpp" #include @@ -9,7 +11,7 @@ namespace DetourNavigator { - void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision) + void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision, const Settings& settings) { const auto path = pathPrefix + "recastmesh" + revision + ".obj"; boost::filesystem::ofstream file(boost::filesystem::path(path), std::ios::out); @@ -17,20 +19,14 @@ namespace DetourNavigator throw NavigatorException("Open file failed: " + path); file.exceptions(std::ios::failbit | std::ios::badbit); file.precision(std::numeric_limits::max_exponent10); - std::size_t count = 0; - for (float v : recastMesh.getMesh().getVertices()) + std::vector vertices = recastMesh.getMesh().getVertices(); + for (std::size_t i = 0; i < vertices.size(); i += 3) { - if (count % 3 == 0) - { - if (count != 0) - file << '\n'; - file << 'v'; - } - file << ' ' << v; - ++count; + file << "v " << toNavMeshCoordinates(settings, vertices[i]) << ' ' + << toNavMeshCoordinates(settings, vertices[i + 2]) << ' ' + << toNavMeshCoordinates(settings, vertices[i + 1]) << '\n'; } - file << '\n'; - count = 0; + std::size_t count = 0; for (int v : recastMesh.getMesh().getIndices()) { if (count % 3 == 0) diff --git a/components/detournavigator/debug.hpp b/components/detournavigator/debug.hpp index 2128f96be4..d86d923a41 100644 --- a/components/detournavigator/debug.hpp +++ b/components/detournavigator/debug.hpp @@ -48,8 +48,9 @@ namespace DetourNavigator } class RecastMesh; + struct Settings; - void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision); + void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision, const Settings& settings); void writeToFile(const dtNavMesh& navMesh, const std::string& pathPrefix, const std::string& revision); }