3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-27 13:55:26 +02:00

Baking - if mesh extraction or compression fails don't change node

Needed to prevent a null (would-be Draco mesh) node being added.
This commit is contained in:
Simon Walton 2018-05-08 13:59:38 -07:00
parent 37ead11cf9
commit 82e43aea11
2 changed files with 31 additions and 31 deletions
libraries
baking/src
fbx/src

View file

@ -257,39 +257,40 @@ void FBXBaker::rewriteAndBakeSceneModels() {
} else if (hasWarnings()) {
continue;
}
}
objectChild.children.push_back(dracoMeshNode);
} else {
objectChild.children.push_back(dracoMeshNode);
static const std::vector<QString> nodeNamesToDelete {
// Node data that is packed into the draco mesh
"Vertices",
"PolygonVertexIndex",
"LayerElementNormal",
"LayerElementColor",
"LayerElementUV",
"LayerElementMaterial",
"LayerElementTexture",
static const std::vector<QString> nodeNamesToDelete {
// Node data that is packed into the draco mesh
"Vertices",
"PolygonVertexIndex",
"LayerElementNormal",
"LayerElementColor",
"LayerElementUV",
"LayerElementMaterial",
"LayerElementTexture",
// Node data that we don't support
"Edges",
"LayerElementTangent",
"LayerElementBinormal",
"LayerElementSmoothing"
};
auto& children = objectChild.children;
auto it = children.begin();
while (it != children.end()) {
auto begin = nodeNamesToDelete.begin();
auto end = nodeNamesToDelete.end();
if (find(begin, end, it->name) != end) {
it = children.erase(it);
} else {
++it;
// Node data that we don't support
"Edges",
"LayerElementTangent",
"LayerElementBinormal",
"LayerElementSmoothing"
};
auto& children = objectChild.children;
auto it = children.begin();
while (it != children.end()) {
auto begin = nodeNamesToDelete.begin();
auto end = nodeNamesToDelete.end();
if (find(begin, end, it->name) != end) {
it = children.erase(it);
} else {
++it;
}
}
}
}
}
} // Geometry Object
} // foreach root child
}
}
}

View file

@ -62,8 +62,7 @@ QByteArray FBXWriter::encodeFBX(const FBXNode& root) {
out.setVersion(QDataStream::Qt_4_5);
out.writeRawData(FBX_BINARY_PROLOG, FBX_BINARY_PROLOG.size());
auto bytes = QByteArray(FBX_HEADER_BYTES_BEFORE_VERSION - FBX_BINARY_PROLOG.size(), '\0');
out.writeRawData(bytes, bytes.size());
out.writeRawData("\0\x1a", 3); // Blender needs this header component.
#ifdef USE_FBX_2016_FORMAT
out << FBX_VERSION_2016;