mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-18 01:25:55 +08:00
Apply clang format.
Remove `const static std::string` global variable.
This commit is contained in:
parent
a472a3fa0f
commit
ff51570c26
42
tiny_gltf.h
42
tiny_gltf.h
@ -242,7 +242,10 @@ class Value {
|
|||||||
boolean_value_(false) {}
|
boolean_value_(false) {}
|
||||||
|
|
||||||
explicit Value(bool b) : type_(BOOL_TYPE) { boolean_value_ = b; }
|
explicit Value(bool b) : type_(BOOL_TYPE) { boolean_value_ = b; }
|
||||||
explicit Value(int i) : type_(INT_TYPE) { int_value_ = i; real_value_ = i; }
|
explicit Value(int i) : type_(INT_TYPE) {
|
||||||
|
int_value_ = i;
|
||||||
|
real_value_ = i;
|
||||||
|
}
|
||||||
explicit Value(double n) : type_(REAL_TYPE) { real_value_ = n; }
|
explicit Value(double n) : type_(REAL_TYPE) { real_value_ = n; }
|
||||||
explicit Value(const std::string &s) : type_(STRING_TYPE) {
|
explicit Value(const std::string &s) : type_(STRING_TYPE) {
|
||||||
string_value_ = s;
|
string_value_ = s;
|
||||||
@ -1165,21 +1168,20 @@ class TinyGLTF {
|
|||||||
///
|
///
|
||||||
void SetFsCallbacks(FsCallbacks callbacks);
|
void SetFsCallbacks(FsCallbacks callbacks);
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Set serializing default values(default = false).
|
/// Set serializing default values(default = false).
|
||||||
/// When true, default values are force serialized to .glTF.
|
/// When true, default values are force serialized to .glTF.
|
||||||
/// This may be helpfull if you want to serialize a full description of glTF data.
|
/// This may be helpfull if you want to serialize a full description of glTF
|
||||||
|
/// data.
|
||||||
///
|
///
|
||||||
/// TODO(LTE): Supply parsing option as function arguments to `LoadASCIIFromFile()` and others, not by a class method
|
/// TODO(LTE): Supply parsing option as function arguments to
|
||||||
|
/// `LoadASCIIFromFile()` and others, not by a class method
|
||||||
///
|
///
|
||||||
void SetSerializeDefaultValues(const bool enabled) {
|
void SetSerializeDefaultValues(const bool enabled) {
|
||||||
serialize_default_values_ = enabled;
|
serialize_default_values_ = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetSerializeDefaultValues() const {
|
bool GetSerializeDefaultValues() const { return serialize_default_values_; }
|
||||||
return serialize_default_values_;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
@ -1196,7 +1198,7 @@ class TinyGLTF {
|
|||||||
size_t bin_size_ = 0;
|
size_t bin_size_ = 0;
|
||||||
bool is_binary_ = false;
|
bool is_binary_ = false;
|
||||||
|
|
||||||
bool serialize_default_values_ = false; ///< Serialize default values?
|
bool serialize_default_values_ = false; ///< Serialize default values?
|
||||||
|
|
||||||
FsCallbacks fs = {
|
FsCallbacks fs = {
|
||||||
#ifndef TINYGLTF_NO_FS
|
#ifndef TINYGLTF_NO_FS
|
||||||
@ -1727,15 +1729,9 @@ std::string base64_decode(std::string const &s);
|
|||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wexit-time-destructors"
|
|
||||||
#pragma clang diagnostic ignored "-Wglobal-constructors"
|
|
||||||
#pragma clang diagnostic ignored "-Wsign-conversion"
|
#pragma clang diagnostic ignored "-Wsign-conversion"
|
||||||
#pragma clang diagnostic ignored "-Wconversion"
|
#pragma clang diagnostic ignored "-Wconversion"
|
||||||
#endif
|
#endif
|
||||||
static const std::string base64_chars =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
|
||||||
"0123456789+/";
|
|
||||||
|
|
||||||
static inline bool is_base64(unsigned char c) {
|
static inline bool is_base64(unsigned char c) {
|
||||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||||
@ -1749,6 +1745,11 @@ std::string base64_encode(unsigned char const *bytes_to_encode,
|
|||||||
unsigned char char_array_3[3];
|
unsigned char char_array_3[3];
|
||||||
unsigned char char_array_4[4];
|
unsigned char char_array_4[4];
|
||||||
|
|
||||||
|
const char *base64_chars =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"0123456789+/";
|
||||||
|
|
||||||
while (in_len--) {
|
while (in_len--) {
|
||||||
char_array_3[i++] = *(bytes_to_encode++);
|
char_array_3[i++] = *(bytes_to_encode++);
|
||||||
if (i == 3) {
|
if (i == 3) {
|
||||||
@ -1789,6 +1790,11 @@ std::string base64_decode(std::string const &encoded_string) {
|
|||||||
unsigned char char_array_4[4], char_array_3[3];
|
unsigned char char_array_4[4], char_array_3[3];
|
||||||
std::string ret;
|
std::string ret;
|
||||||
|
|
||||||
|
const std::string base64_chars =
|
||||||
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
"0123456789+/";
|
||||||
|
|
||||||
while (in_len-- && (encoded_string[in_] != '=') &&
|
while (in_len-- && (encoded_string[in_] != '=') &&
|
||||||
is_base64(encoded_string[in_])) {
|
is_base64(encoded_string[in_])) {
|
||||||
char_array_4[i++] = encoded_string[in_];
|
char_array_4[i++] = encoded_string[in_];
|
||||||
@ -3764,8 +3770,9 @@ static bool ParsePbrMetallicRoughness(PbrMetallicRoughness *pbr,
|
|||||||
static bool ParseMaterial(Material *material, std::string *err, const json &o) {
|
static bool ParseMaterial(Material *material, std::string *err, const json &o) {
|
||||||
ParseStringProperty(&material->name, err, o, "name", /* required */ false);
|
ParseStringProperty(&material->name, err, o, "name", /* required */ false);
|
||||||
|
|
||||||
if(ParseNumberArrayProperty(&material->emissiveFactor, err, o, "emissiveFactor",
|
if (ParseNumberArrayProperty(&material->emissiveFactor, err, o,
|
||||||
/* required */ false)) {
|
"emissiveFactor",
|
||||||
|
/* required */ false)) {
|
||||||
if (material->emissiveFactor.size() != 3) {
|
if (material->emissiveFactor.size() != 3) {
|
||||||
if (err) {
|
if (err) {
|
||||||
(*err) +=
|
(*err) +=
|
||||||
@ -3775,8 +3782,7 @@ static bool ParseMaterial(Material *material, std::string *err, const json &o) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// fill with default values
|
// fill with default values
|
||||||
material->emissiveFactor = {0.0, 0.0, 0.0};
|
material->emissiveFactor = {0.0, 0.0, 0.0};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user