mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:24:07 +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;
|
||||
|
||||
bool doesIntersect() const override { return intersects; }
|
||||
bool needsToCompareResults() const override { return true; }
|
||||
bool checkOrFilterAgainstMaxDistance(float maxDistance) override { return true; }
|
||||
|
||||
PickResultPointer compareAndProcessNewResult(const PickResultPointer& newRes) override;
|
||||
|
|
|
@ -115,6 +115,7 @@ public:
|
|||
}
|
||||
|
||||
virtual bool doesIntersect() const = 0;
|
||||
virtual bool needsToCompareResults() const { return doesIntersect(); }
|
||||
|
||||
// for example: if we want the closest result, compare based on distance
|
||||
// if we want all results, combine them
|
||||
|
|
|
@ -57,8 +57,8 @@ bool PickCacheOptimizer<T>::checkAndCompareCachedResults(T& pick, PickCache& cac
|
|||
}
|
||||
|
||||
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) {
|
||||
if (intersects) {
|
||||
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 (needToCompareResults) {
|
||||
cache[mathPick][key] = resTemp;
|
||||
res = res->compareAndProcessNewResult(resTemp);
|
||||
} else {
|
||||
|
@ -92,7 +92,7 @@ void PickCacheOptimizer<T>::update(std::unordered_map<uint32_t, std::shared_ptr<
|
|||
if (!checkAndCompareCachedResults(mathematicalPick, results, res, entityKey)) {
|
||||
PickResultPointer entityRes = pick->getEntityIntersection(mathematicalPick);
|
||||
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)) {
|
||||
PickResultPointer overlayRes = pick->getOverlayIntersection(mathematicalPick);
|
||||
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)) {
|
||||
PickResultPointer avatarRes = pick->getAvatarIntersection(mathematicalPick);
|
||||
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