Merge pull request #169 from Ybalrid/remove_mesh_targets

Remove Mesh::targets, as targets only exists inside `Primitive`
This commit is contained in:
Syoyo Fujita 2019-05-26 16:23:46 +09:00 committed by GitHub
commit f65e06c5ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -707,7 +707,6 @@ struct Mesh {
std::string name; std::string name;
std::vector<Primitive> primitives; std::vector<Primitive> primitives;
std::vector<double> weights; // weights to be applied to the Morph Targets std::vector<double> weights; // weights to be applied to the Morph Targets
std::vector<std::map<std::string, int> > targets;
ExtensionMap extensions; ExtensionMap extensions;
Value extras; Value extras;
@ -1303,8 +1302,7 @@ bool Material::operator==(const Material &other) const {
} }
bool Mesh::operator==(const Mesh &other) const { bool Mesh::operator==(const Mesh &other) const {
return this->extensions == other.extensions && this->extras == other.extras && return this->extensions == other.extensions && this->extras == other.extras &&
this->name == other.name && this->primitives == other.primitives && this->name == other.name && this->primitives == other.primitives;
this->targets == other.targets && Equals(this->weights, other.weights);
} }
bool Model::operator==(const Model &other) const { bool Model::operator==(const Model &other) const {
return this->accessors == other.accessors && return this->accessors == other.accessors &&
@ -3382,24 +3380,6 @@ static bool ParseMesh(Mesh *mesh, Model *model, std::string *err,
} }
} }
// Look for morph targets
json::const_iterator targetsObject = o.find("targets");
if ((targetsObject != o.end()) && targetsObject.value().is_array()) {
for (json::const_iterator i = targetsObject.value().begin();
i != targetsObject.value().end(); i++) {
std::map<std::string, int> targetAttribues;
const json &dict = i.value();
json::const_iterator dictIt(dict.begin());
json::const_iterator dictItEnd(dict.end());
for (; dictIt != dictItEnd; ++dictIt) {
targetAttribues[dictIt.key()] = static_cast<int>(dictIt.value());
}
mesh->targets.push_back(targetAttribues);
}
}
// Should probably check if has targets and if dimensions fit // Should probably check if has targets and if dimensions fit
ParseNumberArrayProperty(&mesh->weights, err, o, "weights", false); ParseNumberArrayProperty(&mesh->weights, err, o, "weights", false);
@ -4911,14 +4891,13 @@ static void SerializeGltfBufferView(BufferView &bufferView, json &o) {
} }
static void SerializeGltfImage(Image &image, json &o) { static void SerializeGltfImage(Image &image, json &o) {
// if uri empty, the mimeType and bufferview should be set // if uri empty, the mimeType and bufferview should be set
if (image.uri.empty()) { if (image.uri.empty()) {
SerializeStringProperty("mimeType", image.mimeType, o); SerializeStringProperty("mimeType", image.mimeType, o);
SerializeNumberProperty<int>("bufferView", image.bufferView, o); SerializeNumberProperty<int>("bufferView", image.bufferView, o);
} } else {
else { SerializeStringProperty("uri", image.uri, o);
SerializeStringProperty("uri", image.uri, o); }
}
if (image.name.size()) { if (image.name.size()) {
SerializeStringProperty("name", image.name, o); SerializeStringProperty("name", image.name, o);