Merge pull request #2550 from merwaaan/fix-obj-line-continuation
Fix line continuations in OBJ filespull/2543/head
commit
5b6fe80883
|
@ -118,7 +118,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
|
|||
size_t lastFilePos( 0 );
|
||||
|
||||
std::vector<char> buffer;
|
||||
while ( streamBuffer.getNextDataLine( buffer, '\0' ) ) {
|
||||
while ( streamBuffer.getNextDataLine( buffer, '\\' ) ) {
|
||||
m_DataIt = buffer.begin();
|
||||
m_DataItEnd = buffer.end();
|
||||
|
||||
|
|
|
@ -448,3 +448,37 @@ TEST_F(utObjImportExport, import_without_linend) {
|
|||
const aiScene *scene = myImporter.ReadFile(ASSIMP_TEST_MODELS_DIR "/OBJ/box_without_lineending.obj", 0);
|
||||
ASSERT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
TEST_F(utObjImportExport, import_with_line_continuations) {
|
||||
static const char *ObjModel =
|
||||
"v -0.5 -0.5 0.5\n"
|
||||
"v -0.5 \\\n"
|
||||
" -0.5 -0.5\n"
|
||||
"v -0.5 \\\n"
|
||||
" 0.5 \\\n"
|
||||
" -0.5\n"
|
||||
"f 1 2 3\n";
|
||||
|
||||
Assimp::Importer myImporter;
|
||||
const aiScene *scene = myImporter.ReadFileFromMemory(ObjModel, strlen(ObjModel), 0);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
|
||||
EXPECT_EQ(scene->mNumMeshes, 1U);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 3U);
|
||||
EXPECT_EQ(scene->mMeshes[0]->mNumFaces, 1U);
|
||||
|
||||
auto vertices = scene->mMeshes[0]->mVertices;
|
||||
const float threshold = 0.0001f;
|
||||
|
||||
EXPECT_NEAR(vertices[0].x, -0.5f, threshold);
|
||||
EXPECT_NEAR(vertices[0].y, -0.5f, threshold);
|
||||
EXPECT_NEAR(vertices[0].z, 0.5f, threshold);
|
||||
|
||||
EXPECT_NEAR(vertices[1].x, -0.5f, threshold);
|
||||
EXPECT_NEAR(vertices[1].y, -0.5f, threshold);
|
||||
EXPECT_NEAR(vertices[1].z, -0.5f, threshold);
|
||||
|
||||
EXPECT_NEAR(vertices[2].x, -0.5f, threshold);
|
||||
EXPECT_NEAR(vertices[2].y, 0.5f, threshold);
|
||||
EXPECT_NEAR(vertices[2].z, -0.5f, threshold);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue