diff --git a/3d-viewer/3d_rendering/raytracing/render_3d_raytrace_base.cpp b/3d-viewer/3d_rendering/raytracing/render_3d_raytrace_base.cpp index 8bd271cc51..aad8fc8a32 100644 --- a/3d-viewer/3d_rendering/raytracing/render_3d_raytrace_base.cpp +++ b/3d-viewer/3d_rendering/raytracing/render_3d_raytrace_base.cpp @@ -396,44 +396,18 @@ void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY, unsigned int nodex1y1 = 0; - if( ( x < ( RAYPACKET_DIM - 1 ) ) && ( y < ( RAYPACKET_DIM - 1 ) ) - && idx1y1 < RAYPACKET_RAYS_PER_PACKET ) - nodex1y1 = aHitPck_X0Y0[idx1y1].m_HitInfo.m_acc_node_info; - - // If all notes are equal we assume there was no change on the object hits. - if( ( ( nodex0y0 == nodex1y0 ) || ( nodex1y0 == 0 ) ) - && ( ( nodex0y0 == nodex0y1 ) || ( nodex0y1 == 0 ) ) - && ( ( nodex0y0 == nodex1y1 ) || ( nodex1y1 == 0 ) ) - && ( nodex0y0 == node_AA_x0y0 ) ) + if( ( x < ( RAYPACKET_DIM - 1 ) ) + && ( y < ( RAYPACKET_DIM - 1 ) ) + && idx1y1 < RAYPACKET_RAYS_PER_PACKET ) { - /// @todo Either get rid of the if statement above or do something with the - /// commented out code below. - // Option 1 - // This option will give a very good quality on reflections (slow) - /* - if( m_accelerator->Intersect( rayAA, hitAA, nodex0y0 ) ) - { - aOutHitColor[i] += shadeHit( aBgColorY[y], rayAA, hitAA, false, 0 ); - } - else - { - if( m_accelerator->Intersect( rayAA, hitAA ) ) - aOutHitColor[i] += shadeHit( aBgColorY[y], rayAA, hitAA, false, 0 ); - else - aOutHitColor[i] += hitColor[i]; - } - */ - - // Option 2 - // Trace again with the same node, - // then if miss just give the same color as before - //if( m_accelerator->Intersect( rayAA, hitAA, nodex0y0 ) ) - // aOutHitColor[i] += shadeHit( aBgColorY[y], rayAA, hitAA, false, 0 ); - - // Option 3 - // Use same color + nodex1y1 = aHitPck_X0Y0[idx1y1].m_HitInfo.m_acc_node_info; } - else + + // If all nodes are equal we assume there was no change on the object hits. + if( ( nodex0y0 != nodex1y0 && nodex1y0 != 0 ) + || ( nodex0y0 != nodex0y1 && nodex0y1 != 0 ) + || ( nodex0y0 != nodex1y1 && nodex1y1 != 0 ) + || ( nodex0y0 != node_AA_x0y0 ) ) { // Try to intersect the different nodes // It tests the possible combination of hitted or not hitted points @@ -442,26 +416,40 @@ void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY, if( nodex0y0 != 0 ) hitted |= m_accelerator->Intersect( rayAA, hitAA, nodex0y0 ); - if( ( nodex1y0 != 0 ) && ( nodex0y0 != nodex1y0 ) ) + if( nodex1y0 != 0 + && nodex0y0 != nodex1y0 ) + { hitted |= m_accelerator->Intersect( rayAA, hitAA, nodex1y0 ); + } - if( ( nodex0y1 != 0 ) && ( nodex0y0 != nodex0y1 ) && ( nodex1y0 != nodex0y1 ) ) + if( nodex0y1 != 0 + && nodex0y0 != nodex0y1 + && nodex1y0 != nodex0y1 ) + { hitted |= m_accelerator->Intersect( rayAA, hitAA, nodex0y1 ); + } - if( ( nodex1y1 != 0 ) && ( nodex0y0 != nodex1y1 ) && ( nodex0y1 != nodex1y1 ) && - ( nodex1y0 != nodex1y1 ) ) + if( nodex1y1 != 0 + && nodex0y0 != nodex1y1 + && nodex0y1 != nodex1y1 + && nodex1y0 != nodex1y1 ) + { hitted |= m_accelerator->Intersect( rayAA, hitAA, nodex1y1 ); + } - if( (node_AA_x0y0 != 0 ) && ( nodex0y0 != node_AA_x0y0 ) && - ( nodex0y1 != node_AA_x0y0 ) && ( nodex1y0 != node_AA_x0y0 ) && - ( nodex1y1 != node_AA_x0y0 ) ) + if( node_AA_x0y0 != 0 + && nodex0y0 != node_AA_x0y0 + && nodex0y1 != node_AA_x0y0 + && nodex1y0 != node_AA_x0y0 + && nodex1y1 != node_AA_x0y0 ) + { hitted |= m_accelerator->Intersect( rayAA, hitAA, node_AA_x0y0 ); + } if( hitted ) { // If we got any result, shade it - aOutHitColor[i] = shadeHit( aBgColorY[y], rayAA, hitAA, false, 0, - is_testShadow ); + aOutHitColor[i] = shadeHit( aBgColorY[y], rayAA, hitAA, false, 0, is_testShadow ); } else { @@ -470,8 +458,7 @@ void RENDER_3D_RAYTRACE_BASE::renderAntiAliasPackets( const SFVEC4F* aBgColorY, // It was missed the 'last nodes' so, trace a ray from the beginning if( m_accelerator->Intersect( rayAA, hitAA ) ) - aOutHitColor[i] = shadeHit( aBgColorY[y], rayAA, hitAA, false, 0, - is_testShadow ); + aOutHitColor[i] = shadeHit( aBgColorY[y], rayAA, hitAA, false, 0, is_testShadow ); } } } @@ -1433,10 +1420,7 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a const SFVEC4F diffuseColorObj = SFVEC4F( aHitInfo.pHitObject->GetDiffuseColor( aHitInfo ), 1.0f ); -#if USE_EXPERIMENTAL_SOFT_SHADOWS - bool is_aa_enabled = m_boardAdapter.m_Cfg->m_Render.raytrace_anti_aliasing && !m_isPreview; -#endif - + bool is_aa_enabled = m_boardAdapter.m_Cfg->m_Render.raytrace_anti_aliasing && !m_isPreview; float shadow_att_factor_sum = 0.0f; unsigned int nr_lights_that_can_cast_shadows = 0; @@ -1460,11 +1444,10 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a if( is_testShadow && light->GetCastShadows() ) { nr_lights_that_can_cast_shadows++; -#if USE_EXPERIMENTAL_SOFT_SHADOWS + // For rays that are recursive, just calculate one hit shadow if( aRecursiveLevel > 0 ) { -#endif RAY rayToLight; rayToLight.Init( hitPoint, vectorToLight ); @@ -1473,7 +1456,6 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a if( m_accelerator->IntersectP( rayToLight, distToLight ) ) shadow_att_factor_light = 0.0f; -#if USE_EXPERIMENTAL_SOFT_SHADOWS } else // Experimental softshadow calculation { @@ -1499,16 +1481,11 @@ SFVEC4F RENDER_3D_RAYTRACE_BASE::shadeHit( const SFVEC4F& aBgColor, const RAY& a rayToLight.Init( hitPoint, disturbed_vector_to_light ); } - // !TODO: there are multiple ways that this tests can be - // optimized. Eg: by packing rays or to test against the - // latest hit object. if( m_accelerator->IntersectP( rayToLight, distToLight ) ) - { shadow_att_factor_light -= shadow_inc_factor; - } } } -#endif + shadow_att_factor_sum += shadow_att_factor_light; } diff --git a/3d-viewer/3d_rendering/raytracing/shapes2D/layer_item_2d.cpp b/3d-viewer/3d_rendering/raytracing/shapes2D/layer_item_2d.cpp index 45c0a90e5c..7504d4e223 100644 --- a/3d-viewer/3d_rendering/raytracing/shapes2D/layer_item_2d.cpp +++ b/3d-viewer/3d_rendering/raytracing/shapes2D/layer_item_2d.cpp @@ -63,8 +63,6 @@ LAYER_ITEM_2D::~LAYER_ITEM_2D() bool LAYER_ITEM_2D::Intersects( const BBOX_2D& aBBox ) const { return m_bbox.Intersects( aBBox ); - // !TODO: improve this implementation - //return false; } diff --git a/common/font/stroke_font.cpp b/common/font/stroke_font.cpp index 10ebcb5801..8f64ccf14e 100644 --- a/common/font/stroke_font.cpp +++ b/common/font/stroke_font.cpp @@ -72,7 +72,7 @@ STROKE_FONT* STROKE_FONT::LoadFont( const wxString& aFontName ) } else { - // FONT TODO: support for other stroke fonts? + // If we ever supported other stroke fonts, the code would go here. return nullptr; } }