mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-31 15:32:45 +00:00
Readded sound listener
This commit is contained in:
parent
ccab8cc9a1
commit
7a3bc69df7
@ -7,11 +7,6 @@
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class CellStore;
|
||||
@ -125,7 +120,7 @@ namespace MWBase
|
||||
///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified.
|
||||
///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
||||
|
||||
virtual MWBase::SoundPtr playManualSound3D(const Ogre::Vector3& initialPos, const std::string& soundId,
|
||||
virtual MWBase::SoundPtr playManualSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
|
||||
float volume, float pitch, PlayType type, PlayMode mode, float offset=0) = 0;
|
||||
///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated manually using Sound::setPosition.
|
||||
|
||||
@ -162,7 +157,7 @@ namespace MWBase
|
||||
|
||||
virtual void update(float duration) = 0;
|
||||
|
||||
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up) = 0;
|
||||
virtual void setListenerPosDir(const osg::Vec3f &pos, const osg::Vec3f &dir, const osg::Vec3f &up) = 0;
|
||||
|
||||
virtual void updatePtr (const MWWorld::Ptr& old, const MWWorld::Ptr& updated) = 0;
|
||||
|
||||
|
@ -802,6 +802,14 @@ namespace MWPhysics
|
||||
}
|
||||
}
|
||||
|
||||
Actor *PhysicsSystem::getActor(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
ActorMap::iterator found = mActors.find(ptr);
|
||||
if (found != mActors.end())
|
||||
return found->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void PhysicsSystem::updateScale(const MWWorld::Ptr &ptr)
|
||||
{
|
||||
ObjectMap::iterator found = mObjects.find(ptr);
|
||||
|
@ -53,6 +53,11 @@ namespace MWPhysics
|
||||
void disableWater();
|
||||
|
||||
void addObject (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
void addActor (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
|
||||
void updatePtr (const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
|
||||
|
||||
Actor* getActor(const MWWorld::Ptr& ptr);
|
||||
|
||||
// Object or Actor
|
||||
void remove (const MWWorld::Ptr& ptr);
|
||||
@ -61,9 +66,6 @@ namespace MWPhysics
|
||||
void updateRotation (const MWWorld::Ptr& ptr);
|
||||
void updatePosition (const MWWorld::Ptr& ptr);
|
||||
|
||||
void updatePtr (const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
|
||||
|
||||
void addActor (const MWWorld::Ptr& ptr, const std::string& mesh);
|
||||
|
||||
void addHeightField (float* heights, int x, int y, float triSize, float sqrtVerts);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <OgreSceneNode.h>
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
|
||||
#include <components/esm/loadcell.hpp>
|
||||
|
||||
@ -519,17 +519,17 @@ namespace MWScript
|
||||
for (int i=0; i<count; ++i)
|
||||
{
|
||||
ESM::Position ipos = actor.getRefData().getPosition();
|
||||
Ogre::Vector3 pos(ipos.pos[0],ipos.pos[1],ipos.pos[2]);
|
||||
Ogre::Quaternion rot(Ogre::Radian(-ipos.rot[2]), Ogre::Vector3::UNIT_Z);
|
||||
if(direction == 0) pos = pos + distance*rot.yAxis();
|
||||
else if(direction == 1) pos = pos - distance*rot.yAxis();
|
||||
else if(direction == 2) pos = pos - distance*rot.xAxis();
|
||||
else if(direction == 3) pos = pos + distance*rot.xAxis();
|
||||
osg::Vec3f pos(ipos.asVec3());
|
||||
osg::Quat rot(ipos.rot[2], osg::Vec3f(0,0,-1));
|
||||
if(direction == 0) pos = pos + (rot * osg::Vec3f(0,1,0)) * distance;
|
||||
else if(direction == 1) pos = pos - (rot * osg::Vec3f(0,1,0)) * distance;
|
||||
else if(direction == 2) pos = pos - (rot * osg::Vec3f(1,0,0)) * distance;
|
||||
else if(direction == 3) pos = pos + (rot * osg::Vec3f(1,0,0)) * distance;
|
||||
else throw std::runtime_error ("direction must be 0,1,2 or 3");
|
||||
|
||||
ipos.pos[0] = pos.x;
|
||||
ipos.pos[1] = pos.y;
|
||||
ipos.pos[2] = pos.z;
|
||||
ipos.pos[0] = pos.x();
|
||||
ipos.pos[1] = pos.y();
|
||||
ipos.pos[2] = pos.z();
|
||||
|
||||
if (actor.getClass().isActor())
|
||||
{
|
||||
@ -670,29 +670,30 @@ namespace MWScript
|
||||
Interpreter::Type_Float movement = (runtime[0].mFloat*MWBase::Environment::get().getFrameDuration());
|
||||
runtime.pop();
|
||||
|
||||
Ogre::Vector3 posChange;
|
||||
osg::Vec3f posChange;
|
||||
if (axis == "x")
|
||||
{
|
||||
posChange=Ogre::Vector3(movement, 0, 0);
|
||||
posChange=osg::Vec3f(movement, 0, 0);
|
||||
}
|
||||
else if (axis == "y")
|
||||
{
|
||||
posChange=Ogre::Vector3(0, movement, 0);
|
||||
posChange=osg::Vec3f(0, movement, 0);
|
||||
}
|
||||
else if (axis == "z")
|
||||
{
|
||||
posChange=Ogre::Vector3(0, 0, movement);
|
||||
posChange=osg::Vec3f(0, 0, movement);
|
||||
}
|
||||
else
|
||||
throw std::runtime_error ("invalid movement axis: " + axis);
|
||||
|
||||
if (!ptr.getRefData().getBaseNodeOld())
|
||||
// is it correct that disabled objects can't be Move-d?
|
||||
if (!ptr.getRefData().getBaseNode())
|
||||
return;
|
||||
|
||||
Ogre::Vector3 diff = ptr.getRefData().getBaseNodeOld()->getOrientation() * posChange;
|
||||
Ogre::Vector3 worldPos(ptr.getRefData().getPosition().pos);
|
||||
osg::Vec3f diff = ptr.getRefData().getBaseNode()->getAttitude() * posChange;
|
||||
osg::Vec3f worldPos(ptr.getRefData().getPosition().asVec3());
|
||||
worldPos += diff;
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, worldPos.x, worldPos.y, worldPos.z);
|
||||
MWBase::Environment::get().getWorld()->moveObject(ptr, worldPos.x(), worldPos.y(), worldPos.z());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "loudness.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "soundmanagerimp.hpp"
|
||||
|
||||
namespace MWSound
|
||||
@ -28,7 +30,7 @@ namespace MWSound
|
||||
value = ((char)(data[sample*advance]^0x80))/128.f;
|
||||
else if (type == SampleType_Int16)
|
||||
{
|
||||
value = *reinterpret_cast<const Ogre::int16*>(&data[sample*advance]);
|
||||
value = *reinterpret_cast<const uint16_t*>(&data[sample*advance]);
|
||||
value /= float(std::numeric_limits<Ogre::int16>::max());
|
||||
}
|
||||
else if (type == SampleType_Float32)
|
||||
|
@ -271,7 +271,7 @@ private:
|
||||
|
||||
|
||||
OpenAL_SoundStream::OpenAL_SoundStream(OpenAL_Output &output, ALuint src, DecoderPtr decoder, float basevol, float pitch, int flags)
|
||||
: Sound(Ogre::Vector3(0.0f), 1.0f, basevol, pitch, 1.0f, 1000.0f, flags)
|
||||
: Sound(osg::Vec3f(0.f, 0.f, 0.f), 1.0f, basevol, pitch, 1.0f, 1000.0f, flags)
|
||||
, mOutput(output), mSource(src), mSamplesQueued(0), mDecoder(decoder), mIsFinished(true), mIsInitialBatchEnqueued(false)
|
||||
{
|
||||
throwALerror();
|
||||
@ -505,7 +505,7 @@ private:
|
||||
OpenAL_Sound& operator=(const OpenAL_Sound &rhs);
|
||||
|
||||
public:
|
||||
OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf, const Ogre::Vector3& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags);
|
||||
OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf, const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags);
|
||||
virtual ~OpenAL_Sound();
|
||||
|
||||
virtual void stop();
|
||||
@ -524,14 +524,14 @@ class OpenAL_Sound3D : public OpenAL_Sound
|
||||
OpenAL_Sound3D& operator=(const OpenAL_Sound &rhs);
|
||||
|
||||
public:
|
||||
OpenAL_Sound3D(OpenAL_Output &output, ALuint src, ALuint buf, const Ogre::Vector3& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
OpenAL_Sound3D(OpenAL_Output &output, ALuint src, ALuint buf, const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
: OpenAL_Sound(output, src, buf, pos, vol, basevol, pitch, mindist, maxdist, flags)
|
||||
{ }
|
||||
|
||||
virtual void update();
|
||||
};
|
||||
|
||||
OpenAL_Sound::OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf, const Ogre::Vector3& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
OpenAL_Sound::OpenAL_Sound(OpenAL_Output &output, ALuint src, ALuint buf, const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
: Sound(pos, vol, basevol, pitch, mindist, maxdist, flags)
|
||||
, mOutput(output), mSource(src), mBuffer(buf)
|
||||
{
|
||||
@ -628,7 +628,7 @@ void OpenAL_Sound3D::update()
|
||||
{
|
||||
ALfloat gain = mVolume*mBaseVolume;
|
||||
ALfloat pitch = mPitch;
|
||||
if(mPos.squaredDistance(mOutput.mPos) > mMaxDistance*mMaxDistance)
|
||||
if((mPos - mOutput.mPos).length2() > mMaxDistance*mMaxDistance)
|
||||
gain = 0.0f;
|
||||
else if(!(mFlags&MWBase::SoundManager::Play_NoEnv) && mOutput.mLastEnvironment == Env_Underwater)
|
||||
{
|
||||
@ -867,7 +867,7 @@ MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, f
|
||||
try
|
||||
{
|
||||
buf = getBuffer(fname).mALBuffer;
|
||||
sound.reset(new OpenAL_Sound(*this, src, buf, Ogre::Vector3(0.0f), vol, basevol, pitch, 1.0f, 1000.0f, flags));
|
||||
sound.reset(new OpenAL_Sound(*this, src, buf, osg::Vec3f(0.f, 0.f, 0.f), vol, basevol, pitch, 1.0f, 1000.0f, flags));
|
||||
}
|
||||
catch(std::exception&)
|
||||
{
|
||||
@ -892,7 +892,7 @@ MWBase::SoundPtr OpenAL_Output::playSound(const std::string &fname, float vol, f
|
||||
return sound;
|
||||
}
|
||||
|
||||
MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const Ogre::Vector3 &pos, float vol, float basevol, float pitch,
|
||||
MWBase::SoundPtr OpenAL_Output::playSound3D(const std::string &fname, const osg::Vec3f &pos, float vol, float basevol, float pitch,
|
||||
float min, float max, int flags, float offset, bool extractLoudness)
|
||||
{
|
||||
boost::shared_ptr<OpenAL_Sound> sound;
|
||||
@ -967,7 +967,7 @@ MWBase::SoundPtr OpenAL_Output::streamSound(DecoderPtr decoder, float volume, fl
|
||||
}
|
||||
|
||||
|
||||
void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env)
|
||||
void OpenAL_Output::updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &updir, Environment env)
|
||||
{
|
||||
mPos = pos;
|
||||
mLastEnvironment = env;
|
||||
@ -975,10 +975,10 @@ void OpenAL_Output::updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3
|
||||
if(mContext)
|
||||
{
|
||||
ALfloat orient[6] = {
|
||||
atdir.x, atdir.y, atdir.z,
|
||||
updir.x, updir.y, updir.z
|
||||
atdir.x(), atdir.y(), atdir.z(),
|
||||
updir.x(), updir.y(), updir.z()
|
||||
};
|
||||
alListener3f(AL_POSITION, mPos.x, mPos.y, mPos.z);
|
||||
alListener3f(AL_POSITION, mPos.x(), mPos.y(), mPos.z());
|
||||
alListenerfv(AL_ORIENTATION, orient);
|
||||
throwALerror();
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ namespace MWSound
|
||||
/// @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
||||
virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags, float offset);
|
||||
/// @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
||||
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
|
||||
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const osg::Vec3f &pos,
|
||||
float vol, float basevol, float pitch, float min, float max, int flags, float offset, bool extractLoudness=false);
|
||||
virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags);
|
||||
|
||||
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env);
|
||||
virtual void updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &updir, Environment env);
|
||||
|
||||
virtual void pauseSounds(int types);
|
||||
virtual void resumeSounds(int types);
|
||||
|
@ -15,7 +15,7 @@ namespace MWSound
|
||||
Sound(const Sound &rhs);
|
||||
|
||||
protected:
|
||||
Ogre::Vector3 mPos;
|
||||
osg::Vec3f mPos;
|
||||
float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */
|
||||
float mBaseVolume;
|
||||
float mPitch;
|
||||
@ -31,7 +31,7 @@ namespace MWSound
|
||||
virtual void stop() = 0;
|
||||
virtual bool isPlaying() = 0;
|
||||
virtual double getTimeOffset() = 0;
|
||||
void setPosition(const Ogre::Vector3 &pos) { mPos = pos; }
|
||||
void setPosition(const osg::Vec3f &pos) { mPos = pos; }
|
||||
void setVolume(float volume) { mVolume = volume; }
|
||||
void setFadeout(float duration) { mFadeOutTime=duration; }
|
||||
void setLoudnessVector(const std::vector<float>& loudnessVector, float loudnessFPS);
|
||||
@ -44,7 +44,7 @@ namespace MWSound
|
||||
{ return (MWBase::SoundManager::PlayType)(mFlags&MWBase::SoundManager::Play_TypeMask); }
|
||||
|
||||
|
||||
Sound(const Ogre::Vector3& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
Sound(const osg::Vec3f& pos, float vol, float basevol, float pitch, float mindist, float maxdist, int flags)
|
||||
: mPos(pos)
|
||||
, mVolume(vol)
|
||||
, mBaseVolume(basevol)
|
||||
|
@ -4,8 +4,6 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
#include <OgreVector3.h>
|
||||
|
||||
#include "soundmanagerimp.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
@ -27,11 +25,11 @@ namespace MWSound
|
||||
/// @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
||||
virtual MWBase::SoundPtr playSound(const std::string &fname, float vol, float basevol, float pitch, int flags, float offset) = 0;
|
||||
/// @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
||||
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const Ogre::Vector3 &pos,
|
||||
virtual MWBase::SoundPtr playSound3D(const std::string &fname, const osg::Vec3f &pos,
|
||||
float vol, float basevol, float pitch, float min, float max, int flags, float offset, bool extractLoudness=false) = 0;
|
||||
virtual MWBase::SoundPtr streamSound(DecoderPtr decoder, float volume, float pitch, int flags) = 0;
|
||||
|
||||
virtual void updateListener(const Ogre::Vector3 &pos, const Ogre::Vector3 &atdir, const Ogre::Vector3 &updir, Environment env) = 0;
|
||||
virtual void updateListener(const osg::Vec3f &pos, const osg::Vec3f &atdir, const osg::Vec3f &updir, Environment env) = 0;
|
||||
|
||||
virtual void pauseSounds(int types) = 0;
|
||||
virtual void resumeSounds(int types) = 0;
|
||||
@ -41,7 +39,7 @@ namespace MWSound
|
||||
|
||||
protected:
|
||||
bool mInitialized;
|
||||
Ogre::Vector3 mPos;
|
||||
osg::Vec3f mPos;
|
||||
|
||||
Sound_Output(SoundManager &mgr)
|
||||
: mManager(mgr)
|
||||
|
@ -268,7 +268,7 @@ namespace MWSound
|
||||
float basevol = volumeFromType(Play_TypeVoice);
|
||||
std::string filePath = "Sound/"+filename;
|
||||
const ESM::Position &pos = ptr.getRefData().getPosition();
|
||||
const Ogre::Vector3 objpos(pos.pos);
|
||||
const osg::Vec3f objpos(pos.asVec3());
|
||||
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
static const float fAudioMinDistanceMult = world->getStore().get<ESM::GameSetting>().find("fAudioMinDistanceMult")->getFloat();
|
||||
@ -396,9 +396,9 @@ namespace MWSound
|
||||
float min, max;
|
||||
std::string file = lookup(soundId, volume, min, max);
|
||||
const ESM::Position &pos = ptr.getRefData().getPosition();
|
||||
const Ogre::Vector3 objpos(pos.pos);
|
||||
const osg::Vec3f objpos(pos.asVec3());
|
||||
|
||||
if ((mode & Play_RemoveAtDistance) && mListenerPos.squaredDistance(objpos) > 2000*2000)
|
||||
if ((mode & Play_RemoveAtDistance) && (mListenerPos-objpos).length2() > 2000*2000)
|
||||
{
|
||||
return MWBase::SoundPtr();
|
||||
}
|
||||
@ -416,7 +416,7 @@ namespace MWSound
|
||||
return sound;
|
||||
}
|
||||
|
||||
MWBase::SoundPtr SoundManager::playManualSound3D(const Ogre::Vector3& initialPos, const std::string& soundId,
|
||||
MWBase::SoundPtr SoundManager::playManualSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
|
||||
float volume, float pitch, PlayType type, PlayMode mode, float offset)
|
||||
{
|
||||
MWBase::SoundPtr sound;
|
||||
@ -666,11 +666,11 @@ namespace MWSound
|
||||
if(!ptr.isEmpty())
|
||||
{
|
||||
const ESM::Position &pos = ptr.getRefData().getPosition();
|
||||
const Ogre::Vector3 objpos(pos.pos);
|
||||
const osg::Vec3f objpos(pos.asVec3());
|
||||
snditer->first->setPosition(objpos);
|
||||
|
||||
if ((snditer->first->mFlags & Play_RemoveAtDistance)
|
||||
&& mListenerPos.squaredDistance(Ogre::Vector3(ptr.getRefData().getPosition().pos)) > 2000*2000)
|
||||
&& (mListenerPos - ptr.getRefData().getPosition().asVec3()).length2() > 2000*2000)
|
||||
{
|
||||
mActiveSounds.erase(snditer++);
|
||||
continue;
|
||||
@ -728,7 +728,7 @@ namespace MWSound
|
||||
}
|
||||
}
|
||||
|
||||
void SoundManager::setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up)
|
||||
void SoundManager::setListenerPosDir(const osg::Vec3f &pos, const osg::Vec3f &dir, const osg::Vec3f &up)
|
||||
{
|
||||
mListenerPos = pos;
|
||||
mListenerDir = dir;
|
||||
@ -738,7 +738,7 @@ namespace MWSound
|
||||
MWBase::Environment::get().getWorld()->getPlayerPtr();
|
||||
const MWWorld::CellStore *cell = player.getCell();
|
||||
|
||||
mListenerUnderwater = ((cell->getCell()->mData.mFlags&ESM::Cell::HasWater) && mListenerPos.z < cell->getWaterLevel());
|
||||
mListenerUnderwater = ((cell->getCell()->mData.mFlags&ESM::Cell::HasWater) && mListenerPos.z() < cell->getWaterLevel());
|
||||
}
|
||||
|
||||
void SoundManager::updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &updated)
|
||||
|
@ -55,9 +55,9 @@ namespace MWSound
|
||||
MWBase::SoundPtr mUnderwaterSound;
|
||||
|
||||
bool mListenerUnderwater;
|
||||
Ogre::Vector3 mListenerPos;
|
||||
Ogre::Vector3 mListenerDir;
|
||||
Ogre::Vector3 mListenerUp;
|
||||
osg::Vec3f mListenerPos;
|
||||
osg::Vec3f mListenerDir;
|
||||
osg::Vec3f mListenerUp;
|
||||
|
||||
int mPausedSoundTypes;
|
||||
|
||||
@ -132,7 +132,7 @@ namespace MWSound
|
||||
///< Play a 3D sound attached to an MWWorld::Ptr. Will be updated automatically with the Ptr's position, unless Play_NoTrack is specified.
|
||||
///< @param offset Value from [0,1] meaning from which fraction the sound the playback starts.
|
||||
|
||||
virtual MWBase::SoundPtr playManualSound3D(const Ogre::Vector3& initialPos, const std::string& soundId,
|
||||
virtual MWBase::SoundPtr playManualSound3D(const osg::Vec3f& initialPos, const std::string& soundId,
|
||||
float volume, float pitch, PlayType type, PlayMode mode, float offset=0);
|
||||
///< Play a 3D sound at \a initialPos. If the sound should be moving, it must be updated manually using Sound::setPosition.
|
||||
|
||||
@ -171,7 +171,7 @@ namespace MWSound
|
||||
|
||||
virtual void update(float duration);
|
||||
|
||||
virtual void setListenerPosDir(const Ogre::Vector3 &pos, const Ogre::Vector3 &dir, const Ogre::Vector3 &up);
|
||||
virtual void setListenerPosDir(const osg::Vec3f &pos, const osg::Vec3f &dir, const osg::Vec3f &up);
|
||||
|
||||
virtual void updatePtr (const MWWorld::Ptr& old, const MWWorld::Ptr& updated);
|
||||
|
||||
|
@ -242,7 +242,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
|
||||
MWWorld::Ptr item = *it;
|
||||
|
||||
// we may have copied an item from the world, so reset a few things first
|
||||
item.getRefData().setBaseNodeOld(NULL); // Especially important, otherwise scripts on the item could think that it's actually in a cell
|
||||
item.getRefData().setBaseNode(NULL); // Especially important, otherwise scripts on the item could think that it's actually in a cell
|
||||
ESM::Position pos;
|
||||
pos.rot[0] = 0;
|
||||
pos.rot[1] = 0;
|
||||
|
@ -6,18 +6,14 @@
|
||||
#include <OgreVector3.h>
|
||||
|
||||
#include <components/esm/effectlist.hpp>
|
||||
#include <components/nifogre/ogrenifloader.hpp>
|
||||
|
||||
#include "../mwbase/soundmanager.hpp"
|
||||
|
||||
#include "ptr.hpp"
|
||||
|
||||
namespace OEngine
|
||||
namespace MWPhysics
|
||||
{
|
||||
namespace Physic
|
||||
{
|
||||
class PhysicEngine;
|
||||
}
|
||||
class PhysicsSystem;
|
||||
}
|
||||
|
||||
namespace Loading
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "../mwclass/door.hpp"
|
||||
|
||||
#include "../mwphysics/physicssystem.hpp"
|
||||
#include "../mwphysics/actor.hpp"
|
||||
|
||||
#include "player.hpp"
|
||||
#include "manualref.hpp"
|
||||
@ -1314,7 +1315,7 @@ namespace MWWorld
|
||||
{
|
||||
ESM::Position pos (ptr.getRefData().getPosition());
|
||||
|
||||
if(!ptr.getRefData().getBaseNodeOld())
|
||||
if(!ptr.getRefData().getBaseNode())
|
||||
{
|
||||
// will be adjusted when Ptr's cell becomes active
|
||||
return;
|
||||
@ -1596,9 +1597,9 @@ namespace MWWorld
|
||||
performUpdateSceneQueries ();
|
||||
|
||||
updateWindowManager ();
|
||||
|
||||
*/
|
||||
updateSoundListener();
|
||||
|
||||
/*
|
||||
if (!paused && mPlayer->getPlayer().getCell()->isExterior())
|
||||
{
|
||||
ESM::Position pos = mPlayer->getPlayer().getRefData().getPosition();
|
||||
@ -1611,17 +1612,21 @@ namespace MWWorld
|
||||
|
||||
void World::updateSoundListener()
|
||||
{
|
||||
/*
|
||||
Ogre::Vector3 playerPos = mPlayer->getPlayer().getRefData().getBaseNodeOld()->getPosition();
|
||||
const ESM::Position& refpos = getPlayerPtr().getRefData().getPosition();
|
||||
osg::Vec3f playerPos = refpos.asVec3();
|
||||
|
||||
const OEngine::Physic::PhysicActor *actor = mPhysEngine->getCharacter(getPlayerPtr().getRefData().getHandle());
|
||||
if(actor) playerPos.z += 1.85f * 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) *
|
||||
Ogre::Quaternion(Ogre::Radian(getPlayerPtr().getRefData().getPosition().rot[1]), Ogre::Vector3::NEGATIVE_UNIT_Y);
|
||||
MWBase::Environment::get().getSoundManager()->setListenerPosDir(playerPos, playerOrient.yAxis(),
|
||||
playerOrient.zAxis());
|
||||
*/
|
||||
const MWPhysics::Actor* actor = mPhysics->getActor(getPlayerPtr());
|
||||
if (actor)
|
||||
playerPos.z() += 1.85f * actor->getHalfExtents().z();
|
||||
|
||||
osg::Quat playerOrient = osg::Quat(refpos.rot[1], osg::Vec3f(0,-1,0)) *
|
||||
osg::Quat(refpos.rot[0], osg::Vec3f(-1,0,0)) *
|
||||
osg::Quat(refpos.rot[2], osg::Vec3f(0,0,-1));
|
||||
|
||||
osg::Vec3f forward = playerOrient * osg::Vec3f(0,1,0);
|
||||
osg::Vec3f up = playerOrient * osg::Vec3f(0,0,1);
|
||||
|
||||
MWBase::Environment::get().getSoundManager()->setListenerPosDir(playerPos, forward, up);
|
||||
}
|
||||
|
||||
void World::updateWindowManager ()
|
||||
@ -1987,9 +1992,9 @@ namespace MWWorld
|
||||
&& isLevitationEnabled())
|
||||
return true;
|
||||
|
||||
//const OEngine::Physic::PhysicActor *actor = 0;//mPhysEngine->getCharacter(ptr.getRefData().getHandle());
|
||||
//if(!actor || !actor->getCollisionMode())
|
||||
// return true;
|
||||
const MWPhysics::Actor* actor = mPhysics->getActor(ptr);
|
||||
if(!actor || !actor->getCollisionMode())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -2027,10 +2032,10 @@ namespace MWWorld
|
||||
const float *fpos = object.getRefData().getPosition().pos;
|
||||
Ogre::Vector3 pos(fpos[0], fpos[1], fpos[2]);
|
||||
|
||||
//const OEngine::Physic::PhysicActor *actor = 0;//mPhysEngine->getCharacter(object.getRefData().getHandle());
|
||||
//if (actor)
|
||||
const MWPhysics::Actor* actor = mPhysics->getActor(object);
|
||||
if (actor)
|
||||
{
|
||||
// pos.z += heightRatio*2*actor->getHalfExtents().z;
|
||||
pos.z += heightRatio*2*actor->getHalfExtents().z();
|
||||
}
|
||||
|
||||
return isUnderwater(object.getCell(), pos);
|
||||
@ -2134,17 +2139,16 @@ namespace MWWorld
|
||||
CellStore *currentCell = mWorldScene->getCurrentCell();
|
||||
|
||||
Ptr player = mPlayer->getPlayer();
|
||||
//RefData &refdata = player.getRefData();
|
||||
//Ogre::Vector3 playerPos(refdata.getPosition().pos);
|
||||
RefData &refdata = player.getRefData();
|
||||
Ogre::Vector3 playerPos(refdata.getPosition().pos);
|
||||
|
||||
/*
|
||||
const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle());
|
||||
if (!physactor)
|
||||
const MWPhysics::Actor* actor = mPhysics->getActor(player);
|
||||
if (!actor)
|
||||
throw std::runtime_error("can't find player");
|
||||
|
||||
if((!physactor->getOnGround()&&physactor->getCollisionMode()) || isUnderwater(currentCell, playerPos) || isWalkingOnWater(player))
|
||||
if((!actor->getOnGround()&&actor->getCollisionMode()) || isUnderwater(currentCell, playerPos) || isWalkingOnWater(player))
|
||||
return 2;
|
||||
*/
|
||||
|
||||
if((currentCell->getCell()->mData.mFlags&ESM::Cell::NoSleep) ||
|
||||
player.getClass().getNpcStats(player).isWerewolf())
|
||||
return 1;
|
||||
@ -2359,9 +2363,10 @@ namespace MWWorld
|
||||
{
|
||||
if (!targetActor.getRefData().isEnabled() || !actor.getRefData().isEnabled())
|
||||
return false; // cannot get LOS unless both NPC's are enabled
|
||||
if (!targetActor.getRefData().getBaseNodeOld() || !targetActor.getRefData().getBaseNodeOld())
|
||||
if (!targetActor.getRefData().getBaseNode() || !targetActor.getRefData().getBaseNode())
|
||||
return false; // not in active cell
|
||||
|
||||
// TODO: move to PhysicsSystem
|
||||
/*
|
||||
OEngine::Physic::PhysicActor* actor1 = mPhysEngine->getCharacter(actor.getRefData().getHandle());
|
||||
OEngine::Physic::PhysicActor* actor2 = mPhysEngine->getCharacter(targetActor.getRefData().getHandle());
|
||||
@ -2402,11 +2407,9 @@ namespace MWWorld
|
||||
|
||||
void World::enableActorCollision(const MWWorld::Ptr& actor, bool enable)
|
||||
{
|
||||
/*
|
||||
OEngine::Physic::PhysicActor *physicActor = 0;//mPhysEngine->getCharacter(actor.getRefData().getHandle());
|
||||
MWPhysics::Actor *physicActor = mPhysics->getActor(actor);
|
||||
if (physicActor)
|
||||
physicActor->enableCollisionBody(enable);
|
||||
*/
|
||||
}
|
||||
|
||||
bool World::findInteriorPosition(const std::string &name, ESM::Position &pos)
|
||||
@ -3261,9 +3264,9 @@ namespace MWWorld
|
||||
{
|
||||
MWBase::SoundManager *sndMgr = MWBase::Environment::get().getSoundManager();
|
||||
if(!effect->mAreaSound.empty())
|
||||
sndMgr->playManualSound3D(origin, effect->mAreaSound, 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack);
|
||||
sndMgr->playManualSound3D(osg::Vec3f(origin.x, origin.y, origin.z), effect->mAreaSound, 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack);
|
||||
else
|
||||
sndMgr->playManualSound3D(origin, schools[effect->mData.mSchool]+" area", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack);
|
||||
sndMgr->playManualSound3D(osg::Vec3f(origin.x, origin.y, origin.z), schools[effect->mData.mSchool]+" area", 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx, MWBase::SoundManager::Play_NoTrack);
|
||||
}
|
||||
// Get the actors in range of the effect
|
||||
std::vector<MWWorld::Ptr> objects;
|
||||
@ -3348,12 +3351,9 @@ namespace MWWorld
|
||||
|
||||
bool World::isWalkingOnWater(const Ptr &actor)
|
||||
{
|
||||
return false;
|
||||
/*
|
||||
OEngine::Physic::PhysicActor* physicActor = mPhysEngine->getCharacter(actor.getRefData().getHandle());
|
||||
MWPhysics::Actor* physicActor = mPhysics->getActor(actor);
|
||||
if (physicActor && physicActor->isWalkingOnWater())
|
||||
return true;
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user