16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 11:19:19 +02:00

minor camera refactoring, division by zero guards

This commit is contained in:
tmj-fstate
2018-08-03 16:07:50 +02:00
parent ff6bed67a9
commit ec1a625c12
20 changed files with 110 additions and 116 deletions

View File

@@ -117,7 +117,7 @@ openal_source::sync_with( sound_properties const &State ) {
::alSourcefv( id, AL_VELOCITY, glm::value_ptr( sound_velocity ) );
// location
properties.location = State.location;
sound_distance = properties.location - glm::dvec3 { Global.pCameraPosition };
sound_distance = properties.location - glm::dvec3 { Global.pCamera.Pos };
if( sound_range > 0 ) {
// range cutoff check
auto const cutoffrange = (
@@ -312,7 +312,7 @@ openal_renderer::update( double const Deltatime ) {
// update listener
// orientation
glm::dmat4 cameramatrix;
Global.pCamera->SetMatrix( cameramatrix );
Global.pCamera.SetMatrix( cameramatrix );
auto rotationmatrix { glm::mat3{ cameramatrix } };
glm::vec3 const orientation[] = {
glm::vec3{ 0, 0,-1 } * rotationmatrix ,
@@ -320,7 +320,7 @@ openal_renderer::update( double const Deltatime ) {
::alListenerfv( AL_ORIENTATION, reinterpret_cast<ALfloat const *>( orientation ) );
// velocity
if( Deltatime > 0 ) {
glm::dvec3 const listenerposition { Global.pCameraPosition };
glm::dvec3 const listenerposition { Global.pCamera.Pos };
glm::dvec3 const listenermovement { listenerposition - m_listenerposition };
m_listenerposition = listenerposition;
m_listenervelocity = (