diff --git a/src/AtlasLayerCombo.h b/src/AtlasLayerCombo.h index 71b31a0..bde1897 100644 --- a/src/AtlasLayerCombo.h +++ b/src/AtlasLayerCombo.h @@ -27,6 +27,7 @@ class AtlasLayerCombo { virtual void setup(const ComboIdentifier & identifier, AtlasLayerComboSettings settings) = 0; virtual void update() = 0; + virtual bool hasChildren() = 0; virtual void careForChild(shared_ptr layer) = 0; virtual void abandonChild(shared_ptr layer) = 0; virtual const ComboIdentifier & getIdentifier() const = 0; diff --git a/src/GPUFontAtlasLayerCombo.cpp b/src/GPUFontAtlasLayerCombo.cpp index ac48336..d3878a8 100644 --- a/src/GPUFontAtlasLayerCombo.cpp +++ b/src/GPUFontAtlasLayerCombo.cpp @@ -139,6 +139,9 @@ const ComboIdentifier & GPUFontAtlasLayerCombo::getIdentifier() const { void GPUFontAtlasLayerCombo::setVFlip(VFlipState vFlipState){ vFlip = vFlipState; } +bool GPUFontAtlasLayerCombo::hasChildren(){ + return layers.size() > 0; +} const vector > & GPUFontAtlasLayerCombo::getLayers(){ return layers; } diff --git a/src/GPUFontAtlasLayerCombo.h b/src/GPUFontAtlasLayerCombo.h index dd1a9c5..16b6d36 100644 --- a/src/GPUFontAtlasLayerCombo.h +++ b/src/GPUFontAtlasLayerCombo.h @@ -63,6 +63,7 @@ class GPUFontAtlasLayerCombo : public AtlasLayerCombo { void abandonChild(shared_ptr layer) override; const ComboIdentifier & getIdentifier() const override; void setVFlip(VFlipState vFlipState) override; + bool hasChildren() override; const vector > & getLayers(); void draw(); diff --git a/src/LayerComposition.cpp b/src/LayerComposition.cpp index fb4bb31..ab49e5a 100644 --- a/src/LayerComposition.cpp +++ b/src/LayerComposition.cpp @@ -20,6 +20,9 @@ void LayerComposition::update(){ if(l.second->wantsNewMom()){ const auto momIdentifier = l.second->getMomsComboIdentifier(); atlasLayerCombos[momIdentifier]->abandonChild(l.second); + if(!atlasLayerCombos[momIdentifier]->hasChildren()){ + atlasLayerCombos.erase(momIdentifier); + } ComboIdentifier idealMom{ l.second->getProps().fontPath, momIdentifier.type diff --git a/src/MsdfAtlasLayerCombo.cpp b/src/MsdfAtlasLayerCombo.cpp index 2742378..1d8cc09 100644 --- a/src/MsdfAtlasLayerCombo.cpp +++ b/src/MsdfAtlasLayerCombo.cpp @@ -74,6 +74,10 @@ void MsdfAtlasLayerCombo::setVFlip(VFlipState vFlipState){ } } +bool MsdfAtlasLayerCombo::hasChildren(){ + return layers.size() > 0; +} + const ofImage & MsdfAtlasLayerCombo::getAtlasImage(){ return atlas->getAtlasImage(); } diff --git a/src/MsdfAtlasLayerCombo.h b/src/MsdfAtlasLayerCombo.h index 8b5b11d..5ee60a6 100644 --- a/src/MsdfAtlasLayerCombo.h +++ b/src/MsdfAtlasLayerCombo.h @@ -19,6 +19,7 @@ class MsdfAtlasLayerCombo : public AtlasLayerCombo { void abandonChild(shared_ptr layer) override; const ComboIdentifier & getIdentifier() const override; void setVFlip(VFlipState vFlipState) override; + bool hasChildren() override; const ofImage & getAtlasImage(); string getAtlasImagePath(); shared_ptr getLayer(); // TODO: is this used