Merge pull request #15282 from kitely/fix-ray-local-entities

Case 21883: Fix safe landing code improperly finding local entities
This commit is contained in:
Sam Gateau 2019-04-10 12:28:07 -07:00 committed by GitHub
commit c33efdf9e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -3889,7 +3889,8 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
// See https://highfidelity.fogbugz.com/f/cases/5003/findRayIntersection-has-option-to-use-collidableOnly-but-doesn-t-actually-use-colliders
QVariantMap extraInfo;
EntityItemID entityID = entityTree->evalRayIntersection(startPointIn, directionIn, include, ignore,
PickFilter(PickFilter::getBitMask(PickFilter::FlagBit::COLLIDABLE) | PickFilter::getBitMask(PickFilter::FlagBit::PRECISE)),
PickFilter(PickFilter::getBitMask(PickFilter::FlagBit::COLLIDABLE) | PickFilter::getBitMask(PickFilter::FlagBit::PRECISE)
| PickFilter::getBitMask(PickFilter::FlagBit::DOMAIN_ENTITIES) | PickFilter::getBitMask(PickFilter::FlagBit::AVATAR_ENTITIES)), // exclude Local entities
element, distance, face, normalOut, extraInfo, lockType, accurateResult);
if (entityID.isNull()) {
return false;

View file

@ -148,9 +148,13 @@ bool EntityTreeElement::checkFilterSettings(const EntityItemPointer& entity, Pic
(!searchFilter.doesPickLocalEntities() && hostType == entity::HostType::LOCAL)) {
return false;
}
// We only check the collidable filters for non-local entities, because local entities are always collisionless
bool collidable = !entity->getCollisionless() && (entity->getShapeType() != SHAPE_TYPE_NONE);
// We only check the collidable filters for non-local entities, because local entities are always collisionless,
// but picks always include COLLIDABLE (see PickScriptingInterface::getPickFilter()), so if we were to respect
// the getCollisionless() property of Local entities then we would *never* intersect them in a pick.
// An unfortunate side effect of the following code is that Local entities are intersected even if the
// pick explicitly requested only COLLIDABLE entities (but, again, Local entities are always collisionless).
if (hostType != entity::HostType::LOCAL) {
bool collidable = !entity->getCollisionless() && (entity->getShapeType() != SHAPE_TYPE_NONE);
if ((collidable && !searchFilter.doesPickCollidable()) || (!collidable && !searchFilter.doesPickNonCollidable())) {
return false;
}