void Face_makeBrush( Face& face, const Brush& brush, brush_vector_t& out, float offset ){
if ( face.contributes() ) {
out.push_back( new Brush( brush ) );
- Face* newFace = out.back()->addFace( face );
+ //face.getPlane().offset( -offset );
+ //face.planeChanged();
+ std::shared_ptr<Face> newFace = out.back()->addFace( face );
if ( newFace != 0 ) {
newFace->flipWinding();
newFace->getPlane().offset( offset );
}
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<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" );
+ 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<Face> 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 );
- }
- }
- }
}
}
};