]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
Merge commit '833d947959e424126907d552840203a557097e8f' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 01:57:16 +0000 (03:57 +0200)
committerThomas Debesse <dev@illwieckz.net>
Tue, 21 Jun 2022 01:57:16 +0000 (03:57 +0200)
1  2 
libs/gtkutil/cursor.cpp
radiant/brushmanip.cpp
radiant/csg.cpp
radiant/mainframe.cpp
radiant/texwindow.cpp

index e4d34b7d1607345ad734c6a362b3399969f48ae9,58d68c95e1604d210f10ffcb9b47426f41ae408a..b2e1e53e95de0f3ad9027d31018812fd5afa3b6a
@@@ -95,87 -66,17 +95,89 @@@ gboolean FreezePointer::motion_delta(ui
        Sys_GetCursorPos( widget, &current_x, &current_y );
        int dx = current_x - self->last_x;
        int dy = current_y - self->last_y;
++#if 0 // NetRadiantCustom
+       int ddx = current_x - self->center_x;
+       int ddy = current_y - self->center_y;
++#else
++      int ddx = current_x - self->recorded_x;
++      int ddy = current_y - self->recorded_y;
++#endif
        self->last_x = current_x;
        self->last_y = current_y;
        if ( dx != 0 || dy != 0 ) {
                //globalOutputStream() << "motion x: " << dx << ", y: " << dy << "\n";
- #if 0 // NetRadiantCustom
-               int ddx = current_x - self->center_x;
-               int ddy = current_y - self->center_y;
- #else
-               int ddx = current_x - self->recorded_x;
-               int ddy = current_y - self->recorded_y;
- #endif
 +#if defined(WORKAROUND_MACOS_GTK2_LAGGYPOINTER)
 +              ui::Dimensions dimensions = widget.dimensions();
 +              int window_x, window_y;
 +              int translated_x, translated_y;
 +
 +              gdk_window_get_origin( gtk_widget_get_window( widget ), &window_x, &window_y);
 +
 +              translated_x = current_x - ( window_x );
 +              translated_y = current_y - ( window_y );
 +
 +#if 0
 +              int widget_x, widget_y;
 +              gtk_widget_translate_coordinates( GTK_WIDGET( widget ), gtk_widget_get_toplevel( GTK_WIDGET( widget ) ), 0, 0, &widget_x, &widget_y);
 +
 +              globalOutputStream()
 +                      << "window_x: " << window_x
 +                      << ", window_y: " << window_y
 +                      << ", widget_x: " << widget_x
 +                      << ", widget_y: " << widget_y
 +                      << ", current x: " << current_x
 +                      << ", current_y: " << current_y
 +                      << ", translated x: " << translated_x
 +                      << ", translated_y: " << translated_y
 +                      << ", width: " << dimensions.width
 +                      << ", height: " << dimensions.height
 +                      << "\n";
 +#endif
 +
 +              if ( translated_x < 32 || translated_x > dimensions.width - 32
 +                      || translated_y < 32 || translated_y > dimensions.height - 32 ) {
 +#if 0
 +                      // Reposition the pointer to the widget center.
 +                      int reposition_x = window_x + dimensions.width / 2;
 +                      int reposition_y = window_y + dimensions.height / 2;
 +#else
 +                      // Move the pointer to the opposite side of the XY Window
 +                      // to maximize the distance that can be moved again.
 +                      int reposition_x = current_x;
 +                      int reposition_y = current_y;
 +
 +                      if ( translated_x < 32 ) {
 +                              reposition_x = window_x + dimensions.width - 32;
 +                      }
 +                      else if ( translated_x > dimensions.width - 32 ) {
 +                              reposition_x = window_x + 32;
 +                      }
 +
 +                      if ( translated_y < 32 ) {
 +                              reposition_y = window_y + dimensions.height - 32;
 +                      }
 +                      else if ( translated_y > dimensions.height - 32 ) {
 +                              reposition_y = window_y + 32;
 +                      }
 +#endif
 +
 +                      Sys_SetCursorPos( widget, reposition_x, reposition_y );
 +                      self->last_x = reposition_x;
 +                      self->last_y = reposition_y;
 +              }
 +#else
                if (ddx < -32 || ddx > 32 || ddy < -32 || ddy > 32) {
 +#if 0 // NetRadiantCustom
                        Sys_SetCursorPos( widget, self->center_x, self->center_y );
- #endif
+                       self->last_x = self->center_x;
+                       self->last_y = self->center_y;
 +#else
 +                      Sys_SetCursorPos( widget, self->recorded_x, self->recorded_y );
 +                      self->last_x = self->recorded_x;
 +                      self->last_y = self->recorded_y;
++#endif
                }
 +#endif
                self->m_function( dx, dy, event->state, self->m_data );
        }
        return FALSE;
@@@ -213,17 -96,8 +215,18 @@@ void FreezePointer::freeze_pointer(ui::
                                                                                                                 | GDK_BUTTON_RELEASE_MASK
                                                                                                                 | GDK_VISIBILITY_NOTIFY_MASK );
  
-       GdkCursor* cursor = create_blank_cursor();
 +#if defined(WORKAROUND_MACOS_GTK2_LAGGYPOINTER)
 +      /* Keep the pointer visible during the move operation.
 +      Because of a bug, it remains visible even if we give
 +      the order to hide it anyway.
 +      Other parts of the code assume the pointer is visible,
 +      so make sure it is consistently visible accross
 +      third-party updates that may fix the mouse pointer
 +      visibility issue. */
 +#else
 +#if 0 // NetRadiantCustom
+       //GdkCursor* cursor = create_blank_cursor();
+       GdkCursor* cursor = gdk_cursor_new( GDK_BLANK_CURSOR );
        //GdkGrabStatus status =
        /*      fixes cursor runaways during srsly quick drags in camera
        drags with pressed buttons have no problem at all w/o this      */
@@@ -271,21 -135,9 +274,21 @@@ void FreezePointer::unfreeze_pointer(ui
        m_function = 0;
        m_data = 0;
  
- //    Sys_SetCursorPos( widget, center_x, center_y );
 +#if defined(WORKAROUND_MACOS_GTK2_LAGGYPOINTER)
 +      /* The pointer was visible during all the move operation,
 +      so, keep the current position. */
 +#else
 +      // NetRadiantCustom still uses window instead of widget.
 +#if 0 // NetRadiantCustom
+       Sys_SetCursorPos( window, recorded_x, recorded_y );
 +#else
 +      Sys_SetCursorPos( widget, recorded_x, recorded_y );
 +#endif
 +#endif
  
+ //    gdk_window_set_cursor( GTK_WIDGET( window )->window, 0 );
        gdk_pointer_ungrab( GDK_CURRENT_TIME );
 +#if 0 // NetRadiantCustom
        gtk_grab_remove( weedjet );
 +#endif
  }
Simple merge
diff --cc radiant/csg.cpp
index c459804a549c3636b244eebfb0603fd05dadf085,4ecbf5cc10d6f2ddde4b00c6c2c685e67d1f0000..c034095df43d925e16d69461fb9be8f4bb3bf1e6
@@@ -63,18 -103,167 +103,167 @@@ class FaceMakeBrus
  const Brush& brush;
  brush_vector_t& out;
  float offset;
- bool room;
+ eHollowType HollowType;
+ DoubleVector3 ExclusionAxis;
+ double &mindot;
+ double &maxdot;
+ bool caulk;
+ bool RemoveInner;
  public:
- FaceMakeBrush( const Brush& brush, brush_vector_t& out, float offset, bool room )
-       : brush( brush ), out( out ), offset( offset ), room( room ){
+ FaceMakeBrush( const Brush& brush,
+                       brush_vector_t& out,
+                       float offset,
+                       eHollowType HollowType,
+                       DoubleVector3 ExclusionAxis,
+                       double &mindot,
+                       double &maxdot,
+                       bool caulk,
+                       bool RemoveInner )
+       : brush( brush ),
+       out( out ),
+       offset( offset ),
+       HollowType( HollowType ),
+       ExclusionAxis( ExclusionAxis ),
+       mindot( mindot ),
+       maxdot( maxdot ),
+       caulk( caulk ),
+       RemoveInner( RemoveInner ){
  }
  void operator()( Face& face ) const {
-       if( room ){
-               Face_extrude( face, brush, out, offset );
+       double dot = vector3_dot( face.getPlane().plane3().normal(), ExclusionAxis );
+       if( dot == 0 || ( dot > mindot + 0.005 && dot < maxdot - 0.005 ) ){
+               if( HollowType == pull ){
+                       if ( face.contributes() ) {
+                               face.getPlane().offset( offset );
+                               face.planeChanged();
+                               out.push_back( new Brush( brush ) );
+                               face.getPlane().offset( -offset );
+                               face.planeChanged();
+                               if( caulk ){
+                                       Brush_forEachFace( *out.back(), CaulkFace( ExclusionAxis, mindot, maxdot ) );
+                               }
 -                              Face* newFace = out.back()->addFace( face );
++                              std::shared_ptr<Face> newFace = out.back()->addFace( face );
+                               if ( newFace != 0 ) {
+                                       newFace->flipWinding();
+                               }
+                       }
+               }
+               else if( HollowType == wrap ){
+                       //Face_makeBrush( face, brush, out, offset );
+                       if ( face.contributes() ) {
+                               face.undoSave();
+                               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 )
+                                       face.SetShader( getCaulkShader() );
+                               if ( newFace != 0 ) {
+                                       newFace->flipWinding();
+                                       newFace->getPlane().offset( offset );
+                                       newFace->planeChanged();
+                               }
+                       }
+               }
+               else if( HollowType == extrude ){
+                       if ( face.contributes() ) {
+                               //face.undoSave();
+                               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();
+                               }
+                               if( !RemoveInner && caulk )
+                                       face.SetShader( getCaulkShader() );
+                               newFace = out.back()->addFace( face );
+                               if ( newFace != 0 ) {
+                                       newFace->flipWinding();
+                               }
+                               Winding& winding = face.getWinding();
+                               TextureProjection projection;
+                               TexDef_Construct_Default( projection );
+                               for ( Winding::iterator j = winding.begin(); j != winding.end(); ++j ){
+                                       std::size_t index = std::distance( winding.begin(), j );
+                                       std::size_t next = Winding_next( winding, index );
+                                       out.back()->addPlane( winding[index].vertex, winding[next].vertex, winding[next].vertex + face.getPlane().plane3().normal() * offset, TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), projection );
+                               }
+                       }
+               }
+               else if( HollowType == diag ){
+                       if ( face.contributes() ) {
+                               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();
+                               }
+                               newFace = out.back()->addFace( face );
+                               if ( newFace != 0 ) {
+                                       if( !RemoveInner && caulk )
+                                               newFace->SetShader( getCaulkShader() );
+                                       newFace->flipWinding();
+                                       newFace->getPlane().offset( offset );
+                                       newFace->planeChanged();
+                               }
+                               Winding& winding = face.getWinding();
+                               TextureProjection projection;
+                               TexDef_Construct_Default( projection );
+                               for ( Winding::iterator i = winding.begin(); i != winding.end(); ++i ){
+                                       std::size_t index = std::distance( winding.begin(), i );
+                                       std::size_t next = Winding_next( winding, index );
+                                       Vector3 BestPoint;
+                                       float bestdist = 999999;
+                                       for( Brush::const_iterator j = brush.begin(); j != brush.end(); ++j ){
+                                               Winding& winding2 = ( *j )->getWinding();
+                                               for ( Winding::iterator k = winding2.begin(); k != winding2.end(); ++k ){
+                                                       std::size_t index2 = std::distance( winding2.begin(), k );
+                                                       float testdist = vector3_length( winding[index].vertex - winding2[index2].vertex );
+                                                       if( testdist < bestdist ){
+                                                               bestdist = testdist;
+                                                               BestPoint = winding2[index2].vertex;
+                                                       }
+                                               }
+                                       }
+                                       out.back()->addPlane( winding[next].vertex, winding[index].vertex, BestPoint, caulk? getCaulkShader() : TextureBrowser_GetSelectedShader( GlobalTextureBrowser() ), projection );
+                               }
+                       }
+               }
        }
