| 218 | } |
| 219 | |
| 220 | void writeToFile(const RecastMesh& recastMesh, const std::string& pathPrefix, const std::string& revision, |
| 221 | const RecastSettings& settings) |
| 222 | { |
| 223 | const auto path = pathPrefix + "recastmesh" + revision + ".obj"; |
| 224 | std::ofstream file(std::filesystem::path(path), std::ios::out); |
| 225 | if (!file.is_open()) |
| 226 | throw std::system_error( |
| 227 | errno, std::generic_category(), "Failed to open file to write recast mesh: " + path); |
| 228 | file.exceptions(std::ios::failbit | std::ios::badbit); |
| 229 | file.precision(std::numeric_limits<float>::max_exponent10); |
| 230 | std::vector<float> vertices = recastMesh.getMesh().getVertices(); |
| 231 | for (std::size_t i = 0; i < vertices.size(); i += 3) |
| 232 | { |
| 233 | file << "v " << toNavMeshCoordinates(settings, vertices[i]) << ' ' |
| 234 | << toNavMeshCoordinates(settings, vertices[i + 2]) << ' ' |
| 235 | << toNavMeshCoordinates(settings, vertices[i + 1]) << '\n'; |
| 236 | } |
| 237 | std::size_t count = 0; |
| 238 | for (int v : recastMesh.getMesh().getIndices()) |
| 239 | { |
| 240 | if (count % 3 == 0) |
| 241 | { |
| 242 | if (count != 0) |
| 243 | file << '\n'; |
| 244 | file << 'f'; |
| 245 | } |
| 246 | file << ' ' << (v + 1); |
| 247 | ++count; |
| 248 | } |
| 249 | file << '\n'; |
| 250 | } |
| 251 | |
| 252 | void writeToFile(const dtNavMesh& navMesh, const std::string& pathPrefix, const std::string& revision) |
| 253 | { |
no test coverage detected