mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
Use glm::length2 instead of glm::length where possible
This commit is contained in:
@@ -1293,7 +1293,8 @@ bool opengl33_renderer::Render_reflections(viewport_config &vp)
|
||||
|
||||
auto const timestamp{ Timer::GetRenderTime() };
|
||||
if( ( timestamp - m_environmentupdatetime < Global.reflectiontune.update_interval )
|
||||
&& ( glm::length( m_renderpass.pass_camera.position() - m_environmentupdatelocation ) < 1000.0 ) ) {
|
||||
&& ( glm::length2( m_renderpass.pass_camera.position() - m_environmentupdatelocation ) < 1000.0 * 1000.0 ) ) // length2 is better than length for comparing because it does not require sqrt function
|
||||
{
|
||||
// run update every 5+ mins of simulation time, or at least 1km from the last location
|
||||
return false;
|
||||
}
|
||||
@@ -4620,7 +4621,7 @@ void opengl33_renderer::Update_Lights(light_array &Lights)
|
||||
break;
|
||||
}
|
||||
auto const lightoffset = glm::vec3{scenelight.position - camera};
|
||||
if (glm::length(lightoffset) > 1000.f) {
|
||||
if (glm::length2(lightoffset) > 1000.f * 1000.f) {
|
||||
// we don't care about lights past arbitrary limit of 1 km.
|
||||
// but there could still be weaker lights which are closer, so keep looking
|
||||
continue;
|
||||
|
||||
@@ -892,7 +892,7 @@ opengl_renderer::Render_reflections() {
|
||||
|
||||
auto const timestamp { Timer::GetRenderTime() };
|
||||
if( ( timestamp - m_environmentupdatetime < Global.reflectiontune.update_interval )
|
||||
&& ( glm::length( m_renderpass.camera.position() - m_environmentupdatelocation ) < 1000.0 ) ) {
|
||||
&& ( glm::length2( m_renderpass.camera.position() - m_environmentupdatelocation ) < 1000.0 * 1000.0 ) ) {
|
||||
// run update every 5+ mins of simulation time, or at least 1km from the last location
|
||||
return false;
|
||||
}
|
||||
@@ -4341,7 +4341,8 @@ opengl_renderer::Update_Lights( light_array &Lights ) {
|
||||
break;
|
||||
}
|
||||
auto const lightoffset = glm::vec3{ scenelight.position - camera };
|
||||
if( glm::length( lightoffset ) > 1000.f ) {
|
||||
// length2 is better than length for comparing because it does not require sqrt function
|
||||
if( glm::length2( lightoffset ) > 1000.f * 1000.f ) {
|
||||
// we don't care about lights past arbitrary limit of 1 km.
|
||||
// but there could still be weaker lights which are closer, so keep looking
|
||||
continue;
|
||||
|
||||
@@ -70,7 +70,9 @@ basic_precipitation::update() {
|
||||
cameramove = glm::dvec3{ 0.0 };
|
||||
}
|
||||
// ... from camera jump to another location
|
||||
if( glm::length( cameramove ) > 100.0 ) {
|
||||
// length2 is better than length for comparing because it does not require sqrt function
|
||||
if( glm::length2( cameramove ) > 100.0 * 100.0 )
|
||||
{
|
||||
cameramove = glm::dvec3{ 0.0 };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user