mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-17 06:36:00 +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) {
|
if (hasBufferView && hasURI) {
|
||||||
// Should not both defined.
|
// Should not both defined.
|
||||||
if (err) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1685,8 +1685,8 @@ static bool ParseImage(Image *image, std::string *err, const json &o,
|
|||||||
|
|
||||||
ParseStringProperty(&image->name, err, o, "name", false);
|
ParseStringProperty(&image->name, err, o, "name", false);
|
||||||
|
|
||||||
double bufferView = -1;
|
|
||||||
if (hasBufferView) {
|
if (hasBufferView) {
|
||||||
|
double bufferView = -1;
|
||||||
if (!ParseNumberProperty(&bufferView, err, o, "bufferView", true)) {
|
if (!ParseNumberProperty(&bufferView, err, o, "bufferView", true)) {
|
||||||
if (err) {
|
if (err) {
|
||||||
(*err) += "Failed to parse `bufferView` for Image.\n";
|
(*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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parse URI & Load image data.
|
||||||
|
|
||||||
std::string uri;
|
std::string uri;
|
||||||
std::string tmp_err;
|
std::string tmp_err;
|
||||||
if (hasURI) {
|
|
||||||
if (!ParseStringProperty(&uri, &tmp_err, o, "uri", true)) {
|
if (!ParseStringProperty(&uri, &tmp_err, o, "uri", true)) {
|
||||||
if (err) {
|
if (err) {
|
||||||
(*err) += "Failed to parse `uri` for Image.\n";
|
(*err) += "Failed to parse `uri` for Image.\n";
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<unsigned char> img;
|
std::vector<unsigned char> img;
|
||||||
|
|
||||||
if (hasURI) {
|
|
||||||
if (IsDataURI(uri)) {
|
if (IsDataURI(uri)) {
|
||||||
if (!DecodeDataURI(&img, uri, 0, false)) {
|
if (!DecodeDataURI(&img, uri, 0, false)) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -1756,7 +1755,6 @@ static bool ParseImage(Image *image, std::string *err, const json &o,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (*LoadImageData == nullptr) {
|
if (*LoadImageData == nullptr) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user