mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-15 01:05:57 +08:00
Merge pull request #456 from haroonq/patch-1
Allow BufferView indices to be unspecified.
This commit is contained in:
commit
5e8a7fd602
10
tiny_gltf.h
10
tiny_gltf.h
@ -6145,21 +6145,23 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bufferView =
|
const auto bufferView =
|
||||||
model->accessors[size_t(primitive.indices)].bufferView;
|
model->accessors[size_t(primitive.indices)].bufferView;
|
||||||
if (bufferView < 0 || size_t(bufferView) >= model->bufferViews.size()) {
|
if (bufferView < 0) {
|
||||||
|
// skip, bufferView could be null(-1) for certain extensions
|
||||||
|
} else if (size_t(bufferView) >= model->bufferViews.size()) {
|
||||||
if (err) {
|
if (err) {
|
||||||
(*err) += "accessor[" + std::to_string(primitive.indices) +
|
(*err) += "accessor[" + std::to_string(primitive.indices) +
|
||||||
"] invalid bufferView";
|
"] invalid bufferView";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
model->bufferViews[size_t(bufferView)].target =
|
model->bufferViews[size_t(bufferView)].target =
|
||||||
TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
|
TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
|
||||||
// we could optionally check if accessors' bufferView type is Scalar, as
|
// we could optionally check if accessors' bufferView type is Scalar, as
|
||||||
// it should be
|
// it should be
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &attribute : primitive.attributes) {
|
for (auto &attribute : primitive.attributes) {
|
||||||
const auto accessorsIndex = size_t(attribute.second);
|
const auto accessorsIndex = size_t(attribute.second);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user