mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Overlay2D return correct getBounds
This commit is contained in:
parent
e8da8e374c
commit
c22f1aa7e1
3 changed files with 11 additions and 4 deletions
|
@ -28,6 +28,11 @@ Overlay2D::Overlay2D(const Overlay2D* overlay2D) :
|
|||
Overlay2D::~Overlay2D() {
|
||||
}
|
||||
|
||||
AABox Overlay2D::getBounds() const {
|
||||
return AABox(glm::vec3(_bounds.x(), _bounds.y(), 0.0f),
|
||||
glm::vec3(_bounds.width(), _bounds.height(), 0.01f));
|
||||
}
|
||||
|
||||
void Overlay2D::setProperties(const QScriptValue& properties) {
|
||||
Overlay::setProperties(properties);
|
||||
|
||||
|
@ -40,7 +45,7 @@ void Overlay2D::setProperties(const QScriptValue& properties) {
|
|||
boundsRect.setHeight(bounds.property("height").toVariant().toInt());
|
||||
setBounds(boundsRect);
|
||||
} else {
|
||||
QRect oldBounds = getBounds();
|
||||
QRect oldBounds = _bounds;
|
||||
QRect newBounds = oldBounds;
|
||||
|
||||
if (properties.property("x").isValid()) {
|
||||
|
|
|
@ -30,6 +30,8 @@ public:
|
|||
Overlay2D(const Overlay2D* overlay2D);
|
||||
~Overlay2D();
|
||||
|
||||
virtual AABox getBounds() const;
|
||||
|
||||
virtual bool is3D() const { return false; }
|
||||
|
||||
// getters
|
||||
|
@ -37,8 +39,8 @@ public:
|
|||
int getY() const { return _bounds.y(); }
|
||||
int getWidth() const { return _bounds.width(); }
|
||||
int getHeight() const { return _bounds.height(); }
|
||||
const QRect& getBounds() const { return _bounds; }
|
||||
|
||||
const QRect& getBoundingRect() const { return _bounds; }
|
||||
|
||||
// setters
|
||||
void setX(int x) { _bounds.setX(x); }
|
||||
void setY(int y) { _bounds.setY(y); }
|
||||
|
|
|
@ -284,7 +284,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
|||
} else {
|
||||
Overlay2D* thisOverlay = static_cast<Overlay2D*>(i.value().get());
|
||||
if (thisOverlay->getVisible() && thisOverlay->isLoaded() &&
|
||||
thisOverlay->getBounds().contains(pointCopy.x, pointCopy.y, false)) {
|
||||
thisOverlay->getBoundingRect().contains(pointCopy.x, pointCopy.y, false)) {
|
||||
return thisID;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue