mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 03:17:08 +02:00
fix getEntityObject and tablet highlighting (Overlays.findOverlays)
This commit is contained in:
parent
391cca787f
commit
4b406bf41c
5 changed files with 23 additions and 8 deletions
|
@ -1955,6 +1955,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EntityTree::setGetEntityObjectOperator([this](const QUuid& id) -> QObject* {
|
||||||
|
auto entities = getEntities();
|
||||||
|
if (auto entity = entities->renderableForEntityId(id)) {
|
||||||
|
return qobject_cast<QObject*>(entity.get());
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
});
|
||||||
|
|
||||||
EntityTree::setTextSizeOperator([this](const QUuid& id, const QString& text) {
|
EntityTree::setTextSizeOperator([this](const QUuid& id, const QString& text) {
|
||||||
auto entities = getEntities();
|
auto entities = getEntities();
|
||||||
if (auto entity = entities->renderableForEntityId(id)) {
|
if (auto entity = entities->renderableForEntityId(id)) {
|
||||||
|
|
|
@ -1326,6 +1326,8 @@ QVector<QUuid> Overlays::findOverlays(const glm::vec3& center, float radius) {
|
||||||
auto entityTree = DependencyManager::get<EntityScriptingInterface>()->getEntityTree();
|
auto entityTree = DependencyManager::get<EntityScriptingInterface>()->getEntityTree();
|
||||||
if (entityTree) {
|
if (entityTree) {
|
||||||
unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::LOCAL_ENTITIES);
|
unsigned int searchFilter = PickFilter::getBitMask(PickFilter::FlagBit::LOCAL_ENTITIES);
|
||||||
|
// For legacy reasons, this only finds visible objects
|
||||||
|
searchFilter = searchFilter | PickFilter::getBitMask(PickFilter::FlagBit::VISIBLE);
|
||||||
entityTree->withReadLock([&] {
|
entityTree->withReadLock([&] {
|
||||||
entityTree->evalEntitiesInSphere(center, radius, PickFilter(searchFilter), result);
|
entityTree->evalEntitiesInSphere(center, radius, PickFilter(searchFilter), result);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1017,14 +1017,7 @@ QString EntityScriptingInterface::getEntityType(const QUuid& entityID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* EntityScriptingInterface::getEntityObject(const QUuid& id) {
|
QObject* EntityScriptingInterface::getEntityObject(const QUuid& id) {
|
||||||
QObject* toReturn { nullptr };
|
return EntityTree::getEntityObject(id);
|
||||||
_entityTree->withReadLock([&] {
|
|
||||||
EntityItemPointer entity = _entityTree->findEntityByEntityItemID(id);
|
|
||||||
if (entity) {
|
|
||||||
toReturn = qobject_cast<QObject*>(&(*entity));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return toReturn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityScriptingInterface::isLoaded(const QUuid& id) {
|
bool EntityScriptingInterface::isLoaded(const QUuid& id) {
|
||||||
|
|
|
@ -2957,6 +2957,7 @@ std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> E
|
||||||
std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> EntityTree::_removeMaterialFromEntityOperator = nullptr;
|
std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> EntityTree::_removeMaterialFromEntityOperator = nullptr;
|
||||||
std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> EntityTree::_addMaterialToAvatarOperator = nullptr;
|
std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> EntityTree::_addMaterialToAvatarOperator = nullptr;
|
||||||
std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> EntityTree::_removeMaterialFromAvatarOperator = nullptr;
|
std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> EntityTree::_removeMaterialFromAvatarOperator = nullptr;
|
||||||
|
std::function<QObject*(const QUuid&)> EntityTree::_getEntityObjectOperator = nullptr;
|
||||||
std::function<QSizeF(const QUuid&, const QString&)> EntityTree::_textSizeOperator = nullptr;
|
std::function<QSizeF(const QUuid&, const QString&)> EntityTree::_textSizeOperator = nullptr;
|
||||||
|
|
||||||
bool EntityTree::addMaterialToEntity(const QUuid& entityID, graphics::MaterialLayer material, const std::string& parentMaterialName) {
|
bool EntityTree::addMaterialToEntity(const QUuid& entityID, graphics::MaterialLayer material, const std::string& parentMaterialName) {
|
||||||
|
@ -2987,6 +2988,13 @@ bool EntityTree::removeMaterialFromAvatar(const QUuid& avatarID, graphics::Mater
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject* EntityTree::getEntityObject(const QUuid& id) {
|
||||||
|
if (_getEntityObjectOperator) {
|
||||||
|
return _getEntityObjectOperator(id);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
QSizeF EntityTree::textSize(const QUuid& id, const QString& text) {
|
QSizeF EntityTree::textSize(const QUuid& id, const QString& text) {
|
||||||
if (_textSizeOperator) {
|
if (_textSizeOperator) {
|
||||||
return _textSizeOperator(id, text);
|
return _textSizeOperator(id, text);
|
||||||
|
|
|
@ -272,6 +272,9 @@ public:
|
||||||
static bool addMaterialToAvatar(const QUuid& avatarID, graphics::MaterialLayer material, const std::string& parentMaterialName);
|
static bool addMaterialToAvatar(const QUuid& avatarID, graphics::MaterialLayer material, const std::string& parentMaterialName);
|
||||||
static bool removeMaterialFromAvatar(const QUuid& avatarID, graphics::MaterialPointer material, const std::string& parentMaterialName);
|
static bool removeMaterialFromAvatar(const QUuid& avatarID, graphics::MaterialPointer material, const std::string& parentMaterialName);
|
||||||
|
|
||||||
|
static void setGetEntityObjectOperator(std::function<QObject*(const QUuid&)> getEntityObjectOperator) { _getEntityObjectOperator = getEntityObjectOperator; }
|
||||||
|
static QObject* getEntityObject(const QUuid& id);
|
||||||
|
|
||||||
static void setTextSizeOperator(std::function<QSizeF(const QUuid&, const QString&)> textSizeOperator) { _textSizeOperator = textSizeOperator; }
|
static void setTextSizeOperator(std::function<QSizeF(const QUuid&, const QString&)> textSizeOperator) { _textSizeOperator = textSizeOperator; }
|
||||||
static QSizeF textSize(const QUuid& id, const QString& text);
|
static QSizeF textSize(const QUuid& id, const QString& text);
|
||||||
|
|
||||||
|
@ -387,6 +390,7 @@ private:
|
||||||
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromEntityOperator;
|
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromEntityOperator;
|
||||||
static std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> _addMaterialToAvatarOperator;
|
static std::function<bool(const QUuid&, graphics::MaterialLayer, const std::string&)> _addMaterialToAvatarOperator;
|
||||||
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromAvatarOperator;
|
static std::function<bool(const QUuid&, graphics::MaterialPointer, const std::string&)> _removeMaterialFromAvatarOperator;
|
||||||
|
static std::function<QObject*(const QUuid&)> _getEntityObjectOperator;
|
||||||
static std::function<QSizeF(const QUuid&, const QString&)> _textSizeOperator;
|
static std::function<QSizeF(const QUuid&, const QString&)> _textSizeOperator;
|
||||||
|
|
||||||
std::vector<int32_t> _staleProxies;
|
std::vector<int32_t> _staleProxies;
|
||||||
|
|
Loading…
Reference in a new issue