Compare commits

..

16 Commits

Author SHA1 Message Date
Syoyo Fujita
817bbcfb58 Show clang version in Travis build. 2019-10-23 00:41:40 +09:00
Selmar Kok
23467959ca pbrMetallicRoughnes default noexcept move operator 2019-10-21 19:23:15 +02:00
Selmar Kok
6f08785e9f Merge remote-tracking branch 'origin/master' into move_operator 2019-10-21 17:58:57 +02:00
Selmar Kok
ff2b1f92dd use default noexcept move constructor / operator 2019-10-21 17:58:09 +02:00
Syoyo Fujita
e886247329 Fix parsing a glTF file with 2GB+ or lareger size. 2019-10-20 17:47:50 +09:00
Syoyo Fujita
83bb1a48d7 Merge pull request #211 from Selmar/add_missing_serialization
small serialization additions
2019-10-19 15:18:19 +09:00
Selmar Kok
c3353e1acd set default values for baseColorFactor so that it has correct values when parsing a material without a pbrMetallicRoughness struct 2019-10-18 18:22:35 +02:00
Selmar Kok
81b672bcc2 add some missing serialization // add mesh==() weights comparison // use const iterator for extension serialization 2019-10-18 16:08:44 +02:00
Syoyo Fujita
cece6ee6d2 Merge pull request #209 from patriciogonzalezvivo/master
Adding glslViewer
2019-10-08 19:21:51 +09:00
Patricio Gonzalez Vivo
31f875ddbc adding glslViewer 2019-10-08 03:07:58 -07:00
Syoyo Fujita
8dccf9bf4e Merge pull request #208 from toshiks/patch-1
Added project to Readme.md (QuickLook GLTF plugin)
2019-09-15 14:50:06 +09:00
Anton Klochkov
508dcfa2e6 Added project to Readme.md (QuickLook GLTF plugin) 2019-09-15 01:25:47 +03:00
Syoyo Fujita
7e009041e3 Do not serialize pbrMetallicRoughness when they have all default values. Fixes #204 2019-09-13 15:32:22 +09:00
Syoyo Fujita
14977937c2 Add a link to Lighthouse 2. 2019-09-09 20:07:54 +09:00
Syoyo Fujita
8bb18fbd9c Merge pull request #202 from Ybalrid/fix_copy_assignment_operator
Fix broken copy-assignment operators
2019-09-06 13:58:54 +09:00
Arthur Brainville (Ybalrid)
9eeaf20133 Fix copy-assignment operator
When manual move constructor are declared, C++ compilers deletes the
copy constructor and copy-assign operator.

Most of these structures recently got a move ctor added, and copy ctor
re-enabled ( = default ). But copy-assignment are missing, thus in some
context, breaking instantiations of templates like std::vector<>.
2019-09-05 13:02:05 +02:00
3 changed files with 122 additions and 247 deletions

View File

@@ -43,6 +43,7 @@ script:
- ${CXX} ${EXTRA_CXXFLAGS} -std=c++11 -Wall -g -o loader_example loader_example.cc
- ./loader_example ./models/Cube/Cube.gltf
- cd tests
- clang++ -v
- make
- ./tester
- ./tester_noexcept

View File

