@@ -107,15 +107,43 @@ void LayerSet::Cull(const sf::FloatRect& bounds)
107107// private
108108void LayerSet::draw (sf::RenderTarget& rt, sf::RenderStates states) const
109109{
110+ // std::vector<sf::Int32> dirtyPatches; //TODO prevent patches being duplicated
110111 for (const auto & q : m_dirtyQuads)
111112 {
112113 for (const auto & p : q->m_indices )
113114 {
114115 m_patches[q->m_patchIndex ][p].position += q->m_movement ;
115116 }
117+ // mark AABB as dirty if patch size has changed - TODO this doesn't shrink AABB :/
118+ // if(!m_boundingBox.contains(m_patches[q->m_patchIndex][0].position)
119+ // || !m_boundingBox.contains(m_patches[q->m_patchIndex][0].position))
120+ // {
121+ // //we only need to check first and 3rd - not all 4
122+ // dirtyPatches.push_back(q->m_patchIndex);
123+ // }
116124 }
117125 m_dirtyQuads.clear ();
118126
127+ // for(auto p : dirtyPatches)
128+ // {
129+ // //update AABB
130+ // sf::Vector2f min, max;
131+ // const auto& verts = m_patches[p];
132+ // for(auto i = 0; i < verts.size(); i += 2) //only check extents
133+ // {
134+ // if(verts[i].position.x < min.x) min.x = verts[i].position.x;
135+ // else if(verts[i].position.x > max.x) max.x = verts[i].position.x;
136+ // if(verts[i].position.y < min.y) min.y = verts[i].position.y;
137+ // else if(verts[i].position.y > max.y) max.y = verts[i].position.y;
138+ // }
139+
140+ // //TODO this doesn't shrink the AABB!
141+ // if(m_boundingBox.left > min.x) m_boundingBox.left = min.x;
142+ // if(m_boundingBox.top > min.y) m_boundingBox.top = min.y;
143+ // if(std::fabs(m_boundingBox.left) + m_boundingBox.width < max.x) m_boundingBox.width = std::fabs(m_boundingBox.left) + max.x;
144+ // if(std::fabs(m_boundingBox.top) + m_boundingBox.height < max.y) m_boundingBox.width = std::fabs(m_boundingBox.top) + max.y;
145+ // }
146+
119147 if (!m_visible) return ;
120148
121149 for (auto x = m_visiblePatchStart.x ; x <= m_visiblePatchEnd.x ; ++x)
0 commit comments