From 4923d993a7aa5204d71495192d1c7df8d674ae7c Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 7 May 2020 18:40:06 -0400 Subject: [PATCH] Factor out raytracing background color calculation --- .../3d_render_raytracing/c3d_render_createscene.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index 2fddc956d5..ab73d6bdea 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -885,6 +885,9 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa const SFVEC3F v2 = SFVEC3F( v1.x, v3.y, v1.z ); const SFVEC3F v4 = SFVEC3F( v3.x, v1.y, v1.z ); + SFVEC3F backgroundColor = + ConvertSRGBToLinear( static_cast( m_boardAdapter.m_BgColorTop ) ); + CTRIANGLE *newTriangle1 = new CTRIANGLE( v1, v2, v3 ); CTRIANGLE *newTriangle2 = new CTRIANGLE( v3, v4, v1 ); @@ -894,8 +897,8 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa newTriangle1->SetMaterial( (const CMATERIAL *)&m_materials.m_Floor ); newTriangle2->SetMaterial( (const CMATERIAL *)&m_materials.m_Floor ); - newTriangle1->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ) ); - newTriangle2->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ) ); + newTriangle1->SetColor( backgroundColor ); + newTriangle2->SetColor( backgroundColor ); // Ceiling triangles const float maxZ = glm::max( containerBBox.Max().z, @@ -915,8 +918,8 @@ void C3D_RENDER_RAYTRACING::reload( REPORTER* aStatusTextReporter, REPORTER* aWa newTriangle3->SetMaterial( (const CMATERIAL *)&m_materials.m_Floor ); newTriangle4->SetMaterial( (const CMATERIAL *)&m_materials.m_Floor ); - newTriangle3->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ) ); - newTriangle4->SetColor( ConvertSRGBToLinear( (SFVEC3F)m_boardAdapter.m_BgColorTop ) ); + newTriangle3->SetColor( backgroundColor ); + newTriangle4->SetColor( backgroundColor ); } } }