mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +02:00
TIL that std::vector<bool> is a bit field
https://howardhinnant.github.io/onvectorbool.html
This commit is contained in:
parent
384b7fd629
commit
65d85138cc
2 changed files with 9 additions and 8 deletions
|
@ -246,11 +246,10 @@ void ModelBaker::bakeSourceCopy() {
|
|||
// Begin hfm baking
|
||||
baker.run();
|
||||
|
||||
for (auto error : baker.getDracoErrors()) {
|
||||
if (error) {
|
||||
handleError("Failed to finalize the baking of a draco Geometry node from model " + _modelURL.toString());
|
||||
return;
|
||||
}
|
||||
const auto& errors = baker.getDracoErrors();
|
||||
if (std::find(errors.cbegin(), errors.cend(), true) != errors.cend()) {
|
||||
handleError("Failed to finalize the baking of a draco Geometry node from model " + _modelURL.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
_hfmModel = baker.getHFMModel();
|
||||
|
|
|
@ -222,21 +222,23 @@ void BuildDracoMeshTask::run(const baker::BakeContextPointer& context, const Inp
|
|||
auto& materialLists = output.edit2();
|
||||
|
||||
dracoBytesPerMesh.reserve(meshes.size());
|
||||
dracoErrorsPerMesh.reserve(meshes.size());
|
||||
// vector<bool> is an exception to the std::vector conventions as it is a bit field
|
||||
// So a bool reference to an element doesn't work
|
||||
dracoErrorsPerMesh.resize(meshes.size());
|
||||
materialLists.reserve(meshes.size());
|
||||
for (size_t i = 0; i < meshes.size(); i++) {
|
||||
const auto& mesh = meshes[i];
|
||||
const auto& normals = baker::safeGet(normalsPerMesh, i);
|
||||
const auto& tangents = baker::safeGet(tangentsPerMesh, i);
|
||||
dracoBytesPerMesh.emplace_back();
|
||||
dracoErrorsPerMesh.emplace_back();
|
||||
auto& dracoBytes = dracoBytesPerMesh.back();
|
||||
auto& dracoError = dracoErrorsPerMesh.back();
|
||||
materialLists.push_back(createMaterialList(mesh));
|
||||
const auto& materialList = materialLists.back();
|
||||
|
||||
bool dracoError;
|
||||
std::unique_ptr<draco::Mesh> dracoMesh;
|
||||
std::tie(dracoMesh, dracoError) = createDracoMesh(mesh, normals, tangents, materialList);
|
||||
dracoErrorsPerMesh[dracoErrorsPerMesh.size()-1] = dracoError;
|
||||
|
||||
if (dracoMesh) {
|
||||
draco::Encoder encoder;
|
||||
|
|
Loading…
Reference in a new issue