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

Use glm::length2 instead of glm::length where possible

This commit is contained in:
docentYT
2026-04-27 23:27:08 +02:00
parent 7d561f8443
commit cba106e22e
9 changed files with 34 additions and 21 deletions

View File

@@ -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;