From: Thomas Debesse Date: Mon, 20 Jun 2022 02:26:13 +0000 (+0200) Subject: Merge commit 'e876e8ef487eeb9123f4906373622ffe3b6ea9d4' into master-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6080bd2e589a86c3cae2b9b4d56dda2020a21452;p=xonotic%2Fnetradiant.git Merge commit 'e876e8ef487eeb9123f4906373622ffe3b6ea9d4' into master-merge --- 6080bd2e589a86c3cae2b9b4d56dda2020a21452 diff --cc radiant/csg.cpp index f28bdc98,9de2dca2..2a59d2fe --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@@ -33,7 -46,9 +46,9 @@@ void Face_makeBrush( Face& face, const void Face_makeBrush( Face& face, const Brush& brush, brush_vector_t& out, float offset ){ if ( face.contributes() ) { out.push_back( new Brush( brush ) ); + //face.getPlane().offset( -offset ); + //face.planeChanged(); - Face* newFace = out.back()->addFace( face ); + std::shared_ptr newFace = out.back()->addFace( face ); if ( newFace != 0 ) { newFace->flipWinding(); newFace->getPlane().offset( offset ); @@@ -416,55 -450,49 +431,55 @@@ bool pre( const scene::Path& path, scen } void post( const scene::Path& path, scene::Instance& instance ) const { - if ( path.top().get().visible() ) { + if ( !path.top().get().visible() ) { + return; + } + - Brush* brush = Node_getBrush( path.top() ); + Brush* brush = Node_getBrush( path.top() ); - if ( brush != 0 - && Instance_getSelectable( instance )->isSelected() ) { + if ( brush == nullptr || !Instance_getSelectable( instance )->isSelected() ) { + return; + } + - Plane3 plane( plane3_for_points( m_p0, m_p1, m_p2 ) ); + Plane3 plane( plane3_for_points( m_p0, m_p1, m_p2 ) ); - if ( plane3_valid( plane ) ) { + if ( !plane3_valid( plane ) ) { + return; + } + - brushsplit_t split = Brush_classifyPlane( *brush, m_split == eFront ? plane3_flipped( plane ) : plane ); - if ( split.counts[ePlaneBack] && split.counts[ePlaneFront] ) { - // the plane intersects this brush - if ( m_split == eFrontAndBack ) { - NodeSmartReference node( ( new BrushNode() )->node() ); - Brush* fragment = Node_getBrush( node ); - fragment->copy( *brush ); + brushsplit_t split = Brush_classifyPlane( *brush, m_split == eFront ? plane3_flipped( plane ) : plane ); + if ( split.counts[ePlaneBack] && split.counts[ePlaneFront] ) { + // the plane intersects this brush + if ( m_split == eFrontAndBack ) { + NodeSmartReference node( ( new BrushNode() )->node() ); + Brush* fragment = Node_getBrush( node ); + fragment->copy( *brush ); - Face* newFace = fragment->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection ); + std::shared_ptr newFace = + fragment->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection ); - if ( newFace != 0 && m_split != eFront ) { - newFace->flipWinding(); - } - fragment->removeEmptyFaces(); - ASSERT_MESSAGE( !fragment->empty(), "brush left with no faces after split" ); + if ( newFace != 0 && m_split != eFront ) { + newFace->flipWinding(); + } + fragment->removeEmptyFaces(); + ASSERT_MESSAGE( !fragment->empty(), "brush left with no faces after split" ); - Node_getTraversable( path.parent() )->insert( node ); - { - scene::Path fragmentPath = path; - fragmentPath.top() = makeReference( node.get() ); - selectPath( fragmentPath, true ); - } - } + Node_getTraversable( path.parent() )->insert( node ); + { + scene::Path fragmentPath = path; + fragmentPath.top() = makeReference( node.get() ); + selectPath( fragmentPath, true ); + } + } - Face* newFace = brush->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection ); + std::shared_ptr newFace = brush->addPlane( m_p0, m_p1, m_p2, m_shader, m_projection ); - if ( newFace != 0 && m_split == eFront ) { - newFace->flipWinding(); - } - brush->removeEmptyFaces(); - ASSERT_MESSAGE( !brush->empty(), "brush left with no faces after split" ); - } - else - // the plane does not intersect this brush - if ( m_split != eFrontAndBack && split.counts[ePlaneBack] != 0 ) { - // the brush is "behind" the plane - Path_deleteTop( path ); + if ( newFace != 0 && m_split == eFront ) { + newFace->flipWinding(); + } + brush->removeEmptyFaces(); + ASSERT_MESSAGE( !brush->empty(), "brush left with no faces after split" ); + } + else + // the plane does not intersect this brush + if ( m_split != eFrontAndBack && split.counts[ePlaneBack] != 0 ) { + // the brush is "behind" the plane + Path_deleteTop( path ); - } - } - } } } };