--- a/src/linetypes/subfilereference.cpp Tue Nov 02 15:43:57 2021 +0200 +++ b/src/linetypes/subfilereference.cpp Thu Mar 03 11:42:52 2022 +0200 @@ -1,6 +1,7 @@ #include "subfilereference.h" #include "documentmanager.h" #include "invert.h" +#include "polygoncache.h" ldraw::SubfileReference::SubfileReference ( @@ -45,11 +46,20 @@ GetPolygonsContext* context ) const { - Model* referencedModel = this->resolve(context->modelId, context->documents); - if (referencedModel != nullptr) + Model* dependency = this->resolve(context->modelId, context->documents); + PolygonCache* referencedModelPolygonBuilder = nullptr; + if (dependency != nullptr) + { + const auto dependencyModelId = context->documents->findIdForModel(dependency); + if (dependencyModelId.has_value()) + { + referencedModelPolygonBuilder = context->documents->getPolygonCacheForModel(dependencyModelId.value()); + } + } + if (referencedModelPolygonBuilder != nullptr) { const bool needInverting = glm::determinant(this->transformation) < 0; - const std::vector<gl::Polygon> modelPolygons = referencedModel->getPolygons(context->documents); + const std::vector<gl::Polygon> modelPolygons = referencedModelPolygonBuilder->getPolygons(context->documents); polygons.reserve(polygons.size() + modelPolygons.size()); for (gl::Polygon polygon : modelPolygons) {