Move draw order sorting into SceneElement
This commit is contained in:
parent
5ca513fcec
commit
3bd9df1191
|
@ -38,12 +38,8 @@ void Scene::insert(SceneElement &element)
|
||||||
{
|
{
|
||||||
SceneElement *e = iter->data;
|
SceneElement *e = iter->data;
|
||||||
|
|
||||||
if (element.z <= e->z)
|
if (element < *e)
|
||||||
{
|
{
|
||||||
if (element.z == e->z)
|
|
||||||
if (element.creationStamp > e->creationStamp)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
elements.insertBefore(element.link, *iter);
|
elements.insertBefore(element.link, *iter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -140,6 +136,20 @@ void SceneElement::setVisible(bool value)
|
||||||
visible = value;
|
visible = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SceneElement::operator<(const SceneElement &o) const
|
||||||
|
{
|
||||||
|
if (z <= o.z)
|
||||||
|
{
|
||||||
|
if (z == o.z)
|
||||||
|
if (creationStamp > o.creationStamp)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SceneElement::unlink()
|
void SceneElement::unlink()
|
||||||
{
|
{
|
||||||
scene->elements.remove(link);
|
scene->elements.remove(link);
|
||||||
|
|
|
@ -81,6 +81,10 @@ protected:
|
||||||
virtual void draw() = 0;
|
virtual void draw() = 0;
|
||||||
virtual void onGeometryChange(const Scene::Geometry &) {}
|
virtual void onGeometryChange(const Scene::Geometry &) {}
|
||||||
|
|
||||||
|
/* Compares to elements in terms of their display priority;
|
||||||
|
* elements with lower priority are drawn earlier */
|
||||||
|
bool operator<(const SceneElement &o) const;
|
||||||
|
|
||||||
void unlink();
|
void unlink();
|
||||||
|
|
||||||
IntruListLink<SceneElement> link;
|
IntruListLink<SceneElement> link;
|
||||||
|
|
Loading…
Reference in New Issue