From a305f82bee61307c6641f20533b510502a83693e Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Mon, 6 May 2024 09:23:51 +0200 Subject: [PATCH] OBJWriter: avoid precision loss when writing coordinates and normals. --- src/OpenMesh/Core/IO/writer/OBJWriter.cc | 33 ++++++++++++++---------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/OpenMesh/Core/IO/writer/OBJWriter.cc b/src/OpenMesh/Core/IO/writer/OBJWriter.cc index f134b89e..42375377 100644 --- a/src/OpenMesh/Core/IO/writer/OBJWriter.cc +++ b/src/OpenMesh/Core/IO/writer/OBJWriter.cc @@ -216,8 +216,6 @@ _OBJWriter_:: write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std::streamsize _precision) const { unsigned int idx; - Vec3f v, n; - Vec2f t; VertexHandle vh; std::vector vhandles; bool useMatrial = false; @@ -296,7 +294,7 @@ write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std:: for (size_t i=0, nV=_be.n_vertices(); i(i)); - t = _be.texcoord(vh); + Vec2f t = _be.texcoord(vh); texMap[t] = static_cast(i); } } @@ -313,18 +311,27 @@ write(std::ostream& _out, BaseExporter& _be, const Options& _writeOptions, std:: } } - // vertex data (point, normals, texcoords) + const bool normal_double = _be.is_normal_double(); + const bool point_double = _be.is_point_double(); for (size_t i=0, nV=_be.n_vertices(); i::max();