mirror of
https://github.com/syoyo/tinygltf.git
synced 2026-06-08 19:23:50 +00:00
Compare commits
11 Commits
harden-api
...
v2.9.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81bd50c106 | ||
|
|
6d8bba0d8a | ||
|
|
2aa77e5d0a | ||
|
|
1fac6234d9 | ||
|
|
bcd666fbd4 | ||
|
|
37250b3470 | ||
|
|
7385235e29 | ||
|
|
3564b48760 | ||
|
|
2ad433b68f | ||
|
|
1b517f2b23 | ||
|
|
bd7255e095 |
@@ -159,9 +159,10 @@ Model model;
|
||||
TinyGLTF loader;
|
||||
std::string err;
|
||||
std::string warn;
|
||||
std::string filename = "input.gltf";
|
||||
|
||||
bool ret = loader.LoadASCIIFromFile(&model, &err, &warn, argv[1]);
|
||||
//bool ret = loader.LoadBinaryFromFile(&model, &err, &warn, argv[1]); // for binary glTF(.glb)
|
||||
bool ret = loader.LoadASCIIFromFile(&model, &err, &warn, filename);
|
||||
//bool ret = loader.LoadBinaryFromFile(&model, &err, &warn, filename); // for binary glTF(.glb)
|
||||
|
||||
if (!warn.empty()) {
|
||||
printf("Warn: %s\n", warn.c_str());
|
||||
@@ -172,8 +173,7 @@ if (!err.empty()) {
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
printf("Failed to parse glTF\n");
|
||||
return -1;
|
||||
printf("Failed to parse glTF: %s\n", filename.c_str());
|
||||
}
|
||||
```
|
||||
|
||||
@@ -194,7 +194,6 @@ if (!ret) {
|
||||
* `TINYGLTF_NO_INCLUDE_STB_IMAGE `: Disable including `stb_image.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.
|
||||
* `TINYGLTF_NO_INCLUDE_STB_IMAGE_WRITE `: Disable including `stb_image_write.h` from within `tiny_gltf.h` because it has been already included before or you want to include it using custom path before including `tiny_gltf.h`.
|
||||
* `TINYGLTF_USE_RAPIDJSON` : Use RapidJSON as a JSON parser/serializer. RapidJSON files are not included in TinyGLTF repo. Please set an include path to RapidJSON if you enable this feature.
|
||||
* `TINYGLTF_USE_CPP14` : Use C++14 feature(requires C++14 compiler). This may give better performance than C++11.
|
||||
|
||||
|
||||
## CMake options
|
||||
|
||||
36
tiny_gltf.h
36
tiny_gltf.h
@@ -50,12 +50,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
// Auto-detect C++14 standard version
|
||||
#if !defined(TINYGLTF_USE_CPP14) && defined(__cplusplus) && \
|
||||
(__cplusplus >= 201402L)
|
||||
#define TINYGLTF_USE_CPP14
|
||||
#endif
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#ifdef TINYGLTF_ANDROID_LOAD_FROM_ASSETS
|
||||
#include <android/asset_manager.h>
|
||||
@@ -834,20 +828,20 @@ struct Accessor {
|
||||
maxValues; // optional. integer value is promoted to double
|
||||
|
||||
struct Sparse {
|
||||
int count;
|
||||
bool isSparse;
|
||||
int count{0};
|
||||
bool isSparse{false};
|
||||
struct {
|
||||
size_t byteOffset;
|
||||
int bufferView;
|
||||
int componentType; // a TINYGLTF_COMPONENT_TYPE_ value
|
||||
size_t byteOffset{0};
|
||||
int bufferView{-1};
|
||||
int componentType{-1}; // a TINYGLTF_COMPONENT_TYPE_ value
|
||||
Value extras;
|
||||
ExtensionMap extensions;
|
||||
std::string extras_json_string;
|
||||
std::string extensions_json_string;
|
||||
} indices;
|
||||
struct {
|
||||
int bufferView;
|
||||
size_t byteOffset;
|
||||
int bufferView{-1};
|
||||
size_t byteOffset{0};
|
||||
Value extras;
|
||||
ExtensionMap extensions;
|
||||
std::string extras_json_string;
|
||||
@@ -898,11 +892,7 @@ struct Accessor {
|
||||
// unreachable return 0;
|
||||
}
|
||||
|
||||
Accessor()
|
||||
|
||||
{
|
||||
sparse.isSparse = false;
|
||||
}
|
||||
Accessor() = default;
|
||||
DEFAULT_METHODS(Accessor)
|
||||
bool operator==(const tinygltf::Accessor &) const;
|
||||
};
|
||||
@@ -4362,7 +4352,7 @@ static bool ParseImage(Image *image, const int image_idx, std::string *err,
|
||||
// Just only save some information here. Loading actual image data from
|
||||
// bufferView is done after this `ParseImage` function.
|
||||
image->bufferView = bufferView;
|
||||
image->mimeType = mime_type;
|
||||
image->mimeType = std::move( mime_type );
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
|
||||
@@ -5261,7 +5251,7 @@ static bool ParseNode(Node *node, std::string *err, const detail::json &o,
|
||||
if (node->extensions.count("MSFT_lod") != 0) {
|
||||
auto const &msft_lod_ext = node->extensions["MSFT_lod"];
|
||||
if (msft_lod_ext.Has("ids")) {
|
||||
auto idsArr = msft_lod_ext.Get("ids");
|
||||
const auto &idsArr = msft_lod_ext.Get("ids");
|
||||
for (size_t i = 0; i < idsArr.ArrayLen(); ++i) {
|
||||
node->lods.emplace_back(idsArr.Get(i).GetNumberAsInt());
|
||||
}
|
||||
@@ -5290,7 +5280,7 @@ static bool ParseScene(Scene *scene, std::string *err, const detail::json &o,
|
||||
if (scene->extensions.count("KHR_audio") != 0) {
|
||||
auto const &audio_ext = scene->extensions["KHR_audio"];
|
||||
if (audio_ext.Has("emitters")) {
|
||||
auto emittersArr = audio_ext.Get("emitters");
|
||||
const auto &emittersArr = audio_ext.Get("emitters");
|
||||
for (size_t i = 0; i < emittersArr.ArrayLen(); ++i) {
|
||||
scene->audioEmitters.emplace_back(emittersArr.Get(i).GetNumberAsInt());
|
||||
}
|
||||
@@ -5326,7 +5316,7 @@ static bool ParsePbrMetallicRoughness(
|
||||
}
|
||||
return false;
|
||||
}
|
||||
pbr->baseColorFactor = baseColorFactor;
|
||||
pbr->baseColorFactor = std::move( baseColorFactor );
|
||||
}
|
||||
|
||||
{
|
||||
@@ -5478,7 +5468,7 @@ static bool ParseMaterial(Material *material, std::string *err, std::string *war
|
||||
if (material->extensions.count("MSFT_lod") != 0) {
|
||||
auto const &msft_lod_ext = material->extensions["MSFT_lod"];
|
||||
if (msft_lod_ext.Has("ids")) {
|
||||
auto idsArr = msft_lod_ext.Get("ids");
|
||||
const auto &idsArr = msft_lod_ext.Get("ids");
|
||||
for (size_t i = 0; i < idsArr.ArrayLen(); ++i) {
|
||||
material->lods.emplace_back(idsArr.Get(i).GetNumberAsInt());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user