mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:07:07 +02:00
Merge pull request #6212 from howard-stearns/dont-use-other-avatar-sounds
Don't play other avatar's collision sounds.
This commit is contained in:
commit
4215ce5d25
4 changed files with 10 additions and 12 deletions
|
@ -286,10 +286,10 @@ void AvatarManager::handleOutgoingChanges(const VectorOfMotionStates& motionStat
|
||||||
|
|
||||||
void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents) {
|
void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents) {
|
||||||
for (Collision collision : collisionEvents) {
|
for (Collision collision : collisionEvents) {
|
||||||
// TODO: Current physics uses null idA or idB for non-entities. The plan is to handle MOTIONSTATE_TYPE_AVATAR,
|
// TODO: The plan is to handle MOTIONSTATE_TYPE_AVATAR, and then MOTIONSTATE_TYPE_MYAVATAR. As it is, other
|
||||||
// and then MOTIONSTATE_TYPE_MYAVATAR. As it is, this code only covers the case of my avatar (in which case one
|
// people's avatars will have an id that doesn't match any entities, and one's own avatar will have
|
||||||
// if the ids will be null), and the behavior for other avatars is not specified. This has to be fleshed
|
// an id of null. Thus this code handles any collision in which one of the participating objects is
|
||||||
// out as soon as we use the new motionstates.
|
// my avatar. (Other user machines will make a similar analysis and inject sound for their collisions.)
|
||||||
if (collision.idA.isNull() || collision.idB.isNull()) {
|
if (collision.idA.isNull() || collision.idB.isNull()) {
|
||||||
MyAvatar* myAvatar = getMyAvatar();
|
MyAvatar* myAvatar = getMyAvatar();
|
||||||
const QString& collisionSoundURL = myAvatar->getCollisionSoundURL();
|
const QString& collisionSoundURL = myAvatar->getCollisionSoundURL();
|
||||||
|
@ -299,9 +299,7 @@ void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents
|
||||||
const bool isSound = (collision.type == CONTACT_EVENT_TYPE_START) && (velocityChange > MIN_AVATAR_COLLISION_ACCELERATION);
|
const bool isSound = (collision.type == CONTACT_EVENT_TYPE_START) && (velocityChange > MIN_AVATAR_COLLISION_ACCELERATION);
|
||||||
|
|
||||||
if (!isSound) {
|
if (!isSound) {
|
||||||
// TODO: When the new motion states are used, we'll probably break from the whole loop as soon as we hit our own avatar
|
return; // No sense iterating for others. We only have one avatar.
|
||||||
// (regardless of isSound), because other users should inject for their own avatars.
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
// Your avatar sound is personal to you, so let's say the "mass" part of the kinetic energy is already accounted for.
|
// Your avatar sound is personal to you, so let's say the "mass" part of the kinetic energy is already accounted for.
|
||||||
const float energy = velocityChange * velocityChange;
|
const float energy = velocityChange * velocityChange;
|
||||||
|
@ -314,7 +312,7 @@ void AvatarManager::handleCollisionEvents(const CollisionEvents& collisionEvents
|
||||||
|
|
||||||
AudioInjector::playSound(collisionSoundURL, energyFactorOfFull, AVATAR_STRETCH_FACTOR, myAvatar->getPosition());
|
AudioInjector::playSound(collisionSoundURL, energyFactorOfFull, AVATAR_STRETCH_FACTOR, myAvatar->getPosition());
|
||||||
myAvatar->collisionWithEntity(collision);
|
myAvatar->collisionWithEntity(collision);
|
||||||
}
|
return; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
AvatarMotionState::AvatarMotionState(Avatar* avatar, btCollisionShape* shape) : ObjectMotionState(shape), _avatar(avatar) {
|
AvatarMotionState::AvatarMotionState(Avatar* avatar, btCollisionShape* shape) : ObjectMotionState(shape), _avatar(avatar) {
|
||||||
assert(_avatar);
|
assert(_avatar);
|
||||||
|
_type = MOTIONSTATE_TYPE_AVATAR;
|
||||||
if (_shape) {
|
if (_shape) {
|
||||||
_mass = 100.0f; // HACK
|
_mass = 100.0f; // HACK
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,6 @@ public slots:
|
||||||
Q_INVOKABLE glm::vec3 localCoordsToVoxelCoords(const QUuid& entityID, glm::vec3 localCoords);
|
Q_INVOKABLE glm::vec3 localCoordsToVoxelCoords(const QUuid& entityID, glm::vec3 localCoords);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
|
||||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||||
|
|
||||||
void canAdjustLocksChanged(bool canAdjustLocks);
|
void canAdjustLocksChanged(bool canAdjustLocks);
|
||||||
|
|
|
@ -360,16 +360,16 @@ const CollisionEvents& PhysicsEngine::getCollisionEvents() {
|
||||||
glm::vec3 velocityChange = (motionStateA ? motionStateA->getObjectLinearVelocityChange() : glm::vec3(0.0f)) +
|
glm::vec3 velocityChange = (motionStateA ? motionStateA->getObjectLinearVelocityChange() : glm::vec3(0.0f)) +
|
||||||
(motionStateB ? motionStateB->getObjectLinearVelocityChange() : glm::vec3(0.0f));
|
(motionStateB ? motionStateB->getObjectLinearVelocityChange() : glm::vec3(0.0f));
|
||||||
|
|
||||||
if (motionStateA && motionStateA->getType() == MOTIONSTATE_TYPE_ENTITY) {
|
if (motionStateA) {
|
||||||
QUuid idA = motionStateA->getObjectID();
|
QUuid idA = motionStateA->getObjectID();
|
||||||
QUuid idB;
|
QUuid idB;
|
||||||
if (motionStateB && motionStateB->getType() == MOTIONSTATE_TYPE_ENTITY) {
|
if (motionStateB) {
|
||||||
idB = motionStateB->getObjectID();
|
idB = motionStateB->getObjectID();
|
||||||
}
|
}
|
||||||
glm::vec3 position = bulletToGLM(contact.getPositionWorldOnB()) + _originOffset;
|
glm::vec3 position = bulletToGLM(contact.getPositionWorldOnB()) + _originOffset;
|
||||||
glm::vec3 penetration = bulletToGLM(contact.distance * contact.normalWorldOnB);
|
glm::vec3 penetration = bulletToGLM(contact.distance * contact.normalWorldOnB);
|
||||||
_collisionEvents.push_back(Collision(type, idA, idB, position, penetration, velocityChange));
|
_collisionEvents.push_back(Collision(type, idA, idB, position, penetration, velocityChange));
|
||||||
} else if (motionStateB && motionStateB->getType() == MOTIONSTATE_TYPE_ENTITY) {
|
} else if (motionStateB) {
|
||||||
QUuid idB = motionStateB->getObjectID();
|
QUuid idB = motionStateB->getObjectID();
|
||||||
glm::vec3 position = bulletToGLM(contact.getPositionWorldOnA()) + _originOffset;
|
glm::vec3 position = bulletToGLM(contact.getPositionWorldOnA()) + _originOffset;
|
||||||
// NOTE: we're flipping the order of A and B (so that the first objectID is never NULL)
|
// NOTE: we're flipping the order of A and B (so that the first objectID is never NULL)
|
||||||
|
|
Loading…
Reference in a new issue