mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 01:59:19 +02:00
Use the sq function to force constexpr expressions for numeric literals and enhance readability
This commit is contained in:
@@ -150,7 +150,7 @@ openal_source::sync_with( sound_properties const &State ) {
|
||||
is_multipart ?
|
||||
EU07_SOUND_CUTOFFRANGE : // we keep multi-part sounds around longer, to minimize restarts as the sounds get out and back in range
|
||||
sound_range * 7.5f );
|
||||
if( glm::length2( sound_distance ) > std::min( ( cutoffrange * cutoffrange ), ( EU07_SOUND_CUTOFFRANGE * EU07_SOUND_CUTOFFRANGE ) ) ) {
|
||||
if( glm::length2( sound_distance ) > std::min( sq(cutoffrange), sq(EU07_SOUND_CUTOFFRANGE) ) ) {
|
||||
stop();
|
||||
sync = sync_state::bad_distance; // flag sync failure for the controller
|
||||
return;
|
||||
@@ -406,7 +406,7 @@ openal_renderer::update( double const Deltatime ) {
|
||||
cameramove = glm::dvec3{ 0.0 };
|
||||
}
|
||||
// ... from camera jump to another location
|
||||
if( glm::length2( cameramove ) > 100.0 * 100.0) { // length2 is better than length for comparing because it does not require sqrt function
|
||||
if( glm::length2( cameramove ) > sq(100.0)) { // length2 is better than length for comparing because it does not require sqrt function
|
||||
cameramove = glm::dvec3{ 0.0 };
|
||||
}
|
||||
m_listenervelocity = limit_velocity( cameramove / Deltatime );
|
||||
|
||||
@@ -363,7 +363,7 @@ sound_source::play( int const Flags ) {
|
||||
|
||||
if( m_range != -1 ) {
|
||||
auto const cutoffrange { std::abs( m_range * 5 ) };
|
||||
if( glm::length2( location() - Global.pCamera.Pos ) > std::min( 2750.f * 2750.f, cutoffrange * cutoffrange ) ) {
|
||||
if( glm::length2( location() - Global.pCamera.Pos ) > std::min( sq(2750.f), sq(cutoffrange) ) ) {
|
||||
// while we drop sounds from beyond sensible and/or audible range
|
||||
// we act as if it was activated normally, meaning no need to include the opening bookend in subsequent calls
|
||||
m_playbeginning = false;
|
||||
|
||||
Reference in New Issue
Block a user