mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-13 00:07:24 +00:00
tinygltf update
This commit is contained in:
parent
7cdcf141f4
commit
8a7dca6af0
18
src/external/tinygltf/README.md
vendored
18
src/external/tinygltf/README.md
vendored
@ -7,6 +7,8 @@ If you are looking for old, C++03 version, please use `devel-picojson` branch(bu
|
||||
|
||||
## Status
|
||||
|
||||
Currently TinyGLTF is stable and maintainance mode. No drastic changes and feature addition planned.
|
||||
|
||||
- v2.4.0 Experimental RapidJSON support. Experimental C++14 support(C++14 may give better performance)
|
||||
- v2.3.0 Modified Material representation according to glTF 2.0 schema(and introduced TextureInfo class)
|
||||
- v2.2.0 release(Support loading 16bit PNG. Sparse accessor support)
|
||||
@ -173,9 +175,23 @@ if (!ret) {
|
||||
* `TINYGLTF_NO_INCLUDE_RAPIDJSON `: Disable including RapidJson's header files 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 `: 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 featrure.
|
||||
* `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
|
||||
|
||||
You can add tinygltf using `add_subdirectory` feature.
|
||||
If you add tinygltf to your project using `add_subdirectory`, it would be better to set `TINYGLTF_HEADER_ONLY` on(just add an include path to tinygltf) and `TINYGLTF_INSTALL` off(Which does not install tinygltf files).
|
||||
|
||||
```
|
||||
// Your project's CMakeLists.txt
|
||||
...
|
||||
|
||||
set(TINYGLTF_HEADER_ONLY ON CACHE INTERNAL "" FORCE)
|
||||
set(TINYGLTF_INSTALL OFF CACHE INTERNAL "" FORCE)
|
||||
add_subdirectory(/path/to/tinygltf)
|
||||
```
|
||||
|
||||
|
||||
### Saving gltTF 2.0 model
|
||||
|
||||
|
||||
18613
src/external/tinygltf/json.hpp
vendored
18613
src/external/tinygltf/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
103
src/external/tinygltf/tiny_gltf.h
vendored
103
src/external/tinygltf/tiny_gltf.h
vendored
@ -253,7 +253,6 @@ bool DecodeDataURI(std::vector<unsigned char> *out, std::string &mime_type,
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
// Suppress warning for : static Value null_value
|
||||
// https://stackoverflow.com/questions/15708411/how-to-deal-with-global-constructor-warning-in-clang
|
||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
||||
#pragma clang diagnostic ignored "-Wpadded"
|
||||
#endif
|
||||
@ -1605,7 +1604,7 @@ class TinyGLTF {
|
||||
|
||||
#endif
|
||||
|
||||
#elif !defined(__ANDROID__)
|
||||
#elif !defined(__ANDROID__) && !defined(__OpenBSD__)
|
||||
#include <wordexp.h>
|
||||
#endif
|
||||
|
||||
@ -2040,9 +2039,12 @@ static std::string GetBaseDir(const std::string &filepath) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/8520560/get-a-file-name-from-a-path
|
||||
static std::string GetBaseFilename(const std::string &filepath) {
|
||||
return filepath.substr(filepath.find_last_of("/\\") + 1);
|
||||
constexpr char path_separators[2] = { '/', '\\' };
|
||||
auto idx = filepath.find_last_of(path_separators);
|
||||
if (idx != std::string::npos)
|
||||
return filepath.substr(idx + 1);
|
||||
return filepath;
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const *, unsigned int len);
|
||||
@ -2188,47 +2190,35 @@ stbi_inline std::string base64_decode(std::string const &encoded_string) {
|
||||
// TODO(syoyo): Use uriparser https://uriparser.github.io/ for stricter Uri
|
||||
// decoding?
|
||||
//
|
||||
// https://stackoverflow.com/questions/18307429/encode-decode-url-in-c
|
||||
// Uri Decoding from DLIB
|
||||
// http://dlib.net/dlib/server/server_http.cpp.html
|
||||
|
||||
// --- dlib beign ------------------------------------------------------------
|
||||
// --- dlib begin ------------------------------------------------------------
|
||||
// Copyright (C) 2003 Davis E. King (davis@dlib.net)
|
||||
// License: Boost Software License See LICENSE.txt for the full license.
|
||||
// License: Boost Software License
|
||||
// Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
namespace dlib {
|
||||
|
||||
#if 0
|
||||
inline unsigned char to_hex( unsigned char x )
|
||||
{
|
||||
return x + (x > 9 ? ('A'-10) : '0');
|
||||
}
|
||||
|
||||
const std::string urlencode( const std::string& s )
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
for ( std::string::const_iterator ci = s.begin(); ci != s.end(); ++ci )
|
||||
{
|
||||
if ( (*ci >= 'a' && *ci <= 'z') ||
|
||||
(*ci >= 'A' && *ci <= 'Z') ||
|
||||
(*ci >= '0' && *ci <= '9') )
|
||||
{ // allowed
|
||||
os << *ci;
|
||||
}
|
||||
else if ( *ci == ' ')
|
||||
{
|
||||
os << '+';
|
||||
}
|
||||
else
|
||||
{
|
||||
os << '%' << to_hex(static_cast<unsigned char>(*ci >> 4)) << to_hex(static_cast<unsigned char>(*ci % 16));
|
||||
}
|
||||
}
|
||||
|
||||
return os.str();
|
||||
}
|
||||
#endif
|
||||
|
||||
inline unsigned char from_hex(unsigned char ch) {
|
||||
if (ch <= '9' && ch >= '0')
|
||||
ch -= '0';
|
||||
@ -2629,7 +2619,7 @@ stbi_inline std::string ExpandFilePath(const std::string &filepath, void *) {
|
||||
#else
|
||||
|
||||
#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) || \
|
||||
defined(__ANDROID__) || defined(__EMSCRIPTEN__)
|
||||
defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__OpenBSD__)
|
||||
// no expansion
|
||||
std::string s = filepath;
|
||||
#else
|
||||
@ -7528,31 +7518,24 @@ static void WriteBinaryGltfStream(std::ostream &stream,
|
||||
const std::string header = "glTF";
|
||||
const int version = 2;
|
||||
|
||||
// https://stackoverflow.com/questions/3407012/c-rounding-up-to-the-nearest-multiple-of-a-number
|
||||
auto roundUp = [](uint32_t numToRound, uint32_t multiple) {
|
||||
if (multiple == 0) return numToRound;
|
||||
|
||||
uint32_t remainder = numToRound % multiple;
|
||||
if (remainder == 0) return numToRound;
|
||||
|
||||
return numToRound + multiple - remainder;
|
||||
};
|
||||
|
||||
const uint32_t padding_size =
|
||||
roundUp(uint32_t(content.size()), 4) - uint32_t(content.size());
|
||||
const uint32_t content_size = uint32_t(content.size());
|
||||
const uint32_t binBuffer_size = uint32_t(binBuffer.size());
|
||||
// determine number of padding bytes required to ensure 4 byte alignment
|
||||
const uint32_t content_padding_size = content_size % 4 == 0 ? 0 : 4 - content_size % 4;
|
||||
const uint32_t bin_padding_size = binBuffer_size % 4 == 0 ? 0 : 4 - binBuffer_size % 4;
|
||||
|
||||
// 12 bytes for header, JSON content length, 8 bytes for JSON chunk info.
|
||||
// Chunk data must be located at 4-byte boundary.
|
||||
// Chunk data must be located at 4-byte boundary, which may require padding
|
||||
const uint32_t length =
|
||||
12 + 8 + roundUp(uint32_t(content.size()), 4) +
|
||||
(binBuffer.size() ? (8 + roundUp(uint32_t(binBuffer.size()), 4)) : 0);
|
||||
12 + 8 + content_size + content_padding_size +
|
||||
(binBuffer_size ? (8 + binBuffer_size + bin_padding_size) : 0);
|
||||
|
||||
stream.write(header.c_str(), std::streamsize(header.size()));
|
||||
stream.write(reinterpret_cast<const char *>(&version), sizeof(version));
|
||||
stream.write(reinterpret_cast<const char *>(&length), sizeof(length));
|
||||
|
||||
// JSON chunk info, then JSON data
|
||||
const uint32_t model_length = uint32_t(content.size()) + padding_size;
|
||||
const uint32_t model_length = uint32_t(content.size()) + content_padding_size;
|
||||
const uint32_t model_format = 0x4E4F534A;
|
||||
stream.write(reinterpret_cast<const char *>(&model_length),
|
||||
sizeof(model_length));
|
||||
@ -7561,13 +7544,11 @@ static void WriteBinaryGltfStream(std::ostream &stream,
|
||||
stream.write(content.c_str(), std::streamsize(content.size()));
|
||||
|
||||
// Chunk must be multiplies of 4, so pad with spaces
|
||||
if (padding_size > 0) {
|
||||
const std::string padding = std::string(size_t(padding_size), ' ');
|
||||
if (content_padding_size > 0) {
|
||||
const std::string padding = std::string(size_t(content_padding_size), ' ');
|
||||
stream.write(padding.c_str(), std::streamsize(padding.size()));
|
||||
}
|
||||
if (binBuffer.size() > 0) {
|
||||
const uint32_t bin_padding_size =
|
||||
roundUp(uint32_t(binBuffer.size()), 4) - uint32_t(binBuffer.size());
|
||||
// BIN chunk info, then BIN data
|
||||
const uint32_t bin_length = uint32_t(binBuffer.size()) + bin_padding_size;
|
||||
const uint32_t bin_format = 0x004e4942;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user