mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 03:55:53 +08:00
Only use valid (triangle) primitive sets
ParsePrimitive returns false immediately on error but the return value wasn't being checked in ParseMesh so invalid / uninitialized primitives were being added to the mesh.
This commit is contained in:
parent
8317ffbe8a
commit
10a3e1da81
@ -1343,8 +1343,10 @@ static bool ParseMesh(Mesh *mesh, std::string *err, const picojson::object &o) {
|
||||
(primObject->second).get<picojson::array>();
|
||||
for (size_t i = 0; i < primArray.size(); i++) {
|
||||
Primitive primitive;
|
||||
ParsePrimitive(&primitive, err, primArray[i].get<picojson::object>());
|
||||
mesh->primitives.push_back(primitive);
|
||||
if(ParsePrimitive(&primitive, err, primArray[i].get<picojson::object>())){
|
||||
// Only add the primitive if the parsing succeeds.
|
||||
mesh->primitives.push_back(primitive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user