mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 15:57:39 +02:00
generalized pointer, laserpointermanager -> pointermanager
This commit is contained in:
parent
d7745efc8e
commit
24ce09f914
14 changed files with 341 additions and 313 deletions
|
@ -193,6 +193,8 @@
|
|||
#include <EntityScriptClient.h>
|
||||
#include <ModelScriptingInterface.h>
|
||||
|
||||
#include <pointers/PickManager.h>
|
||||
#include <pointers/PointerManager.h>
|
||||
#include <raypick/RayPickScriptingInterface.h>
|
||||
#include <raypick/LaserPointerScriptingInterface.h>
|
||||
#include <raypick/MouseRayPick.h>
|
||||
|
@ -690,6 +692,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
|||
|
||||
DependencyManager::set<FadeEffect>();
|
||||
|
||||
DependencyManager::set<PickManager>();
|
||||
DependencyManager::set<PointerManager>();
|
||||
DependencyManager::set<LaserPointerScriptingInterface>();
|
||||
DependencyManager::set<RayPickScriptingInterface>();
|
||||
|
||||
|
@ -751,7 +755,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
_notifiedPacketVersionMismatchThisDomain(false),
|
||||
_maxOctreePPS(maxOctreePacketsPerSecond.get()),
|
||||
_lastFaceTrackerUpdate(0),
|
||||
_snapshotSound(nullptr) {
|
||||
_snapshotSound(nullptr)
|
||||
{
|
||||
auto steamClient = PluginManager::getInstance()->getSteamClientPlugin();
|
||||
setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
|
||||
setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
|
||||
|
@ -850,13 +855,13 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
|
||||
auto audioIO = DependencyManager::get<AudioClient>();
|
||||
audioIO->setPositionGetter([] {
|
||||
audioIO->setPositionGetter([]{
|
||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||
auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
|
||||
|
||||
return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
|
||||
});
|
||||
audioIO->setOrientationGetter([] {
|
||||
audioIO->setOrientationGetter([]{
|
||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||
auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
|
||||
|
||||
|
@ -867,7 +872,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
audioIO->handleRecordedAudioInput(frame->data);
|
||||
});
|
||||
|
||||
connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio) {
|
||||
connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio){
|
||||
static auto recorder = DependencyManager::get<recording::Recorder>();
|
||||
if (recorder->isRecording()) {
|
||||
static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AudioConstants::getAudioFrameName());
|
||||
|
@ -956,14 +961,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
|
||||
// use our MyAvatar position and quat for address manager path
|
||||
addressManager->setPositionGetter([this] { return getMyAvatar()->getPosition(); });
|
||||
addressManager->setOrientationGetter([this] { return getMyAvatar()->getOrientation(); });
|
||||
addressManager->setPositionGetter([this]{ return getMyAvatar()->getPosition(); });
|
||||
addressManager->setOrientationGetter([this]{ return getMyAvatar()->getOrientation(); });
|
||||
|
||||
connect(addressManager.data(), &AddressManager::hostChanged, this, &Application::updateWindowTitle);
|
||||
connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress);
|
||||
|
||||
connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount);
|
||||
connect(this, &Application::activeDisplayPluginChanged, this, []() {
|
||||
connect(this, &Application::activeDisplayPluginChanged, this, [](){
|
||||
qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode());
|
||||
});
|
||||
connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode);
|
||||
|
@ -973,7 +978,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
DependencyManager::get<AddressManager>().data(), &AddressManager::storeCurrentAddress);
|
||||
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
|
||||
scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine) {
|
||||
scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){
|
||||
registerScriptEngineWithApplicationServices(engine);
|
||||
});
|
||||
|
||||
|
@ -989,7 +994,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
}, Qt::QueuedConnection);
|
||||
|
||||
connect(scriptEngines, &ScriptEngines::scriptLoadError,
|
||||
scriptEngines, [](const QString& filename, const QString& error) {
|
||||
scriptEngines, [](const QString& filename, const QString& error){
|
||||
OffscreenUi::asyncWarning(nullptr, "Error Loading Script", filename + " failed to load.");
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
|
@ -1101,7 +1106,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
}
|
||||
|
||||
// add firstRun flag from settings to launch event
|
||||
Setting::Handle<bool> firstRun{ Settings::firstRun, true };
|
||||
Setting::Handle<bool> firstRun { Settings::firstRun, true };
|
||||
|
||||
// once the settings have been loaded, check if we need to flip the default for UserActivityLogger
|
||||
auto& userActivityLogger = UserActivityLogger::getInstance();
|
||||
|
@ -1202,42 +1207,42 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
static int lastKey = Qt::Key_unknown;
|
||||
bool navAxis = false;
|
||||
switch (actionEnum) {
|
||||
case Action::UI_NAV_VERTICAL:
|
||||
navAxis = true;
|
||||
if (state > 0.0f) {
|
||||
key = Qt::Key_Up;
|
||||
} else if (state < 0.0f) {
|
||||
key = Qt::Key_Down;
|
||||
}
|
||||
break;
|
||||
case Action::UI_NAV_VERTICAL:
|
||||
navAxis = true;
|
||||
if (state > 0.0f) {
|
||||
key = Qt::Key_Up;
|
||||
} else if (state < 0.0f) {
|
||||
key = Qt::Key_Down;
|
||||
}
|
||||
break;
|
||||
|
||||
case Action::UI_NAV_LATERAL:
|
||||
navAxis = true;
|
||||
if (state > 0.0f) {
|
||||
key = Qt::Key_Right;
|
||||
} else if (state < 0.0f) {
|
||||
key = Qt::Key_Left;
|
||||
}
|
||||
break;
|
||||
case Action::UI_NAV_LATERAL:
|
||||
navAxis = true;
|
||||
if (state > 0.0f) {
|
||||
key = Qt::Key_Right;
|
||||
} else if (state < 0.0f) {
|
||||
key = Qt::Key_Left;
|
||||
}
|
||||
break;
|
||||
|
||||
case Action::UI_NAV_GROUP:
|
||||
navAxis = true;
|
||||
if (state > 0.0f) {
|
||||
key = Qt::Key_Tab;
|
||||
} else if (state < 0.0f) {
|
||||
key = Qt::Key_Backtab;
|
||||
}
|
||||
break;
|
||||
case Action::UI_NAV_GROUP:
|
||||
navAxis = true;
|
||||
if (state > 0.0f) {
|
||||
key = Qt::Key_Tab;
|
||||
} else if (state < 0.0f) {
|
||||
key = Qt::Key_Backtab;
|
||||
}
|
||||
break;
|
||||
|
||||
case Action::UI_NAV_BACK:
|
||||
key = Qt::Key_Escape;
|
||||
break;
|
||||
case Action::UI_NAV_BACK:
|
||||
key = Qt::Key_Escape;
|
||||
break;
|
||||
|
||||
case Action::UI_NAV_SELECT:
|
||||
key = Qt::Key_Return;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case Action::UI_NAV_SELECT:
|
||||
key = Qt::Key_Return;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
auto window = tabletScriptingInterface->getTabletWindow();
|
||||
|
@ -1376,8 +1381,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
|
||||
QTimer* settingsTimer = new QTimer();
|
||||
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer] {
|
||||
connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer] {
|
||||
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
|
||||
connect(qApp, &Application::beforeAboutToQuit, [this, settingsTimer]{
|
||||
// Disconnect the signal from the save settings
|
||||
QObject::disconnect(settingsTimer, &QTimer::timeout, this, &Application::saveSettings);
|
||||
// Stop the settings timer
|
||||
|
@ -1439,7 +1444,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
// Now that menu is initialized we can sync myAvatar with it's state.
|
||||
myAvatar->updateMotionBehaviorFromMenu();
|
||||
|
||||
// FIXME spacemouse code still needs cleanup
|
||||
// FIXME spacemouse code still needs cleanup
|
||||
#if 0
|
||||
// the 3Dconnexion device wants to be initialized after a window is displayed.
|
||||
SpacemouseManager::getInstance().init();
|
||||
|
@ -1448,7 +1453,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
// If the user clicks an an entity, we will check that it's an unlocked web entity, and if so, set the focus to it
|
||||
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
|
||||
connect(entityScriptingInterface.data(), &EntityScriptingInterface::clickDownOnEntity,
|
||||
[this](const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||
[this](const EntityItemID& entityItemID, const PointerEvent& event) {
|
||||
if (getEntities()->wantsKeyboardFocus(entityItemID)) {
|
||||
setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
|
||||
setKeyboardFocusEntity(entityItemID);
|
||||
|
@ -1663,8 +1668,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
totalServerOctreeElements += i->second.getTotalElements();
|
||||
}
|
||||
|
||||
properties["local_octree_elements"] = (qint64)OctreeElement::getInternalNodeCount();
|
||||
properties["server_octree_elements"] = (qint64)totalServerOctreeElements;
|
||||
properties["local_octree_elements"] = (qint64) OctreeElement::getInternalNodeCount();
|
||||
properties["server_octree_elements"] = (qint64) totalServerOctreeElements;
|
||||
|
||||
properties["active_display_plugin"] = getActiveDisplayPlugin()->getName();
|
||||
properties["using_hmd"] = isHMDMode();
|
||||
|
@ -1685,7 +1690,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
if (_autoSwitchDisplayModeSupportedHMDPlugin) {
|
||||
if (getActiveDisplayPlugin() != _autoSwitchDisplayModeSupportedHMDPlugin &&
|
||||
!_autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
|
||||
startHMDStandBySession();
|
||||
startHMDStandBySession();
|
||||
}
|
||||
// Poll periodically to check whether the user has worn HMD or not. Switch Display mode accordingly.
|
||||
// If the user wears HMD then switch to VR mode. If the user removes HMD then switch to Desktop mode.
|
||||
|
@ -1729,7 +1734,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
connect(checkNearbyAvatarsTimer, &QTimer::timeout, this, [this]() {
|
||||
auto avatarManager = DependencyManager::get<AvatarManager>();
|
||||
int nearbyAvatars = avatarManager->numberOfAvatarsInRange(avatarManager->getMyAvatar()->getPosition(),
|
||||
NEARBY_AVATAR_RADIUS_METERS) - 1;
|
||||
NEARBY_AVATAR_RADIUS_METERS) - 1;
|
||||
if (nearbyAvatars != lastCountOfNearbyAvatars) {
|
||||
lastCountOfNearbyAvatars = nearbyAvatars;
|
||||
UserActivityLogger::getInstance().logAction("nearby_avatars", { { "count", nearbyAvatars } });
|
||||
|
@ -1817,15 +1822,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged);
|
||||
|
||||
_pickManager.setShouldPickHUDOperator([&]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
|
||||
DependencyManager::get<PickManager>()->setShouldPickHUDOperator([&]() { return DependencyManager::get<HMDScriptingInterface>()->isHMDMode(); });
|
||||
|
||||
// Setup the mouse ray pick and related operators
|
||||
DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_pickManager.addPick(RAY, std::make_shared<MouseRayPick>(
|
||||
DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(DependencyManager::get<PickManager>()->addPick(RAY, std::make_shared<MouseRayPick>(
|
||||
PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()), 0.0f, true)));
|
||||
DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {
|
||||
RayToEntityIntersectionResult entityResult;
|
||||
entityResult.intersects = false;
|
||||
QVariantMap result = _pickManager.getPrevPickResult(rayPickID);
|
||||
QVariantMap result = DependencyManager::get<PickManager>()->getPrevPickResult(rayPickID);
|
||||
if (result["type"].isValid()) {
|
||||
entityResult.intersects = result["type"] != RayPickScriptingInterface::INTERSECTED_NONE();
|
||||
if (entityResult.intersects) {
|
||||
|
@ -1839,7 +1844,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
return entityResult;
|
||||
});
|
||||
DependencyManager::get<EntityTreeRenderer>()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) {
|
||||
_pickManager.setPrecisionPicking(rayPickID, value);
|
||||
DependencyManager::get<PickManager>()->setPrecisionPicking(rayPickID, value);
|
||||
});
|
||||
|
||||
qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID());
|
||||
|
@ -4912,12 +4917,12 @@ void Application::update(float deltaTime) {
|
|||
// TODO: break these out into distinct perfTimers when they prove interesting
|
||||
{
|
||||
PROFILE_RANGE(app, "PickManager");
|
||||
_pickManager.update();
|
||||
DependencyManager::get<PickManager>()->update();
|
||||
}
|
||||
|
||||
{
|
||||
PROFILE_RANGE(app, "LaserPointerManager");
|
||||
_laserPointerManager.update();
|
||||
PROFILE_RANGE(app, "PointerManager");
|
||||
DependencyManager::get<PointerManager>()->update();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -70,9 +70,6 @@
|
|||
#include "ui/overlays/Overlays.h"
|
||||
#include "UndoStackScriptingInterface.h"
|
||||
|
||||
#include <pointers/PickManager.h>
|
||||
#include "raypick/LaserPointerManager.h"
|
||||
|
||||
#include <procedural/ProceduralSkybox.h>
|
||||
#include <model/Skybox.h>
|
||||
#include <ModelScriptingInterface.h>
|
||||
|
@ -298,9 +295,6 @@ public:
|
|||
QUrl getAvatarOverrideUrl() { return _avatarOverrideUrl; }
|
||||
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
|
||||
|
||||
LaserPointerManager& getLaserPointerManager() { return _laserPointerManager; }
|
||||
PickManager& getPickManager() { return _pickManager; }
|
||||
|
||||
signals:
|
||||
void svoImportRequested(const QString& url);
|
||||
|
||||
|
@ -713,9 +707,6 @@ private:
|
|||
bool _saveAvatarOverrideUrl { false };
|
||||
QObject* _renderEventHandler{ nullptr };
|
||||
|
||||
PickManager _pickManager;
|
||||
LaserPointerManager _laserPointerManager;
|
||||
|
||||
friend class RenderEventHandler;
|
||||
};
|
||||
#endif // hifi_Application_h
|
||||
|
|
|
@ -13,18 +13,20 @@
|
|||
#include "Application.h"
|
||||
#include "avatar/AvatarManager.h"
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <pointers/PickManager.h>
|
||||
#include "RayPickScriptingInterface.h"
|
||||
|
||||
LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& renderStates, const DefaultRenderStateMap& defaultRenderStates,
|
||||
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool enabled) :
|
||||
Pointer(DependencyManager::get<RayPickScriptingInterface>()->createRayPick(rayProps)),
|
||||
_renderingEnabled(enabled),
|
||||
_renderStates(renderStates),
|
||||
_defaultRenderStates(defaultRenderStates),
|
||||
_faceAvatar(faceAvatar),
|
||||
_centerEndY(centerEndY),
|
||||
_lockEnd(lockEnd),
|
||||
_rayPickUID(DependencyManager::get<RayPickScriptingInterface>()->createRayPick(rayProps))
|
||||
_lockEnd(lockEnd)
|
||||
{
|
||||
|
||||
|
||||
for (auto& state : _renderStates) {
|
||||
if (!enabled || state.first != _currentRenderState) {
|
||||
disableRenderState(state.second);
|
||||
|
@ -38,8 +40,6 @@ LaserPointer::LaserPointer(const QVariant& rayProps, const RenderStateMap& rende
|
|||
}
|
||||
|
||||
LaserPointer::~LaserPointer() {
|
||||
qApp->getPickManager().removePick(_rayPickUID);
|
||||
|
||||
for (auto& renderState : _renderStates) {
|
||||
renderState.second.deleteOverlays();
|
||||
}
|
||||
|
@ -49,14 +49,14 @@ LaserPointer::~LaserPointer() {
|
|||
}
|
||||
|
||||
void LaserPointer::enable() {
|
||||
qApp->getPickManager().enablePick(_rayPickUID);
|
||||
Pointer::enable();
|
||||
withWriteLock([&] {
|
||||
_renderingEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
void LaserPointer::disable() {
|
||||
qApp->getPickManager().disablePick(_rayPickUID);
|
||||
Pointer::disable();
|
||||
withWriteLock([&] {
|
||||
_renderingEnabled = false;
|
||||
if (!_currentRenderState.empty()) {
|
||||
|
@ -100,10 +100,6 @@ void LaserPointer::updateRenderStateOverlay(const OverlayID& id, const QVariant&
|
|||
}
|
||||
}
|
||||
|
||||
const QVariantMap LaserPointer::getPrevRayPickResult() {
|
||||
return qApp->getPickManager().getPrevPickResult(_rayPickUID);
|
||||
}
|
||||
|
||||
void LaserPointer::updateRenderState(const RenderState& renderState, const IntersectionType type, const float distance, const QUuid& objectID, const PickRay& pickRay, const bool defaultState) {
|
||||
if (!renderState.getStartID().isNull()) {
|
||||
QVariantMap startProps;
|
||||
|
@ -197,7 +193,7 @@ void LaserPointer::disableRenderState(const RenderState& renderState) {
|
|||
void LaserPointer::update() {
|
||||
// This only needs to be a read lock because update won't change any of the properties that can be modified from scripts
|
||||
withReadLock([&] {
|
||||
QVariantMap prevRayPickResult = qApp->getPickManager().getPrevPickResult(_rayPickUID);
|
||||
QVariantMap prevRayPickResult = DependencyManager::get<PickManager>()->getPrevPickResult(_pickUID);
|
||||
IntersectionType type = IntersectionType(prevRayPickResult["type"].toInt());
|
||||
PickRay pickRay = PickRay(prevRayPickResult["searchRay"].toMap());
|
||||
QUuid uid = prevRayPickResult["objectID"].toUuid();
|
||||
|
@ -216,13 +212,9 @@ void LaserPointer::update() {
|
|||
});
|
||||
}
|
||||
|
||||
void LaserPointer::setPrecisionPicking(const bool precisionPicking) {
|
||||
qApp->getPickManager().setPrecisionPicking(_rayPickUID, precisionPicking);
|
||||
}
|
||||
|
||||
void LaserPointer::setLaserLength(const float laserLength) {
|
||||
void LaserPointer::setLength(const float length) {
|
||||
withWriteLock([&] {
|
||||
_laserLength = laserLength;
|
||||
_laserLength = length;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -232,14 +224,6 @@ void LaserPointer::setLockEndUUID(QUuid objectID, const bool isOverlay) {
|
|||
});
|
||||
}
|
||||
|
||||
void LaserPointer::setIgnoreItems(const QVector<QUuid>& ignoreItems) const {
|
||||
qApp->getPickManager().setIgnoreItems(_rayPickUID, ignoreItems);
|
||||
}
|
||||
|
||||
void LaserPointer::setIncludeItems(const QVector<QUuid>& includeItems) const {
|
||||
qApp->getPickManager().setIncludeItems(_rayPickUID, includeItems);
|
||||
}
|
||||
|
||||
RenderState::RenderState(const OverlayID& startID, const OverlayID& pathID, const OverlayID& endID) :
|
||||
_startID(startID), _pathID(pathID), _endID(endID)
|
||||
{
|
||||
|
|
|
@ -14,12 +14,10 @@
|
|||
#include <QString>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <shared/ReadWriteLockable.h>
|
||||
|
||||
#include "ui/overlays/Overlay.h"
|
||||
|
||||
#include "RayPickScriptingInterface.h"
|
||||
#include <pointers/Pointer.h>
|
||||
#include <pointers/Pick.h>
|
||||
|
||||
class RenderState {
|
||||
|
||||
|
@ -45,12 +43,9 @@ private:
|
|||
bool _endIgnoreRays;
|
||||
};
|
||||
|
||||
|
||||
class LaserPointer : public ReadWriteLockable {
|
||||
class LaserPointer : public Pointer {
|
||||
|
||||
public:
|
||||
using Pointer = std::shared_ptr<LaserPointer>;
|
||||
|
||||
typedef std::unordered_map<std::string, RenderState> RenderStateMap;
|
||||
typedef std::unordered_map<std::string, std::pair<float, RenderState>> DefaultRenderStateMap;
|
||||
|
||||
|
@ -58,23 +53,17 @@ public:
|
|||
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool enabled);
|
||||
~LaserPointer();
|
||||
|
||||
QUuid getRayUID() { return _rayPickUID; }
|
||||
void enable();
|
||||
void disable();
|
||||
const QVariantMap getPrevRayPickResult();
|
||||
void enable() override;
|
||||
void disable() override;
|
||||
|
||||
void setRenderState(const std::string& state);
|
||||
void setRenderState(const std::string& state) override;
|
||||
// You cannot use editRenderState to change the overlay type of any part of the laser pointer. You can only edit the properties of the existing overlays.
|
||||
void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps);
|
||||
void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) override;
|
||||
|
||||
void setPrecisionPicking(const bool precisionPicking);
|
||||
void setLaserLength(const float laserLength);
|
||||
void setLockEndUUID(QUuid objectID, const bool isOverlay);
|
||||
void setLength(const float length) override;
|
||||
void setLockEndUUID(QUuid objectID, const bool isOverlay) override;
|
||||
|
||||
void setIgnoreItems(const QVector<QUuid>& ignoreItems) const;
|
||||
void setIncludeItems(const QVector<QUuid>& includeItems) const;
|
||||
|
||||
void update();
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
bool _renderingEnabled;
|
||||
|
@ -87,8 +76,6 @@ private:
|
|||
bool _lockEnd;
|
||||
std::pair<QUuid, bool> _objectLockEnd { std::pair<QUuid, bool>(QUuid(), false)};
|
||||
|
||||
const QUuid _rayPickUID;
|
||||
|
||||
void updateRenderStateOverlay(const OverlayID& id, const QVariant& props);
|
||||
void updateRenderState(const RenderState& renderState, const IntersectionType type, const float distance, const QUuid& objectID, const PickRay& pickRay, const bool defaultState);
|
||||
void disableRenderState(const RenderState& renderState);
|
||||
|
|
|
@ -1,121 +0,0 @@
|
|||
//
|
||||
// LaserPointerManager.cpp
|
||||
// interface/src/raypick
|
||||
//
|
||||
// Created by Sam Gondelman 7/11/2017
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "LaserPointerManager.h"
|
||||
|
||||
QUuid LaserPointerManager::createLaserPointer(const QVariant& rayProps, const LaserPointer::RenderStateMap& renderStates, const LaserPointer::DefaultRenderStateMap& defaultRenderStates,
|
||||
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool enabled) {
|
||||
QUuid result;
|
||||
std::shared_ptr<LaserPointer> laserPointer = std::make_shared<LaserPointer>(rayProps, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, enabled);
|
||||
if (!laserPointer->getRayUID().isNull()) {
|
||||
result = QUuid::createUuid();
|
||||
withWriteLock([&] { _laserPointers[result] = laserPointer; });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
LaserPointer::Pointer LaserPointerManager::find(const QUuid& uid) const {
|
||||
return resultWithReadLock<LaserPointer::Pointer>([&] {
|
||||
auto itr = _laserPointers.find(uid);
|
||||
if (itr != _laserPointers.end()) {
|
||||
return *itr;
|
||||
}
|
||||
return LaserPointer::Pointer();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void LaserPointerManager::removeLaserPointer(const QUuid& uid) {
|
||||
withWriteLock([&] {
|
||||
_laserPointers.remove(uid);
|
||||
});
|
||||
}
|
||||
|
||||
void LaserPointerManager::enableLaserPointer(const QUuid& uid) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->enable();
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::disableLaserPointer(const QUuid& uid) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->disable();
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::setRenderState(const QUuid& uid, const std::string& renderState) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->setRenderState(renderState);
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::editRenderState(const QUuid& uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->editRenderState(state, startProps, pathProps, endProps);
|
||||
}
|
||||
}
|
||||
|
||||
const QVariantMap LaserPointerManager::getPrevRayPickResult(const QUuid& uid) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
return laserPointer->getPrevRayPickResult();
|
||||
}
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
void LaserPointerManager::update() {
|
||||
auto cachedLaserPointers = resultWithReadLock<QList<std::shared_ptr<LaserPointer>>>([&] {
|
||||
return _laserPointers.values();
|
||||
});
|
||||
|
||||
for (const auto& laserPointer : cachedLaserPointers) {
|
||||
laserPointer->update();
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::setPrecisionPicking(const QUuid& uid, const bool precisionPicking) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->setPrecisionPicking(precisionPicking);
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::setLaserLength(const QUuid& uid, const float laserLength) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->setLaserLength(laserLength);
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::setIgnoreItems(const QUuid& uid, const QVector<QUuid>& ignoreEntities) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->setIgnoreItems(ignoreEntities);
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::setIncludeItems(const QUuid& uid, const QVector<QUuid>& includeEntities) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->setIncludeItems(includeEntities);
|
||||
}
|
||||
}
|
||||
|
||||
void LaserPointerManager::setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay) const {
|
||||
auto laserPointer = find(uid);
|
||||
if (laserPointer) {
|
||||
laserPointer->setLockEndUUID(objectID, isOverlay);
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
//
|
||||
// LaserPointerManager.h
|
||||
// interface/src/raypick
|
||||
//
|
||||
// Created by Sam Gondelman 7/11/2017
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#ifndef hifi_LaserPointerManager_h
|
||||
#define hifi_LaserPointerManager_h
|
||||
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <shared/ReadWriteLockable.h>
|
||||
|
||||
#include "LaserPointer.h"
|
||||
|
||||
class LaserPointerManager : protected ReadWriteLockable {
|
||||
|
||||
public:
|
||||
QUuid createLaserPointer(const QVariant& rayProps, const LaserPointer::RenderStateMap& renderStates, const LaserPointer::DefaultRenderStateMap& defaultRenderStates,
|
||||
const bool faceAvatar, const bool centerEndY, const bool lockEnd, const bool enabled);
|
||||
void removeLaserPointer(const QUuid& uid);
|
||||
void enableLaserPointer(const QUuid& uid) const;
|
||||
void disableLaserPointer(const QUuid& uid) const;
|
||||
void setRenderState(const QUuid& uid, const std::string& renderState) const;
|
||||
void editRenderState(const QUuid& uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) const;
|
||||
const QVariantMap getPrevRayPickResult(const QUuid& uid) const;
|
||||
|
||||
void setPrecisionPicking(const QUuid& uid, const bool precisionPicking) const;
|
||||
void setLaserLength(const QUuid& uid, const float laserLength) const;
|
||||
void setIgnoreItems(const QUuid& uid, const QVector<QUuid>& ignoreEntities) const;
|
||||
void setIncludeItems(const QUuid& uid, const QVector<QUuid>& includeEntities) const;
|
||||
|
||||
void setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay) const;
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
LaserPointer::Pointer find(const QUuid& uid) const;
|
||||
QHash<QUuid, std::shared_ptr<LaserPointer>> _laserPointers;
|
||||
};
|
||||
|
||||
#endif // hifi_LaserPointerManager_h
|
|
@ -15,11 +15,13 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
void LaserPointerScriptingInterface::setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreItems) const {
|
||||
qApp->getLaserPointerManager().setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems));
|
||||
DependencyManager::get<PointerManager>()->setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems));
|
||||
}
|
||||
void LaserPointerScriptingInterface::setIncludeItems(const QUuid& uid, const QScriptValue& includeItems) const {
|
||||
qApp->getLaserPointerManager().setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems));
|
||||
DependencyManager::get<PointerManager>()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems));
|
||||
}
|
||||
|
||||
QUuid LaserPointerScriptingInterface::createLaserPointer(const QVariant& properties) const {
|
||||
|
@ -74,7 +76,7 @@ QUuid LaserPointerScriptingInterface::createLaserPointer(const QVariant& propert
|
|||
}
|
||||
}
|
||||
|
||||
return qApp->getLaserPointerManager().createLaserPointer(properties, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, enabled);
|
||||
return DependencyManager::get<PointerManager>()->addPointer(std::make_shared<LaserPointer>(properties, renderStates, defaultRenderStates, faceAvatar, centerEndY, lockEnd, enabled));
|
||||
}
|
||||
|
||||
void LaserPointerScriptingInterface::editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const {
|
||||
|
@ -95,7 +97,7 @@ void LaserPointerScriptingInterface::editRenderState(const QUuid& uid, const QSt
|
|||
endProps = propMap["end"];
|
||||
}
|
||||
|
||||
qApp->getLaserPointerManager().editRenderState(uid, renderState.toStdString(), startProps, pathProps, endProps);
|
||||
DependencyManager::get<PointerManager>()->editRenderState(uid, renderState.toStdString(), startProps, pathProps, endProps);
|
||||
}
|
||||
|
||||
RenderState LaserPointerScriptingInterface::buildRenderState(const QVariantMap& propMap) {
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
#include <QtCore/QObject>
|
||||
|
||||
#include "DependencyManager.h"
|
||||
#include "Application.h"
|
||||
#include <pointers/PointerManager.h>
|
||||
|
||||
#include "LaserPointer.h"
|
||||
|
||||
class LaserPointerScriptingInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
@ -22,19 +24,19 @@ class LaserPointerScriptingInterface : public QObject, public Dependency {
|
|||
|
||||
public slots:
|
||||
Q_INVOKABLE QUuid createLaserPointer(const QVariant& properties) const;
|
||||
Q_INVOKABLE void enableLaserPointer(const QUuid& uid) const { qApp->getLaserPointerManager().enableLaserPointer(uid); }
|
||||
Q_INVOKABLE void disableLaserPointer(const QUuid& uid) const { qApp->getLaserPointerManager().disableLaserPointer(uid); }
|
||||
Q_INVOKABLE void removeLaserPointer(const QUuid& uid) const { qApp->getLaserPointerManager().removeLaserPointer(uid); }
|
||||
Q_INVOKABLE void enableLaserPointer(const QUuid& uid) const { DependencyManager::get<PointerManager>()->enablePointer(uid); }
|
||||
Q_INVOKABLE void disableLaserPointer(const QUuid& uid) const { DependencyManager::get<PointerManager>()->disablePointer(uid); }
|
||||
Q_INVOKABLE void removeLaserPointer(const QUuid& uid) const { DependencyManager::get<PointerManager>()->removePointer(uid); }
|
||||
Q_INVOKABLE void editRenderState(const QUuid& uid, const QString& renderState, const QVariant& properties) const;
|
||||
Q_INVOKABLE void setRenderState(const QUuid& uid, const QString& renderState) const { qApp->getLaserPointerManager().setRenderState(uid, renderState.toStdString()); }
|
||||
Q_INVOKABLE QVariantMap getPrevRayPickResult(QUuid uid) const { return qApp->getLaserPointerManager().getPrevRayPickResult(uid); }
|
||||
Q_INVOKABLE void setRenderState(const QUuid& uid, const QString& renderState) const { DependencyManager::get<PointerManager>()->setRenderState(uid, renderState.toStdString()); }
|
||||
Q_INVOKABLE QVariantMap getPrevRayPickResult(QUuid uid) const { return DependencyManager::get<PointerManager>()->getPrevRayPickResult(uid); }
|
||||
|
||||
Q_INVOKABLE void setPrecisionPicking(const QUuid& uid, bool precisionPicking) const { qApp->getLaserPointerManager().setPrecisionPicking(uid, precisionPicking); }
|
||||
Q_INVOKABLE void setLaserLength(const QUuid& uid, float laserLength) const { qApp->getLaserPointerManager().setLaserLength(uid, laserLength); }
|
||||
Q_INVOKABLE void setPrecisionPicking(const QUuid& uid, bool precisionPicking) const { DependencyManager::get<PointerManager>()->setPrecisionPicking(uid, precisionPicking); }
|
||||
Q_INVOKABLE void setLaserLength(const QUuid& uid, float laserLength) const { DependencyManager::get<PointerManager>()->setLength(uid, laserLength); }
|
||||
Q_INVOKABLE void setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreEntities) const;
|
||||
Q_INVOKABLE void setIncludeItems(const QUuid& uid, const QScriptValue& includeEntities) const;
|
||||
|
||||
Q_INVOKABLE void setLockEndUUID(const QUuid& uid, const QUuid& objectID, bool isOverlay) const { qApp->getLaserPointerManager().setLockEndUUID(uid, objectID, isOverlay); }
|
||||
Q_INVOKABLE void setLockEndUUID(const QUuid& uid, const QUuid& objectID, bool isOverlay) const { DependencyManager::get<PointerManager>()->setLockEndUUID(uid, objectID, isOverlay); }
|
||||
|
||||
private:
|
||||
static RenderState buildRenderState(const QVariantMap& propMap);
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
|
||||
#include <QVariant>
|
||||
#include "GLMHelpers.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <pointers/PickManager.h>
|
||||
|
||||
#include "StaticRayPick.h"
|
||||
#include "JointRayPick.h"
|
||||
|
@ -52,10 +53,10 @@ QUuid RayPickScriptingInterface::createRayPick(const QVariant& properties) {
|
|||
dirOffset = vec3FromVariant(propMap["dirOffset"]);
|
||||
}
|
||||
|
||||
return qApp->getPickManager().addPick(RAY, std::make_shared<JointRayPick>(jointName, posOffset, dirOffset, filter, maxDistance, enabled));
|
||||
return DependencyManager::get<PickManager>()->addPick(RAY, std::make_shared<JointRayPick>(jointName, posOffset, dirOffset, filter, maxDistance, enabled));
|
||||
|
||||
} else {
|
||||
return qApp->getPickManager().addPick(RAY, std::make_shared<MouseRayPick>(filter, maxDistance, enabled));
|
||||
return DependencyManager::get<PickManager>()->addPick(RAY, std::make_shared<MouseRayPick>(filter, maxDistance, enabled));
|
||||
}
|
||||
} else if (propMap["position"].isValid()) {
|
||||
glm::vec3 position = vec3FromVariant(propMap["position"]);
|
||||
|
@ -65,36 +66,36 @@ QUuid RayPickScriptingInterface::createRayPick(const QVariant& properties) {
|
|||
direction = vec3FromVariant(propMap["direction"]);
|
||||
}
|
||||
|
||||
return qApp->getPickManager().addPick(RAY, std::make_shared<StaticRayPick>(position, direction, filter, maxDistance, enabled));
|
||||
return DependencyManager::get<PickManager>()->addPick(RAY, std::make_shared<StaticRayPick>(position, direction, filter, maxDistance, enabled));
|
||||
}
|
||||
|
||||
return QUuid();
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::enableRayPick(const QUuid& uid) {
|
||||
qApp->getPickManager().enablePick(uid);
|
||||
DependencyManager::get<PickManager>()->enablePick(uid);
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::disableRayPick(const QUuid& uid) {
|
||||
qApp->getPickManager().disablePick(uid);
|
||||
DependencyManager::get<PickManager>()->disablePick(uid);
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::removeRayPick(const QUuid& uid) {
|
||||
qApp->getPickManager().removePick(uid);
|
||||
DependencyManager::get<PickManager>()->removePick(uid);
|
||||
}
|
||||
|
||||
QVariantMap RayPickScriptingInterface::getPrevRayPickResult(const QUuid& uid) {
|
||||
return qApp->getPickManager().getPrevPickResult(uid);
|
||||
return DependencyManager::get<PickManager>()->getPrevPickResult(uid);
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::setPrecisionPicking(const QUuid& uid, const bool precisionPicking) {
|
||||
qApp->getPickManager().setPrecisionPicking(uid, precisionPicking);
|
||||
DependencyManager::get<PickManager>()->setPrecisionPicking(uid, precisionPicking);
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreItems) {
|
||||
qApp->getPickManager().setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems));
|
||||
DependencyManager::get<PickManager>()->setIgnoreItems(uid, qVectorQUuidFromScriptValue(ignoreItems));
|
||||
}
|
||||
|
||||
void RayPickScriptingInterface::setIncludeItems(const QUuid& uid, const QScriptValue& includeItems) {
|
||||
qApp->getPickManager().setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems));
|
||||
DependencyManager::get<PickManager>()->setIncludeItems(uid, qVectorQUuidFromScriptValue(includeItems));
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include "RegisteredMetaTypes.h"
|
||||
|
||||
#include "Pick.h"
|
||||
|
@ -20,7 +21,8 @@ enum PickType {
|
|||
STYLUS
|
||||
};
|
||||
|
||||
class PickManager : protected ReadWriteLockable {
|
||||
class PickManager : public Dependency, protected ReadWriteLockable {
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
PickManager();
|
||||
|
|
39
libraries/pointers/src/pointers/Pointer.cpp
Normal file
39
libraries/pointers/src/pointers/Pointer.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// Created by Sam Gondelman 10/19/2017
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "Pointer.h"
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include "PickManager.h"
|
||||
|
||||
Pointer::~Pointer() {
|
||||
DependencyManager::get<PickManager>()->removePick(_pickUID);
|
||||
}
|
||||
|
||||
void Pointer::enable() {
|
||||
DependencyManager::get<PickManager>()->enablePick(_pickUID);
|
||||
}
|
||||
|
||||
void Pointer::disable() {
|
||||
DependencyManager::get<PickManager>()->disablePick(_pickUID);
|
||||
}
|
||||
|
||||
const QVariantMap Pointer::getPrevPickResult() {
|
||||
return DependencyManager::get<PickManager>()->getPrevPickResult(_pickUID);
|
||||
}
|
||||
|
||||
void Pointer::setPrecisionPicking(const bool precisionPicking) {
|
||||
DependencyManager::get<PickManager>()->setPrecisionPicking(_pickUID, precisionPicking);
|
||||
}
|
||||
|
||||
void Pointer::setIgnoreItems(const QVector<QUuid>& ignoreItems) const {
|
||||
DependencyManager::get<PickManager>()->setIgnoreItems(_pickUID, ignoreItems);
|
||||
}
|
||||
|
||||
void Pointer::setIncludeItems(const QVector<QUuid>& includeItems) const {
|
||||
DependencyManager::get<PickManager>()->setIncludeItems(_pickUID, includeItems);
|
||||
}
|
46
libraries/pointers/src/pointers/Pointer.h
Normal file
46
libraries/pointers/src/pointers/Pointer.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// Created by Sam Gondelman 10/17/2017
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#ifndef hifi_Pointer_h
|
||||
#define hifi_Pointer_h
|
||||
|
||||
#include <QtCore/QUuid>
|
||||
#include <QVector>
|
||||
#include <QVariant>
|
||||
|
||||
#include <shared/ReadWriteLockable.h>
|
||||
|
||||
class Pointer : protected ReadWriteLockable {
|
||||
public:
|
||||
Pointer(const QUuid& uid) : _pickUID(uid) {}
|
||||
|
||||
virtual ~Pointer();
|
||||
|
||||
virtual void enable();
|
||||
virtual void disable();
|
||||
virtual const QVariantMap getPrevPickResult();
|
||||
|
||||
virtual void setRenderState(const std::string& state) = 0;
|
||||
virtual void editRenderState(const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) = 0;
|
||||
|
||||
virtual void setPrecisionPicking(const bool precisionPicking);
|
||||
virtual void setIgnoreItems(const QVector<QUuid>& ignoreItems) const;
|
||||
virtual void setIncludeItems(const QVector<QUuid>& includeItems) const;
|
||||
|
||||
// Pointers can choose to implement these
|
||||
virtual void setLength(const float length) {}
|
||||
virtual void setLockEndUUID(QUuid objectID, const bool isOverlay) {}
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
QUuid getRayUID() { return _pickUID; }
|
||||
|
||||
protected:
|
||||
const QUuid _pickUID;
|
||||
};
|
||||
|
||||
#endif // hifi_Pick_h
|
|
@ -1,6 +1,115 @@
|
|||
//
|
||||
// Created by Bradley Austin Davis on 2017/10/16
|
||||
// Copyright 2013-2017 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "PointerManager.h"
|
||||
|
||||
PointerManager::PointerManager() {
|
||||
|
||||
std::shared_ptr<Pointer> PointerManager::find(const QUuid& uid) const {
|
||||
return resultWithReadLock<std::shared_ptr<Pointer>>([&] {
|
||||
auto itr = _pointers.find(uid);
|
||||
if (itr != _pointers.end()) {
|
||||
return *itr;
|
||||
}
|
||||
return std::shared_ptr<Pointer>();
|
||||
});
|
||||
}
|
||||
|
||||
QUuid PointerManager::addPointer(std::shared_ptr<Pointer> pointer) {
|
||||
QUuid result;
|
||||
if (!pointer->getRayUID().isNull()) {
|
||||
result = QUuid::createUuid();
|
||||
withWriteLock([&] { _pointers[result] = pointer; });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void PointerManager::removePointer(const QUuid& uid) {
|
||||
withWriteLock([&] {
|
||||
_pointers.remove(uid);
|
||||
});
|
||||
}
|
||||
|
||||
void PointerManager::enablePointer(const QUuid& uid) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->enable();
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::disablePointer(const QUuid& uid) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->disable();
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setRenderState(const QUuid& uid, const std::string& renderState) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setRenderState(renderState);
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::editRenderState(const QUuid& uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->editRenderState(state, startProps, pathProps, endProps);
|
||||
}
|
||||
}
|
||||
|
||||
const QVariantMap PointerManager::getPrevRayPickResult(const QUuid& uid) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
return pointer->getPrevPickResult();
|
||||
}
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
void PointerManager::update() {
|
||||
auto cachedPointers = resultWithReadLock<QList<std::shared_ptr<Pointer>>>([&] {
|
||||
return _pointers.values();
|
||||
});
|
||||
|
||||
for (const auto& pointer : cachedPointers) {
|
||||
pointer->update();
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setPrecisionPicking(const QUuid& uid, const bool precisionPicking) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setPrecisionPicking(precisionPicking);
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setIgnoreItems(const QUuid& uid, const QVector<QUuid>& ignoreEntities) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setIgnoreItems(ignoreEntities);
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setIncludeItems(const QUuid& uid, const QVector<QUuid>& includeEntities) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setIncludeItems(includeEntities);
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setLength(const QUuid& uid, const float length) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setLength(length);
|
||||
}
|
||||
}
|
||||
|
||||
void PointerManager::setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay) const {
|
||||
auto pointer = find(uid);
|
||||
if (pointer) {
|
||||
pointer->setLockEndUUID(objectID, isOverlay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,39 @@
|
|||
#include <DependencyManager.h>
|
||||
#include <PointerEvent.h>
|
||||
|
||||
class PointerManager : public QObject, public Dependency {
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include <shared/ReadWriteLockable.h>
|
||||
|
||||
#include "Pointer.h"
|
||||
|
||||
class PointerManager : public QObject, public Dependency, protected ReadWriteLockable{
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
public:
|
||||
PointerManager();
|
||||
PointerManager() {}
|
||||
|
||||
QUuid addPointer(std::shared_ptr<Pointer> pointer);
|
||||
void removePointer(const QUuid& uid);
|
||||
void enablePointer(const QUuid& uid) const;
|
||||
void disablePointer(const QUuid& uid) const;
|
||||
void setRenderState(const QUuid& uid, const std::string& renderState) const;
|
||||
void editRenderState(const QUuid& uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps) const;
|
||||
const QVariantMap getPrevRayPickResult(const QUuid& uid) const;
|
||||
|
||||
void setPrecisionPicking(const QUuid& uid, const bool precisionPicking) const;
|
||||
void setIgnoreItems(const QUuid& uid, const QVector<QUuid>& ignoreEntities) const;
|
||||
void setIncludeItems(const QUuid& uid, const QVector<QUuid>& includeEntities) const;
|
||||
|
||||
void setLength(const QUuid& uid, const float length) const;
|
||||
void setLockEndUUID(const QUuid& uid, const QUuid& objectID, const bool isOverlay) const;
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
std::shared_ptr<Pointer> find(const QUuid& uid) const;
|
||||
QHash<QUuid, std::shared_ptr<Pointer>> _pointers;
|
||||
|
||||
signals:
|
||||
void triggerBegin(const QUuid& id, const PointerEvent& pointerEvent);
|
||||
|
|
Loading…
Reference in a new issue