@@ -75,6 +75,9 @@ In extension(`ExtensionMap`), JSON number value is parsed as int or float(number
* GLTF loader plugin for OGRE 2.1. Support for PBR materials via HLMS/PBS https://github.com/Ybalrid/Ogre_glTF
* [TinyGltfImporter](http://doc.magnum.graphics/magnum/classMagnum_1_1Trade_1_1TinyGltfImporter.html) plugin for [Magnum](https://github.com/mosra/magnum), a lightweight and modular C++11/C++14 graphics middleware for games and data visualization.
* [Diligent Engine](https://github.com/DiligentGraphics/DiligentEngine) - A modern cross-platform low-level graphics library and rendering framework
* Lighthouse 2: a rendering framework for real-time ray tracing / path tracing experiments. https://github.com/jbikker/lighthouse2
* [QuickLook GLTF](https://github.com/toshiks/glTF-quicklook) - quicklook plugin for macos. Also SceneKit wrapper for tinygltf.
* [GlslViewer](https://github.com/patriciogonzalezvivo/glslViewer) - live GLSL coding for MacOS and Linux
* Your projects here! (Please send PR)
## TODOs

View File

@@ -271,23 +271,10 @@ class Value {
explicit Value(const Object &o) : type_(OBJECT_TYPE) { object_value_ = o; }
explicit Value(Object &&o) noexcept : type_(OBJECT_TYPE),
object_value_(std::move(o)) {}
Value(Value &&rhs) noexcept : type_(rhs.type_),
int_value_(rhs.int_value_),
real_value_(rhs.real_value_),
string_value_(std::move(rhs.string_value_)),
binary_value_(std::move(rhs.binary_value_)),
array_value_(std::move(rhs.array_value_)),
object_value_(std::move(rhs.object_value_)),
boolean_value_(rhs.boolean_value_) {}
Value(const Value &rhs) = default;
Value &operator=(const Value &rhs) = default;
Value &operator=(Value &&rhs) {
if (this != &rhs) {
this->~Value();
new (reinterpret_cast<void *>(this)) Value(std::move(rhs));
}
return *this;
}
Value(const Value &) = default;
Value(Value &&) noexcept = default;
Value &operator=(const Value &) = default;
Value &operator=(Value &&) noexcept = default;
char Type() const { return static_cast<const char>(type_); }
@@ -498,6 +485,11 @@ struct Parameter {
(number_array.size() > 3 ? number_array[3] : 1.0)}};
}
Parameter() = default;
Parameter(const Parameter &) = default;
Parameter(Parameter &&) noexcept = default;
Parameter &operator=(const Parameter &) = default;
Parameter &operator=(Parameter &&) noexcept = default;
bool operator==(const Parameter &) const;
};
@@ -522,6 +514,10 @@ struct AnimationChannel {
ExtensionMap extensions;
AnimationChannel() : sampler(-1), target_node(-1) {}
AnimationChannel(const AnimationChannel &) = default;
AnimationChannel(AnimationChannel &&) noexcept = default;
AnimationChannel &operator=(const AnimationChannel &) = default;
AnimationChannel &operator=(AnimationChannel &&) noexcept = default;
bool operator==(const AnimationChannel &) const;
};
@@ -533,6 +529,10 @@ struct AnimationSampler {
Value extras;
AnimationSampler() : input(-1), output(-1), interpolation("LINEAR") {}
AnimationSampler(const AnimationSampler &) = default;
AnimationSampler(AnimationSampler &&) noexcept = default;
AnimationSampler &operator=(const AnimationSampler &) = default;
AnimationSampler &operator=(AnimationSampler &&) noexcept = default;
bool operator==(const AnimationSampler &) const;
};
@@ -543,6 +543,11 @@ struct Animation {
Value extras;
ExtensionMap extensions;
Animation() = default;
Animation(const Animation &) = default;
Animation(Animation &&) noexcept = default;
Animation &operator=(const Animation &) = default;
Animation &operator=(Animation &&) noexcept = default;
bool operator==(const Animation &) const;
};
@@ -556,6 +561,10 @@ struct Skin {
inverseBindMatrices = -1;
skeleton = -1;
}
Skin(const Skin &) = default;
Skin(Skin &&) noexcept = default;
Skin &operator=(const Skin &) = default;
Skin &operator=(Skin &&) noexcept = default;
bool operator==(const Skin &) const;
};
@@ -585,13 +594,9 @@ struct Sampler {
wrapT(TINYGLTF_TEXTURE_WRAP_REPEAT),
wrapR(TINYGLTF_TEXTURE_WRAP_REPEAT) {}
Sampler(const Sampler &) = default;
Sampler(Sampler &&rhs) noexcept : name(std::move(rhs.name)),
minFilter(rhs.minFilter),
magFilter(rhs.magFilter),
wrapS(rhs.wrapS),
wrapT(rhs.wrapT),
wrapR(rhs.wrapR),
extras(std::move(rhs.extras)) {}
Sampler(Sampler &&) noexcept = default;
Sampler &operator=(const Sampler &) = default;
Sampler &operator=(Sampler &&) noexcept = default;
bool operator==(const Sampler &) const;
};
@@ -626,19 +631,9 @@ struct Image {
component = -1;
}
Image(const Image &) = default;
Image(Image &&rhs) noexcept : name(std::move(rhs.name)),
width(rhs.width),
height(rhs.height),
component(rhs.component),
bits(rhs.bits),
pixel_type(rhs.pixel_type),
image(std::move(rhs.image)),
bufferView(rhs.bufferView),
mimeType(std::move(rhs.mimeType)),
uri(std::move(rhs.uri)),
extras(std::move(rhs.extras)),
extensions(std::move(rhs.extensions)),
as_is(rhs.as_is) {}
Image(Image &&) noexcept = default;
Image &operator=(const Image &) = default;
Image &operator=(Image &&) noexcept = default;
bool operator==(const Image &) const;
};
@@ -653,11 +648,9 @@ struct Texture {
Texture() : sampler(-1), source(-1) {}
Texture(const Texture &) = default;
Texture(Texture &&rhs) noexcept : name(std::move(rhs.name)),
sampler(rhs.sampler),
source(rhs.source),
extras(std::move(rhs.extras)),
extensions(std::move(rhs.extensions)) {}
Texture(Texture &&) noexcept = default;
Texture &operator=(const Texture &) = default;
Texture &operator=(Texture &&) noexcept = default;
bool operator==(const Texture &) const;
};
@@ -672,11 +665,9 @@ struct TextureInfo {
TextureInfo() : index(-1), texCoord(0) {}
TextureInfo(const TextureInfo &) = default;
TextureInfo(TextureInfo &&rhs) noexcept
: index(rhs.index),
texCoord(rhs.texCoord),
extras(std::move(rhs.extras)),
extensions(std::move(rhs.extensions)) {}
TextureInfo(TextureInfo &&) noexcept = default;
TextureInfo &operator=(const TextureInfo &) = default;
TextureInfo &operator=(TextureInfo &&) noexcept = default;
bool operator==(const TextureInfo &) const;
};
@@ -692,12 +683,9 @@ struct NormalTextureInfo {
NormalTextureInfo() : index(-1), texCoord(0), scale(1.0) {}
NormalTextureInfo(const NormalTextureInfo &) = default;
NormalTextureInfo(NormalTextureInfo &&rhs) noexcept
: index(rhs.index),
texCoord(rhs.texCoord),
scale(rhs.scale),
extras(std::move(rhs.extras)),
extensions(std::move(rhs.extensions)) {}
NormalTextureInfo(NormalTextureInfo &&) noexcept = default;
NormalTextureInfo &operator=(const NormalTextureInfo &) = default;
NormalTextureInfo &operator=(NormalTextureInfo &&) noexcept = default;
bool operator==(const NormalTextureInfo &) const;
};
@@ -713,12 +701,9 @@ struct OcclusionTextureInfo {
OcclusionTextureInfo() : index(-1), texCoord(0), strength(1.0) {}
OcclusionTextureInfo(const OcclusionTextureInfo &) = default;
OcclusionTextureInfo(OcclusionTextureInfo &&rhs) noexcept
: index(rhs.index),
texCoord(rhs.texCoord),
strength(rhs.strength),
extras(std::move(rhs.extras)),
extensions(std::move(rhs.extensions)) {}
OcclusionTextureInfo(OcclusionTextureInfo &&) noexcept = default;
OcclusionTextureInfo &operator=(const OcclusionTextureInfo &) = default;
OcclusionTextureInfo &operator=(OcclusionTextureInfo &&) noexcept = default;
bool operator==(const OcclusionTextureInfo &) const;
};
@@ -733,16 +718,11 @@ struct PbrMetallicRoughness {
Value extras;
ExtensionMap extensions;
PbrMetallicRoughness() : metallicFactor(1.0), roughnessFactor(1.0) {}
PbrMetallicRoughness() : baseColorFactor(std::vector<double>{ 1.0,1.0,1.0,1.0 }), metallicFactor(1.0), roughnessFactor(1.0) {}
PbrMetallicRoughness(const PbrMetallicRoughness &) = default;
PbrMetallicRoughness(PbrMetallicRoughness &&rhs) noexcept
: baseColorFactor(std::move(rhs.baseColorFactor)),
baseColorTexture(std::move(rhs.baseColorTexture)),
metallicFactor(rhs.metallicFactor),
roughnessFactor(rhs.roughnessFactor),
metallicRoughnessTexture(std::move(rhs.metallicRoughnessTexture)),
extras(std::move(rhs.extras)),
extensions(std::move(rhs.extensions)) {}
PbrMetallicRoughness(PbrMetallicRoughness &&rhs) noexcept = default;
PbrMetallicRoughness &operator=(const PbrMetallicRoughness &) = default;
PbrMetallicRoughness &operator=(PbrMetallicRoughness &&) noexcept = default;
bool operator==(const PbrMetallicRoughness &) const;
};
@@ -773,20 +753,9 @@ struct Material {
Material() : alphaMode("OPAQUE"), alphaCutoff(0.5), doubleSided(false) {}
Material(const Material &) = default;
Material(Material &&rhs) noexcept
: name(std::move(rhs.name)),
emissiveFactor(std::move(rhs.emissiveFactor)),
alphaMode(std::move(rhs.alphaMode)),
alphaCutoff(rhs.alphaCutoff),
doubleSided(rhs.doubleSided),
pbrMetallicRoughness(std::move(rhs.pbrMetallicRoughness)),
normalTexture(std::move(rhs.normalTexture)),
occlusionTexture(std::move(rhs.occlusionTexture)),
emissiveTexture(std::move(rhs.emissiveTexture)),
values(std::move(rhs.values)),
additionalValues(std::move(rhs.additionalValues)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Material(Material &&rhs) noexcept = default;
Material &operator=(const Material &) = default;
Material &operator=(Material &&) noexcept = default;
bool operator==(const Material &) const;
};
@@ -804,14 +773,9 @@ struct BufferView {
BufferView() : byteOffset(0), byteStride(0), dracoDecoded(false) {}
BufferView(const BufferView &) = default;
BufferView(BufferView &&rhs) noexcept : name(std::move(rhs.name)),
buffer(rhs.buffer),
byteOffset(rhs.byteOffset),
byteLength(rhs.byteLength),
byteStride(rhs.byteStride),
target(rhs.target),
extras(std::move(rhs.extras)),
dracoDecoded(rhs.dracoDecoded) {}
BufferView(BufferView &&) noexcept = default;
BufferView &operator=(const BufferView &) = default;
BufferView &operator=(BufferView &&) noexcept = default;
bool operator==(const BufferView &) const;
};
@@ -885,17 +849,9 @@ struct Accessor {
sparse.isSparse = false;
}
Accessor(const Accessor &) = default;
Accessor(Accessor &&rhs) noexcept : bufferView(rhs.bufferView),
name(std::move(rhs.name)),
byteOffset(rhs.byteOffset),
normalized(rhs.normalized),
componentType(rhs.componentType),
count(rhs.count),
type(rhs.type),
extras(std::move(rhs.extras)),
minValues(std::move(rhs.minValues)),
maxValues(std::move(rhs.maxValues)),
sparse(rhs.sparse) {}
Accessor(Accessor &&) noexcept = default;
Accessor &operator=(const Accessor &) = default;
Accessor &operator=(Accessor &&) noexcept = default;
bool operator==(const tinygltf::Accessor &) const;
};
@@ -912,13 +868,9 @@ struct PerspectiveCamera {
,
znear(0.0) {}
PerspectiveCamera(const PerspectiveCamera &) = default;
PerspectiveCamera(PerspectiveCamera &&rhs) noexcept
: aspectRatio(rhs.aspectRatio),
yfov(rhs.yfov),
zfar(rhs.zfar),
znear(rhs.znear),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
PerspectiveCamera(PerspectiveCamera &&) noexcept = default;
PerspectiveCamera &operator=(const PerspectiveCamera &) = default;
PerspectiveCamera &operator=(PerspectiveCamera &&) noexcept = default;
bool operator==(const PerspectiveCamera &) const;
ExtensionMap extensions;
@@ -933,13 +885,9 @@ struct OrthographicCamera {
OrthographicCamera() : xmag(0.0), ymag(0.0), zfar(0.0), znear(0.0) {}
OrthographicCamera(const OrthographicCamera &) = default;
OrthographicCamera(OrthographicCamera &&rhs) noexcept
: xmag(rhs.xmag),
ymag(rhs.ymag),
zfar(rhs.zfar),
znear(rhs.znear),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
OrthographicCamera(OrthographicCamera &&) noexcept = default;
OrthographicCamera &operator=(const OrthographicCamera &) = default;
OrthographicCamera &operator=(OrthographicCamera &&) noexcept = default;
bool operator==(const OrthographicCamera &) const;
ExtensionMap extensions;
@@ -955,12 +903,9 @@ struct Camera {
Camera() {}
Camera(const Camera &) = default;
Camera(Camera &&rhs) noexcept : type(std::move(rhs.type)),
name(std::move(rhs.name)),
perspective(std::move(rhs.perspective)),
orthographic(std::move(rhs.orthographic)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Camera(Camera &&) noexcept = default;
Camera &operator=(const Camera &) = default;
Camera &operator=(Camera &&) noexcept = default;
bool operator==(const Camera &) const;
ExtensionMap extensions;
@@ -988,13 +933,9 @@ struct Primitive {
indices = -1;
}
Primitive(const Primitive &) = default;
Primitive(Primitive &&rhs) noexcept : attributes(std::move(rhs.attributes)),
material(rhs.material),
indices(rhs.indices),
mode(rhs.mode),
targets(std::move(rhs.targets)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Primitive(Primitive &&) noexcept = default;
Primitive &operator=(const Primitive &) = default;
Primitive &operator=(Primitive &&) noexcept = default;
bool operator==(const Primitive &) const;
};
@@ -1008,19 +949,9 @@ struct Mesh {
Mesh() = default;
~Mesh() = default;
Mesh(const Mesh &) = default;
Mesh(Mesh &&rhs) noexcept : name(std::move(rhs.name)),
primitives(std::move(rhs.primitives)),
weights(std::move(rhs.weights)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Mesh(Mesh &&) noexcept = default;
Mesh &operator=(const Mesh &) = default;
Mesh &operator=(Mesh &&rhs) {
if (&rhs != this) {
this->~Mesh();
new (reinterpret_cast<void *>(this)) Mesh(std::move(rhs));
}
return *this;
}
Mesh &operator=(Mesh &&) noexcept = default;
bool operator==(const Mesh &) const;
};
@@ -1028,45 +959,10 @@ class Node {
public:
Node() : camera(-1), skin(-1), mesh(-1) {}
// TODO(syoyo): Could use `default`
Node(const Node &rhs) {
camera = rhs.camera;
name = rhs.name;
skin = rhs.skin;
mesh = rhs.mesh;
children = rhs.children;
rotation = rhs.rotation;
scale = rhs.scale;
translation = rhs.translation;
matrix = rhs.matrix;
weights = rhs.weights;
extensions = rhs.extensions;
extras = rhs.extras;
}
Node(Node &&rhs) noexcept : camera(rhs.camera),
name(std::move(rhs.name)),
skin(rhs.skin),
mesh(rhs.mesh),
children(std::move(rhs.children)),
rotation(std::move(rhs.rotation)),
scale(std::move(rhs.scale)),
translation(std::move(rhs.translation)),
matrix(std::move(rhs.matrix)),
weights(std::move(rhs.weights)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
~Node() {}
Node &operator=(const Node &rhs) = default;
Node &operator=(Node &&rhs) {
if (&rhs != this) {
this->~Node();
new (reinterpret_cast<void *>(this)) Node(std::move(rhs));
}
return *this;
}
Node(const Node &) = default;
Node(Node &&) noexcept = default;
Node &operator=(const Node &) = default;
Node &operator=(Node &&) noexcept = default;
bool operator==(const Node &) const;
@@ -1088,10 +984,10 @@ class Node {
struct Buffer {
Buffer() = default;
Buffer(Buffer &&rhs) noexcept : name(std::move(rhs.name)),
data(std::move(rhs.data)),
uri(std::move(rhs.uri)),
extras(std::move(rhs.extras)) {}
Buffer(const Buffer &) = default;
Buffer(Buffer &&) noexcept = default;
Buffer &operator=(const Buffer &) = default;
Buffer &operator=(Buffer &&) noexcept = default;
std::string name;
std::vector<unsigned char> data;
std::string
@@ -1112,20 +1008,9 @@ struct Asset {
Asset() = default;
~Asset() = default;
Asset(const Asset &) = default;
Asset(Asset &&rhs) noexcept : version(std::move(rhs.version)),
generator(std::move(rhs.generator)),
minVersion(std::move(rhs.minVersion)),
copyright(std::move(rhs.copyright)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Asset(Asset &&) noexcept = default;
Asset &operator=(const Asset &) = default;
Asset &operator=(Asset &&rhs) {
if (&rhs != this) {
this->~Asset();
new (reinterpret_cast<void *>(this)) Asset(std::move(rhs));
}
return *this;
}
Asset &operator=(Asset &&) noexcept = default;
bool operator==(const Asset &) const;
};
@@ -1138,10 +1023,9 @@ struct Scene {
Scene() = default;
Scene(const Scene &) = default;
Scene(Scene &&rhs) noexcept : name(std::move(rhs.name)),
nodes(std::move(rhs.nodes)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Scene(Scene &&) noexcept = default;
Scene &operator=(const Scene &) = default;
Scene &operator=(Scene &&) noexcept = default;
bool operator==(const Scene &) const;
};
@@ -1151,11 +1035,9 @@ struct SpotLight {
SpotLight() : innerConeAngle(0.0), outerConeAngle(0.7853981634) {}
SpotLight(const SpotLight &) = default;
SpotLight(SpotLight &&rhs) noexcept : innerConeAngle(rhs.innerConeAngle),
outerConeAngle(rhs.outerConeAngle),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
SpotLight(SpotLight &&) noexcept = default;
SpotLight &operator=(const SpotLight &) = default;
SpotLight &operator=(SpotLight &&) noexcept = default;
bool operator==(const SpotLight &) const;
ExtensionMap extensions;
@@ -1172,14 +1054,9 @@ struct Light {
Light() : intensity(1.0), range(0.0) {}
Light(const Light &) = default;
Light(Light &&rhs) noexcept : name(std::move(rhs.name)),
color(std::move(rhs.color)),
intensity(rhs.intensity),
type(std::move(rhs.type)),
range(rhs.range),
spot(std::move(rhs.spot)),
extensions(std::move(rhs.extensions)),
extras(std::move(rhs.extras)) {}
Light(Light &&) noexcept = default;
Light &operator=(const Light &) = default;
Light &operator=(Light &&) noexcept = default;
bool operator==(const Light &) const;
@@ -1189,33 +1066,11 @@ struct Light {
class Model {
public:
Model() {}
Model() = default;
Model(const Model &) = default;
Model(Model &&) noexcept = default;
Model &operator=(const Model &) = default;
Model(Model &&rhs) noexcept
: accessors(std::move(rhs.accessors)),
animations(std::move(rhs.animations)),
buffers(std::move(rhs.buffers)),
bufferViews(std::move(rhs.bufferViews)),
materials(std::move(rhs.materials)),
meshes(std::move(rhs.meshes)),
nodes(std::move(rhs.nodes)),
textures(std::move(rhs.textures)),
images(std::move(rhs.images)),
skins(std::move(rhs.skins)),
samplers(std::move(rhs.samplers)),
cameras(std::move(rhs.cameras)),
scenes(std::move(rhs.scenes)),
lights(std::move(rhs.lights)),
extensions(std::move(rhs.extensions)),
defaultScene(rhs.defaultScene),
extensionsUsed(std::move(rhs.extensionsUsed)),
extensionsRequired(std::move(rhs.extensionsRequired)),
asset(std::move(rhs.asset)),
extras(std::move(rhs.extras)) {}
~Model() {}
Model &operator=(Model &&) noexcept = default;
bool operator==(const Model &) const;
@@ -1836,7 +1691,8 @@ bool Material::operator==(const Material &other) const {
}
bool Mesh::operator==(const Mesh &other) const {
return this->extensions == other.extensions && this->extras == other.extras &&
this->name == other.name && this->primitives == other.primitives;
this->name == other.name && Equals(this->weights, other.weights) &&
this->primitives == other.primitives;
}
bool Model::operator==(const Model &other) const {
return this->accessors == other.accessors &&
@@ -2546,7 +2402,7 @@ bool ReadWholeFile(std::vector<unsigned char> *out, std::string *err,
size_t sz = static_cast<size_t>(f.tellg());
f.seekg(0, f.beg);
if (int(sz) < 0) {
if (int64_t(sz) < 0) {
if (err) {
(*err) += "Invalid file size : " + filepath +
" (does the path point to a directory?)";
@@ -4344,11 +4200,8 @@ static bool ParsePbrMetallicRoughness(PbrMetallicRoughness *pbr,
}
return false;
}
} else {
// fill with default values
baseColorFactor = {1.0, 1.0, 1.0, 1.0};
pbr->baseColorFactor = baseColorFactor;
}
pbr->baseColorFactor = baseColorFactor;
{
json_const_iterator it;
@@ -5891,11 +5744,11 @@ static void SerializeParameterMap(ParameterMap &param, json &o) {
}
#endif
static void SerializeExtensionMap(ExtensionMap &extensions, json &o) {
static void SerializeExtensionMap(const ExtensionMap &extensions, json &o) {
if (!extensions.size()) return;
json extMap;
for (ExtensionMap::iterator extIt = extensions.begin();
for (ExtensionMap::const_iterator extIt = extensions.begin();
extIt != extensions.end(); ++extIt) {
// Allow an empty object for extension(#97)
json ret;
@@ -6247,7 +6100,15 @@ static void SerializeGltfMaterial(Material &material, json &o) {
json pbrMetallicRoughness;
SerializeGltfPbrMetallicRoughness(material.pbrMetallicRoughness,
pbrMetallicRoughness);
JsonAddMember(o, "pbrMetallicRoughness", std::move(pbrMetallicRoughness));
// Issue 204
// Do not serialize `pbrMetallicRoughness` if pbrMetallicRoughness has all
// default values(json is null). Otherwise it will serialize to
// `pbrMetallicRoughness : null`, which cannot be read by other glTF
// importers(and validators).
//
if (!JsonIsNull(pbrMetallicRoughness)) {
JsonAddMember(o, "pbrMetallicRoughness", std::move(pbrMetallicRoughness));
}
}
#if 0 // legacy way. just for the record.
@@ -6313,6 +6174,8 @@ static void SerializeGltfMesh(Mesh &mesh, json &o) {
JsonAddMember(primitive, "targets", std::move(targets));
}
SerializeExtensionMap(gltfPrimitive.extensions, o);
if (gltfPrimitive.extras.Type() != NULL_TYPE) {
SerializeValue("extras", gltfPrimitive.extras, primitive);
}
@@ -6330,6 +6193,7 @@ static void SerializeGltfMesh(Mesh &mesh, json &o) {
SerializeStringProperty("name", mesh.name, o);
}
SerializeExtensionMap(mesh.extensions, o);
if (mesh.extras.Type() != NULL_TYPE) {
SerializeValue("extras", mesh.extras, o);
}
@@ -6339,6 +6203,9 @@ static void SerializeSpotLight(SpotLight &spot, json &o) {
SerializeNumberProperty("innerConeAngle", spot.innerConeAngle, o);
SerializeNumberProperty("outerConeAngle", spot.outerConeAngle, o);
SerializeExtensionMap(spot.extensions, o);
if (spot.extras.Type() != NULL_TYPE) {
SerializeValue("extras", spot.extras, o);
}
}
static void SerializeGltfLight(Light &light, json &o) {
@@ -6352,6 +6219,10 @@ static void SerializeGltfLight(Light &light, json &o) {
SerializeSpotLight(light.spot, spot);
JsonAddMember(o, "spot", std::move(spot));
}
SerializeExtensionMap(light.extensions, o);
if (light.extras.Type() != NULL_TYPE) {
SerializeValue("extras", light.extras, o);
}
}
static void SerializeGltfNode(Node &node, json &o) {