]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/csg.cpp
Merge commit '54a2bda443aace9c00a1615af10cc1dc8b1f0cd1' into master-merge
[xonotic/netradiant.git] / radiant / csg.cpp
index b9ebfcd035402b02eafd1fc791d857cbdfad8636..5d20bf1c742b9753953e804201eee50a27109bc6 100644 (file)
@@ -34,7 +34,7 @@
 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 );
+               std::shared_ptr<Face> newFace = out.back()->addFace( face );
                face.getPlane().offset( -offset );
                face.planeChanged();
                if ( newFace != 0 ) {
@@ -50,7 +50,7 @@ void Face_extrude( Face& face, const Brush& brush, brush_vector_t& out, float of
                face.getPlane().offset( offset );
                out.push_back( new Brush( brush ) );
                face.getPlane().offset( -offset );
-               Face* newFace = out.back()->addFace( face );
+               std::shared_ptr<Face> newFace = out.back()->addFace( face );
                if ( newFace != 0 ) {
                        newFace->flipWinding();
                        newFace->planeChanged();
@@ -61,6 +61,7 @@ void Face_extrude( Face& face, const Brush& brush, brush_vector_t& out, float of
 #include "preferences.h"
 #include "texwindow.h"
 
+typedef std::vector<DoubleVector3> doublevector_vector_t;
 
 enum eHollowType
 {
@@ -84,17 +85,28 @@ class CaulkFace
 DoubleVector3 ExclusionAxis;
 double &mindot;
 double &maxdot;
+doublevector_vector_t &exclude_vec;
 public:
 CaulkFace( DoubleVector3 ExclusionAxis,
                        double &mindot,
-                       double &maxdot ):
+                       double &maxdot,
+                       doublevector_vector_t &exclude_vec ):
                        ExclusionAxis( ExclusionAxis ),
                        mindot( mindot ),
-                       maxdot( maxdot ){}
+                       maxdot( maxdot ),
+                       exclude_vec( exclude_vec ){}
 void operator()( Face& face ) const {
        double dot = vector3_dot( face.getPlane().plane3().normal(), ExclusionAxis );
-       if( dot == 0 || ( dot > mindot + 0.005 && dot < maxdot - 0.005 ) )
+       if( dot == 0 || ( dot > mindot + 0.005 && dot < maxdot - 0.005 ) ){
+               if( !exclude_vec.empty() ){
+                       for ( doublevector_vector_t::const_iterator i = exclude_vec.begin(); i != exclude_vec.end(); ++i ){
+                               if( ( *i ) == face.getPlane().plane3().normal() ){
+                                       return;
+                               }
+                       }
+               }
                face.SetShader( getCaulkShader() );
+       }
 }
 };
 
@@ -107,6 +119,7 @@ eHollowType HollowType;
 DoubleVector3 ExclusionAxis;
 double &mindot;
 double &maxdot;
+doublevector_vector_t &exclude_vec;
 bool caulk;
 bool RemoveInner;
 public:
@@ -117,6 +130,7 @@ FaceMakeBrush( const Brush& brush,
                        DoubleVector3 ExclusionAxis,
                        double &mindot,
                        double &maxdot,
+                       doublevector_vector_t &exclude_vec,
                        bool caulk,
                        bool RemoveInner )
        : brush( brush ),
@@ -126,12 +140,21 @@ FaceMakeBrush( const Brush& brush,
        ExclusionAxis( ExclusionAxis ),
        mindot( mindot ),
        maxdot( maxdot ),
+       exclude_vec( exclude_vec ),
        caulk( caulk ),
        RemoveInner( RemoveInner ){
 }
 void operator()( Face& face ) const {
        double dot = vector3_dot( face.getPlane().plane3().normal(), ExclusionAxis );
        if( dot == 0 || ( dot > mindot + 0.005 && dot < maxdot - 0.005 ) ){
+               if( !exclude_vec.empty() ){
+                       for ( doublevector_vector_t::const_iterator i = exclude_vec.begin(); i != exclude_vec.end(); ++i ){
+                               if( ( *i ) == face.getPlane().plane3().normal() ){
+                                       return;
+                               }
+                       }
+               }
+
                if( HollowType == pull ){
                        if ( face.contributes() ) {
                                face.getPlane().offset( offset );
@@ -141,9 +164,9 @@ void operator()( Face& face ) const {
                                face.planeChanged();
 
                                if( caulk ){
-                                       Brush_forEachFace( *out.back(), CaulkFace( ExclusionAxis, mindot, maxdot ) );
+                                       Brush_forEachFace( *out.back(), CaulkFace( ExclusionAxis, mindot, maxdot, exclude_vec ) );
                                }
-                               Face* newFace = out.back()->addFace( face );
+                               std::shared_ptr<Face> newFace = out.back()->addFace( face );
                                if ( newFace != 0 ) {
                                        newFace->flipWinding();
                                }
@@ -156,7 +179,7 @@ void operator()( Face& face ) const {
                                out.push_back( new Brush( brush ) );
                                if( !RemoveInner && caulk )
                                        face.SetShader( getCaulkShader() );
-                               Face* newFace = out.back()->addFace( face );
+                               std::shared_ptr<Face> newFace = out.back()->addFace( face );
                                face.getPlane().offset( -offset );
                                face.planeChanged();
                                if( caulk )
@@ -174,7 +197,7 @@ void operator()( Face& face ) const {
                                out.push_back( new Brush( brush ) );
                                out.back()->clear();
 
-                               Face* newFace = out.back()->addFace( face );
+                               std::shared_ptr<Face> newFace = out.back()->addFace( face );
                                if ( newFace != 0 ) {
                                        newFace->getPlane().offset( offset );
                                        newFace->planeChanged();
@@ -202,7 +225,7 @@ void operator()( Face& face ) const {
                                out.push_back( new Brush( brush ) );
                                out.back()->clear();
 
-                               Face* newFace = out.back()->addFace( face );
+                               std::shared_ptr<Face> newFace = out.back()->addFace( face );
                                if ( newFace != 0 ) {
 
                                        newFace->planeChanged();
@@ -273,13 +296,21 @@ float offset;
 DoubleVector3 ExclusionAxis;
 double &mindot;
 double &maxdot;
+doublevector_vector_t &exclude_vec;
 public:
-FaceOffset( float offset, DoubleVector3 ExclusionAxis, double &mindot, double &maxdot )
-       : offset( offset ), ExclusionAxis( ExclusionAxis ), mindot( mindot ), maxdot( maxdot ){
+FaceOffset( float offset, DoubleVector3 ExclusionAxis, double &mindot, double &maxdot, doublevector_vector_t &exclude_vec )
+       : offset( offset ), ExclusionAxis( ExclusionAxis ), mindot( mindot ), maxdot( maxdot ), exclude_vec( exclude_vec ){
 }
 void operator()( Face& face ) const {
        double dot = vector3_dot( face.getPlane().plane3().normal(), ExclusionAxis );
        if( dot == 0 || ( dot > mindot + 0.005 && dot < maxdot - 0.005 ) ){
+               if( !exclude_vec.empty() ){
+                       for ( doublevector_vector_t::const_iterator i = exclude_vec.begin(); i != exclude_vec.end(); ++i ){
+                               if( ( *i ) == face.getPlane().plane3().normal() ){
+                                       return;
+                               }
+                       }
+               }
                face.undoSave();
                face.getPlane().offset( offset );
                face.planeChanged();
@@ -287,6 +318,19 @@ void operator()( Face& face ) const {
 }
 };
 
+class FaceExcludeSelected
+{
+doublevector_vector_t &outvec;
+public:
+FaceExcludeSelected( doublevector_vector_t &outvec ): outvec( outvec ){
+}
+void operator()( FaceInstance& face ) const {
+       if( face.isSelected() ){
+               outvec.push_back( face.getFace().getPlane().plane3().normal() );
+       }
+}
+};
+
 
 DoubleVector3 getExclusion();
 bool getCaulk();
@@ -307,47 +351,51 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
                         && Instance_getSelectable( instance )->isSelected()
                         && path.size() > 1 ) {
                        brush_vector_t out;
+                       doublevector_vector_t exclude_vec;
                        double mindot = 0;
                        double maxdot = 0;
                        if( HollowType != room ){
                                Brush_forEachFace( *brush, FaceExclude( getExclusion(), mindot, maxdot ) );
+                               if( mindot == 0 && maxdot == 0 ){
+                                       Brush_ForEachFaceInstance( *Instance_getBrush( instance ), FaceExcludeSelected( exclude_vec ) );
+                               }
                        }
                        if( HollowType == room ){
                                Brush* tmpbrush = new Brush( *brush );
                                tmpbrush->removeEmptyFaces();
-                               Brush_forEachFace( *brush, FaceMakeBrush( *brush, out, offset, pull, DoubleVector3( 0, 0, 0 ), mindot, maxdot, true, true ) );
+                               Brush_forEachFace( *brush, FaceMakeBrush( *brush, out, offset, pull, DoubleVector3( 0, 0, 0 ), mindot, maxdot, exclude_vec, true, true ) );
                                delete tmpbrush;
                        }
                        else if( HollowType == pull ){
                                if( !getRemoveInner() && getCaulk() ){
-                                       Brush_forEachFace( *brush, CaulkFace( getExclusion(), mindot, maxdot ) );
+                                       Brush_forEachFace( *brush, CaulkFace( getExclusion(), mindot, maxdot, exclude_vec ) );
                                }
                                Brush* tmpbrush = new Brush( *brush );
                                tmpbrush->removeEmptyFaces();
-                               Brush_forEachFace( *tmpbrush, FaceMakeBrush( *tmpbrush, out, offset, HollowType, getExclusion(), mindot, maxdot, getCaulk(), getRemoveInner() ) );
+                               Brush_forEachFace( *tmpbrush, FaceMakeBrush( *tmpbrush, out, offset, HollowType, getExclusion(), mindot, maxdot, exclude_vec, getCaulk(), getRemoveInner() ) );
                                delete tmpbrush;
                        }
                        else if( HollowType == diag ){
                                Brush* tmpbrush = new Brush( *brush );
-                               Brush_forEachFace( *tmpbrush, FaceOffset( offset, getExclusion(), mindot, maxdot ) );
+                               Brush_forEachFace( *tmpbrush, FaceOffset( offset, getExclusion(), mindot, maxdot, exclude_vec ) );
                                tmpbrush->removeEmptyFaces();
-                               Brush_forEachFace( *tmpbrush, FaceMakeBrush( *brush, out, offset, HollowType, getExclusion(), mindot, maxdot, getCaulk(), getRemoveInner() ) );
+                               Brush_forEachFace( *tmpbrush, FaceMakeBrush( *brush, out, offset, HollowType, getExclusion(), mindot, maxdot, exclude_vec, getCaulk(), getRemoveInner() ) );
                                delete tmpbrush;
                                if( !getRemoveInner() && getCaulk() ){
-                                       Brush_forEachFace( *brush, CaulkFace( getExclusion(), mindot, maxdot ) );
+                                       Brush_forEachFace( *brush, CaulkFace( getExclusion(), mindot, maxdot, exclude_vec ) );
                                }
                        }
                        else{
-                               Brush_forEachFace( *brush, FaceMakeBrush( *brush, out, offset, HollowType, getExclusion(), mindot, maxdot, getCaulk(), getRemoveInner() ) );
+                               Brush_forEachFace( *brush, FaceMakeBrush( *brush, out, offset, HollowType, getExclusion(), mindot, maxdot, exclude_vec, getCaulk(), getRemoveInner() ) );
                        }
                        for ( brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i )
                        {
                                ( *i )->removeEmptyFaces();
                                if( ( *i )->hasContributingFaces() ){
-                                       NodeSmartReference node( ( new BrushNode() )->node() );
-                                       Node_getBrush( node )->copy( *( *i ) );
-                                       delete ( *i );
-                                       Node_getTraversable( path.parent() )->insert( node );
+                               NodeSmartReference node( ( new BrushNode() )->node() );
+                               Node_getBrush( node )->copy( *( *i ) );
+                               delete ( *i );
+                               Node_getTraversable( path.parent() )->insert( node );
                                        //path.push( makeReference( node.get() ) );
                                        //selectPath( path, true );
                                        //Instance_getSelectable( *GlobalSceneGraph().find( path ) )->setSelected( true );
@@ -485,15 +533,6 @@ inline Dereference<Functor> makeDereference( const Functor& functor ){
        return Dereference<Functor>( functor );
 }
 
-typedef Face* FacePointer;
-const FacePointer c_nullFacePointer = 0;
-
-template<typename Predicate>
-Face* Brush_findIf( const Brush& brush, const Predicate& predicate ){
-       Brush::const_iterator i = std::find_if( brush.begin(), brush.end(), makeDereference( predicate ) );
-       return i == brush.end() ? c_nullFacePointer : *i; // uses c_nullFacePointer instead of 0 because otherwise gcc 4.1 attempts conversion to int
-}
-
 template<typename Caller>
 class BindArguments1
 {
@@ -543,7 +582,6 @@ typedef Function<bool ( const Face &, const Plane3 &, bool ), Face_testPlane> Fa
 /// \li flipped && brush is FRONT or ON
 bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){
        brush.evaluateBRep();
-#if 1
        for ( Brush::const_iterator i( brush.begin() ); i != brush.end(); ++i )
        {
                if ( Face_testPlane( *( *i ), plane, flipped ) ) {
@@ -551,9 +589,6 @@ bool Brush_testPlane( const Brush& brush, const Plane3& plane, bool flipped ){
                }
        }
        return true;
-#else
-       return Brush_findIf( brush, bindArguments( FaceTestPlane(), makeReference( plane ), flipped ) ) == 0;
-#endif
 }
 
 brushsplit_t Brush_classifyPlane( const Brush& brush, const Plane3& plane ){
@@ -574,24 +609,24 @@ bool Brush_subtract( const Brush& brush, const Brush& other, brush_vector_t& ret
                fragments.reserve( other.size() );
                Brush back( brush );
 
-               for ( Brush::const_iterator i( other.begin() ); i != other.end(); ++i )
+               for ( const std::shared_ptr<Face>& b : other )
                {
-                       if ( ( *i )->contributes() ) {
-                               brushsplit_t split = Brush_classifyPlane( back, ( *i )->plane3() );
+                       if ( b->contributes() ) {
+                               brushsplit_t split = Brush_classifyPlane( back, b->plane3() );
                                if ( split.counts[ePlaneFront] != 0
                                         && split.counts[ePlaneBack] != 0 ) {
                                        fragments.push_back( new Brush( back ) );
-                                       Face* newFace = fragments.back()->addFace( *( *i ) );
-                                       if ( newFace != 0 ) {
+                                       std::shared_ptr<Face> newFace = fragments.back()->addFace( *b );
+                                       if ( newFace != nullptr ) {
                                                newFace->flipWinding();
                                        }
-                                       back.addFace( *( *i ) );
+                                       back.addFace( *b );
                                }
                                else if ( split.counts[ePlaneBack] == 0 ) {
-                                       for ( brush_vector_t::iterator i = fragments.begin(); i != fragments.end(); ++i )
-                                       {
-                                               delete( *i );
+                                       for ( Brush *i : fragments ) {
+                                               delete( i );
                                        }
+                                       fragments.clear();
                                        return false;
                                }
                        }
@@ -656,22 +691,19 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
                        else
                        {
                                ++m_before;
-                               for ( brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i )
-                               {
+                               for ( Brush *b : out ) {
                                        ++m_after;
-                                       ( *i )->removeEmptyFaces();
-                                       if ( !( *i )->empty() ) {
+                                       b->removeEmptyFaces();
+                                       if ( !b->empty() ) {
                                                NodeSmartReference node( ( new BrushNode() )->node() );
-                                               Node_getBrush( node )->copy( *( *i ) );
-                                               delete ( *i );
+                                               Node_getBrush( node )->copy( *b );
                                                Node_getTraversable( path.parent() )->insert( node );
                                        }
-                                       else{
-                                               delete ( *i );
-                                       }
+                                       delete b;
                                }
+                               scene::Node& parent = path.parent();
                                Path_deleteTop( path );
-                               if( Node_getTraversable( path.parent() )->empty() ){
+                               if( Node_getTraversable( parent )->empty() ){
                                        m_eraseParent = true;
                                }
                        }
@@ -694,9 +726,7 @@ void CSG_Subtract(){
 
        if ( selected_brushes.empty() ) {
                globalOutputStream() << "CSG Subtract: No brushes selected.\n";
-       }
-       else
-       {
+       } else {
                globalOutputStream() << "CSG Subtract: Subtracting " << Unsigned( selected_brushes.size() ) << " brushes.\n";
 
                UndoableCommand undo( "brushSubtract" );
@@ -731,12 +761,20 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
 }
 
 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() );
-               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 ) );
-                       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
@@ -744,7 +782,8 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
                                                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();
                                                }
@@ -759,7 +798,7 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
                                                }
                                        }
 
-                                       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();
                                        }
@@ -771,9 +810,6 @@ void post( const scene::Path& path, scene::Instance& instance ) const {
                                if ( m_split != eFrontAndBack && split.counts[ePlaneBack] != 0 ) {
                                        // the brush is "behind" the plane
                                        Path_deleteTop( path );
-                               }
-                       }
-               }
        }
 }
 };
@@ -955,26 +991,45 @@ void CSG_Merge( void ){
 #include "gtkutil/dialog.h"
 #include "gtkutil/button.h"
 #include "gtkutil/accelerator.h"
+#include "xywindow.h"
+#include "camwindow.h"
 
 struct CSGToolDialog
 {
        GtkSpinButton* spin;
        bool allocated{false};
        ui::Window window{ui::null};
-       GtkToggleButton *radXYZ, *radX, *radY, *radZ, *caulk, *removeInner;
+       GtkToggleButton *radFaces, *radProj, *radCam, *caulk, *removeInner;
 };
 
 CSGToolDialog g_csgtool_dialog;
 
 DoubleVector3 getExclusion(){
-       if( gtk_toggle_button_get_active( g_csgtool_dialog.radX ) ){
-               return DoubleVector3( 1, 0, 0 );
-       }
-       else if( gtk_toggle_button_get_active( g_csgtool_dialog.radY ) ){
-               return DoubleVector3( 0, 1, 0 );
+       if( gtk_toggle_button_get_active( g_csgtool_dialog.radProj ) ){
+               if( GlobalXYWnd_getCurrentViewType() == YZ ){
+                       return DoubleVector3( 1, 0, 0 );
+               }
+               else if( GlobalXYWnd_getCurrentViewType() == XZ ){
+                       return DoubleVector3( 0, 1, 0 );
+               }
+               else if( GlobalXYWnd_getCurrentViewType() == XY ){
+                       return DoubleVector3( 0, 0, 1 );
+               }
        }
-       else if( gtk_toggle_button_get_active( g_csgtool_dialog.radZ ) ){
-               return DoubleVector3( 0, 0, 1 );
+       if( gtk_toggle_button_get_active( g_csgtool_dialog.radCam ) ){
+               Vector3 angles( Camera_getAngles( *g_pParentWnd->GetCamWnd() ) );
+//             globalOutputStream() << angles << " angles\n";
+               DoubleVector3 radangles( degrees_to_radians( angles[0] ), degrees_to_radians( angles[1] ), degrees_to_radians( angles[2] ) );
+//             globalOutputStream() << radangles << " radangles\n";
+//             x = cos(yaw)*cos(pitch)
+//             y = sin(yaw)*cos(pitch)
+//             z = sin(pitch)
+               DoubleVector3 viewvector;
+               viewvector[0] = cos( radangles[1] ) * cos( radangles[0] );
+               viewvector[1] = sin( radangles[1] ) * cos( radangles[0] );
+               viewvector[2] = sin( radangles[0] );
+//             globalOutputStream() << viewvector << " viewvector\n";
+               return viewvector;
        }
        return DoubleVector3( 0, 0, 0 );
 }
@@ -1003,8 +1058,12 @@ BrushFaceOffset( float offset )
 void operator()( BrushInstance& brush ) const {
        double mindot = 0;
        double maxdot = 0;
+       doublevector_vector_t exclude_vec;
        Brush_forEachFace( brush, FaceExclude( getExclusion(), mindot, maxdot ) );
-       Brush_forEachFace( brush, FaceOffset( offset, getExclusion(), mindot, maxdot ) );
+       if( mindot == 0 && maxdot == 0 ){
+               Brush_ForEachFaceInstance( brush, FaceExcludeSelected( exclude_vec ) );
+       }
+       Brush_forEachFace( brush, FaceOffset( offset, getExclusion(), mindot, maxdot, exclude_vec ) );
 }
 };
 
@@ -1123,32 +1182,30 @@ void CSG_Tool(){
                                }
                                {
                                        //radio button group for choosing the exclude axis
-                                       GtkWidget* radXYZ = gtk_radio_button_new_with_label( NULL, "XYZ" );
-                                       GtkWidget* radX = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(radXYZ), "-X" );
-                                       GtkWidget* radY = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(radXYZ), "-Y" );
-                                       GtkWidget* radZ = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(radXYZ), "-Z" );
-                                       gtk_widget_show( radXYZ );
-                                       gtk_widget_show( radX );
-                                       gtk_widget_show( radY );
-                                       gtk_widget_show( radZ );
-
-                                       gtk_table_attach( table, radXYZ, 2, 3, 0, 1,
-                                                                       (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
-                                                                       (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       gtk_table_attach( table, radX, 3, 4, 0, 1,
+                                       GtkWidget* radFaces = gtk_radio_button_new_with_label( NULL, "-faces" );
+                                       gtk_widget_set_tooltip_text( radFaces, "Exclude selected faces" );
+                                       GtkWidget* radProj = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(radFaces), "-proj" );
+                                       gtk_widget_set_tooltip_text( radProj, "Exclude faces, most orthogonal to active projection" );
+                                       GtkWidget* radCam = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(radFaces), "-cam" );
+                                       gtk_widget_set_tooltip_text( radCam, "Exclude faces, most orthogonal to camera view" );
+
+                                       gtk_widget_show( radFaces );
+                                       gtk_widget_show( radProj );
+                                       gtk_widget_show( radCam );
+
+                                       gtk_table_attach( table, radFaces, 2, 3, 0, 1,
                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       gtk_table_attach( table, radY, 4, 5, 0, 1,
+                                       gtk_table_attach( table, radProj, 3, 4, 0, 1,
                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
-                                       gtk_table_attach( table, radZ, 5, 6, 0, 1,
+                                       gtk_table_attach( table, radCam, 4, 5, 0, 1,
                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 
-                                       g_csgtool_dialog.radXYZ = GTK_TOGGLE_BUTTON( radXYZ );
-                                       g_csgtool_dialog.radX = GTK_TOGGLE_BUTTON( radX );
-                                       g_csgtool_dialog.radY = GTK_TOGGLE_BUTTON( radY );
-                                       g_csgtool_dialog.radZ = GTK_TOGGLE_BUTTON( radZ );
+                                       g_csgtool_dialog.radFaces = GTK_TOGGLE_BUTTON( radFaces );
+                                       g_csgtool_dialog.radProj = GTK_TOGGLE_BUTTON( radProj );
+                                       g_csgtool_dialog.radCam = GTK_TOGGLE_BUTTON( radCam );
                                }
                                {
                                        GtkWidget* button = gtk_toggle_button_new();