mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 02:15:34 +00:00
Attach sound listener to the player head instead of camera
This commit is contained in:
parent
cf85cbbc8e
commit
f6960debcb
4 changed files with 14 additions and 14 deletions
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/refdata.hpp"
|
||||
|
@ -120,15 +119,6 @@ namespace MWRender
|
|||
setPosition(Ogre::Vector3(x,y,z));
|
||||
}
|
||||
|
||||
void Camera::updateListener()
|
||||
{
|
||||
Ogre::Vector3 pos = mCamera->getRealPosition();
|
||||
Ogre::Vector3 dir = mCamera->getRealDirection();
|
||||
Ogre::Vector3 up = mCamera->getRealUp();
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->setListenerPosDir(pos, dir, up);
|
||||
}
|
||||
|
||||
void Camera::update(float duration, bool paused)
|
||||
{
|
||||
if (mAnimation->upperBodyReady())
|
||||
|
@ -148,7 +138,6 @@ namespace MWRender
|
|||
}
|
||||
}
|
||||
|
||||
updateListener();
|
||||
if (paused)
|
||||
return;
|
||||
|
||||
|
|
|
@ -50,9 +50,6 @@ namespace MWRender
|
|||
bool mVanityToggleQueued;
|
||||
bool mViewModeToggleQueued;
|
||||
|
||||
/// Updates sound manager listener data
|
||||
void updateListener();
|
||||
|
||||
void setPosition(const Ogre::Vector3& position);
|
||||
void setPosition(float x, float y, float z);
|
||||
|
||||
|
|
|
@ -1560,6 +1560,8 @@ namespace MWWorld
|
|||
|
||||
updateWindowManager ();
|
||||
|
||||
updateSoundListener();
|
||||
|
||||
if (!paused && mPlayer->getPlayer().getCell()->isExterior())
|
||||
{
|
||||
ESM::Position pos = mPlayer->getPlayer().getRefData().getPosition();
|
||||
|
@ -1567,6 +1569,17 @@ namespace MWWorld
|
|||
}
|
||||
}
|
||||
|
||||
void World::updateSoundListener()
|
||||
{
|
||||
Ogre::Vector3 playerPos = mPlayer->getPlayer().getRefData().getBaseNode()->getPosition();
|
||||
const OEngine::Physic::PhysicActor *actor = mPhysEngine->getCharacter(getPlayerPtr().getRefData().getHandle());
|
||||
if(actor) playerPos.z += 1.85*actor->getHalfExtents().z;
|
||||
Ogre::Quaternion playerOrient = Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[2]), Ogre::Vector3::NEGATIVE_UNIT_Z) *
|
||||
Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[0]), Ogre::Vector3::NEGATIVE_UNIT_X);
|
||||
MWBase::Environment::get().getSoundManager()->setListenerPosDir(playerPos, playerOrient.yAxis(),
|
||||
playerOrient.zAxis());
|
||||
}
|
||||
|
||||
void World::updateWindowManager ()
|
||||
{
|
||||
// inform the GUI about focused object
|
||||
|
|
|
@ -109,6 +109,7 @@ namespace MWWorld
|
|||
|
||||
Ptr copyObjectToCell(const Ptr &ptr, CellStore* cell, ESM::Position pos, bool adjustPos=true);
|
||||
|
||||
void updateSoundListener();
|
||||
void updateWindowManager ();
|
||||
void performUpdateSceneQueries ();
|
||||
void getFacedHandle(std::string& facedHandle, float maxDistance, bool ignorePlayer=true);
|
||||
|
|
Loading…
Reference in a new issue