mirror of
https://git.mirrors.martin98.com/https://github.com/google/draco
synced 2025-08-11 17:59:02 +08:00
Fixed loading of .obj files that do not end with a new line character.
This commit is contained in:
parent
6763aa325e
commit
0d42cbb586
@ -369,12 +369,12 @@ bool ObjDecoder::ParseFace(bool *error) {
|
||||
} else {
|
||||
// Non-whitespace reached.. assume it's index declaration, skip it.
|
||||
num_indices++;
|
||||
while (!parser::PeekWhitespace(buffer(), &is_end)) {
|
||||
while (!parser::PeekWhitespace(buffer(), &is_end) && !is_end) {
|
||||
buffer()->Advance(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_end || num_indices < 3 || num_indices > 4) {
|
||||
if (num_indices < 3 || num_indices > 4) {
|
||||
*error = true;
|
||||
return false;
|
||||
}
|
||||
|
@ -89,4 +89,12 @@ TEST_F(ObjDecoderTest, ComplexPolyOBJ) {
|
||||
ASSERT_EQ(mesh, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(ObjDecoderTest, EOFTestOBJ) {
|
||||
// Tests loading of .obj models with no new line at the end of the file.
|
||||
const std::string file_name = "eof_test.obj";
|
||||
const std::unique_ptr<Mesh> mesh(DecodeObj<Mesh>(file_name));
|
||||
ASSERT_NE(mesh, nullptr);
|
||||
ASSERT_EQ(mesh->num_faces(), 1);
|
||||
}
|
||||
|
||||
} // namespace draco
|
||||
|
4
testdata/eof_test.obj
vendored
Normal file
4
testdata/eof_test.obj
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
v 1.00 0.10 0.00
|
||||
v 2.00 0.01 0.00
|
||||
v 3.00 0.11 0.00
|
||||
f 1 2 3
|
Loading…
x
Reference in New Issue
Block a user