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
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;
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();