mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-16 14:16:03 +08:00
Code clean-up. Reviewed by @Squareeyes.
This commit is contained in:
parent
ba28ddcc9e
commit
246654a15a
10
tiny_gltf.h
10
tiny_gltf.h
@ -1671,7 +1671,7 @@ static bool ParseImage(Image *image, std::string *err, const json &o,
|
||||
if (hasBufferView && hasURI) {
|
||||
// Should not both defined.
|
||||
if (err) {
|
||||
(*err) += "One of `bufferView` or `uri` should be defined, but both are defined for Image.\n";
|
||||
(*err) += "Only one of `bufferView` or `uri` should be defined, but both are defined for Image.\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1685,8 +1685,8 @@ static bool ParseImage(Image *image, std::string *err, const json &o,
|
||||
|
||||
ParseStringProperty(&image->name, err, o, "name", false);
|
||||
|
||||
double bufferView = -1;
|
||||
if (hasBufferView) {
|
||||
double bufferView = -1;
|
||||
if (!ParseNumberProperty(&bufferView, err, o, "bufferView", true)) {
|
||||
if (err) {
|
||||
(*err) += "Failed to parse `bufferView` for Image.\n";
|
||||
@ -1713,20 +1713,19 @@ static bool ParseImage(Image *image, std::string *err, const json &o,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse URI & Load image data.
|
||||
|
||||
std::string uri;
|
||||
std::string tmp_err;
|
||||
if (hasURI) {
|
||||
if (!ParseStringProperty(&uri, &tmp_err, o, "uri", true)) {
|
||||
if (err) {
|
||||
(*err) += "Failed to parse `uri` for Image.\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<unsigned char> img;
|
||||
|
||||
if (hasURI) {
|
||||
if (IsDataURI(uri)) {
|
||||
if (!DecodeDataURI(&img, uri, 0, false)) {
|
||||
if (err) {
|
||||
@ -1756,7 +1755,6 @@ static bool ParseImage(Image *image, std::string *err, const json &o,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (*LoadImageData == nullptr) {
|
||||
if (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user