Cancel door sound if collision is detected and the sound is playing

pull/2514/head
James Stephens 5 years ago committed by Alexei Dobrohotov
parent 2daecc633e
commit bafbc0a055

@ -18,6 +18,7 @@
Bug #3894: Hostile spell effects not detected/present on first frame of OnPCHitMe
Bug #4202: Open .omwaddon files without needing toopen openmw-cs first
Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect
Bug #4270: Closing doors while they are obstructed desyncs closing sfx
Bug #4276: Resizing character window differs from vanilla
Bug #4329: Removed birthsign abilities are restored after reloading the save
Bug #4341: Error message about missing GDB is too vague

@ -1632,11 +1632,14 @@ namespace MWWorld
bool reached = (targetRot == maxRot && state != MWWorld::DoorState::Idle) || targetRot == minRot;
/// \todo should use convexSweepTest here
bool collisionWithActor = false;
std::vector<MWWorld::Ptr> collisions = mPhysics->getCollisions(door, MWPhysics::CollisionType_Door, MWPhysics::CollisionType_Actor);
for (MWWorld::Ptr& ptr : collisions)
{
if (ptr.getClass().isActor())
{
collisionWithActor = true;
// Collided with actor, ask actor to try to avoid door
if(ptr != getPlayerPtr() )
{
@ -1651,6 +1654,25 @@ namespace MWWorld
}
}
// Cancel door closing sound if collision with actor is detected
if (collisionWithActor)
{
const ESM::Door* ref = door.get<ESM::Door>()->mBase;
if (state == MWWorld::DoorState::Opening)
{
const std::string& openSound = ref->mOpenSound;
if (!openSound.empty() && MWBase::Environment::get().getSoundManager()->getSoundPlaying(door, openSound))
MWBase::Environment::get().getSoundManager()->stopSound3D(door, openSound);
}
else if (state == MWWorld::DoorState::Closing)
{
const std::string& closeSound = ref->mCloseSound;
if (!closeSound.empty() && MWBase::Environment::get().getSoundManager()->getSoundPlaying(door, closeSound))
MWBase::Environment::get().getSoundManager()->stopSound3D(door, closeSound);
}
}
// the rotation order we want to use
mWorldScene->updateObjectRotation(door, false);
return reached;

Loading…
Cancel
Save