mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
Update setting drawOnHUD and update to write lock for editOverlay
This commit is contained in:
parent
413cbacbc1
commit
68a9d80ba3
4 changed files with 28 additions and 38 deletions
|
@ -48,13 +48,6 @@ Base3DOverlay::Base3DOverlay(const Base3DOverlay* base3DOverlay) :
|
||||||
Base3DOverlay::~Base3DOverlay() {
|
Base3DOverlay::~Base3DOverlay() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Base3DOverlay::setDrawOnHUD(bool value) {
|
|
||||||
if (_drawOnHUD != value) {
|
|
||||||
_drawOnHUD = value;
|
|
||||||
Application::getInstance()->getOverlays().overlayDrawOnChanged(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
||||||
Overlay::setProperties(properties);
|
Overlay::setProperties(properties);
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
void setRotation(const glm::quat& value) { _rotation = value; }
|
void setRotation(const glm::quat& value) { _rotation = value; }
|
||||||
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
|
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
|
||||||
void setDrawInFront(bool value) { _drawInFront = value; }
|
void setDrawInFront(bool value) { _drawInFront = value; }
|
||||||
void setDrawOnHUD(bool value);
|
void setDrawOnHUD(bool value) { _drawOnHUD = value; }
|
||||||
|
|
||||||
virtual void setProperties(const QScriptValue& properties);
|
virtual void setProperties(const QScriptValue& properties);
|
||||||
virtual QScriptValue getProperty(const QString& property);
|
virtual QScriptValue getProperty(const QString& property);
|
||||||
|
|
|
@ -224,17 +224,36 @@ unsigned int Overlays::cloneOverlay(unsigned int id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
bool Overlays::editOverlay(unsigned int id, const QScriptValue& properties) {
|
||||||
|
QWriteLocker lock(&_lock);
|
||||||
Overlay* thisOverlay = NULL;
|
Overlay* thisOverlay = NULL;
|
||||||
{
|
|
||||||
QReadLocker lock(&_lock);
|
if (_overlaysHUD.contains(id)) {
|
||||||
if (_overlaysHUD.contains(id)) {
|
thisOverlay = _overlaysHUD[id];
|
||||||
thisOverlay = _overlaysHUD[id];
|
} else if (_overlaysWorld.contains(id)) {
|
||||||
} else if (_overlaysWorld.contains(id)) {
|
thisOverlay = _overlaysWorld[id];
|
||||||
thisOverlay = _overlaysWorld[id];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thisOverlay) {
|
if (thisOverlay) {
|
||||||
thisOverlay->setProperties(properties);
|
if (thisOverlay->is3D()) {
|
||||||
|
Base3DOverlay* overlay3D = static_cast<Base3DOverlay*>(thisOverlay);
|
||||||
|
|
||||||
|
bool oldDrawOnHUD = overlay3D->getDrawOnHUD();
|
||||||
|
thisOverlay->setProperties(properties);
|
||||||
|
bool drawOnHUD = overlay3D->getDrawOnHUD();
|
||||||
|
|
||||||
|
if (drawOnHUD != oldDrawOnHUD) {
|
||||||
|
if (drawOnHUD) {
|
||||||
|
_overlaysWorld.remove(id);
|
||||||
|
_overlaysHUD[id] = thisOverlay;
|
||||||
|
} else {
|
||||||
|
_overlaysHUD.remove(id);
|
||||||
|
_overlaysWorld[id] = thisOverlay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
thisOverlay->setProperties(properties);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -450,25 +469,6 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
|
||||||
value.extraInfo = object.property("extraInfo").toVariant().toString();
|
value.extraInfo = object.property("extraInfo").toVariant().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::overlayDrawOnChanged(Base3DOverlay* overlay) {
|
|
||||||
QWriteLocker lock(&_lock);
|
|
||||||
if (overlay->getDrawOnHUD()) {
|
|
||||||
for (unsigned int id : _overlaysWorld.keys()) {
|
|
||||||
if (_overlaysWorld[id] == overlay) {
|
|
||||||
_overlaysWorld.remove(id);
|
|
||||||
_overlaysHUD[id] = overlay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (unsigned int id : _overlaysHUD.keys()) {
|
|
||||||
if (_overlaysHUD[id] == overlay) {
|
|
||||||
_overlaysHUD.remove(id);
|
|
||||||
_overlaysWorld[id] = overlay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Overlays::isLoaded(unsigned int id) {
|
bool Overlays::isLoaded(unsigned int id) {
|
||||||
QReadLocker lock(&_lock);
|
QReadLocker lock(&_lock);
|
||||||
Overlay* thisOverlay = NULL;
|
Overlay* thisOverlay = NULL;
|
||||||
|
|
|
@ -82,9 +82,6 @@ public slots:
|
||||||
|
|
||||||
/// returns details about the closest 3D Overlay hit by the pick ray
|
/// returns details about the closest 3D Overlay hit by the pick ray
|
||||||
RayToOverlayIntersectionResult findRayIntersection(const PickRay& ray);
|
RayToOverlayIntersectionResult findRayIntersection(const PickRay& ray);
|
||||||
|
|
||||||
// called by Base3DOverlay when drawOnHUD changes
|
|
||||||
void overlayDrawOnChanged(Base3DOverlay* overlay);
|
|
||||||
|
|
||||||
/// returns whether the overlay's assets are loaded or not
|
/// returns whether the overlay's assets are loaded or not
|
||||||
bool isLoaded(unsigned int id);
|
bool isLoaded(unsigned int id);
|
||||||
|
|
Loading…
Reference in a new issue