mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 03:19:33 +02:00
uuid keys for overlays appears to work
This commit is contained in:
parent
c1e41311fc
commit
05c135b9d8
8 changed files with 43 additions and 64 deletions
|
@ -529,7 +529,7 @@ bool setupEssentials(int& argc, char** argv) {
|
||||||
// to take care of highlighting keyboard focused items, rather than
|
// to take care of highlighting keyboard focused items, rather than
|
||||||
// continuing to overburden Application.cpp
|
// continuing to overburden Application.cpp
|
||||||
std::shared_ptr<Cube3DOverlay> _keyboardFocusHighlight{ nullptr };
|
std::shared_ptr<Cube3DOverlay> _keyboardFocusHighlight{ nullptr };
|
||||||
OverlayID _keyboardFocusHighlightID{ -1 };
|
OverlayID _keyboardFocusHighlightID{ UNKNOWN_OVERLAY_ID };
|
||||||
|
|
||||||
|
|
||||||
// FIXME hack access to the internal share context for the Chromium helper
|
// FIXME hack access to the internal share context for the Chromium helper
|
||||||
|
@ -1683,9 +1683,9 @@ void Application::cleanupBeforeQuit() {
|
||||||
_applicationStateDevice.reset();
|
_applicationStateDevice.reset();
|
||||||
|
|
||||||
{
|
{
|
||||||
if (_keyboardFocusHighlightID) {
|
if (_keyboardFocusHighlightID != UNKNOWN_OVERLAY_ID) {
|
||||||
getOverlays().deleteOverlay(_keyboardFocusHighlightID);
|
getOverlays().deleteOverlay(_keyboardFocusHighlightID);
|
||||||
_keyboardFocusHighlightID = UNKNOWN_OVERLAY_ID;
|
_keyboardFocusHighlightID = UNKNOWN_OVERLAY_ID;
|
||||||
}
|
}
|
||||||
_keyboardFocusHighlight = nullptr;
|
_keyboardFocusHighlight = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -3072,7 +3072,7 @@ void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
buttons, event->modifiers());
|
buttons, event->modifiers());
|
||||||
|
|
||||||
if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() ||
|
if (compositor.getReticleVisible() || !isHMDMode() || !compositor.getReticleOverDesktop() ||
|
||||||
getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y()))) {
|
getOverlays().getOverlayAtPoint(glm::vec2(transformedPos.x(), transformedPos.y())) != UNKNOWN_OVERLAY_ID) {
|
||||||
getOverlays().mouseMoveEvent(&mappedEvent);
|
getOverlays().mouseMoveEvent(&mappedEvent);
|
||||||
getEntities()->mouseMoveEvent(&mappedEvent);
|
getEntities()->mouseMoveEvent(&mappedEvent);
|
||||||
}
|
}
|
||||||
|
@ -4091,7 +4091,7 @@ void Application::rotationModeChanged() const {
|
||||||
|
|
||||||
void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm::quat& rotation, const glm::vec3& dimensions) {
|
void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm::quat& rotation, const glm::vec3& dimensions) {
|
||||||
// Create focus
|
// Create focus
|
||||||
if (_keyboardFocusHighlightID == UNKNOWN_OVERLAY_ID || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) {
|
if (_keyboardFocusHighlightID == UNKNOWN_OVERLAY_ID || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) {
|
||||||
_keyboardFocusHighlight = std::make_shared<Cube3DOverlay>();
|
_keyboardFocusHighlight = std::make_shared<Cube3DOverlay>();
|
||||||
_keyboardFocusHighlight->setAlpha(1.0f);
|
_keyboardFocusHighlight->setAlpha(1.0f);
|
||||||
_keyboardFocusHighlight->setBorderSize(1.0f);
|
_keyboardFocusHighlight->setBorderSize(1.0f);
|
||||||
|
|
|
@ -193,7 +193,7 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui
|
||||||
_calibrationCount(0),
|
_calibrationCount(0),
|
||||||
_calibrationValues(),
|
_calibrationValues(),
|
||||||
_calibrationBillboard(NULL),
|
_calibrationBillboard(NULL),
|
||||||
_calibrationBillboardID(0),
|
_calibrationBillboardID(UNKNOWN_OVERLAY_ID),
|
||||||
_calibrationMessage(QString()),
|
_calibrationMessage(QString()),
|
||||||
_isCalibrated(false)
|
_isCalibrated(false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,9 @@ public:
|
||||||
Base3DOverlay();
|
Base3DOverlay();
|
||||||
Base3DOverlay(const Base3DOverlay* base3DOverlay);
|
Base3DOverlay(const Base3DOverlay* base3DOverlay);
|
||||||
|
|
||||||
|
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
|
||||||
|
void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
virtual bool is3D() const override { return true; }
|
virtual bool is3D() const override { return true; }
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ float Overlay::updatePulse() {
|
||||||
_pulseDirection *= -1.0f;
|
_pulseDirection *= -1.0f;
|
||||||
}
|
}
|
||||||
_pulse += pulseDelta;
|
_pulse += pulseDelta;
|
||||||
|
|
||||||
return _pulse;
|
return _pulse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,11 +205,11 @@ void Overlay::removeFromScene(Overlay::Pointer overlay, std::shared_ptr<render::
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue OverlayIDtoScriptValue(QScriptEngine* engine, const OverlayID& id) {
|
QScriptValue OverlayIDtoScriptValue(QScriptEngine* engine, const OverlayID& id) {
|
||||||
return QScriptValue(id.id);
|
return quuidToScriptValue(engine, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverlayIDfromScriptValue(const QScriptValue &object, OverlayID& id) {
|
void OverlayIDfromScriptValue(const QScriptValue &object, OverlayID& id) {
|
||||||
id = object.toUInt32();
|
quuidFromScriptValue(object, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<OverlayID> qVectorOverlayIDFromScriptValue(const QScriptValue& array) {
|
QVector<OverlayID> qVectorOverlayIDFromScriptValue(const QScriptValue& array) {
|
||||||
|
@ -220,9 +220,7 @@ QVector<OverlayID> qVectorOverlayIDFromScriptValue(const QScriptValue& array) {
|
||||||
int length = array.property("length").toInteger();
|
int length = array.property("length").toInteger();
|
||||||
newVector.reserve(length);
|
newVector.reserve(length);
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
OverlayID id;
|
newVector << OverlayID(array.property(i).toString());
|
||||||
OverlayIDfromScriptValue(array.property(i), id);
|
|
||||||
newVector << id;
|
|
||||||
}
|
}
|
||||||
return newVector;
|
return newVector;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,22 +15,11 @@
|
||||||
#include <SharedUtil.h> // for xColor
|
#include <SharedUtil.h> // for xColor
|
||||||
#include <render/Scene.h>
|
#include <render/Scene.h>
|
||||||
|
|
||||||
class OverlayID {
|
class OverlayID : public QUuid {
|
||||||
public:
|
public:
|
||||||
OverlayID() {}
|
OverlayID() : QUuid() {}
|
||||||
OverlayID(int value) { id = value; }
|
OverlayID(QString v) : QUuid(v) {}
|
||||||
|
OverlayID(QUuid v) : QUuid(v) {}
|
||||||
OverlayID& operator=(const OverlayID& other) { id = other.id; return *this; }
|
|
||||||
OverlayID& operator++() { id++; return *this; }
|
|
||||||
|
|
||||||
// OverlayID& operator=(unsigned int value) { id = value; return *this; }
|
|
||||||
bool operator==(const OverlayID& other) const { return id == other.id; }
|
|
||||||
bool operator!=(const OverlayID& other) const { return id != other.id; }
|
|
||||||
// bool operator<(const OverlayID& other) const { return id < other.id; }
|
|
||||||
// bool operator>(const OverlayID& other) const { return id > other.id; }
|
|
||||||
operator bool() const { return id != 0; }
|
|
||||||
|
|
||||||
unsigned int id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Overlay : public QObject {
|
class Overlay : public QObject {
|
||||||
|
@ -50,8 +39,8 @@ public:
|
||||||
Overlay(const Overlay* overlay);
|
Overlay(const Overlay* overlay);
|
||||||
~Overlay();
|
~Overlay();
|
||||||
|
|
||||||
OverlayID getOverlayID() { return _overlayID; }
|
virtual OverlayID getOverlayID() const { return _overlayID; }
|
||||||
void setOverlayID(OverlayID overlayID) { _overlayID = overlayID; }
|
virtual void setOverlayID(OverlayID overlayID) { _overlayID = overlayID; }
|
||||||
|
|
||||||
virtual void update(float deltatime) {}
|
virtual void update(float deltatime) {}
|
||||||
virtual void render(RenderArgs* args) = 0;
|
virtual void render(RenderArgs* args) = 0;
|
||||||
|
@ -107,8 +96,6 @@ protected:
|
||||||
|
|
||||||
render::ItemID _renderItemID{ render::Item::INVALID_ITEM_ID };
|
render::ItemID _renderItemID{ render::Item::INVALID_ITEM_ID };
|
||||||
|
|
||||||
OverlayID _overlayID; // what Overlays.cpp knows this instance as
|
|
||||||
|
|
||||||
bool _isLoaded;
|
bool _isLoaded;
|
||||||
float _alpha;
|
float _alpha;
|
||||||
|
|
||||||
|
@ -125,10 +112,13 @@ protected:
|
||||||
xColor _color;
|
xColor _color;
|
||||||
bool _visible; // should the overlay be drawn at all
|
bool _visible; // should the overlay be drawn at all
|
||||||
Anchor _anchor;
|
Anchor _anchor;
|
||||||
|
|
||||||
|
private:
|
||||||
|
OverlayID _overlayID; // only used for non-3d overlays
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace render {
|
namespace render {
|
||||||
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay);
|
template <> const ItemKey payloadGetKey(const Overlay::Pointer& overlay);
|
||||||
template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay);
|
template <> const Item::Bound payloadGetBound(const Overlay::Pointer& overlay);
|
||||||
template <> int payloadGetLayer(const Overlay::Pointer& overlay);
|
template <> int payloadGetLayer(const Overlay::Pointer& overlay);
|
||||||
template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args);
|
template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args);
|
||||||
|
@ -141,5 +131,5 @@ QScriptValue OverlayIDtoScriptValue(QScriptEngine* engine, const OverlayID& id);
|
||||||
void OverlayIDfromScriptValue(const QScriptValue &object, OverlayID& id);
|
void OverlayIDfromScriptValue(const QScriptValue &object, OverlayID& id);
|
||||||
QVector<OverlayID> qVectorOverlayIDFromScriptValue(const QScriptValue& array);
|
QVector<OverlayID> qVectorOverlayIDFromScriptValue(const QScriptValue& array);
|
||||||
|
|
||||||
|
|
||||||
#endif // hifi_Overlay_h
|
#endif // hifi_Overlay_h
|
||||||
|
|
|
@ -89,7 +89,7 @@ QVariant OverlayPanel::getProperty(const QString &property) {
|
||||||
if (property == "children") {
|
if (property == "children") {
|
||||||
QVariantList array;
|
QVariantList array;
|
||||||
for (int i = 0; i < _children.length(); i++) {
|
for (int i = 0; i < _children.length(); i++) {
|
||||||
array.append(OverlayIDtoScriptValue(nullptr, _children[i]));
|
array.append(OverlayIDtoScriptValue(nullptr, _children[i]).toVariant());
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,6 @@
|
||||||
|
|
||||||
Q_LOGGING_CATEGORY(trace_render_overlays, "trace.render.overlays")
|
Q_LOGGING_CATEGORY(trace_render_overlays, "trace.render.overlays")
|
||||||
|
|
||||||
Overlays::Overlays() :
|
|
||||||
_nextOverlayID(1) {}
|
|
||||||
|
|
||||||
void Overlays::cleanupAllOverlays() {
|
void Overlays::cleanupAllOverlays() {
|
||||||
{
|
{
|
||||||
QWriteLocker lock(&_lock);
|
QWriteLocker lock(&_lock);
|
||||||
|
@ -188,14 +185,13 @@ OverlayID Overlays::addOverlay(const QString& type, const QVariant& properties)
|
||||||
thisOverlay->setProperties(properties.toMap());
|
thisOverlay->setProperties(properties.toMap());
|
||||||
return addOverlay(thisOverlay);
|
return addOverlay(thisOverlay);
|
||||||
}
|
}
|
||||||
return 0;
|
return UNKNOWN_OVERLAY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayID Overlays::addOverlay(Overlay::Pointer overlay) {
|
OverlayID Overlays::addOverlay(Overlay::Pointer overlay) {
|
||||||
QWriteLocker lock(&_lock);
|
QWriteLocker lock(&_lock);
|
||||||
OverlayID thisID = _nextOverlayID;
|
OverlayID thisID = OverlayID(QUuid::createUuid());
|
||||||
overlay->setOverlayID(thisID);
|
overlay->setOverlayID(thisID);
|
||||||
++_nextOverlayID;
|
|
||||||
if (overlay->is3D()) {
|
if (overlay->is3D()) {
|
||||||
_overlaysWorld[thisID] = overlay;
|
_overlaysWorld[thisID] = overlay;
|
||||||
|
|
||||||
|
@ -220,9 +216,9 @@ OverlayID Overlays::cloneOverlay(OverlayID id) {
|
||||||
attachable->getParentPanel()->addChild(cloneId);
|
attachable->getParentPanel()->addChild(cloneId);
|
||||||
}
|
}
|
||||||
return cloneId;
|
return cloneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; // Not found
|
return UNKNOWN_OVERLAY_ID; // Not found
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Overlays::editOverlay(OverlayID id, const QVariant& properties) {
|
bool Overlays::editOverlay(OverlayID id, const QVariant& properties) {
|
||||||
|
@ -242,13 +238,7 @@ bool Overlays::editOverlays(const QVariant& propertiesById) {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
QWriteLocker lock(&_lock);
|
QWriteLocker lock(&_lock);
|
||||||
for (const auto& key : map.keys()) {
|
for (const auto& key : map.keys()) {
|
||||||
bool convertSuccess;
|
OverlayID id = OverlayID(key);
|
||||||
OverlayID id = key.toUInt(&convertSuccess);
|
|
||||||
if (!convertSuccess) {
|
|
||||||
success = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Overlay::Pointer thisOverlay = getOverlay(id);
|
Overlay::Pointer thisOverlay = getOverlay(id);
|
||||||
if (!thisOverlay) {
|
if (!thisOverlay) {
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -310,7 +300,7 @@ OverlayID Overlays::getParentPanel(OverlayID childId) const {
|
||||||
} else if (_panels.contains(childId)) {
|
} else if (_panels.contains(childId)) {
|
||||||
return _panels.key(getPanel(childId)->getParentPanel());
|
return _panels.key(getPanel(childId)->getParentPanel());
|
||||||
}
|
}
|
||||||
return 0;
|
return UNKNOWN_OVERLAY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::setParentPanel(OverlayID childId, OverlayID panelId) {
|
void Overlays::setParentPanel(OverlayID childId, OverlayID panelId) {
|
||||||
|
@ -347,7 +337,7 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
glm::vec2 pointCopy = point;
|
glm::vec2 pointCopy = point;
|
||||||
QReadLocker lock(&_lock);
|
QReadLocker lock(&_lock);
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
return 0;
|
return UNKNOWN_OVERLAY_ID;
|
||||||
}
|
}
|
||||||
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysHUD);
|
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysHUD);
|
||||||
i.toBack();
|
i.toBack();
|
||||||
|
@ -378,7 +368,7 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; // not found
|
return UNKNOWN_OVERLAY_ID; // not found
|
||||||
}
|
}
|
||||||
|
|
||||||
OverlayPropertyResult Overlays::getProperty(OverlayID id, const QString& property) {
|
OverlayPropertyResult Overlays::getProperty(OverlayID id, const QString& property) {
|
||||||
|
@ -447,14 +437,14 @@ RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
RayToOverlayIntersectionResult::RayToOverlayIntersectionResult() :
|
RayToOverlayIntersectionResult::RayToOverlayIntersectionResult() :
|
||||||
intersects(false),
|
intersects(false),
|
||||||
overlayID(-1),
|
overlayID(UNKNOWN_OVERLAY_ID),
|
||||||
distance(0),
|
distance(0),
|
||||||
face(),
|
face(),
|
||||||
intersection(),
|
intersection(),
|
||||||
extraInfo()
|
extraInfo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue RayToOverlayIntersectionResultToScriptValue(QScriptEngine* engine, const RayToOverlayIntersectionResult& value) {
|
QScriptValue RayToOverlayIntersectionResultToScriptValue(QScriptEngine* engine, const RayToOverlayIntersectionResult& value) {
|
||||||
|
@ -463,7 +453,7 @@ QScriptValue RayToOverlayIntersectionResultToScriptValue(QScriptEngine* engine,
|
||||||
obj.setProperty("overlayID", OverlayIDtoScriptValue(engine, value.overlayID));
|
obj.setProperty("overlayID", OverlayIDtoScriptValue(engine, value.overlayID));
|
||||||
obj.setProperty("distance", value.distance);
|
obj.setProperty("distance", value.distance);
|
||||||
|
|
||||||
QString faceName = "";
|
QString faceName = "";
|
||||||
// handle BoxFace
|
// handle BoxFace
|
||||||
switch (value.face) {
|
switch (value.face) {
|
||||||
case MIN_X_FACE:
|
case MIN_X_FACE:
|
||||||
|
@ -499,7 +489,7 @@ QScriptValue RayToOverlayIntersectionResultToScriptValue(QScriptEngine* engine,
|
||||||
void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& objectVar, RayToOverlayIntersectionResult& value) {
|
void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& objectVar, RayToOverlayIntersectionResult& value) {
|
||||||
QVariantMap object = objectVar.toVariant().toMap();
|
QVariantMap object = objectVar.toVariant().toMap();
|
||||||
value.intersects = object["intersects"].toBool();
|
value.intersects = object["intersects"].toBool();
|
||||||
value.overlayID = object["overlayID"].toInt();
|
value.overlayID = OverlayID(QUuid(object["overlayID"].toString()));
|
||||||
value.distance = object["distance"].toFloat();
|
value.distance = object["distance"].toFloat();
|
||||||
|
|
||||||
QString faceName = object["face"].toString();
|
QString faceName = object["face"].toString();
|
||||||
|
@ -556,8 +546,7 @@ QSizeF Overlays::textSize(OverlayID id, const QString& text) const {
|
||||||
OverlayID Overlays::addPanel(OverlayPanel::Pointer panel) {
|
OverlayID Overlays::addPanel(OverlayPanel::Pointer panel) {
|
||||||
QWriteLocker lock(&_lock);
|
QWriteLocker lock(&_lock);
|
||||||
|
|
||||||
OverlayID thisID = _nextOverlayID;
|
OverlayID thisID = QUuid::createUuid();
|
||||||
++_nextOverlayID;
|
|
||||||
_panels[thisID] = panel;
|
_panels[thisID] = panel;
|
||||||
|
|
||||||
return thisID;
|
return thisID;
|
||||||
|
|
|
@ -77,7 +77,7 @@ void RayToOverlayIntersectionResultFromScriptValue(const QScriptValue& object, R
|
||||||
* @namespace Overlays
|
* @namespace Overlays
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const OverlayID UNKNOWN_OVERLAY_ID = 0;
|
const OverlayID UNKNOWN_OVERLAY_ID = OverlayID();
|
||||||
|
|
||||||
class Overlays : public QObject {
|
class Overlays : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -85,7 +85,7 @@ class Overlays : public QObject {
|
||||||
Q_PROPERTY(OverlayID keyboardFocusOverlay READ getKeyboardFocusOverlay WRITE setKeyboardFocusOverlay)
|
Q_PROPERTY(OverlayID keyboardFocusOverlay READ getKeyboardFocusOverlay WRITE setKeyboardFocusOverlay)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Overlays();
|
Overlays() {};
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void update(float deltatime);
|
void update(float deltatime);
|
||||||
|
@ -305,7 +305,6 @@ private:
|
||||||
QMap<OverlayID, Overlay::Pointer> _overlaysWorld;
|
QMap<OverlayID, Overlay::Pointer> _overlaysWorld;
|
||||||
QMap<OverlayID, OverlayPanel::Pointer> _panels;
|
QMap<OverlayID, OverlayPanel::Pointer> _panels;
|
||||||
QList<Overlay::Pointer> _overlaysToDelete;
|
QList<Overlay::Pointer> _overlaysToDelete;
|
||||||
OverlayID _nextOverlayID;
|
|
||||||
|
|
||||||
QReadWriteLock _lock;
|
QReadWriteLock _lock;
|
||||||
QReadWriteLock _deleteLock;
|
QReadWriteLock _deleteLock;
|
||||||
|
|
Loading…
Reference in a new issue