void EditorLevel::lower_object(LevelObjPtr obj) { Objects::reverse_iterator i = std::find(impl->objects.rbegin(), impl->objects.rend(), obj); if (i == impl->objects.rend()) { log_error("couldn't find object: %1%", obj); } else { Objects::reverse_iterator j = i; ++j; j = std::find_if(j, impl->objects.rend(), OverlapsWith(obj->get_rect())); if (j == impl->objects.rend()) { // object overlaps with no other object, no point in lowering it } else { // the base() of base in one further then where the reverse // iterator was, so we have to move back to get the same // position impl->objects.erase(--(i.base())); impl->objects.insert(--(j.base()), obj); } } }
void EditorLevel::raise_object(LevelObjPtr obj) { Objects::iterator i = std::find(impl->objects.begin(), impl->objects.end(), obj); if (i == impl->objects.end()) { log_error("couldn't find object: %1%", obj); } else { Objects::iterator j = i; ++j; j = std::find_if(j, impl->objects.end(), OverlapsWith(obj->get_rect())); if (j == impl->objects.end()) { // object overlaps with no other object, no point in raising it } else { impl->objects.erase(i); impl->objects.insert(++j, obj); } } }
Boole AxisAlignedQuad::OverlapsWith(const Vector3& Other) const { if(DistanceFromOrigin == Other[AlignedOn]) { return OverlapsWith( DropAxisToCreateVector2(Other, AlignedOn) ); } return false; }
bool LabelBlock::Bucket::Check(const PixelRect rc) const { for (auto i = blocks.begin(), end = blocks.end(); i != end; ++i) if (i->OverlapsWith(rc)) return false; return true; }