mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +00:00 
			
		
		
		
	Be more consistent with the vector orientations given the sound handler
This commit is contained in:
		
							parent
							
								
									cbeff4657f
								
							
						
					
					
						commit
						7160d20db3
					
				
					 4 changed files with 18 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -368,7 +368,7 @@ Sound* OpenAL_Output::PlaySound(const std::string &fname, std::auto_ptr<Sound_De
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                  MWWorld::Ptr ptr, float volume, float pitch,
 | 
			
		||||
                                  const float *pos, float volume, float pitch,
 | 
			
		||||
                                  float min, float max, bool loop)
 | 
			
		||||
{
 | 
			
		||||
    throwALerror();
 | 
			
		||||
| 
						 | 
				
			
			@ -393,7 +393,6 @@ Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr<Sound_
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    std::auto_ptr<OpenAL_Sound> sound(new OpenAL_Sound(src, buf));
 | 
			
		||||
    const float *pos = ptr.getCellRef().pos.pos;
 | 
			
		||||
    alSource3f(src, AL_POSITION, pos[0], pos[2], -pos[1]);
 | 
			
		||||
    alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
 | 
			
		||||
    alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
 | 
			
		||||
| 
						 | 
				
			
			@ -430,10 +429,14 @@ Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptr<Sound_
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void OpenAL_Output::UpdateListener(float pos[3], float atdir[3], float updir[3])
 | 
			
		||||
void OpenAL_Output::UpdateListener(const float *pos, const float *atdir, const float *updir)
 | 
			
		||||
{
 | 
			
		||||
    float orient[6] = { atdir[0], atdir[1], atdir[2], updir[0], updir[1], updir[2] };
 | 
			
		||||
    alListenerfv(AL_POSITION, pos);
 | 
			
		||||
    float orient[6] = {
 | 
			
		||||
        atdir[0], atdir[2], -atdir[1],
 | 
			
		||||
        updir[0], updir[2], -updir[1]
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    alListener3f(AL_POSITION, pos[0], pos[2], -pos[1]);
 | 
			
		||||
    alListenerfv(AL_ORIENTATION, orient);
 | 
			
		||||
    throwALerror();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,13 +25,13 @@ namespace MWSound
 | 
			
		|||
        virtual Sound *PlaySound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                 float volume, float pitch, bool loop);
 | 
			
		||||
        virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                   MWWorld::Ptr ptr, float volume, float pitch,
 | 
			
		||||
                                   const float *pos, float volume, float pitch,
 | 
			
		||||
                                   float min, float max, bool loop);
 | 
			
		||||
 | 
			
		||||
        virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                   float volume, float pitch);
 | 
			
		||||
 | 
			
		||||
        virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]);
 | 
			
		||||
        virtual void UpdateListener(const float *pos, const float *atdir, const float *updir);
 | 
			
		||||
 | 
			
		||||
        OpenAL_Output(SoundManager &mgr);
 | 
			
		||||
        virtual ~OpenAL_Output();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,13 +22,12 @@ namespace MWSound
 | 
			
		|||
        virtual Sound *PlaySound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                 float volume, float pitch, bool loop) = 0;
 | 
			
		||||
        virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                   MWWorld::Ptr ptr, float volume, float pitch,
 | 
			
		||||
                                   const float *pos, float volume, float pitch,
 | 
			
		||||
                                   float min, float max, bool loop) = 0;
 | 
			
		||||
        virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
 | 
			
		||||
                                   float volume, float pitch) = 0;
 | 
			
		||||
 | 
			
		||||
        // FIXME: This should take an MWWorld::Ptr that represents the in-world camera
 | 
			
		||||
        virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]) = 0;
 | 
			
		||||
        virtual void UpdateListener(const float *pos, const float *atdir, const float *updir) = 0;
 | 
			
		||||
 | 
			
		||||
        Sound_Output(SoundManager &mgr) : mgr(mgr) { }
 | 
			
		||||
    public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -125,8 +125,9 @@ namespace MWSound
 | 
			
		|||
        try
 | 
			
		||||
        {
 | 
			
		||||
            Sound *sound;
 | 
			
		||||
            const float *pos = ptr.getCellRef().pos.pos;
 | 
			
		||||
            std::auto_ptr<Sound_Decoder> decoder(new DEFAULT_DECODER);
 | 
			
		||||
            sound = Output->PlaySound3D(file, decoder, ptr, volume, pitch, min, max, loop);
 | 
			
		||||
            sound = Output->PlaySound3D(file, decoder, pos, volume, pitch, min, max, loop);
 | 
			
		||||
            if(untracked)
 | 
			
		||||
                LooseSounds[id] = SoundPtr(sound);
 | 
			
		||||
            else
 | 
			
		||||
| 
						 | 
				
			
			@ -444,7 +445,10 @@ namespace MWSound
 | 
			
		|||
            nDir = cam->getRealDirection();
 | 
			
		||||
            nUp  = cam->getRealUp();
 | 
			
		||||
 | 
			
		||||
            Output->UpdateListener(&nPos[0], &nDir[0], &nUp[0]);
 | 
			
		||||
            float pos[3] = { nPos[0], -nPos[2], nPos[1] };
 | 
			
		||||
            float at[3] = { nDir[0], -nDir[2], nDir[1] };
 | 
			
		||||
            float up[3] = { nUp[0], -nUp[2], nUp[1] };
 | 
			
		||||
            Output->UpdateListener(pos, at, up);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            IDMap::iterator snditer = LooseSounds.begin();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue