mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-20 20:29:30 +02:00
Do not assume picks with doesIntersect()==false have no results to compare. Fixes CollisionPickResult 'loaded' value always evaluating to false when not colliding
This commit is contained in:
parent
6e160ad22f
commit
cce62f4d92
3 changed files with 7 additions and 5 deletions
|
@ -53,6 +53,7 @@ public:
|
||||||
QVariantMap toVariantMap() const override;
|
QVariantMap toVariantMap() const override;
|
||||||
|
|
||||||
bool doesIntersect() const override { return intersects; }
|
bool doesIntersect() const override { return intersects; }
|
||||||
|
bool needsToCompareResults() const override { return true; }
|
||||||
bool checkOrFilterAgainstMaxDistance(float maxDistance) override { return true; }
|
bool checkOrFilterAgainstMaxDistance(float maxDistance) override { return true; }
|
||||||
|
|
||||||
PickResultPointer compareAndProcessNewResult(const PickResultPointer& newRes) override;
|
PickResultPointer compareAndProcessNewResult(const PickResultPointer& newRes) override;
|
||||||
|
|
|
@ -115,6 +115,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool doesIntersect() const = 0;
|
virtual bool doesIntersect() const = 0;
|
||||||
|
virtual bool needsToCompareResults() const { return doesIntersect(); }
|
||||||
|
|
||||||
// for example: if we want the closest result, compare based on distance
|
// for example: if we want the closest result, compare based on distance
|
||||||
// if we want all results, combine them
|
// if we want all results, combine them
|
||||||
|
|
|
@ -57,8 +57,8 @@ bool PickCacheOptimizer<T>::checkAndCompareCachedResults(T& pick, PickCache& cac
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void PickCacheOptimizer<T>::cacheResult(const bool intersects, const PickResultPointer& resTemp, const PickCacheKey& key, PickResultPointer& res, T& mathPick, PickCache& cache, const std::shared_ptr<Pick<T>> pick) {
|
void PickCacheOptimizer<T>::cacheResult(const bool needToCompareResults, const PickResultPointer& resTemp, const PickCacheKey& key, PickResultPointer& res, T& mathPick, PickCache& cache, const std::shared_ptr<Pick<T>> pick) {
|
||||||
if (intersects) {
|
if (needToCompareResults) {
|
||||||
cache[mathPick][key] = resTemp;
|
cache[mathPick][key] = resTemp;
|
||||||
res = res->compareAndProcessNewResult(resTemp);
|
res = res->compareAndProcessNewResult(resTemp);
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,7 +92,7 @@ void PickCacheOptimizer<T>::update(std::unordered_map<uint32_t, std::shared_ptr<
|
||||||
if (!checkAndCompareCachedResults(mathematicalPick, results, res, entityKey)) {
|
if (!checkAndCompareCachedResults(mathematicalPick, results, res, entityKey)) {
|
||||||
PickResultPointer entityRes = pick->getEntityIntersection(mathematicalPick);
|
PickResultPointer entityRes = pick->getEntityIntersection(mathematicalPick);
|
||||||
if (entityRes) {
|
if (entityRes) {
|
||||||
cacheResult(entityRes->doesIntersect(), entityRes, entityKey, res, mathematicalPick, results, pick);
|
cacheResult(entityRes->needsToCompareResults(), entityRes, entityKey, res, mathematicalPick, results, pick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ void PickCacheOptimizer<T>::update(std::unordered_map<uint32_t, std::shared_ptr<
|
||||||
if (!checkAndCompareCachedResults(mathematicalPick, results, res, overlayKey)) {
|
if (!checkAndCompareCachedResults(mathematicalPick, results, res, overlayKey)) {
|
||||||
PickResultPointer overlayRes = pick->getOverlayIntersection(mathematicalPick);
|
PickResultPointer overlayRes = pick->getOverlayIntersection(mathematicalPick);
|
||||||
if (overlayRes) {
|
if (overlayRes) {
|
||||||
cacheResult(overlayRes->doesIntersect(), overlayRes, overlayKey, res, mathematicalPick, results, pick);
|
cacheResult(overlayRes->needsToCompareResults(), overlayRes, overlayKey, res, mathematicalPick, results, pick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ void PickCacheOptimizer<T>::update(std::unordered_map<uint32_t, std::shared_ptr<
|
||||||
if (!checkAndCompareCachedResults(mathematicalPick, results, res, avatarKey)) {
|
if (!checkAndCompareCachedResults(mathematicalPick, results, res, avatarKey)) {
|
||||||
PickResultPointer avatarRes = pick->getAvatarIntersection(mathematicalPick);
|
PickResultPointer avatarRes = pick->getAvatarIntersection(mathematicalPick);
|
||||||
if (avatarRes) {
|
if (avatarRes) {
|
||||||
cacheResult(avatarRes->doesIntersect(), avatarRes, avatarKey, res, mathematicalPick, results, pick);
|
cacheResult(avatarRes->needsToCompareResults(), avatarRes, avatarKey, res, mathematicalPick, results, pick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue