From a904ae1a8ad74e87c78fea9818ba333b0abedba8 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 22 Aug 2017 11:41:20 -0700 Subject: [PATCH 1/4] can set precision picking on lasers/raypicks, EntityTreeRender uses ray pick API --- interface/src/Application.cpp | 19 ++++++++ interface/src/raypick/LaserPointer.h | 1 + interface/src/raypick/LaserPointerManager.cpp | 8 ++++ interface/src/raypick/LaserPointerManager.h | 1 + .../raypick/LaserPointerScriptingInterface.h | 1 + interface/src/raypick/RayPick.h | 4 ++ interface/src/raypick/RayPickManager.cpp | 14 +++++- interface/src/raypick/RayPickManager.h | 1 + .../src/raypick/RayPickScriptingInterface.cpp | 4 ++ .../src/raypick/RayPickScriptingInterface.h | 2 +- .../src/EntityTreeRenderer.cpp | 43 +++---------------- .../src/EntityTreeRenderer.h | 15 ++++--- 12 files changed, 68 insertions(+), 45 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 398b2dbdb4..8d7892c4cc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1735,6 +1735,25 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged); + // Setup the mouse ray pick and related operators + DependencyManager::get()->setMouseRayPickID(_rayPickManager.createRayPick(RayPickFilter(RayPickFilter::PICK_ENTITIES), 0.0f, true)); + DependencyManager::get()->setMouseRayPickResultOperator([&](QUuid rayPickID) { + RayToEntityIntersectionResult entityResult; + RayPickResult result = _rayPickManager.getPrevRayPickResult(rayPickID); + entityResult.intersects = result.type != DependencyManager::get()->INTERSECTED_NONE(); + if (entityResult.intersects) { + entityResult.intersection = result.intersection; + entityResult.distance = result.distance; + entityResult.surfaceNormal = result.surfaceNormal; + entityResult.entityID = result.objectID; + entityResult.entity = DependencyManager::get()->getTree()->findEntityByID(entityResult.entityID); + } + return entityResult; + }); + DependencyManager::get()->setSetPrecisionPickingOperator([&](QUuid rayPickID, bool value) { + _rayPickManager.setPrecisionPicking(rayPickID, value); + }); + qCDebug(interfaceapp) << "Metaverse session ID is" << uuidStringWithoutCurlyBraces(accountManager->getSessionID()); } diff --git a/interface/src/raypick/LaserPointer.h b/interface/src/raypick/LaserPointer.h index d901d12cf4..23f023cf7a 100644 --- a/interface/src/raypick/LaserPointer.h +++ b/interface/src/raypick/LaserPointer.h @@ -64,6 +64,7 @@ public: // 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 setPrecisionPicking(const bool precisionPicking) { DependencyManager::get()->setPrecisionPicking(_rayPickUID, precisionPicking); } void setIgnoreEntities(const QScriptValue& ignoreEntities) { DependencyManager::get()->setIgnoreEntities(_rayPickUID, ignoreEntities); } void setIncludeEntities(const QScriptValue& includeEntities) { DependencyManager::get()->setIncludeEntities(_rayPickUID, includeEntities); } void setIgnoreOverlays(const QScriptValue& ignoreOverlays) { DependencyManager::get()->setIgnoreOverlays(_rayPickUID, ignoreOverlays); } diff --git a/interface/src/raypick/LaserPointerManager.cpp b/interface/src/raypick/LaserPointerManager.cpp index 908bcc39f1..1fd0fe9e88 100644 --- a/interface/src/raypick/LaserPointerManager.cpp +++ b/interface/src/raypick/LaserPointerManager.cpp @@ -97,6 +97,14 @@ void LaserPointerManager::update() { } } +void LaserPointerManager::setPrecisionPicking(QUuid uid, const bool precisionPicking) { + QReadLocker lock(&_containsLock); + if (_laserPointers.contains(uid)) { + QWriteLocker laserLock(_laserPointerLocks[uid].get()); + _laserPointers[uid]->setPrecisionPicking(precisionPicking); + } +} + void LaserPointerManager::setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities) { QReadLocker lock(&_containsLock); if (_laserPointers.contains(uid)) { diff --git a/interface/src/raypick/LaserPointerManager.h b/interface/src/raypick/LaserPointerManager.h index 020b778983..b573410fe7 100644 --- a/interface/src/raypick/LaserPointerManager.h +++ b/interface/src/raypick/LaserPointerManager.h @@ -31,6 +31,7 @@ public: void editRenderState(QUuid uid, const std::string& state, const QVariant& startProps, const QVariant& pathProps, const QVariant& endProps); const RayPickResult getPrevRayPickResult(const QUuid uid); + void setPrecisionPicking(QUuid uid, const bool precisionPicking); void setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities); void setIncludeEntities(QUuid uid, const QScriptValue& includeEntities); void setIgnoreOverlays(QUuid uid, const QScriptValue& ignoreOverlays); diff --git a/interface/src/raypick/LaserPointerScriptingInterface.h b/interface/src/raypick/LaserPointerScriptingInterface.h index 8ae263b0ec..d65eb335b3 100644 --- a/interface/src/raypick/LaserPointerScriptingInterface.h +++ b/interface/src/raypick/LaserPointerScriptingInterface.h @@ -30,6 +30,7 @@ public slots: Q_INVOKABLE void setRenderState(QUuid uid, const QString& renderState) { qApp->getLaserPointerManager().setRenderState(uid, renderState.toStdString()); } Q_INVOKABLE RayPickResult getPrevRayPickResult(QUuid uid) { return qApp->getLaserPointerManager().getPrevRayPickResult(uid); } + Q_INVOKABLE void setPrecisionPicking(QUuid uid, const bool precisionPicking) { qApp->getLaserPointerManager().setPrecisionPicking(uid, precisionPicking); } Q_INVOKABLE void setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities) { qApp->getLaserPointerManager().setIgnoreEntities(uid, ignoreEntities); } Q_INVOKABLE void setIncludeEntities(QUuid uid, const QScriptValue& includeEntities) { qApp->getLaserPointerManager().setIncludeEntities(uid, includeEntities); } Q_INVOKABLE void setIgnoreOverlays(QUuid uid, const QScriptValue& ignoreOverlays) { qApp->getLaserPointerManager().setIgnoreOverlays(uid, ignoreOverlays); } diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index e108145d55..3b973358e9 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -102,6 +102,9 @@ public: const bool& isEnabled() { return _enabled; } const RayPickResult& getPrevRayPickResult() { return _prevResult; } + void setPrecisionPicking(bool precisionPicking) { _precisionPicking = precisionPicking; } + const bool& doesPrecisionPicking() { return _precisionPicking; } + void setRayPickResult(const RayPickResult& rayPickResult) { _prevResult = rayPickResult; } const QVector& getIgnoreEntites() { return _ignoreEntities; } @@ -123,6 +126,7 @@ private: bool _enabled; RayPickResult _prevResult; + bool _precisionPicking { true }; QVector _ignoreEntities; QVector _includeEntities; QVector _ignoreOverlays; diff --git a/interface/src/raypick/RayPickManager.cpp b/interface/src/raypick/RayPickManager.cpp index 8b639d4a81..971b08c82e 100644 --- a/interface/src/raypick/RayPickManager.cpp +++ b/interface/src/raypick/RayPickManager.cpp @@ -67,7 +67,8 @@ void RayPickManager::update() { bool noncollidable = rayPick->getFilter().doesPickNonCollidable(); RayPickFilter::Flags entityMask = rayPick->getFilter().getEntityFlags(); if (!checkAndCompareCachedResults(rayKey, results, res, entityMask)) { - entityRes = DependencyManager::get()->findRayIntersectionVector(ray, true, rayPick->getIncludeEntites(), rayPick->getIgnoreEntites(), !invisible, !noncollidable); + entityRes = DependencyManager::get()->findRayIntersectionVector(ray, rayPick->doesPrecisionPicking(), + rayPick->getIncludeEntites(), rayPick->getIgnoreEntites(), !invisible, !noncollidable); fromCache = false; } @@ -84,7 +85,8 @@ void RayPickManager::update() { bool noncollidable = rayPick->getFilter().doesPickNonCollidable(); RayPickFilter::Flags overlayMask = rayPick->getFilter().getOverlayFlags(); if (!checkAndCompareCachedResults(rayKey, results, res, overlayMask)) { - overlayRes = qApp->getOverlays().findRayIntersectionVector(ray, true, rayPick->getIncludeOverlays(), rayPick->getIgnoreOverlays(), !invisible, !noncollidable); + overlayRes = qApp->getOverlays().findRayIntersectionVector(ray, rayPick->doesPrecisionPicking(), + rayPick->getIncludeOverlays(), rayPick->getIgnoreOverlays(), !invisible, !noncollidable); fromCache = false; } @@ -204,6 +206,14 @@ const RayPickResult RayPickManager::getPrevRayPickResult(const QUuid uid) { return RayPickResult(); } +void RayPickManager::setPrecisionPicking(QUuid uid, const bool precisionPicking) { + QReadLocker containsLock(&_containsLock); + if (_rayPicks.contains(uid)) { + QWriteLocker lock(_rayPickLocks[uid].get()); + _rayPicks[uid]->setPrecisionPicking(precisionPicking); + } +} + void RayPickManager::setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities) { QReadLocker containsLock(&_containsLock); if (_rayPicks.contains(uid)) { diff --git a/interface/src/raypick/RayPickManager.h b/interface/src/raypick/RayPickManager.h index 8ef2ceebe0..f2b1ff4ae4 100644 --- a/interface/src/raypick/RayPickManager.h +++ b/interface/src/raypick/RayPickManager.h @@ -38,6 +38,7 @@ public: void disableRayPick(const QUuid uid); const RayPickResult getPrevRayPickResult(const QUuid uid); + void setPrecisionPicking(QUuid uid, const bool precisionPicking); void setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities); void setIncludeEntities(QUuid uid, const QScriptValue& includeEntities); void setIgnoreOverlays(QUuid uid, const QScriptValue& ignoreOverlays); diff --git a/interface/src/raypick/RayPickScriptingInterface.cpp b/interface/src/raypick/RayPickScriptingInterface.cpp index aa1613d696..015f8fd7d1 100644 --- a/interface/src/raypick/RayPickScriptingInterface.cpp +++ b/interface/src/raypick/RayPickScriptingInterface.cpp @@ -82,6 +82,10 @@ RayPickResult RayPickScriptingInterface::getPrevRayPickResult(QUuid uid) { return qApp->getRayPickManager().getPrevRayPickResult(uid); } +void RayPickScriptingInterface::setPrecisionPicking(QUuid uid, const bool precisionPicking) { + qApp->getRayPickManager().setPrecisionPicking(uid, precisionPicking); +} + void RayPickScriptingInterface::setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities) { qApp->getRayPickManager().setIgnoreEntities(uid, ignoreEntities); } diff --git a/interface/src/raypick/RayPickScriptingInterface.h b/interface/src/raypick/RayPickScriptingInterface.h index e576b5d076..f7ed2e6fa6 100644 --- a/interface/src/raypick/RayPickScriptingInterface.h +++ b/interface/src/raypick/RayPickScriptingInterface.h @@ -43,6 +43,7 @@ public slots: Q_INVOKABLE void removeRayPick(QUuid uid); Q_INVOKABLE RayPickResult getPrevRayPickResult(QUuid uid); + Q_INVOKABLE void setPrecisionPicking(QUuid uid, const bool precisionPicking); Q_INVOKABLE void setIgnoreEntities(QUuid uid, const QScriptValue& ignoreEntities); Q_INVOKABLE void setIncludeEntities(QUuid uid, const QScriptValue& includeEntities); Q_INVOKABLE void setIgnoreOverlays(QUuid uid, const QScriptValue& ignoreOverlays); @@ -50,7 +51,6 @@ public slots: Q_INVOKABLE void setIgnoreAvatars(QUuid uid, const QScriptValue& ignoreAvatars); Q_INVOKABLE void setIncludeAvatars(QUuid uid, const QScriptValue& includeAvatars); -private: unsigned int PICK_NOTHING() { return RayPickFilter::getBitMask(RayPickFilter::FlagBit::PICK_NOTHING); } unsigned int PICK_ENTITIES() { return RayPickFilter::getBitMask(RayPickFilter::FlagBit::PICK_ENTITIES); } unsigned int PICK_OVERLAYS() { return RayPickFilter::getBitMask(RayPickFilter::FlagBit::PICK_OVERLAYS); } diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index a8eca41077..a2d2d34837 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -53,7 +53,6 @@ EntityTreeRenderer::EntityTreeRenderer(bool wantScripts, AbstractViewStateInterf _viewState(viewState), _scriptingServices(scriptingServices), _displayModelBounds(false), - _dontDoPrecisionPicking(false), _layeredZones(this) { REGISTER_ENTITY_TYPE_WITH_FACTORY(Model, RenderableModelEntityItem::factory) @@ -428,28 +427,6 @@ void EntityTreeRenderer::deleteReleasedModels() { } } -RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType, - bool precisionPicking, const QVector& entityIdsToInclude, - const QVector& entityIdsToDiscard, bool visibleOnly, bool collidableOnly) { - RayToEntityIntersectionResult result; - if (_tree) { - EntityTreePointer entityTree = std::static_pointer_cast(_tree); - - OctreeElementPointer element; - EntityItemPointer intersectedEntity = NULL; - result.intersects = entityTree->findRayIntersection(ray.origin, ray.direction, - entityIdsToInclude, entityIdsToDiscard, visibleOnly, collidableOnly, precisionPicking, - element, result.distance, result.face, result.surfaceNormal, - (void**)&intersectedEntity, lockType, &result.accurate); - if (result.intersects && intersectedEntity) { - result.entityID = intersectedEntity->getEntityItemID(); - result.intersection = ray.origin + (ray.direction * result.distance); - result.entity = intersectedEntity; - } - } - return result; -} - void EntityTreeRenderer::connectSignalsToSlots(EntityScriptingInterface* entityScriptingInterface) { connect(this, &EntityTreeRenderer::mousePressOnEntity, entityScriptingInterface, &EntityScriptingInterface::mousePressOnEntity); @@ -530,11 +507,10 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) { if (!_tree || _shuttingDown) { return; } + PerformanceTimer perfTimer("EntityTreeRenderer::mousePressEvent"); PickRay ray = _viewState->computePickRay(event->x(), event->y()); - - bool precisionPicking = !_dontDoPrecisionPicking; - RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking); + RayToEntityIntersectionResult rayPickResult = _getPrevRayPickResultOperator(_mouseRayPickID); if (rayPickResult.intersects) { //qCDebug(entitiesrenderer) << "mousePressEvent over entity:" << rayPickResult.entityID; @@ -579,11 +555,10 @@ void EntityTreeRenderer::mouseDoublePressEvent(QMouseEvent* event) { if (!_tree || _shuttingDown) { return; } + PerformanceTimer perfTimer("EntityTreeRenderer::mouseDoublePressEvent"); PickRay ray = _viewState->computePickRay(event->x(), event->y()); - - bool precisionPicking = !_dontDoPrecisionPicking; - RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking); + RayToEntityIntersectionResult rayPickResult = _getPrevRayPickResultOperator(_mouseRayPickID); if (rayPickResult.intersects) { //qCDebug(entitiesrenderer) << "mouseDoublePressEvent over entity:" << rayPickResult.entityID; @@ -622,8 +597,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) { PerformanceTimer perfTimer("EntityTreeRenderer::mouseReleaseEvent"); PickRay ray = _viewState->computePickRay(event->x(), event->y()); - bool precisionPicking = !_dontDoPrecisionPicking; - RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking); + RayToEntityIntersectionResult rayPickResult = _getPrevRayPickResultOperator(_mouseRayPickID); if (rayPickResult.intersects) { //qCDebug(entitiesrenderer) << "mouseReleaseEvent over entity:" << rayPickResult.entityID; @@ -671,14 +645,11 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { if (!_tree || _shuttingDown) { return; } + PerformanceTimer perfTimer("EntityTreeRenderer::mouseMoveEvent"); - PickRay ray = _viewState->computePickRay(event->x(), event->y()); - - bool precisionPicking = false; // for mouse moves we do not do precision picking - RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::TryLock, precisionPicking); + RayToEntityIntersectionResult rayPickResult = _getPrevRayPickResultOperator(_mouseRayPickID); if (rayPickResult.intersects) { - glm::vec2 pos2D = projectOntoEntityXYPlane(rayPickResult.entity, ray, rayPickResult); PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.h b/libraries/entities-renderer/src/EntityTreeRenderer.h index f4909a2036..b70252d68c 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.h +++ b/libraries/entities-renderer/src/EntityTreeRenderer.h @@ -59,6 +59,10 @@ public: float getEntityLoadingPriority(const EntityItem& item) const { return _calculateEntityLoadingPriorityFunc(item); } void setEntityLoadingPriorityFunction(CalculateEntityLoadingPriority fn) { this->_calculateEntityLoadingPriorityFunc = fn; } + void setMouseRayPickID(QUuid rayPickID) { _mouseRayPickID = rayPickID; } + void setMouseRayPickResultOperator(std::function getPrevRayPickResultOperator) { _getPrevRayPickResultOperator = getPrevRayPickResultOperator; } + void setSetPrecisionPickingOperator(std::function setPrecisionPickingOperator) { _setPrecisionPickingOperator = setPrecisionPickingOperator; } + void shutdown(); void update(); @@ -130,7 +134,7 @@ public slots: // optional slots that can be wired to menu items void setDisplayModelBounds(bool value) { _displayModelBounds = value; } - void setDontDoPrecisionPicking(bool value) { _dontDoPrecisionPicking = value; } + void setPrecisionPicking(bool value) { _setPrecisionPickingOperator(_mouseRayPickID, value); } protected: virtual OctreePointer createTree() override { @@ -150,10 +154,6 @@ private: void checkAndCallPreload(const EntityItemID& entityID, bool reload = false, bool unloadFirst = false); QList _releasedModels; - RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType, - bool precisionPicking, const QVector& entityIdsToInclude = QVector(), - const QVector& entityIdsToDiscard = QVector(), bool visibleOnly=false, - bool collidableOnly = false); EntityItemID _currentHoverOverEntityID; EntityItemID _currentClickingOnEntityID; @@ -176,12 +176,15 @@ private: AbstractViewStateInterface* _viewState; AbstractScriptingServicesInterface* _scriptingServices; bool _displayModelBounds; - bool _dontDoPrecisionPicking; bool _shuttingDown { false }; QMultiMap _waitingOnPreload; + QUuid _mouseRayPickID; + std::function _getPrevRayPickResultOperator; + std::function _setPrecisionPickingOperator; + class LayeredZone { public: LayeredZone(std::shared_ptr zone, QUuid id, float volume) : zone(zone), id(id), volume(volume) {} From b8a7fce2011adcdff1077f4b66614fa4e6925aff Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 22 Aug 2017 11:54:55 -0700 Subject: [PATCH 2/4] boop --- interface/src/raypick/RayPick.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 3b973358e9..17969fd9a6 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -98,12 +98,12 @@ public: void disable() { _enabled = false; } const RayPickFilter& getFilter() { return _filter; } - const float& getMaxDistance() { return _maxDistance; } - const bool& isEnabled() { return _enabled; } + float getMaxDistance() { return _maxDistance; } + bool isEnabled() { return _enabled; } const RayPickResult& getPrevRayPickResult() { return _prevResult; } void setPrecisionPicking(bool precisionPicking) { _precisionPicking = precisionPicking; } - const bool& doesPrecisionPicking() { return _precisionPicking; } + bool doesPrecisionPicking() { return _precisionPicking; } void setRayPickResult(const RayPickResult& rayPickResult) { _prevResult = rayPickResult; } From d7b3686364b0995d690cb67c72e74c1b88947b38 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Tue, 22 Aug 2017 17:37:51 -0700 Subject: [PATCH 3/4] include noncollidable entities --- interface/src/Application.cpp | 4 +++- interface/src/raypick/RayPick.h | 6 +++--- interface/src/raypick/RayPickManager.cpp | 12 ++++++------ scripts/system/controllers/handControllerGrab.js | 4 ++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 8d7892c4cc..d3b547a54c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1736,7 +1736,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(&_myCamera, &Camera::modeUpdated, this, &Application::cameraModeChanged); // Setup the mouse ray pick and related operators - DependencyManager::get()->setMouseRayPickID(_rayPickManager.createRayPick(RayPickFilter(RayPickFilter::PICK_ENTITIES), 0.0f, true)); + DependencyManager::get()->setMouseRayPickID(_rayPickManager.createRayPick( + RayPickFilter(DependencyManager::get()->PICK_ENTITIES() | DependencyManager::get()->PICK_INCLUDE_NONCOLLIDABLE()), + 0.0f, true)); DependencyManager::get()->setMouseRayPickResultOperator([&](QUuid rayPickID) { RayToEntityIntersectionResult entityResult; RayPickResult result = _rayPickManager.getPrevRayPickResult(rayPickID); diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 17969fd9a6..188779bb83 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -47,6 +47,8 @@ public: bool operator== (const RayPickFilter& rhs) const { return _flags == rhs._flags; } bool operator!= (const RayPickFilter& rhs) const { return _flags != rhs._flags; } + void setFlag(FlagBit flag, bool value) { _flags[flag] = value; } + bool doesPickNothing() const { return _flags[PICK_NOTHING]; } bool doesPickEntities() const { return _flags[PICK_ENTITIES]; } bool doesPickOverlays() const { return _flags[PICK_OVERLAYS]; } @@ -102,8 +104,7 @@ public: bool isEnabled() { return _enabled; } const RayPickResult& getPrevRayPickResult() { return _prevResult; } - void setPrecisionPicking(bool precisionPicking) { _precisionPicking = precisionPicking; } - bool doesPrecisionPicking() { return _precisionPicking; } + void setPrecisionPicking(bool precisionPicking) { _filter.setFlag(RayPickFilter::PICK_COURSE, !precisionPicking); } void setRayPickResult(const RayPickResult& rayPickResult) { _prevResult = rayPickResult; } @@ -126,7 +127,6 @@ private: bool _enabled; RayPickResult _prevResult; - bool _precisionPicking { true }; QVector _ignoreEntities; QVector _includeEntities; QVector _ignoreOverlays; diff --git a/interface/src/raypick/RayPickManager.cpp b/interface/src/raypick/RayPickManager.cpp index 971b08c82e..1ec8efc331 100644 --- a/interface/src/raypick/RayPickManager.cpp +++ b/interface/src/raypick/RayPickManager.cpp @@ -64,11 +64,11 @@ void RayPickManager::update() { RayToEntityIntersectionResult entityRes; bool fromCache = true; bool invisible = rayPick->getFilter().doesPickInvisible(); - bool noncollidable = rayPick->getFilter().doesPickNonCollidable(); + bool nonCollidable = rayPick->getFilter().doesPickNonCollidable(); RayPickFilter::Flags entityMask = rayPick->getFilter().getEntityFlags(); if (!checkAndCompareCachedResults(rayKey, results, res, entityMask)) { - entityRes = DependencyManager::get()->findRayIntersectionVector(ray, rayPick->doesPrecisionPicking(), - rayPick->getIncludeEntites(), rayPick->getIgnoreEntites(), !invisible, !noncollidable); + entityRes = DependencyManager::get()->findRayIntersectionVector(ray, !rayPick->getFilter().doesPickCourse(), + rayPick->getIncludeEntites(), rayPick->getIgnoreEntites(), !invisible, !nonCollidable); fromCache = false; } @@ -82,11 +82,11 @@ void RayPickManager::update() { RayToOverlayIntersectionResult overlayRes; bool fromCache = true; bool invisible = rayPick->getFilter().doesPickInvisible(); - bool noncollidable = rayPick->getFilter().doesPickNonCollidable(); + bool nonCollidable = rayPick->getFilter().doesPickNonCollidable(); RayPickFilter::Flags overlayMask = rayPick->getFilter().getOverlayFlags(); if (!checkAndCompareCachedResults(rayKey, results, res, overlayMask)) { - overlayRes = qApp->getOverlays().findRayIntersectionVector(ray, rayPick->doesPrecisionPicking(), - rayPick->getIncludeOverlays(), rayPick->getIgnoreOverlays(), !invisible, !noncollidable); + overlayRes = qApp->getOverlays().findRayIntersectionVector(ray, !rayPick->getFilter().doesPickCourse(), + rayPick->getIncludeOverlays(), rayPick->getIgnoreOverlays(), !invisible, !nonCollidable); fromCache = false; } diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 9318873f64..f6eec7ab76 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -1182,7 +1182,7 @@ function MyController(hand) { this.fullEnd = fullEnd; this.laserPointer = LaserPointers.createLaserPointer({ joint: (hand == RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_INCLUDE_NONCOLLIDABLE, maxDistance: PICK_MAX_DISTANCE, posOffset: getGrabPointSphereOffset(this.handToController()), renderStates: renderStates, @@ -1191,7 +1191,7 @@ function MyController(hand) { }); this.headLaserPointer = LaserPointers.createLaserPointer({ joint: "Avatar", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS, + filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_INCLUDE_NONCOLLIDABLE, maxDistance: PICK_MAX_DISTANCE, renderStates: headRenderStates, faceAvatar: true, From 206862a90f813d343907c881501e0dd7fb026ace Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Wed, 23 Aug 2017 12:20:30 -0700 Subject: [PATCH 4/4] fix flag bits --- interface/src/raypick/RayPick.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/interface/src/raypick/RayPick.h b/interface/src/raypick/RayPick.h index 188779bb83..04045b2116 100644 --- a/interface/src/raypick/RayPick.h +++ b/interface/src/raypick/RayPick.h @@ -41,7 +41,7 @@ public: // The key is the Flags Flags _flags; - RayPickFilter() : _flags(PICK_NOTHING) {} + RayPickFilter() : _flags(getBitMask(PICK_NOTHING)) {} RayPickFilter(const Flags& flags) : _flags(flags) {} bool operator== (const RayPickFilter& rhs) const { return _flags == rhs._flags; } @@ -63,27 +63,27 @@ public: // Helpers for RayPickManager Flags getEntityFlags() const { - Flags toReturn(PICK_ENTITIES); + unsigned int toReturn = getBitMask(PICK_ENTITIES); if (doesPickInvisible()) { - toReturn |= Flags(PICK_INCLUDE_INVISIBLE); + toReturn |= getBitMask(PICK_INCLUDE_INVISIBLE); } if (doesPickNonCollidable()) { - toReturn |= Flags(PICK_INCLUDE_NONCOLLIDABLE); + toReturn |= getBitMask(PICK_INCLUDE_NONCOLLIDABLE); } - return toReturn; + return Flags(toReturn); } Flags getOverlayFlags() const { - Flags toReturn(PICK_OVERLAYS); + unsigned int toReturn = getBitMask(PICK_OVERLAYS); if (doesPickInvisible()) { - toReturn |= Flags(PICK_INCLUDE_INVISIBLE); + toReturn |= getBitMask(PICK_INCLUDE_INVISIBLE); } if (doesPickNonCollidable()) { - toReturn |= Flags(PICK_INCLUDE_NONCOLLIDABLE); + toReturn |= getBitMask(PICK_INCLUDE_NONCOLLIDABLE); } - return toReturn; + return Flags(toReturn); } - Flags getAvatarFlags() const { return Flags(PICK_AVATARS); } - Flags getHUDFlags() const { return Flags(PICK_HUD); } + Flags getAvatarFlags() const { return Flags(getBitMask(PICK_AVATARS)); } + Flags getHUDFlags() const { return Flags(getBitMask(PICK_HUD)); } static unsigned int getBitMask(FlagBit bit) { return 1 << bit; }