MCPcopy Create free account
hub / github.com/OpenMW/openmw / writeToFile

Function writeToFile

components/detournavigator/debug.cpp:220–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 2

writeDebugRecastMeshFunction · 0.85
writeDebugNavMeshFunction · 0.85

Calls 4

toNavMeshCoordinatesFunction · 0.85
getMeshMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected