- if ( path.top().get().visible() ) {
- Brush* brush = Node_getBrush( path.top() );
- if ( brush != 0
- && Instance_getSelectable( instance )->isSelected() ) {
- Plane3 plane( plane3_for_points( m_p0, m_p1, m_p2 ) );
- if ( plane3_valid( plane ) ) {
- 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 );
- std::shared_ptr<Face> 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" );