PROFILE_SCOPE("Document::GenQuadChild()");
QuadTreeIndex new_index = m_quadtree.nodes.size();
Debug("-------------- Generating Quadtree Node %d (parent %d, type %d) ----------------------", new_index, parent, type);
- m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, parent, type, 0, 0, -1});
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, parent, type, 0, 0, -1, true});
m_quadtree.nodes[new_index].object_begin = m_objects.bounds.size();
for (QuadTreeIndex overlay = parent; overlay != -1; overlay = m_quadtree.nodes[overlay].next_overlay)
PROFILE_SCOPE("Document::OverlayQuadChildren()");
QuadTreeIndex new_index = m_quadtree.nodes.size();
Debug("-------------- Generating Quadtree Node %d (orig %d parent %d, type %d) ----------------------", new_index, orig_parent, parent, type);
- m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, orig_parent, type, 0, 0, -1});
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, orig_parent, type, 0, 0, -1, true});
m_quadtree.nodes[new_index].object_begin = m_objects.bounds.size();
for (unsigned i = m_quadtree.nodes[parent].object_dirty; i < m_quadtree.nodes[parent].object_end; ++i)
{
PROFILE_SCOPE("Document::OverlayQuadParent()");
QuadTreeIndex new_index = m_quadtree.nodes.size();
- m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, -1, QTC_UNKNOWN, 0, 0, -1});
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, -1, QTC_UNKNOWN, 0, 0, -1, true});
m_quadtree.nodes[new_index].object_begin = m_objects.bounds.size();
m_quadtree.nodes[new_index].object_dirty = m_objects.bounds.size();
{
for (unsigned i = m_quadtree.nodes[overlay].object_begin; i < m_quadtree.nodes[overlay].object_end; ++i)
{
- m_objects.bounds.push_back(TransformFromQuadChild(m_objects.bounds[i], type));
+ Rect new_bounds = TransformFromQuadChild(m_objects.bounds[i], type);
+ // If the object is too small to be seen, discard it.
+ if (!new_bounds.w || !new_bounds.h) continue;
+ m_objects.bounds.push_back(new_bounds);
m_objects.types.push_back(m_objects.types[i]);
m_objects.data_indices.push_back(m_objects.data_indices[i]);
m_count++;
QuadTreeIndex prev_overlay = orig_node;
while (m_quadtree.nodes[prev_overlay].next_overlay != -1) prev_overlay = m_quadtree.nodes[prev_overlay].next_overlay;
m_quadtree.nodes[prev_overlay].next_overlay = new_index;
+ Debug("OverlayQuadParent(%d, %d, %d) = %d", orig_child, child, type, new_index);
// Recurse into any extant parent.
if (m_quadtree.nodes[orig_node].parent != -1)
if (m_quadtree.nodes[overlay].object_dirty == m_quadtree.nodes[overlay].object_end) continue;
// Recurse into our parent, should we have any.
if (m_quadtree.nodes[node].parent != -1)
- OverlayQuadParent(node, overlay, m_quadtree.nodes[overlay].child_type);
+ OverlayQuadParent(node, overlay, m_quadtree.nodes[node].child_type);
// Recurse into any extant children.
if (m_quadtree.nodes[node].top_left != -1)
OverlayQuadChildren(node, overlay, QTC_TOP_LEFT);
QuadTreeIndex Document::GenQuadParent(QuadTreeIndex child, QuadTreeNodeChildren type)
{
QuadTreeIndex new_index = m_quadtree.nodes.size();
- m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, -1, QTC_UNKNOWN, 0, 0, -1});
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, -1, QTC_UNKNOWN, 0, 0, -1, true});
m_quadtree.nodes[new_index].object_begin = m_objects.bounds.size();
for (QuadTreeIndex overlay = child; overlay != -1; overlay = m_quadtree.nodes[overlay].next_overlay)
{
for (unsigned i = m_quadtree.nodes[overlay].object_begin; i < m_quadtree.nodes[overlay].object_end; ++i)
{
- m_objects.bounds.push_back(TransformFromQuadChild(m_objects.bounds[i], type));
+ Rect new_bounds = TransformFromQuadChild(m_objects.bounds[i], type);
+ // If the object is too small to be seen, discard it.
+ if (!new_bounds.w || !new_bounds.h) continue;
+ m_objects.bounds.push_back(new_bounds);
m_objects.types.push_back(m_objects.types[i]);
m_objects.data_indices.push_back(m_objects.data_indices[i]);
m_count++;
{
PROFILE_SCOPE("Document::Add");
Rect new_bounds = bounds;
- int num_added = 1;
- bool still_to_add = true;
#ifndef QUADTREE_DISABLED
+ int num_added = 1;
if (qti == -1) qti = m_current_insert_node;
if (qti != -1)
{
// Move the object to the quadtree node it should be in.
m_quadtree.GetCanonicalCoords(qti, new_bounds.x, new_bounds.y, this);
Rect cliprect = Rect(0,0,1,1);
- // If an object spans multiple quadtree nodes...
- if (!cliprect.Contains(new_bounds))
- {
- num_added = AddClip(type, new_bounds, data_index, cliprect);
- still_to_add = false;
- }
+ num_added = AddClip(type, new_bounds, data_index, cliprect);
}
+ else
#endif
- if (still_to_add)
{
m_objects.types.push_back(type);
m_objects.bounds.push_back(new_bounds);
m_objects.data_indices.push_back(data_index);
}
+ m_document_dirty = true;
#ifndef QUADTREE_DISABLED
if (qti != -1)
{
if (m_count == m_quadtree.nodes[new_qti].object_end+1)
{
m_quadtree.nodes[new_qti].object_end += num_added;
- goto done;
+ m_quadtree.nodes[new_qti].render_dirty = true;
+ new_qti = -1;
+ break;
}
new_qti = m_quadtree.nodes[new_qti].next_overlay;
}
+ if (new_qti != -1)
{
QuadTreeIndex overlay = m_quadtree.nodes.size();
Debug("Adding new overlay, nqti = %d, overlay = %d", new_qti, overlay);
- m_quadtree.nodes.push_back(m_quadtree.nodes[qti]);
+ m_quadtree.nodes.push_back(QuadTreeNode{QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, QUADTREE_EMPTY, -1, QTC_UNKNOWN, 0, 0, -1});
m_quadtree.nodes[overlay].object_begin = m_count;
// All objects are dirty.
m_quadtree.nodes[overlay].object_dirty = m_count;
m_quadtree.nodes[overlay].object_end = m_count+num_added;
m_quadtree.nodes[overlay].next_overlay = -1;
+ m_quadtree.nodes[overlay].render_dirty = true;
m_quadtree.nodes[new_qti].next_overlay = overlay;
new_qti = overlay;
}
-done: // matches is not amused, but sulix is nice and moved it inside the #ifdef for him.
- m_count += num_added;
}
+ m_count += num_added;
return m_count-num_added;
#else // words fail me (still not amused)
return (m_count++);