mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 06:48:09 +02:00
keep grabbed and worn entities from spamming entity-server
This commit is contained in:
parent
2ab606a98b
commit
f75e59c0a6
5 changed files with 98 additions and 75 deletions
|
@ -2016,9 +2016,7 @@ void EntityItem::computeCollisionGroupAndFinalMask(int16_t& group, int16_t& mask
|
||||||
// if this entity is a descendant of MyAvatar, don't collide with MyAvatar. This avoids the
|
// if this entity is a descendant of MyAvatar, don't collide with MyAvatar. This avoids the
|
||||||
// "bootstrapping" problem where you can shoot yourself across the room by grabbing something
|
// "bootstrapping" problem where you can shoot yourself across the room by grabbing something
|
||||||
// and holding it against your own avatar.
|
// and holding it against your own avatar.
|
||||||
QUuid ancestorID = findAncestorOfType(NestableType::Avatar);
|
if (isChildOfMyAvatar()) {
|
||||||
if (!ancestorID.isNull() &&
|
|
||||||
(ancestorID == Physics::getSessionUUID() || ancestorID == AVATAR_SELF_ID)) {
|
|
||||||
iAmHoldingThis = true;
|
iAmHoldingThis = true;
|
||||||
}
|
}
|
||||||
// also, don't bootstrap our own avatar with a hold action
|
// also, don't bootstrap our own avatar with a hold action
|
||||||
|
@ -2425,6 +2423,7 @@ QVariantMap EntityItem::getActionArguments(const QUuid& actionID) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityItem::shouldSuppressLocationEdits() const {
|
bool EntityItem::shouldSuppressLocationEdits() const {
|
||||||
|
// if any of the actions indicate they'd like suppression, suppress
|
||||||
QHash<QUuid, EntityDynamicPointer>::const_iterator i = _objectActions.begin();
|
QHash<QUuid, EntityDynamicPointer>::const_iterator i = _objectActions.begin();
|
||||||
while (i != _objectActions.end()) {
|
while (i != _objectActions.end()) {
|
||||||
if (i.value()->shouldSuppressLocationEdits()) {
|
if (i.value()->shouldSuppressLocationEdits()) {
|
||||||
|
@ -2433,6 +2432,11 @@ bool EntityItem::shouldSuppressLocationEdits() const {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if any of the ancestors are MyAvatar, suppress
|
||||||
|
if (isChildOfMyAvatar()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2837,6 +2841,11 @@ void EntityItem::setVisible(bool value) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EntityItem::isChildOfMyAvatar() const {
|
||||||
|
QUuid ancestorID = findAncestorOfType(NestableType::Avatar);
|
||||||
|
return !ancestorID.isNull() && (ancestorID == Physics::getSessionUUID() || ancestorID == AVATAR_SELF_ID);
|
||||||
|
}
|
||||||
|
|
||||||
bool EntityItem::getCollisionless() const {
|
bool EntityItem::getCollisionless() const {
|
||||||
bool result;
|
bool result;
|
||||||
withReadLock([&] {
|
withReadLock([&] {
|
||||||
|
|
|
@ -273,6 +273,8 @@ public:
|
||||||
inline bool isVisible() const { return getVisible(); }
|
inline bool isVisible() const { return getVisible(); }
|
||||||
inline bool isInvisible() const { return !getVisible(); }
|
inline bool isInvisible() const { return !getVisible(); }
|
||||||
|
|
||||||
|
bool isChildOfMyAvatar() const;
|
||||||
|
|
||||||
bool getCollisionless() const;
|
bool getCollisionless() const;
|
||||||
void setCollisionless(bool value);
|
void setCollisionless(bool value);
|
||||||
|
|
||||||
|
|
|
@ -491,6 +491,10 @@ bool EntityMotionState::shouldSendUpdate(uint32_t simulationStep) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_entity->shouldSuppressLocationEdits()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isLocallyOwned()) {
|
if (!isLocallyOwned()) {
|
||||||
// we don't own the simulation
|
// we don't own the simulation
|
||||||
|
|
||||||
|
@ -577,7 +581,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.transformChanged()) {
|
if (properties.transformChanged()) {
|
||||||
if (_entity->checkAndMaybeUpdateQueryAACube()) {
|
if (_entity->checkAndMaybeUpdateQueryAACube(true)) {
|
||||||
// due to parenting, the server may not know where something is in world-space, so include the bounding cube.
|
// due to parenting, the server may not know where something is in world-space, so include the bounding cube.
|
||||||
properties.setQueryAACube(_entity->getQueryAACube());
|
properties.setQueryAACube(_entity->getQueryAACube());
|
||||||
}
|
}
|
||||||
|
|
|
@ -963,19 +963,21 @@ AACube SpatiallyNestable::getMaximumAACube(bool& success) const {
|
||||||
|
|
||||||
const float PARENTED_EXPANSION_FACTOR = 3.0f;
|
const float PARENTED_EXPANSION_FACTOR = 3.0f;
|
||||||
|
|
||||||
bool SpatiallyNestable::checkAndMaybeUpdateQueryAACube() {
|
bool SpatiallyNestable::checkAndMaybeUpdateQueryAACube(bool forcePuffed) {
|
||||||
|
bool updated = false;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
AACube maxAACube = getMaximumAACube(success);
|
AACube maxAACube = getMaximumAACube(success);
|
||||||
if (success) {
|
if (success) {
|
||||||
// maybe update _queryAACube
|
// maybe update _queryAACube
|
||||||
if (!_queryAACubeSet || (_parentID.isNull() && _children.size() == 0) || !_queryAACube.contains(maxAACube)) {
|
if (!_queryAACubeSet || (_parentID.isNull() && _children.size() == 0) || !_queryAACube.contains(maxAACube)) {
|
||||||
if (_parentJointIndex != INVALID_JOINT_INDEX || _children.size() > 0 ) {
|
if (forcePuffed || _parentJointIndex != INVALID_JOINT_INDEX || _children.size() > 0 ) {
|
||||||
// make an expanded AACube centered on the object
|
// make an expanded AACube centered on the object
|
||||||
float scale = PARENTED_EXPANSION_FACTOR * maxAACube.getScale();
|
float scale = PARENTED_EXPANSION_FACTOR * maxAACube.getScale();
|
||||||
_queryAACube = AACube(maxAACube.calcCenter() - glm::vec3(0.5f * scale), scale);
|
_queryAACube = AACube(maxAACube.calcCenter() - glm::vec3(0.5f * scale), scale);
|
||||||
} else {
|
} else {
|
||||||
_queryAACube = maxAACube;
|
_queryAACube = maxAACube;
|
||||||
}
|
}
|
||||||
|
updated = true;
|
||||||
|
|
||||||
forEachDescendant([&](const SpatiallyNestablePointer& descendant) {
|
forEachDescendant([&](const SpatiallyNestablePointer& descendant) {
|
||||||
bool childSuccess;
|
bool childSuccess;
|
||||||
|
@ -991,7 +993,7 @@ bool SpatiallyNestable::checkAndMaybeUpdateQueryAACube() {
|
||||||
_queryAACubeSet = true;
|
_queryAACubeSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpatiallyNestable::setQueryAACube(const AACube& queryAACube) {
|
void SpatiallyNestable::setQueryAACube(const AACube& queryAACube) {
|
||||||
|
@ -1008,6 +1010,12 @@ bool SpatiallyNestable::queryAACubeNeedsUpdate() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool success;
|
||||||
|
AACube maxAACube = getMaximumAACube(success);
|
||||||
|
if (success && !_queryAACube.contains(maxAACube)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// make sure children are still in their boxes, also.
|
// make sure children are still in their boxes, also.
|
||||||
bool childNeedsUpdate = false;
|
bool childNeedsUpdate = false;
|
||||||
forEachDescendantTest([&](const SpatiallyNestablePointer& descendant) {
|
forEachDescendantTest([&](const SpatiallyNestablePointer& descendant) {
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
virtual glm::vec3 getParentAngularVelocity(bool& success) const;
|
virtual glm::vec3 getParentAngularVelocity(bool& success) const;
|
||||||
|
|
||||||
virtual AACube getMaximumAACube(bool& success) const;
|
virtual AACube getMaximumAACube(bool& success) const;
|
||||||
bool checkAndMaybeUpdateQueryAACube();
|
bool checkAndMaybeUpdateQueryAACube(bool forcePuffed = false);
|
||||||
void updateQueryAACube();
|
void updateQueryAACube();
|
||||||
|
|
||||||
virtual void setQueryAACube(const AACube& queryAACube);
|
virtual void setQueryAACube(const AACube& queryAACube);
|
||||||
|
|
Loading…
Reference in a new issue