mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-07-31 01:52:00 +08:00
Refactor source code.
Add compiler matrix in Travis build.
This commit is contained in:
parent
c4bc323c0e
commit
7c87797176
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
BasedOnStyle: LLVM
|
BasedOnStyle: Google
|
||||||
IndentWidth: 2
|
IndentWidth: 2
|
||||||
TabWidth: 2
|
TabWidth: 2
|
||||||
UseTab: Never
|
UseTab: Never
|
||||||
|
44
.travis.yml
44
.travis.yml
@ -1,10 +1,46 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
|
sudo: false
|
||||||
compiler: gcc
|
matrix:
|
||||||
|
include:
|
||||||
|
- addons: &1
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- george-edison55-precise-backports
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
- llvm-toolchain-precise-3.7
|
||||||
|
packages:
|
||||||
|
- g++-4.9
|
||||||
|
- clang-3.7
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER_VERSION=3.7 BUILD_TYPE=Debug
|
||||||
|
- addons: *1
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER_VERSION=3.7 BUILD_TYPE=Release
|
||||||
|
- addons: &2
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- george-edison55-precise-backports
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages:
|
||||||
|
- g++-4.9
|
||||||
|
compiler: gcc
|
||||||
|
env: COMPILER_VERSION=4.9 BUILD_TYPE=Debug
|
||||||
|
- addons: *2
|
||||||
|
compiler: gcc
|
||||||
|
env: COMPILER_VERSION=4.9 BUILD_TYPE=Release
|
||||||
|
- addons: *1
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER_VERSION=3.7 BUILD_TYPE=Debug CFLAGS="-O0 --coverage" CXXFLAGS="-O0
|
||||||
|
--coverage" REPORT_COVERAGE=1
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get update -qq -y
|
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade; fi
|
||||||
|
- if [ -n "$REPORT_COVERAGE" ]; then pip install --user cpp-coveralls; fi
|
||||||
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- make
|
- export CC="${CC}-${COMPILER_VERSION}"
|
||||||
|
- export CXX="${CXX}-${COMPILER_VERSION}"
|
||||||
|
- ${CC} -v
|
||||||
|
- ${CXX} -fsanitize=address -Wall -Werror -g -o loader_test test.cc
|
||||||
- ./loader_test box.gltf
|
- ./loader_test box.gltf
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
// - base64: base64 decode/encode library.
|
// - base64: base64 decode/encode library.
|
||||||
// - stb_image: Image loading library.
|
// - stb_image: Image loading library.
|
||||||
//
|
//
|
||||||
#ifndef TINY_GLTF_LOADER_H
|
#ifndef TINY_GLTF_LOADER_H_
|
||||||
#define TINY_GLTF_LOADER_H
|
#define TINY_GLTF_LOADER_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -140,7 +140,7 @@ typedef struct {
|
|||||||
} Accessor;
|
} Accessor;
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
public:
|
public:
|
||||||
Camera() {}
|
Camera() {}
|
||||||
~Camera() {}
|
~Camera() {}
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ typedef struct {
|
|||||||
} Mesh;
|
} Mesh;
|
||||||
|
|
||||||
class Node {
|
class Node {
|
||||||
public:
|
public:
|
||||||
Node() {}
|
Node() {}
|
||||||
~Node() {}
|
~Node() {}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ typedef struct {
|
|||||||
} Asset;
|
} Asset;
|
||||||
|
|
||||||
class Scene {
|
class Scene {
|
||||||
public:
|
public:
|
||||||
Scene() {}
|
Scene() {}
|
||||||
~Scene() {}
|
~Scene() {}
|
||||||
|
|
||||||
@ -220,9 +220,9 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class TinyGLTFLoader {
|
class TinyGLTFLoader {
|
||||||
public:
|
public:
|
||||||
TinyGLTFLoader(){};
|
TinyGLTFLoader() {}
|
||||||
~TinyGLTFLoader(){};
|
~TinyGLTFLoader() {}
|
||||||
|
|
||||||
/// Loads glTF asset from a file.
|
/// Loads glTF asset from a file.
|
||||||
/// Returns false and set error string to `err` if there's an error.
|
/// Returns false and set error string to `err` if there's an error.
|
||||||
@ -242,6 +242,7 @@ public:
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "picojson.h"
|
#include "picojson.h"
|
||||||
#include "stb_image.h"
|
#include "stb_image.h"
|
||||||
@ -384,10 +385,8 @@ std::string base64_decode(std::string const &s);
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include "base64.h"
|
static const std::string base64_chars =
|
||||||
//#include <iostream>
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
|
||||||
static const std::string base64_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
"0123456789+/";
|
"0123456789+/";
|
||||||
|
|
||||||
@ -395,51 +394,6 @@ static inline bool is_base64(unsigned char c) {
|
|||||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
|
||||||
std::string ret;
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
unsigned char char_array_3[3];
|
|
||||||
unsigned char char_array_4[4];
|
|
||||||
|
|
||||||
while (in_len--) {
|
|
||||||
char_array_3[i++] = *(bytes_to_encode++);
|
|
||||||
if (i == 3) {
|
|
||||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
|
||||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
|
||||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
|
||||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
|
||||||
|
|
||||||
for(i = 0; (i <4) ; i++)
|
|
||||||
ret += base64_chars[char_array_4[i]];
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i)
|
|
||||||
{
|
|
||||||
for(j = i; j < 3; j++)
|
|
||||||
char_array_3[j] = '\0';
|
|
||||||
|
|
||||||
char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
|
|
||||||
char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
|
|
||||||
char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
|
|
||||||
char_array_4[3] = char_array_3[2] & 0x3f;
|
|
||||||
|
|
||||||
for (j = 0; (j < i + 1); j++)
|
|
||||||
ret += base64_chars[char_array_4[j]];
|
|
||||||
|
|
||||||
while((i++ < 3))
|
|
||||||
ret += '=';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string base64_decode(std::string const &encoded_string) {
|
std::string base64_decode(std::string const &encoded_string) {
|
||||||
int in_len = encoded_string.size();
|
int in_len = encoded_string.size();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -462,15 +416,13 @@ std::string base64_decode(std::string const &encoded_string) {
|
|||||||
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
for (i = 0; (i < 3); i++)
|
for (i = 0; (i < 3); i++) ret += char_array_3[i];
|
||||||
ret += char_array_3[i];
|
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i) {
|
if (i) {
|
||||||
for (j = i; j < 4; j++)
|
for (j = i; j < 4; j++) char_array_4[j] = 0;
|
||||||
char_array_4[j] = 0;
|
|
||||||
|
|
||||||
for (j = 0; j < 4; j++)
|
for (j = 0; j < 4; j++)
|
||||||
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
char_array_4[j] = base64_chars.find(char_array_4[j]);
|
||||||
@ -480,8 +432,7 @@ std::string base64_decode(std::string const &encoded_string) {
|
|||||||
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
|
||||||
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
|
||||||
|
|
||||||
for (j = 0; (j < i - 1); j++)
|
for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
|
||||||
ret += char_array_3[j];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -728,7 +679,6 @@ bool ParseStringArrayProperty(std::vector<std::string> &ret, std::string &err,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ParseAsset(Asset &asset, std::string &err, const picojson::object &o) {
|
bool ParseAsset(Asset &asset, std::string &err, const picojson::object &o) {
|
||||||
|
|
||||||
ParseStringProperty(asset.generator, err, o, "generator", false);
|
ParseStringProperty(asset.generator, err, o, "generator", false);
|
||||||
ParseBooleanProperty(asset.premultipliedAlpha, err, o, "premultipliedAlpha",
|
ParseBooleanProperty(asset.premultipliedAlpha, err, o, "premultipliedAlpha",
|
||||||
false);
|
false);
|
||||||
@ -751,7 +701,6 @@ bool ParseAsset(Asset &asset, std::string &err, const picojson::object &o) {
|
|||||||
|
|
||||||
bool ParseImage(Image &image, std::string &err, const picojson::object &o,
|
bool ParseImage(Image &image, std::string &err, const picojson::object &o,
|
||||||
const std::string &basedir) {
|
const std::string &basedir) {
|
||||||
|
|
||||||
std::string uri;
|
std::string uri;
|
||||||
if (!ParseStringProperty(uri, err, o, "uri", true)) {
|
if (!ParseStringProperty(uri, err, o, "uri", true)) {
|
||||||
return false;
|
return false;
|
||||||
@ -801,7 +750,6 @@ bool ParseImage(Image &image, std::string &err, const picojson::object &o,
|
|||||||
|
|
||||||
bool ParseTexture(Texture &texture, std::string &err, const picojson::object &o,
|
bool ParseTexture(Texture &texture, std::string &err, const picojson::object &o,
|
||||||
const std::string &basedir) {
|
const std::string &basedir) {
|
||||||
|
|
||||||
if (!ParseStringProperty(texture.sampler, err, o, "sampler", true)) {
|
if (!ParseStringProperty(texture.sampler, err, o, "sampler", true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -998,7 +946,8 @@ bool ParsePrimitive(Primitive &primitive, std::string &err,
|
|||||||
|
|
||||||
int primMode = static_cast<int>(mode);
|
int primMode = static_cast<int>(mode);
|
||||||
if (primMode != TINYGLTF_MODE_TRIANGLES) {
|
if (primMode != TINYGLTF_MODE_TRIANGLES) {
|
||||||
err += "Currently TinyGLTFLoader doesn not support primitive mode other \n"
|
err +=
|
||||||
|
"Currently TinyGLTFLoader doesn not support primitive mode other \n"
|
||||||
"than TRIANGLES.\n";
|
"than TRIANGLES.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1085,7 +1034,6 @@ bool ParseMaterial(Material &material, std::string &err,
|
|||||||
material.values.clear();
|
material.values.clear();
|
||||||
picojson::object::const_iterator valuesIt = o.find("values");
|
picojson::object::const_iterator valuesIt = o.find("values");
|
||||||
if ((valuesIt != o.end()) && (valuesIt->second).is<picojson::object>()) {
|
if ((valuesIt != o.end()) && (valuesIt->second).is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &valuesObject =
|
const picojson::object &valuesObject =
|
||||||
(valuesIt->second).get<picojson::object>();
|
(valuesIt->second).get<picojson::object>();
|
||||||
picojson::object::const_iterator it(valuesObject.begin());
|
picojson::object::const_iterator it(valuesObject.begin());
|
||||||
@ -1112,7 +1060,8 @@ bool ParseMaterial(Material &material, std::string &err,
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
||||||
const char *str, unsigned int length,
|
const char *str, unsigned int length,
|
||||||
@ -1189,7 +1138,6 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Buffer buffer;
|
Buffer buffer;
|
||||||
if (!ParseBuffer(buffer, err, (it->second).get<picojson::object>(),
|
if (!ParseBuffer(buffer, err, (it->second).get<picojson::object>(),
|
||||||
baseDir)) {
|
baseDir)) {
|
||||||
@ -1203,13 +1151,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
// 2. Parse BufferView
|
// 2. Parse BufferView
|
||||||
if (v.contains("bufferViews") &&
|
if (v.contains("bufferViews") &&
|
||||||
v.get("bufferViews").is<picojson::object>()) {
|
v.get("bufferViews").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("bufferViews").get<picojson::object>();
|
const picojson::object &root = v.get("bufferViews").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
BufferView bufferView;
|
BufferView bufferView;
|
||||||
if (!ParseBufferView(bufferView, err,
|
if (!ParseBufferView(bufferView, err,
|
||||||
(it->second).get<picojson::object>())) {
|
(it->second).get<picojson::object>())) {
|
||||||
@ -1222,13 +1168,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 3. Parse Accessor
|
// 3. Parse Accessor
|
||||||
if (v.contains("accessors") && v.get("accessors").is<picojson::object>()) {
|
if (v.contains("accessors") && v.get("accessors").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("accessors").get<picojson::object>();
|
const picojson::object &root = v.get("accessors").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Accessor accessor;
|
Accessor accessor;
|
||||||
if (!ParseAccessor(accessor, err, (it->second).get<picojson::object>())) {
|
if (!ParseAccessor(accessor, err, (it->second).get<picojson::object>())) {
|
||||||
return false;
|
return false;
|
||||||
@ -1240,13 +1184,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 4. Parse Mesh
|
// 4. Parse Mesh
|
||||||
if (v.contains("meshes") && v.get("meshes").is<picojson::object>()) {
|
if (v.contains("meshes") && v.get("meshes").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("meshes").get<picojson::object>();
|
const picojson::object &root = v.get("meshes").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Mesh mesh;
|
Mesh mesh;
|
||||||
if (!ParseMesh(mesh, err, (it->second).get<picojson::object>())) {
|
if (!ParseMesh(mesh, err, (it->second).get<picojson::object>())) {
|
||||||
return false;
|
return false;
|
||||||
@ -1258,13 +1200,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 5. Parse Node
|
// 5. Parse Node
|
||||||
if (v.contains("nodes") && v.get("nodes").is<picojson::object>()) {
|
if (v.contains("nodes") && v.get("nodes").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("nodes").get<picojson::object>();
|
const picojson::object &root = v.get("nodes").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Node node;
|
Node node;
|
||||||
if (!ParseNode(node, err, (it->second).get<picojson::object>())) {
|
if (!ParseNode(node, err, (it->second).get<picojson::object>())) {
|
||||||
return false;
|
return false;
|
||||||
@ -1276,13 +1216,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 6. Parse scenes.
|
// 6. Parse scenes.
|
||||||
if (v.contains("scenes") && v.get("scenes").is<picojson::object>()) {
|
if (v.contains("scenes") && v.get("scenes").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("scenes").get<picojson::object>();
|
const picojson::object &root = v.get("scenes").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
const picojson::object &o = (it->second).get<picojson::object>();
|
const picojson::object &o = (it->second).get<picojson::object>();
|
||||||
std::vector<std::string> nodes;
|
std::vector<std::string> nodes;
|
||||||
if (!ParseStringArrayProperty(nodes, err, o, "nodes", false)) {
|
if (!ParseStringArrayProperty(nodes, err, o, "nodes", false)) {
|
||||||
@ -1295,7 +1233,6 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 7. Parse default scenes.
|
// 7. Parse default scenes.
|
||||||
if (v.contains("scene") && v.get("scene").is<std::string>()) {
|
if (v.contains("scene") && v.get("scene").is<std::string>()) {
|
||||||
|
|
||||||
const std::string defaultScene = v.get("scene").get<std::string>();
|
const std::string defaultScene = v.get("scene").get<std::string>();
|
||||||
|
|
||||||
scene.defaultScene = defaultScene;
|
scene.defaultScene = defaultScene;
|
||||||
@ -1303,13 +1240,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 8. Parse Material
|
// 8. Parse Material
|
||||||
if (v.contains("materials") && v.get("materials").is<picojson::object>()) {
|
if (v.contains("materials") && v.get("materials").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("materials").get<picojson::object>();
|
const picojson::object &root = v.get("materials").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Material material;
|
Material material;
|
||||||
if (!ParseMaterial(material, err, (it->second).get<picojson::object>())) {
|
if (!ParseMaterial(material, err, (it->second).get<picojson::object>())) {
|
||||||
return false;
|
return false;
|
||||||
@ -1321,13 +1256,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 9. Parse Image
|
// 9. Parse Image
|
||||||
if (v.contains("images") && v.get("images").is<picojson::object>()) {
|
if (v.contains("images") && v.get("images").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("images").get<picojson::object>();
|
const picojson::object &root = v.get("images").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Image image;
|
Image image;
|
||||||
if (!ParseImage(image, err, (it->second).get<picojson::object>(),
|
if (!ParseImage(image, err, (it->second).get<picojson::object>(),
|
||||||
baseDir)) {
|
baseDir)) {
|
||||||
@ -1340,13 +1273,11 @@ bool TinyGLTFLoader::LoadFromString(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
// 9. Parse Texture
|
// 9. Parse Texture
|
||||||
if (v.contains("textures") && v.get("textures").is<picojson::object>()) {
|
if (v.contains("textures") && v.get("textures").is<picojson::object>()) {
|
||||||
|
|
||||||
const picojson::object &root = v.get("textures").get<picojson::object>();
|
const picojson::object &root = v.get("textures").get<picojson::object>();
|
||||||
|
|
||||||
picojson::object::const_iterator it(root.begin());
|
picojson::object::const_iterator it(root.begin());
|
||||||
picojson::object::const_iterator itEnd(root.end());
|
picojson::object::const_iterator itEnd(root.end());
|
||||||
for (; it != itEnd; it++) {
|
for (; it != itEnd; it++) {
|
||||||
|
|
||||||
Texture texture;
|
Texture texture;
|
||||||
if (!ParseTexture(texture, err, (it->second).get<picojson::object>(),
|
if (!ParseTexture(texture, err, (it->second).get<picojson::object>(),
|
||||||
baseDir)) {
|
baseDir)) {
|
||||||
@ -1388,4 +1319,4 @@ bool TinyGLTFLoader::LoadFromFile(Scene &scene, std::string &err,
|
|||||||
|
|
||||||
#endif // TINYGLTF_LOADER_IMPLEMENTATION
|
#endif // TINYGLTF_LOADER_IMPLEMENTATION
|
||||||
|
|
||||||
#endif // TINY_GLTF_LOADER_H
|
#endif // TINY_GLTF_LOADER_H_
|
||||||
|
Loading…
x
Reference in New Issue
Block a user