From 6dbb6dc0ae197792732d2ed939d37df3c80006c3 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 19 Jun 2009 14:14:26 +0000 Subject: [PATCH] From Gino van den Bergen, "AFAICS, OSG's OBJ loader correctly handles backslash-newlines that are used for continuation of lines. However, I recently ran into a problem with OBJs that where converted from another source using Right Hemisphere Deep Exploration. In these OBJs newlines are escaped in the following way: f 15939/9999/16177 15941/10000/16178 15940/10001/16179\ 15938/10002/16180 In the OBJ loader the newline would be interpreted as follows f 15939/9999/16177 15941/10000/16178 15940/10001/1617915938/10002/16180 However, for correctly loading the model it should be interpreted as f 15939/9999/16177 15941/10000/16178 15940/10001/16179 15938/10002/16180 Thus, the escaped newline should be interpreted as a space. I tried to lookup what the correct interpretation for a backslash-newline was in the OBJ spec but did not find anything useful. Nevertheless, my suggestion would be to adopt replacing the escaped newline by a space in order to avoid problems as stated above. I cannot imagine a meaningful usage of a newline within a numerical literal so I do not foresee cases where replacing a backslash-newline by a space would be harmful. The fixed obj.cpp is zipped and attached to this mail." --- src/osgPlugins/obj/obj.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/obj/obj.cpp b/src/osgPlugins/obj/obj.cpp index be97b0c1e..aa73b7b0d 100644 --- a/src/osgPlugins/obj/obj.cpp +++ b/src/osgPlugins/obj/obj.cpp @@ -137,6 +137,7 @@ bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE) if (skipNewline) { skipNewline = false; + *ptr++ = ' '; continue; } else break; @@ -146,6 +147,7 @@ bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE) if (skipNewline) { skipNewline = false; + *ptr++ = ' '; continue; } else break; @@ -156,7 +158,7 @@ bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE) // osg::notify(osg::NOTICE)<<"We have unix line ending"<