From a305f82bee61307c6641f20533b510502a83693e Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Mon, 6 May 2024 09:23:51 +0200 Subject: [PATCH 1/3] 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(); From 6e9c776acf358d41b8f72b11e415c526ba62675d Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Mon, 6 May 2024 10:34:10 +0200 Subject: [PATCH 2/3] OBJReader: avoid precision loss. --- src/OpenMesh/Core/IO/reader/OBJReader.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenMesh/Core/IO/reader/OBJReader.cc b/src/OpenMesh/Core/IO/reader/OBJReader.cc index 56b9a134..b855e29f 100644 --- a/src/OpenMesh/Core/IO/reader/OBJReader.cc +++ b/src/OpenMesh/Core/IO/reader/OBJReader.cc @@ -287,8 +287,8 @@ read_vertices(std::istream& _in, BaseImporter& _bi, Options& _opt, std::vector & vertexHandles, Options & fileOptions) { - float x, y, z, u, v, w; - float r, g, b; + double x, y, z, u, v, w; + double r, g, b; std::string line; std::string keyWrd; From 9eefd50027d76c460ad3c86e9606cfbf64eec4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 7 May 2024 08:41:58 +0000 Subject: [PATCH 3/3] Update changelog.docu --- Doc/changelog.docu | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/changelog.docu b/Doc/changelog.docu index 266011a1..d83fb61a 100644 --- a/Doc/changelog.docu +++ b/Doc/changelog.docu @@ -26,6 +26,7 @@ IO
  • PLY reader/writer: Fixed color trait Vec3f compilation for PLY writer
  • +
  • OBJ Reader/Writer: Avoid precision loss when writing coordinates and normals.
Build System