mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 20:34:07 +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() {
|
||||
}
|
||||
|
||||
void Base3DOverlay::setDrawOnHUD(bool value) {
|
||||
if (_drawOnHUD != value) {
|
||||
_drawOnHUD = value;
|
||||
Application::getInstance()->getOverlays().overlayDrawOnChanged(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Base3DOverlay::setProperties(const QScriptValue& properties) {
|
||||
Overlay::setProperties(properties);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
void setRotation(const glm::quat& value) { _rotation = value; }
|
||||
void setIgnoreRayIntersection(bool value) { _ignoreRayIntersection = value; }
|
||||
void setDrawInFront(bool value) { _drawInFront = value; }
|
||||
void setDrawOnHUD(bool value);
|
||||
void setDrawOnHUD(bool value) { _drawOnHUD = value; }
|
||||
|
||||
virtual void setProperties(const QScriptValue& properties);
|
||||
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) {
|
||||
QWriteLocker lock(&_lock);
|
||||
Overlay* thisOverlay = NULL;
|
||||
{
|
||||
QReadLocker lock(&_lock);
|
||||
if (_overlaysHUD.contains(id)) {
|
||||
thisOverlay = _overlaysHUD[id];
|
||||
} else if (_overlaysWorld.contains(id)) {
|
||||
thisOverlay = _overlaysWorld[id];
|
||||
}
|
||||
|
||||
if (_overlaysHUD.contains(id)) {
|
||||
thisOverlay = _overlaysHUD[id];
|
||||
} else if (_overlaysWorld.contains(id)) {
|
||||
thisOverlay = _overlaysWorld[id];
|
||||
}
|
||||
|
||||
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 false;
|
||||
|
@ -450,25 +469,6 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
|
|||
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) {
|
||||
QReadLocker lock(&_lock);
|
||||
Overlay* thisOverlay = NULL;
|
||||
|
|
|
@ -82,9 +82,6 @@ public slots:
|
|||
|
||||
/// returns details about the closest 3D Overlay hit by the pick 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
|
||||
bool isLoaded(unsigned int id);
|
||||
|
|
Loading…
Reference in a new issue