From bafbc0a0559b0c0c8cf0f0b95c5ce690731b7e2e Mon Sep 17 00:00:00 2001 From: James Stephens Date: Thu, 5 Sep 2019 07:49:53 +0000 Subject: [PATCH] Cancel door sound if collision is detected and the sound is playing --- CHANGELOG.md | 1 + apps/openmw/mwworld/worldimp.cpp | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46f44ea06..42565e87d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 3ea994683..07680e76f 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -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 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()->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;