History

updates based on austin's comments

SamGondelman committed 9 years ago

Commit 640ad511 parent 05f48835 files · +26 −27Browse files

Unified · Split

5 files
  1. interface/src/Application.cpp +2 −2
  2. interface/src/raypick/Pick.h +6 −6
  3. interface/src/raypick/PickManager.h +3 −3
  4. interface/src/raypick/RayPickScriptingInterface.h +14 −14
  5. libraries/shared/src/RegisteredMetaTypes.h +1 −2
interface/src/Application.cpp+2−2
@@ -1819,12 +1819,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1818 unmodified lines
1819 1819
1820 // Setup the mouse ray pick and related operators1820 // Setup the mouse ray pick and related operators
1821 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_rayPickManager.createRayPick(1821 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickID(_rayPickManager.createRayPick(
1822 PickFilter(DependencyManager::get<RayPickScriptingInterface>()->PICK_ENTITIES() | DependencyManager::get<RayPickScriptingInterface>()->PICK_INCLUDE_NONCOLLIDABLE()),1822 PickFilter(RayPickScriptingInterface::PICK_ENTITIES() | RayPickScriptingInterface::PICK_INCLUDE_NONCOLLIDABLE()),
1823 0.0f, true));1823 0.0f, true));
1824 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {1824 DependencyManager::get<EntityTreeRenderer>()->setMouseRayPickResultOperator([&](QUuid rayPickID) {
1825 RayToEntityIntersectionResult entityResult;1825 RayToEntityIntersectionResult entityResult;
1826 RayPickResult result = _rayPickManager.getPrevPickResult(rayPickID);1826 RayPickResult result = _rayPickManager.getPrevPickResult(rayPickID);
1827 entityResult.intersects = result.type != DependencyManager::get<RayPickScriptingInterface>()->INTERSECTED_NONE();1827 entityResult.intersects = result.type != RayPickScriptingInterface::INTERSECTED_NONE();
1828 if (entityResult.intersects) {1828 if (entityResult.intersects) {
1829 entityResult.intersection = result.intersection;1829 entityResult.intersection = result.intersection;
1830 entityResult.distance = result.distance;1830 entityResult.distance = result.distance;
interface/src/raypick/Pick.h+6−6
@@ -133,9 +133,9 @@ public: · 132 unmodified lines
133 QVector<QUuid> getIgnoreItems() const;133 QVector<QUuid> getIgnoreItems() const;
134 QVector<QUuid> getIncludeItems() const;134 QVector<QUuid> getIncludeItems() const;
135 135
136 template <typename T> 136 template <typename S>
137 QVector<T> getIgnoreItemsAs() const {137 QVector<S> getIgnoreItemsAs() const {
138 QVector<T> result;138 QVector<S> result;
139 withReadLock([&] {139 withReadLock([&] {
140 for (const auto& uid : _ignoreItems) {140 for (const auto& uid : _ignoreItems) {
141 result.push_back(uid);141 result.push_back(uid);
@@ -144,9 +144,9 @@ public: · 2 unmodified lines
144 return result;144 return result;
145 }145 }
146 146
147 template <typename T>147 template <typename S>
148 QVector<T> getIncludeItemsAs() const {148 QVector<S> getIncludeItemsAs() const {
149 QVector<T> result;149 QVector<S> result;
150 withReadLock([&] {150 withReadLock([&] {
151 for (const auto& uid : _includeItems) {151 for (const auto& uid : _includeItems) {
152 result.push_back(uid);152 result.push_back(uid);
interface/src/raypick/PickManager.h+3−3
@@ -130,7 +130,7 @@ void PickManager<T>::update() { · 129 unmodified lines
130 PickCacheKey entityKey = { pick->getFilter().getEntityFlags(), pick->getIncludeItems(), pick->getIgnoreItems() };130 PickCacheKey entityKey = { pick->getFilter().getEntityFlags(), pick->getIncludeItems(), pick->getIgnoreItems() };
131 if (!checkAndCompareCachedResults(mathematicalPick, results, res, entityKey)) {131 if (!checkAndCompareCachedResults(mathematicalPick, results, res, entityKey)) {
132 entityRes = pick->getEntityIntersection(mathematicalPick, !pick->getFilter().doesPickCoarse(),132 entityRes = pick->getEntityIntersection(mathematicalPick, !pick->getFilter().doesPickCoarse(),
133 pick->getIncludeItemsAs<EntityItemID>(), pick->getIgnoreItemsAs<EntityItemID>(), !invisible, !nonCollidable);133 pick->(template getIncludeItemsAs<EntityItemID>()), (template pick->getIgnoreItemsAs<EntityItemID>()), !invisible, !nonCollidable);
134 fromCache = false;134 fromCache = false;
135 }135 }
136 136
@@ -148,7 +148,7 @@ void PickManager<T>::update() { · 11 unmodified lines
148 PickCacheKey overlayKey = { pick->getFilter().getOverlayFlags(), pick->getIncludeItems(), pick->getIgnoreItems() };148 PickCacheKey overlayKey = { pick->getFilter().getOverlayFlags(), pick->getIncludeItems(), pick->getIgnoreItems() };
149 if (!checkAndCompareCachedResults(mathematicalPick, results, res, overlayKey)) {149 if (!checkAndCompareCachedResults(mathematicalPick, results, res, overlayKey)) {
150 overlayRes = pick->getOverlayIntersection(mathematicalPick, !pick->getFilter().doesPickCoarse(),150 overlayRes = pick->getOverlayIntersection(mathematicalPick, !pick->getFilter().doesPickCoarse(),
151 pick->getIncludeItemsAs<OverlayID>(), pick->getIgnoreItemsAs<OverlayID>(), !invisible, !nonCollidable);151 pick->(template getIncludeItemsAs<OverlayID>()), pick->(template getIgnoreItemsAs<OverlayID>()), !invisible, !nonCollidable);
152 fromCache = false;152 fromCache = false;
153 }153 }
154 154
@@ -162,7 +162,7 @@ void PickManager<T>::update() { · 7 unmodified lines
162 PickCacheKey avatarKey = { pick->getFilter().getAvatarFlags(), pick->getIncludeItems(), pick->getIgnoreItems() };162 PickCacheKey avatarKey = { pick->getFilter().getAvatarFlags(), pick->getIncludeItems(), pick->getIgnoreItems() };
163 if (!checkAndCompareCachedResults(mathematicalPick, results, res, avatarKey)) {163 if (!checkAndCompareCachedResults(mathematicalPick, results, res, avatarKey)) {
164 RayToAvatarIntersectionResult avatarRes = pick->getAvatarIntersection(mathematicalPick,164 RayToAvatarIntersectionResult avatarRes = pick->getAvatarIntersection(mathematicalPick,
165 pick->getIncludeItemsAs<EntityItemID>(), pick->getIgnoreItemsAs<EntityItemID>());165 pick->(template getIncludeItemsAs<EntityItemID>()), pick->(template getIgnoreItemsAs<EntityItemID>()));
166 cacheResult(avatarRes.intersects, RayPickResult(IntersectionType::AVATAR, avatarRes.avatarID, avatarRes.distance, avatarRes.intersection, mathematicalPick), avatarKey, res, mathematicalPick, results);166 cacheResult(avatarRes.intersects, RayPickResult(IntersectionType::AVATAR, avatarRes.avatarID, avatarRes.distance, avatarRes.intersection, mathematicalPick), avatarKey, res, mathematicalPick, results);
167 }167 }
168 }168 }
interface/src/raypick/RayPickScriptingInterface.h+14−14
@@ -46,20 +46,20 @@ public slots: · 45 unmodified lines
46 Q_INVOKABLE void setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreEntities);46 Q_INVOKABLE void setIgnoreItems(const QUuid& uid, const QScriptValue& ignoreEntities);
47 Q_INVOKABLE void setIncludeItems(const QUuid& uid, const QScriptValue& includeEntities);47 Q_INVOKABLE void setIncludeItems(const QUuid& uid, const QScriptValue& includeEntities);
48 48
49 unsigned int PICK_NOTHING() { return 0; }49 static unsigned int PICK_NOTHING() { return 0; }
50 unsigned int PICK_ENTITIES() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ENTITIES); }50 static unsigned int PICK_ENTITIES() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ENTITIES); }
51 unsigned int PICK_OVERLAYS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_OVERLAYS); }51 static unsigned int PICK_OVERLAYS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_OVERLAYS); }
52 unsigned int PICK_AVATARS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_AVATARS); }52 static unsigned int PICK_AVATARS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_AVATARS); }
53 unsigned int PICK_HUD() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_HUD); }53 static unsigned int PICK_HUD() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_HUD); }
54 unsigned int PICK_COARSE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_COARSE); }54 static unsigned int PICK_COARSE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_COARSE); }
55 unsigned int PICK_INCLUDE_INVISIBLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_INVISIBLE); }55 static unsigned int PICK_INCLUDE_INVISIBLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_INVISIBLE); }
56 unsigned int PICK_INCLUDE_NONCOLLIDABLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_NONCOLLIDABLE); }56 static unsigned int PICK_INCLUDE_NONCOLLIDABLE() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_INCLUDE_NONCOLLIDABLE); }
57 unsigned int PICK_ALL_INTERSECTIONS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ALL_INTERSECTIONS); }57 static unsigned int PICK_ALL_INTERSECTIONS() { return PickFilter::getBitMask(PickFilter::FlagBit::PICK_ALL_INTERSECTIONS); }
58 unsigned int INTERSECTED_NONE() { return IntersectionType::NONE; }58 static unsigned int INTERSECTED_NONE() { return IntersectionType::NONE; }
59 unsigned int INTERSECTED_ENTITY() { return IntersectionType::ENTITY; }59 static unsigned int INTERSECTED_ENTITY() { return IntersectionType::ENTITY; }
60 unsigned int INTERSECTED_OVERLAY() { return IntersectionType::OVERLAY; }60 static unsigned int INTERSECTED_OVERLAY() { return IntersectionType::OVERLAY; }
61 unsigned int INTERSECTED_AVATAR() { return IntersectionType::AVATAR; }61 static unsigned int INTERSECTED_AVATAR() { return IntersectionType::AVATAR; }
62 unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; }62 static unsigned int INTERSECTED_HUD() { return IntersectionType::HUD; }
63};63};
64 64
65#endif // hifi_RayPickScriptingInterface_h65#endif // hifi_RayPickScriptingInterface_h
libraries/shared/src/RegisteredMetaTypes.h+1−2
@@ -133,8 +133,7 @@ public: · 132 unmodified lines
133 glm::vec3 direction;133 glm::vec3 direction;
134 134
135 operator bool() const {135 operator bool() const {
136 auto isNan = glm::isnan(origin) || glm::isnan(direction);136 return !(glm::any(glm::isnan(origin)) || glm::any(glm::isnan(direction)));
137 return !isNan.x && !isNan.y && !isNan.z;
138 }137 }
139 bool operator==(const PickRay& other) const {138 bool operator==(const PickRay& other) const {
140 return (origin == other.origin && direction == other.direction);139 return (origin == other.origin && direction == other.direction);