1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-26 06:40:22 +00:00

Merge branch 'CancelDoorShutSoundWhenDoorBlocked' into 'master'

Bug #4270: Cancel door sound if collision is detected and the sound is playing

See merge request OpenMW/openmw!147
This commit is contained in:
Alexei Dobrohotov 2019-09-05 07:49:53 +00:00
commit 9ce556832e
2 changed files with 23 additions and 0 deletions

View File

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

View File

@ -1632,11 +1632,14 @@ namespace MWWorld
bool reached = (targetRot == maxRot && state != MWWorld::DoorState::Idle) || targetRot == minRot; bool reached = (targetRot == maxRot && state != MWWorld::DoorState::Idle) || targetRot == minRot;
/// \todo should use convexSweepTest here /// \todo should use convexSweepTest here
bool collisionWithActor = false;
std::vector<MWWorld::Ptr> collisions = mPhysics->getCollisions(door, MWPhysics::CollisionType_Door, MWPhysics::CollisionType_Actor); std::vector<MWWorld::Ptr> collisions = mPhysics->getCollisions(door, MWPhysics::CollisionType_Door, MWPhysics::CollisionType_Actor);
for (MWWorld::Ptr& ptr : collisions) for (MWWorld::Ptr& ptr : collisions)
{ {
if (ptr.getClass().isActor()) if (ptr.getClass().isActor())
{ {
collisionWithActor = true;
// Collided with actor, ask actor to try to avoid door // Collided with actor, ask actor to try to avoid door
if(ptr != getPlayerPtr() ) 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 // the rotation order we want to use
mWorldScene->updateObjectRotation(door, false); mWorldScene->updateObjectRotation(door, false);
return reached; return reached;