-       else{
-               Face_makeBrush( face, brush, out, offset );
  }
+ };
+ class FaceExclude
+ {
+ DoubleVector3 ExclusionAxis;
+ double &mindot;
+ double &maxdot;
+ public:
+ FaceExclude( DoubleVector3 ExclusionAxis, double &mindot, double &maxdot )
+       : ExclusionAxis( ExclusionAxis ), mindot( mindot ), maxdot( maxdot ){
+ }
+ void operator()( Face& face ) const {
+       if( vector3_length_squared( ExclusionAxis ) != 0 ){
+               double dot = vector3_dot( face.getPlane().plane3().normal(), ExclusionAxis );
+               if( dot < mindot ){
+                       mindot = dot;
+               }
+               else if( dot > maxdot ){
+                       maxdot = dot;
+               }
+       }
  }
  };
  
@@@ -101,10 -343,16 +343,16 @@@ bool pre( const scene::Path& path, scen
                        for ( brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i )
                        {
                                ( *i )->removeEmptyFaces();
 -                                      NodeSmartReference node( ( new BrushNode() )->node() );
 -                                      Node_getBrush( node )->copy( *( *i ) );
 -                                      delete ( *i );
 -                                      Node_getTraversable( path.parent() )->insert( node );
+                               if( ( *i )->hasContributingFaces() ){
 +                              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 );
+                                       //Path_deleteTop( path );
+                               }
                        }
                }
        }
Simple merge
Simple merge