From 3f2cada6c67c3c41f75df6050db73deb2fa7e272 Mon Sep 17 00:00:00 2001 From: Mario Luzeiro Date: Fri, 4 Sep 2020 01:25:23 +0100 Subject: [PATCH] 3D-Viewer: fix a bug introduced in the previous commits --- .../3d_render_raytracing/c3d_render_createscene.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 c5772fa716..bb8eb8ba01 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 @@ -1545,9 +1545,15 @@ void C3D_RENDER_RAYTRACING::add_3D_models( CCONTAINER &aDstContainer, ((mesh.m_FaceIdxSize % 3) == 0) && (mesh.m_MaterialIdx < a3DModel->m_MaterialsSize) ) { - const CBLINN_PHONG_MATERIAL &blinn_material = (*materialVector)[mesh.m_MaterialIdx]; + float moduleTransparency; + const CBLINN_PHONG_MATERIAL *blinn_material; - const float moduleTransparency = 1.0f - ( ( 1.0f - blinn_material.GetTransparency() ) * aModuleOpacity ); + if( !aSkipMaterialInformation ) + { + blinn_material = &(*materialVector)[mesh.m_MaterialIdx]; + + moduleTransparency = 1.0f - ( ( 1.0f - blinn_material->GetTransparency() ) * aModuleOpacity ); + } // Add all face triangles for( unsigned int faceIdx = 0; @@ -1592,7 +1598,7 @@ void C3D_RENDER_RAYTRACING::add_3D_models( CCONTAINER &aDstContainer, if( !aSkipMaterialInformation ) { - newTriangle->SetMaterial( (const CMATERIAL *)&blinn_material ); + newTriangle->SetMaterial( blinn_material ); newTriangle->SetModelTransparency( moduleTransparency ); if( mesh.m_Color == NULL )