mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 05:26:02 +08:00
add some missing serialization // add mesh==() weights comparison // use const iterator for extension serialization
This commit is contained in:
parent
cece6ee6d2
commit
81b672bcc2
17
tiny_gltf.h
17
tiny_gltf.h
@ -1903,7 +1903,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 &&
|
||||
@ -5958,11 +5959,11 @@ static void SerializeParameterMap(ParameterMap ¶m, 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;
|
||||
@ -6388,6 +6389,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);
|
||||
}
|
||||
@ -6405,6 +6408,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);
|
||||
}
|
||||
@ -6414,6 +6418,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) {
|
||||
@ -6427,6 +6434,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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user