mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
respect extra viewport transforms for audio calc
This commit is contained in:
@@ -126,8 +126,13 @@ openal_source::sync_with( sound_properties const &State ) {
|
|||||||
}
|
}
|
||||||
// NOTE: velocity at this point can be either listener velocity for global sounds, actual sound velocity, or 0 if sound position is yet unknown
|
// NOTE: velocity at this point can be either listener velocity for global sounds, actual sound velocity, or 0 if sound position is yet unknown
|
||||||
::alSourcefv( id, AL_VELOCITY, glm::value_ptr( sound_velocity ) );
|
::alSourcefv( id, AL_VELOCITY, glm::value_ptr( sound_velocity ) );
|
||||||
|
|
||||||
|
glm::dmat4 cameramatrix;
|
||||||
|
Global.pCamera.SetMatrix( cameramatrix );
|
||||||
|
auto cameraposition = Global.pCamera.Pos + (Global.viewport_move * glm::mat3(cameramatrix));
|
||||||
|
|
||||||
// location
|
// location
|
||||||
sound_distance = State.location - glm::dvec3 { Global.pCamera.Pos };
|
sound_distance = State.location - glm::dvec3 { cameraposition };
|
||||||
if( sound_range != -1 ) {
|
if( sound_range != -1 ) {
|
||||||
// range cutoff check for songs other than 'unlimited'
|
// range cutoff check for songs other than 'unlimited'
|
||||||
// NOTE: since we're comparing squared distances we can ignore that sound range can be negative
|
// NOTE: since we're comparing squared distances we can ignore that sound range can be negative
|
||||||
@@ -363,6 +368,8 @@ openal_renderer::update( double const Deltatime ) {
|
|||||||
// orientation
|
// orientation
|
||||||
glm::dmat4 cameramatrix;
|
glm::dmat4 cameramatrix;
|
||||||
Global.pCamera.SetMatrix( cameramatrix );
|
Global.pCamera.SetMatrix( cameramatrix );
|
||||||
|
auto cameraposition = Global.pCamera.Pos + (Global.viewport_move * glm::mat3(cameramatrix));
|
||||||
|
cameramatrix = glm::dmat4(glm::inverse(Global.viewport_rotate)) * cameramatrix;
|
||||||
auto rotationmatrix { glm::mat3{ cameramatrix } };
|
auto rotationmatrix { glm::mat3{ cameramatrix } };
|
||||||
glm::vec3 const orientation[] = {
|
glm::vec3 const orientation[] = {
|
||||||
glm::vec3{ 0, 0,-1 } * rotationmatrix ,
|
glm::vec3{ 0, 0,-1 } * rotationmatrix ,
|
||||||
@@ -370,8 +377,8 @@ openal_renderer::update( double const Deltatime ) {
|
|||||||
::alListenerfv( AL_ORIENTATION, reinterpret_cast<ALfloat const *>( orientation ) );
|
::alListenerfv( AL_ORIENTATION, reinterpret_cast<ALfloat const *>( orientation ) );
|
||||||
// velocity
|
// velocity
|
||||||
if( Deltatime > 0 ) {
|
if( Deltatime > 0 ) {
|
||||||
auto cameramove { glm::dvec3{ Global.pCamera.Pos - m_camerapos} };
|
auto cameramove { glm::dvec3{ cameraposition - m_camerapos} };
|
||||||
m_camerapos = Global.pCamera.Pos;
|
m_camerapos = cameraposition;
|
||||||
// intercept sudden user-induced camera jumps...
|
// intercept sudden user-induced camera jumps...
|
||||||
// ...from free fly mode change
|
// ...from free fly mode change
|
||||||
if( m_freeflymode != FreeFlyModeFlag ) {
|
if( m_freeflymode != FreeFlyModeFlag ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user