]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
various: readability improvements
authorAntoine Fontaine <antoine.fontaine@epfl.ch>
Sun, 28 Mar 2021 15:03:10 +0000 (17:03 +0200)
committerAntoine Fontaine <antoine.fontaine@epfl.ch>
Mon, 3 May 2021 23:03:43 +0000 (01:03 +0200)
radiant/camwindow.cpp
radiant/csg.cpp

index f157b87e2bd811cfe997a7b6f0284bb6449f08b3..fb05ae0f0603d4f67f4ce9eab97da361d4dc435c 100644 (file)
@@ -1361,9 +1361,11 @@ void PopState(){
        m_state_stack.pop_back();
 }
 void Highlight( EHighlightMode mode, bool bEnable = true ){
-       ( bEnable )
-       ? m_state_stack.back().m_highlight |= mode
-                                                                                 : m_state_stack.back().m_highlight &= ~mode;
+       if ( bEnable ) {
+               m_state_stack.back().m_highlight |= mode;
+       } else {
+               m_state_stack.back().m_highlight &= ~mode;
+       }
 }
 void setLights( const LightList& lights ){
        m_state_stack.back().m_lights = &lights;
@@ -1586,7 +1588,7 @@ void CamWnd::BenchMark(){
                Vector3 angles;
                angles[CAMERA_ROLL] = 0;
                angles[CAMERA_PITCH] = 0;
-               angles[CAMERA_YAW] = static_cast<float>( i * ( 360.0 / 100.0 ) );
+               angles[CAMERA_YAW] = i * 360.0f / 100.0f;
                Camera_setAngles( *this, angles );
        }
        double dEnd = Sys_DoubleTime();
@@ -1602,7 +1604,7 @@ void GlobalCamera_ResetAngles(){
        CamWnd& camwnd = *g_camwnd;
        Vector3 angles;
        angles[CAMERA_ROLL] = angles[CAMERA_PITCH] = 0;
-       angles[CAMERA_YAW] = static_cast<float>( 22.5 * floor( ( Camera_getAngles( camwnd )[CAMERA_YAW] + 11 ) / 22.5 ) );
+       angles[CAMERA_YAW] = 22.5f * floorf( ( Camera_getAngles( camwnd )[CAMERA_YAW] + 11 ) / 22.5f );
        Camera_setAngles( camwnd, angles );
 }
 
index 337b394176b80d0ffa08d06a038e46131d9c6c5c..f28bdc98d202d0465f8bac6654f4e05b2abbfe4b 100644 (file)
@@ -358,19 +358,15 @@ 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;
                                }
                                Path_deleteTop( path );
                        }
@@ -385,9 +381,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" );
@@ -422,50 +416,55 @@ 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() ) {
-               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" );
+       if ( !path.top().get().visible() ) {
+               return;
+       }
 
-                                               Node_getTraversable( path.parent() )->insert( node );
-                                               {
-                                                       scene::Path fragmentPath = path;
-                                                       fragmentPath.top() = makeReference( node.get() );
-                                                       selectPath( fragmentPath, true );
-                                               }
-                                       }
+       Brush* brush = Node_getBrush( path.top() );
+       if ( brush == nullptr || !Instance_getSelectable( instance )->isSelected() ) {
+               return;
+       }
 
-                                       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 );
-                               }
+       Plane3 plane( plane3_for_points( m_p0, m_p1, m_p2 ) );
+       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 );
+                       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" );
+
+                       Node_getTraversable( path.parent() )->insert( node );
+                       {
+                               scene::Path fragmentPath = path;
+                               fragmentPath.top() = makeReference( node.get() );
+                               selectPath( fragmentPath, true );
+                       }
+               }
+
+               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 );
        }
 }
 };