if something is a child of the local avatar, never let it collide with MY_AVATAR

This commit is contained in:
Seth Alves 2017-01-09 16:40:28 -08:00
parent 01ff3f14b6
commit 45a26d599f
3 changed files with 7 additions and 4 deletions

View file

@ -1780,7 +1780,6 @@ void EntityItem::updateCreated(uint64_t value) {
}
void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask) const {
// TODO: detect attachment status and adopt group of wearer
if (_collisionless) {
group = BULLET_COLLISION_GROUP_COLLISIONLESS;
mask = 0;
@ -1794,10 +1793,14 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
}
uint8_t userMask = getCollisionMask();
if (hasAncestorOfType(NestableType::Avatar)) {
userMask &= ~USER_COLLISION_GROUP_MY_AVATAR;
}
if ((bool)(userMask & USER_COLLISION_GROUP_MY_AVATAR) !=
(bool)(userMask & USER_COLLISION_GROUP_OTHER_AVATAR)) {
// asymmetric avatar collision mask bits
if (!getSimulatorID().isNull() && (!getSimulatorID().isNull()) && getSimulatorID() != Physics::getSessionUUID()) {
if (!getSimulatorID().isNull() && getSimulatorID() != Physics::getSessionUUID()) {
// someone else owns the simulation, so we toggle the avatar bits (swap interpretation)
userMask ^= USER_COLLISION_MASK_AVATARS | ~userMask;
}

View file

@ -1015,7 +1015,7 @@ AACube SpatiallyNestable::getQueryAACube() const {
return result;
}
bool SpatiallyNestable::hasAncestorOfType(NestableType nestableType) {
bool SpatiallyNestable::hasAncestorOfType(NestableType nestableType) const {
bool success;
SpatiallyNestablePointer parent = getParentPointer(success);
if (!success || !parent) {

View file

@ -163,7 +163,7 @@ public:
bool isParentIDValid() const { bool success = false; getParentPointer(success); return success; }
virtual SpatialParentTree* getParentTree() const { return nullptr; }
bool hasAncestorOfType(NestableType nestableType);
bool hasAncestorOfType(NestableType nestableType) const;
SpatiallyNestablePointer getParentPointer(bool& success) const;
static SpatiallyNestablePointer findByID(QUuid id, bool& success);