]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '9fed37bae007bd5e53963ec67e925381609a2980' into garux-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 11 Feb 2019 05:17:07 +0000 (06:17 +0100)
committerThomas Debesse <dev@illwieckz.net>
Mon, 11 Feb 2019 06:00:11 +0000 (07:00 +0100)
20 files changed:
1  2 
radiant/brush.h
radiant/brush_primit.cpp
radiant/brushmanip.cpp
radiant/brushmanip.h
radiant/camwindow.cpp
radiant/mainframe.cpp
radiant/select.cpp
radiant/surfacedialog.cpp
tools/quake3/q3map2/bsp.c
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/map.c
tools/quake3/q3map2/model.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/shaders.c
tools/quake3/q3map2/surface.c
tools/quake3/q3map2/vis.c

diff --cc radiant/brush.h
Simple merge
Simple merge
index fc3054e1516d6e308656587e729fadb3b523143f,79b8465737736096f5ecccded5fc6df5d9e00951..900e78b9b506c0c1ebdbc3594a6b4f539acd1ecc
@@@ -555,10 -620,41 +555,32 @@@ void Scene_BrushFindReplaceShader_Compo
  }
  
  
 -class FaceFitTexture
 -{
 -float m_s_repeat, m_t_repeat;
 -public:
 -FaceFitTexture( float s_repeat, float t_repeat ) : m_s_repeat( s_repeat ), m_t_repeat( t_repeat ){
 -}
 -void operator()( Face& face ) const {
 -      face.FitTexture( m_s_repeat, m_t_repeat );
 -}
 -};
 -
+ class FaceFitTextureW
+ {
+ float m_s_repeat, m_t_repeat;
+ public:
+ FaceFitTextureW( float s_repeat, float t_repeat ) : m_s_repeat( s_repeat ), m_t_repeat( t_repeat ){
+ }
+ void operator()( Face& face ) const {
+       face.FitTextureW( m_s_repeat, m_t_repeat );
+ }
+ };
+ class FaceFitTextureH
+ {
+ float m_s_repeat, m_t_repeat;
+ public:
+ FaceFitTextureH( float s_repeat, float t_repeat ) : m_s_repeat( s_repeat ), m_t_repeat( t_repeat ){
+ }
+ void operator()( Face& face ) const {
+       face.FitTextureH( m_s_repeat, m_t_repeat );
+ }
+ };
  void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat ){
 -      Scene_ForEachSelectedBrush_ForEachFace( graph, FaceFitTexture( s_repeat, t_repeat ) );
 +      Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
 +              face.FitTexture(s_repeat, t_repeat);
 +      });
        SceneChangeNotify();
  }
  
@@@ -569,8 -663,27 +591,28 @@@ void Scene_BrushFitTexture_Component_Se
        SceneChangeNotify();
  }
  
+ void Scene_BrushFitTexture_SelectedW( scene::Graph& graph, float s_repeat, float t_repeat ){
+       Scene_ForEachSelectedBrush_ForEachFace( graph, FaceFitTextureW( s_repeat, t_repeat ) );
+       SceneChangeNotify();
+ }
+ void Scene_BrushFitTexture_Component_SelectedW( scene::Graph& graph, float s_repeat, float t_repeat ){
+       Scene_ForEachSelectedBrushFace( graph, FaceFitTextureW( s_repeat, t_repeat ) );
+       SceneChangeNotify();
+ }
+ void Scene_BrushFitTexture_SelectedH( scene::Graph& graph, float s_repeat, float t_repeat ){
+       Scene_ForEachSelectedBrush_ForEachFace( graph, FaceFitTextureH( s_repeat, t_repeat ) );
+       SceneChangeNotify();
+ }
+ void Scene_BrushFitTexture_Component_SelectedH( scene::Graph& graph, float s_repeat, float t_repeat ){
+       Scene_ForEachSelectedBrushFace( graph, FaceFitTextureH( s_repeat, t_repeat ) );
+       SceneChangeNotify();
+ }
  TextureProjection g_defaultTextureProjection;
 +
  const TextureProjection& TextureTransform_getDefault(){
        TexDef_Construct_Default( g_defaultTextureProjection );
        return g_defaultTextureProjection;
@@@ -634,23 -746,44 +676,23 @@@ void Scene_BrushSelectByShader( scene::
        graph.traverse( BrushSelectByShaderWalker( name ) );
  }
  
 -class FaceSelectByShader
 -{
 -const char* m_name;
 -public:
 -FaceSelectByShader( const char* name )
 -      : m_name( name ){
 -}
 -void operator()( FaceInstance& face ) const {
 -      printf( "checking %s = %s\n", face.getFace().GetShader(), m_name );
 -      if ( shader_equal( face.getFace().GetShader(), m_name ) ) {
 -              face.setSelected( SelectionSystem::eFace, true );
 -      }
 -}
 -};
 -
  void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name ){
 -      Scene_ForEachSelectedBrush_ForEachFaceInstance( graph, FaceSelectByShader( name ) );
 -}
 -
 -class FaceGetTexdef
 -{
 -TextureProjection& m_projection;
 -mutable bool m_done;
 -public:
 -FaceGetTexdef( TextureProjection& projection )
 -      : m_projection( projection ), m_done( false ){
 -}
 -void operator()( Face& face ) const {
 -      if ( !m_done ) {
 -              m_done = true;
 -              face.GetTexdef( m_projection );
 +      Scene_ForEachSelectedBrush_ForEachFaceInstance(graph, [&](FaceInstance &face) {
 +              printf("checking %s = %s\n", face.getFace().GetShader(), name);
 +              if (shader_equal(face.getFace().GetShader(), name)) {
-                       face.setSelected(SelectionSystem::eFace, true);
-               }
++              face.setSelected( SelectionSystem::eFace, true );
+       }
 +      });
  }
 -};
 -
  
  void Scene_BrushGetTexdef_Selected( scene::Graph& graph, TextureProjection& projection ){
 -      Scene_ForEachSelectedBrush_ForEachFace( graph, FaceGetTexdef( projection ) );
 +      bool done = false;
 +      Scene_ForEachSelectedBrush_ForEachFace(graph, [&](Face &face) {
 +              if (!done) {
 +                      done = true;
 +                      face.GetTexdef(projection);
-               }
++}
 +      });
  }
  
  void Scene_BrushGetTexdef_Component_Selected( scene::Graph& graph, TextureProjection& projection ){
@@@ -1243,15 -1409,15 +1285,15 @@@ void Brush_registerCommands()
        GlobalCommands_insert( "Brush8Sided", BrushMakeSided::SetCaller( g_brushmakesided8 ), Accelerator( '8', (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "Brush9Sided", BrushMakeSided::SetCaller( g_brushmakesided9 ), Accelerator( '9', (GdkModifierType)GDK_CONTROL_MASK ) );
  
 -      GlobalCommands_insert( "ClipSelected", FreeCaller<ClipSelected>(), Accelerator( GDK_Return ) );
 -      GlobalCommands_insert( "SplitSelected", FreeCaller<SplitSelected>(), Accelerator( GDK_Return, (GdkModifierType)GDK_SHIFT_MASK ) );
 -      GlobalCommands_insert( "FlipClip", FreeCaller<FlipClipper>(), Accelerator( GDK_Return, (GdkModifierType)GDK_CONTROL_MASK ) );
 +      GlobalCommands_insert( "ClipSelected", makeCallbackF(ClipSelected), Accelerator( GDK_KEY_Return ) );
 +      GlobalCommands_insert( "SplitSelected", makeCallbackF(SplitSelected), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_SHIFT_MASK ) );
 +      GlobalCommands_insert( "FlipClip", makeCallbackF(FlipClipper), Accelerator( GDK_KEY_Return, (GdkModifierType)GDK_CONTROL_MASK ) );
  
-       GlobalCommands_insert( "MakeDetail", makeCallbackF(Select_MakeDetail), Accelerator( 'M', (GdkModifierType)GDK_CONTROL_MASK ) );
 -      GlobalCommands_insert( "MakeDetail", FreeCaller<Select_MakeDetail>(), Accelerator( 'D', (GdkModifierType)GDK_MOD1_MASK ) );
 -      GlobalCommands_insert( "MakeStructural", FreeCaller<Select_MakeStructural>(), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
++      GlobalCommands_insert( "MakeDetail", makeCallbackF(Select_MakeDetail), Accelerator( 'D', (GdkModifierType)GDK_MOD1_MASK ) );
 +      GlobalCommands_insert( "MakeStructural", makeCallbackF(Select_MakeStructural), Accelerator( 'S', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
  }
  
 -void Brush_constructMenu( GtkMenu* menu ){
 +void Brush_constructMenu( ui::Menu menu ){
        create_menu_item_with_mnemonic( menu, "Prism...", "BrushPrism" );
        create_menu_item_with_mnemonic( menu, "Cone...", "BrushCone" );
        create_menu_item_with_mnemonic( menu, "Sphere...", "BrushSphere" );
index 5a1f62b00cd060894501d61753ecafb602427d5e,f26e68abb4cd0c79509dd3e90205a070929cc960..ac34e45528215e1280e1ebd45e9bb28cb327048a
@@@ -71,10 -70,15 +71,14 @@@ void Scene_BrushSelectByShader( scene::
  void Scene_BrushSelectByShader_Component( scene::Graph& graph, const char* name );
  void Scene_BrushFitTexture_Selected( scene::Graph& graph, float s_repeat, float t_repeat );
  void Scene_BrushFitTexture_Component_Selected( scene::Graph& graph, float s_repeat, float t_repeat );
+ void Scene_BrushFitTexture_SelectedW( scene::Graph& graph, float s_repeat, float t_repeat );
+ void Scene_BrushFitTexture_Component_SelectedW( scene::Graph& graph, float s_repeat, float t_repeat );
+ void Scene_BrushFitTexture_SelectedH( scene::Graph& graph, float s_repeat, float t_repeat );
+ void Scene_BrushFitTexture_Component_SelectedH( scene::Graph& graph, float s_repeat, float t_repeat );
  
 -typedef struct _GtkMenu GtkMenu;
 -void Brush_constructMenu( GtkMenu* menu );
 +void Brush_constructMenu( ui::Menu menu );
  
 -extern Callback g_texture_lock_status_changed;
 +extern Callback<void()> g_texture_lock_status_changed;
  
  void BrushFilters_construct();
  void Brush_registerCommands();
index 04110ee7ab11f13fca10b49e36c77857ee31fe50,3d0c6a51880b8e886eeeb1e673a470ec695298cb..fb9a2a7f3e1ba27683a1827b260f4cbb0f441117
@@@ -908,48 -913,48 +908,48 @@@ void KeyEvent_disconnect( const char* n
  }
  
  void CamWnd_registerCommands( CamWnd& camwnd ){
 -      GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_Up ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveForward_KeyUp>( camwnd.getCamera() )
 +      GlobalKeyEvents_insert( "CameraForward", Accelerator( GDK_KEY_Up ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveForward_KeyUp>( camwnd.getCamera() )
                                                        );
 -      GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_Down ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveBack_KeyUp>( camwnd.getCamera() )
 +      GlobalKeyEvents_insert( "CameraBack", Accelerator( GDK_KEY_Down ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveBack_KeyUp>( camwnd.getCamera() )
                                                        );
 -      GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_Left ),
 -                                                      ReferenceCaller<camera_t, Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
 +      GlobalKeyEvents_insert( "CameraLeft", Accelerator( GDK_KEY_Left ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_RotateLeft_KeyUp>( camwnd.getCamera() )
                                                        );
 -      GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_Right ),
 -                                                      ReferenceCaller<camera_t, Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_RotateRight_KeyUp>( camwnd.getCamera() )
 +      GlobalKeyEvents_insert( "CameraRight", Accelerator( GDK_KEY_Right ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_RotateRight_KeyUp>( camwnd.getCamera() )
                                                        );
 -      GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_period ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveRight_KeyUp>( camwnd.getCamera() )
 +      GlobalKeyEvents_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveRight_KeyUp>( camwnd.getCamera() )
                                                        );
 -      GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_comma ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
 +      GlobalKeyEvents_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveLeft_KeyUp>( camwnd.getCamera() )
                                                        );
        GlobalKeyEvents_insert( "CameraUp", Accelerator( 'D' ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveUp_KeyUp>( camwnd.getCamera() )
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveUp_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveUp_KeyUp>( camwnd.getCamera() )
                                                        );
        GlobalKeyEvents_insert( "CameraDown", Accelerator( 'C' ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_MoveDown_KeyUp>( camwnd.getCamera() )
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveDown_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_MoveDown_KeyUp>( camwnd.getCamera() )
                                                        );
        GlobalKeyEvents_insert( "CameraAngleDown", Accelerator( 'A' ),
 -                                                      ReferenceCaller<camera_t, Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_PitchDown_KeyUp>( camwnd.getCamera() )
 +                                                      ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_PitchDown_KeyUp>( camwnd.getCamera() )
                                                        );
        GlobalKeyEvents_insert( "CameraAngleUp", Accelerator( 'Z' ),
 -                                                      ReferenceCaller<camera_t, Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
 -                                                      ReferenceCaller<camera_t, Camera_PitchUp_KeyUp>( camwnd.getCamera() )
 +                                                      ReferenceCaller<camera_t, void(), Camera_PitchUp_KeyDown>( camwnd.getCamera() ),
 +                                                      ReferenceCaller<camera_t, void(), Camera_PitchUp_KeyUp>( camwnd.getCamera() )
                                                        );
  
-       GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( GDK_KEY_Up ),
+       GlobalKeyEvents_insert( "CameraFreeMoveForward", Accelerator( 'W' ),
                                                        FreeMoveCameraMoveForwardKeyDownCaller( camwnd.getCamera() ),
                                                        FreeMoveCameraMoveForwardKeyUpCaller( camwnd.getCamera() )
                                                        );
@@@ -1039,35 -1044,36 +1039,35 @@@ void CamWnd_Move_Discrete_Disable( CamW
        command_disconnect_accelerator( "CameraAngleDown" );
  }
  
 -void CamWnd_Move_Discrete_Import( CamWnd& camwnd, bool value ){
 +struct CamWnd_Move_Discrete {
 +      static void Export(const Callback<void(bool)> &returnz) {
 +              returnz(g_camwindow_globals_private.m_bCamDiscrete);
 +      }
 +
 +      static void Import(bool value) {
 +              if (g_camwnd) {
 +                      Import_(*g_camwnd, value);
 +              } else {
 +                      g_camwindow_globals_private.m_bCamDiscrete = value;
 +              }
 +      }
 +
 +      static void Import_(CamWnd &camwnd, bool value) {
-               if (g_camwindow_globals_private.m_bCamDiscrete) {
-                       CamWnd_Move_Discrete_Disable(camwnd);
+       if ( g_camwindow_globals_private.m_bCamDiscrete ) {
+               CamWnd_Move_Discrete_Disable( camwnd );
 -      }
 -      else
 -      {
 +              } else {
-                       CamWnd_Move_Disable(camwnd);
-               }
+               CamWnd_Move_Disable( camwnd );
+       }
  
-               g_camwindow_globals_private.m_bCamDiscrete = value;
+       g_camwindow_globals_private.m_bCamDiscrete = value;
  
-               if (g_camwindow_globals_private.m_bCamDiscrete) {
-                       CamWnd_Move_Discrete_Enable(camwnd);
+       if ( g_camwindow_globals_private.m_bCamDiscrete ) {
+               CamWnd_Move_Discrete_Enable( camwnd );
 -      }
 -      else
 -      {
 +              } else {
-                       CamWnd_Move_Enable(camwnd);
-               }
+               CamWnd_Move_Enable( camwnd );
        }
 -
 -void CamWnd_Move_Discrete_Import( bool value ){
 -      if ( g_camwnd != 0 ) {
 -              CamWnd_Move_Discrete_Import( *g_camwnd, value );
 -      }
 -      else
 -      {
 -              g_camwindow_globals_private.m_bCamDiscrete = value;
 -      }
 -}
 -
+ }
 +};
  
  
  void CamWnd_Add_Handlers_Move( CamWnd& camwnd ){
@@@ -1754,43 -1752,46 +1754,43 @@@ void GlobalCamera_LookThroughCamera()
        CamWnd_LookThroughCamera( *g_camwnd );
  }
  
 +struct RenderMode {
 +      static void Export(const Callback<void(int)> &returnz) {
 +              switch (CamWnd_GetMode()) {
 +                      case cd_wire:
 +                              returnz(0);
 +                              break;
 +                      case cd_solid:
 +                              returnz(1);
 +                              break;
 +                      case cd_texture:
 +                              returnz(2);
 +                              break;
 +                      case cd_lighting:
 +                              returnz(3);
 +                              break;
 +              }
 +      }
  
 -void RenderModeImport( int value ){
 -      switch ( value )
 -      {
 +      static void Import(int value) {
 +              switch (value) {
-                       case 0:
-                               CamWnd_SetMode(cd_wire);
-                               break;
-                       case 1:
-                               CamWnd_SetMode(cd_solid);
-                               break;
-                       case 2:
-                               CamWnd_SetMode(cd_texture);
-                               break;
-                       case 3:
-                               CamWnd_SetMode(cd_lighting);
-                               break;
-                       default:
-                               CamWnd_SetMode(cd_texture);
-               }
+       case 0:
+               CamWnd_SetMode( cd_wire );
+               break;
+       case 1:
+               CamWnd_SetMode( cd_solid );
+               break;
+       case 2:
+               CamWnd_SetMode( cd_texture );
+               break;
+       case 3:
+               CamWnd_SetMode( cd_lighting );
+               break;
+       default:
+               CamWnd_SetMode( cd_texture );
        }
 -typedef FreeCaller1<int, RenderModeImport> RenderModeImportCaller;
 -
 -void RenderModeExport( const IntImportCallback& importer ){
 -      switch ( CamWnd_GetMode() )
 -      {
 -      case cd_wire:
 -              importer( 0 );
 -              break;
 -      case cd_solid:
 -              importer( 1 );
 -              break;
 -      case cd_texture:
 -              importer( 2 );
 -              break;
 -      case cd_lighting:
 -              importer( 3 );
 -              break;
 -      }
 -}
 -typedef FreeCaller1<const IntImportCallback&, RenderModeExport> RenderModeExportCaller;
+ }
 +};
  
  void Camera_constructPreferences( PreferencesPage& page ){
        page.appendSlider( "Movement Speed", g_camwindow_globals_private.m_nMoveSpeed, TRUE, 0, 0, 100, MIN_CAM_SPEED, MAX_CAM_SPEED, 1, 10 );
@@@ -1866,57 -1873,57 +1866,57 @@@ void CameraSpeed_decrease()
  
  /// \brief Initialisation for things that have the same lifespan as this module.
  void CamWnd_Construct(){
 -      GlobalCommands_insert( "CenterView", FreeCaller<GlobalCamera_ResetAngles>(), Accelerator( GDK_End ) );
 +      GlobalCommands_insert( "CenterView", makeCallbackF(GlobalCamera_ResetAngles), Accelerator( GDK_KEY_End ) );
  
 -      GlobalToggles_insert( "ToggleCubicClip", FreeCaller<Camera_ToggleFarClip>(), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) );
 -      GlobalCommands_insert( "CubicClipZoomIn", FreeCaller<Camera_CubeIn>(), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) );
 -      GlobalCommands_insert( "CubicClipZoomOut", FreeCaller<Camera_CubeOut>(), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) );
 +      GlobalToggles_insert( "ToggleCubicClip", makeCallbackF(Camera_ToggleFarClip), ToggleItem::AddCallbackCaller( g_getfarclip_item ), Accelerator( '\\', (GdkModifierType)GDK_CONTROL_MASK ) );
 +      GlobalCommands_insert( "CubicClipZoomIn", makeCallbackF(Camera_CubeIn), Accelerator( '[', (GdkModifierType)GDK_CONTROL_MASK ) );
 +      GlobalCommands_insert( "CubicClipZoomOut", makeCallbackF(Camera_CubeOut), Accelerator( ']', (GdkModifierType)GDK_CONTROL_MASK ) );
  
 -      GlobalCommands_insert( "UpFloor", FreeCaller<Camera_ChangeFloorUp>(), Accelerator( GDK_Prior ) );
 -      GlobalCommands_insert( "DownFloor", FreeCaller<Camera_ChangeFloorDown>(), Accelerator( GDK_Next ) );
 +      GlobalCommands_insert( "UpFloor", makeCallbackF(Camera_ChangeFloorUp), Accelerator( GDK_KEY_Prior ) );
 +      GlobalCommands_insert( "DownFloor", makeCallbackF(Camera_ChangeFloorDown), Accelerator( GDK_KEY_Next ) );
  
        GlobalToggles_insert( "ToggleCamera", ToggleShown::ToggleCaller( g_camera_shown ), ToggleItem::AddCallbackCaller( g_camera_shown.m_item ), Accelerator( 'C', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
 -      GlobalCommands_insert( "LookThroughSelected", FreeCaller<GlobalCamera_LookThroughSelected>() );
 -      GlobalCommands_insert( "LookThroughCamera", FreeCaller<GlobalCamera_LookThroughCamera>() );
 +      GlobalCommands_insert( "LookThroughSelected", makeCallbackF(GlobalCamera_LookThroughSelected) );
 +      GlobalCommands_insert( "LookThroughCamera", makeCallbackF(GlobalCamera_LookThroughCamera) );
  
        if ( g_pGameDescription->mGameType == "doom3" ) {
 -              GlobalCommands_insert( "TogglePreview", FreeCaller<CamWnd_TogglePreview>(), Accelerator( GDK_F3 ) );
 +              GlobalCommands_insert( "TogglePreview", makeCallbackF(CamWnd_TogglePreview), Accelerator( GDK_KEY_F3 ) );
        }
  
 -      GlobalCommands_insert( "CameraSpeedInc", FreeCaller<CameraSpeed_increase>(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) );
 -      GlobalCommands_insert( "CameraSpeedDec", FreeCaller<CameraSpeed_decrease>(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) );
 +      GlobalCommands_insert( "CameraSpeedInc", makeCallbackF(CameraSpeed_increase), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_SHIFT_MASK ) );
 +      GlobalCommands_insert( "CameraSpeedDec", makeCallbackF(CameraSpeed_decrease), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_SHIFT_MASK ) );
  
 -      GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_Up ) );
 -      GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_Down ) );
 -      GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_Left ) );
 -      GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_Right ) );
 -      GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( GDK_period ) );
 -      GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( GDK_comma ) );
 +      GlobalShortcuts_insert( "CameraForward", Accelerator( GDK_KEY_Up ) );
 +      GlobalShortcuts_insert( "CameraBack", Accelerator( GDK_KEY_Down ) );
 +      GlobalShortcuts_insert( "CameraLeft", Accelerator( GDK_KEY_Left ) );
 +      GlobalShortcuts_insert( "CameraRight", Accelerator( GDK_KEY_Right ) );
 +      GlobalShortcuts_insert( "CameraStrafeRight", Accelerator( GDK_KEY_period ) );
 +      GlobalShortcuts_insert( "CameraStrafeLeft", Accelerator( GDK_KEY_comma ) );
  
-       GlobalShortcuts_insert( "CameraUp", Accelerator( 'D' ) );
-       GlobalShortcuts_insert( "CameraDown", Accelerator( 'C' ) );
-       GlobalShortcuts_insert( "CameraAngleUp", Accelerator( 'A' ) );
-       GlobalShortcuts_insert( "CameraAngleDown", Accelerator( 'Z' ) );
+       GlobalShortcuts_insert( "CameraUp", accelerator_null() );
+       GlobalShortcuts_insert( "CameraDown", accelerator_null() );
+       GlobalShortcuts_insert( "CameraAngleUp", accelerator_null() );
+       GlobalShortcuts_insert( "CameraAngleDown", accelerator_null() );
  
-       GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( GDK_KEY_Up ) );
-       GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( GDK_KEY_Down ) );
-       GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( GDK_KEY_Left ) );
-       GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( GDK_KEY_Right ) );
 -      GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( 'W' ) );
 -      GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( 'S' ) );
 -      GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( 'A' ) );
 -      GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( 'D' ) );
 -
 -      GlobalToggles_insert( "ShowStats", ShowStatsToggleCaller(), ToggleItem::AddCallbackCaller( g_show_stats ) );
 -
 -      GlobalPreferenceSystem().registerPreference( "ShowStats", BoolImportStringCaller( g_camwindow_globals_private.m_showStats ), BoolExportStringCaller( g_camwindow_globals_private.m_showStats ) );
 -      GlobalPreferenceSystem().registerPreference( "MoveSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nMoveSpeed ) );
 -      GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", BoolImportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamLinkSpeed ) );
 -      GlobalPreferenceSystem().registerPreference( "AngleSpeed", IntImportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ), IntExportStringCaller( g_camwindow_globals_private.m_nAngleSpeed ) );
 -      GlobalPreferenceSystem().registerPreference( "CamInverseMouse", BoolImportStringCaller( g_camwindow_globals_private.m_bCamInverseMouse ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamInverseMouse ) );
 -      GlobalPreferenceSystem().registerPreference( "CamDiscrete", makeBoolStringImportCallback( CamWndMoveDiscreteImportCaller() ), BoolExportStringCaller( g_camwindow_globals_private.m_bCamDiscrete ) );
 -      GlobalPreferenceSystem().registerPreference( "CubicClipping", BoolImportStringCaller( g_camwindow_globals_private.m_bCubicClipping ), BoolExportStringCaller( g_camwindow_globals_private.m_bCubicClipping ) );
 -      GlobalPreferenceSystem().registerPreference( "CubicScale", IntImportStringCaller( g_camwindow_globals.m_nCubicScale ), IntExportStringCaller( g_camwindow_globals.m_nCubicScale ) );
 -      GlobalPreferenceSystem().registerPreference( "SI_Colors4", Vector3ImportStringCaller( g_camwindow_globals.color_cameraback ), Vector3ExportStringCaller( g_camwindow_globals.color_cameraback ) );
 -      GlobalPreferenceSystem().registerPreference( "SI_Colors12", Vector3ImportStringCaller( g_camwindow_globals.color_selbrushes3d ), Vector3ExportStringCaller( g_camwindow_globals.color_selbrushes3d ) );
 -      GlobalPreferenceSystem().registerPreference( "CameraRenderMode", makeIntStringImportCallback( RenderModeImportCaller() ), makeIntStringExportCallback( RenderModeExportCaller() ) );
 -      GlobalPreferenceSystem().registerPreference( "StrafeMode", IntImportStringCaller( g_camwindow_globals_private.m_nStrafeMode ), IntExportStringCaller( g_camwindow_globals_private.m_nStrafeMode ) );
++      GlobalShortcuts_insert( "CameraFreeMoveForward", Accelerator( GDK_Up ) );
++      GlobalShortcuts_insert( "CameraFreeMoveBack", Accelerator( GDK_Down ) );
++      GlobalShortcuts_insert( "CameraFreeMoveLeft", Accelerator( GDK_Left ) );
++      GlobalShortcuts_insert( "CameraFreeMoveRight", Accelerator( GDK_Right ) );
 +
 +      GlobalToggles_insert( "ShowStats", makeCallbackF(ShowStatsToggle), ToggleItem::AddCallbackCaller( g_show_stats ) );
 +
 +      GlobalPreferenceSystem().registerPreference( "ShowStats", make_property_string( g_camwindow_globals_private.m_showStats ) );
 +      GlobalPreferenceSystem().registerPreference( "MoveSpeed", make_property_string( g_camwindow_globals_private.m_nMoveSpeed ) );
 +      GlobalPreferenceSystem().registerPreference( "CamLinkSpeed", make_property_string( g_camwindow_globals_private.m_bCamLinkSpeed ) );
 +      GlobalPreferenceSystem().registerPreference( "AngleSpeed", make_property_string( g_camwindow_globals_private.m_nAngleSpeed ) );
 +      GlobalPreferenceSystem().registerPreference( "CamInverseMouse", make_property_string( g_camwindow_globals_private.m_bCamInverseMouse ) );
 +      GlobalPreferenceSystem().registerPreference( "CamDiscrete", make_property_string<CamWnd_Move_Discrete>());
 +      GlobalPreferenceSystem().registerPreference( "CubicClipping", make_property_string( g_camwindow_globals_private.m_bCubicClipping ) );
 +      GlobalPreferenceSystem().registerPreference( "CubicScale", make_property_string( g_camwindow_globals.m_nCubicScale ) );
 +      GlobalPreferenceSystem().registerPreference( "SI_Colors4", make_property_string( g_camwindow_globals.color_cameraback ) );
 +      GlobalPreferenceSystem().registerPreference( "SI_Colors12", make_property_string( g_camwindow_globals.color_selbrushes3d ) );
 +      GlobalPreferenceSystem().registerPreference( "CameraRenderMode", make_property_string<RenderMode>() );
 +      GlobalPreferenceSystem().registerPreference( "StrafeMode", make_property_string( g_camwindow_globals_private.m_nStrafeMode ) );
  
        CamWnd_constructStatic();
  
index 4968123864ebeeecec72f2b30a77e8f183f36fa0,8fb38e32e4b6bdc1c2ab557a38749ae8b20be47a..5a9f9be6d93a6f82ec2633b0b2d814d96270b3c4
@@@ -129,48 -146,22 +129,48 @@@ glwindow_globals_t g_glwindow_globals
  
  
  // VFS
 +
 +bool g_vfsInitialized = false;
 +
 +void VFS_Init(){
 +      if ( g_vfsInitialized ) return;
 +      QE_InitVFS();
 +      GlobalFileSystem().initialise();
 +      g_vfsInitialized = true;
 +}
 +
 +void VFS_Shutdown(){
 +      if ( !g_vfsInitialized ) return;
 +      GlobalFileSystem().shutdown();
 +      g_vfsInitialized = false;
 +}
 +
 +void VFS_Refresh(){
 +      if ( !g_vfsInitialized ) return;
 +      GlobalFileSystem().clear();
 +      QE_InitVFS();
 +      GlobalFileSystem().refresh();
 +      g_vfsInitialized = true;
 +      // also refresh models
 +      RefreshReferences();
 +      // also refresh texture browser
 +      TextureBrowser_RefreshShaders();
 +}
 +
 +void VFS_Restart(){
 +      VFS_Shutdown();
 +      VFS_Init();
 +}
 +
  class VFSModuleObserver : public ModuleObserver
  {
 -std::size_t m_unrealised;
  public:
 -VFSModuleObserver() : m_unrealised( 1 ){
 -}
  void realise(){
 -      if ( --m_unrealised == 0 ) {
 -              QE_InitVFS();
 -              GlobalFileSystem().initialise();
 +      VFS_Init();
- }
      }
 -}
 +
  void unrealise(){
 -      if ( ++m_unrealised == 1 ) {
 -              GlobalFileSystem().shutdown();
 -      }
 +      VFS_Shutdown();
  }
  };
  
@@@ -186,8 -176,8 +186,8 @@@ void VFS_Destroy()
  
  // Home Paths
  
 -#ifdef WIN32
 +#if GDEF_OS_WINDOWS
                                                                                                                      #include <shlobj.h>
+ #include <shlobj.h>
  #include <objbase.h>
  const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}};
  #define qREFKNOWNFOLDERID GUID
@@@ -477,104 -407,17 +477,104 @@@ const char* GameToolsPath_get()
        return g_strGameToolsPath.c_str();
  }
  
 -void EnginePathImport( CopiedString& self, const char* value ){
 +struct EnginePath {
 +      static void Export(const CopiedString &self, const Callback<void(const char *)> &returnz) {
 +              returnz(self.c_str());
 +      }
 +
 +      static void Import(CopiedString &self, const char *value) {
        setEnginePath( value );
  }
 -typedef ReferenceCaller1<CopiedString, const char*, EnginePathImport> EnginePathImportCaller;
 +};
 +
 +struct PakPath0 {
 +      static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
 +              returnz( self.c_str() );
 +      }
 +
 +      static void Import( CopiedString &self, const char *value ) {
 +              setPakPath( 0, value );
 +      }
 +};
 +
 +struct PakPath1 {
 +      static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
 +              returnz( self.c_str() );
 +      }
 +
 +      static void Import( CopiedString &self, const char *value ) {
 +              setPakPath( 1, value );
 +      }
 +};
 +
 +struct PakPath2 {
 +      static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
 +              returnz( self.c_str() );
 +      }
 +
 +      static void Import( CopiedString &self, const char *value ) {
 +              setPakPath( 2, value );
 +      }
 +};
 +
 +struct PakPath3 {
 +      static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
 +              returnz( self.c_str() );
 +      }
 +
 +      static void Import( CopiedString &self, const char *value ) {
 +              setPakPath( 3, value );
 +      }
 +};
 +
 +struct PakPath4 {
 +      static void Export( const CopiedString &self, const Callback<void(const char*)> &returnz ) {
 +              returnz( self.c_str() );
 +      }
 +
 +      static void Import( CopiedString &self, const char *value ) {
 +              setPakPath( 4, value );
 +      }
 +};
 +
 +bool g_disableEnginePath = false;
 +bool g_disableHomePath = false;
  
  void Paths_constructPreferences( PreferencesPage& page ){
 -      page.appendPathEntry( "Engine Path", true,
 -                                                StringImportCallback( EnginePathImportCaller( g_strEnginePath ) ),
 -                                                StringExportCallback( StringExportCaller( g_strEnginePath ) )
 +      page.appendPathEntry( "Engine Path", true, make_property<EnginePath>(g_strEnginePath) );
 +
 +      page.appendCheckBox(
 +              "", "Do not use Engine Path",
 +              g_disableEnginePath
-               );
+                                                 );
 +
 +      page.appendCheckBox(
 +              "", "Do not use Home Path",
 +              g_disableHomePath
 +              );
 +
 +      for ( int i = 0; i < g_pakPathCount; i++ ) {
 +              std::string label = "Pak Path " + std::to_string(i);
 +              switch (i) {
 +                      case 0:
 +                      page.appendPathEntry( label.c_str(), true, make_property<PakPath0>( g_strPakPath[i] ) );
 +                      break;
 +                      case 1:
 +                      page.appendPathEntry( label.c_str(), true, make_property<PakPath1>( g_strPakPath[i] ) );
 +                      break;
 +                      case 2:
 +                      page.appendPathEntry( label.c_str(), true, make_property<PakPath2>( g_strPakPath[i] ) );
 +                      break;
 +                      case 3:
 +                      page.appendPathEntry( label.c_str(), true, make_property<PakPath3>( g_strPakPath[i] ) );
 +                      break;
 +                      case 4:
 +                      page.appendPathEntry( label.c_str(), true, make_property<PakPath4>( g_strPakPath[i] ) );
 +                      break;
-               }
+ }
 +      }
 +}
 +
  void Paths_constructPage( PreferenceGroup& group ){
        PreferencesPage page( group.createPage( "Paths", "Path Settings" ) );
        Paths_constructPreferences( page );
Simple merge
index f4471578bf404487d5479b9b468f4ddcfbe2ae4c,3d64f4115fab1d3249d732658a3f9b99021172f6..63c5b472f9ffd187a40715f05b8503b144786717
@@@ -431,23 -441,37 +431,33 @@@ void SurfaceInspector_FitTexture()
        Select_FitTexture( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical );
  }
  
 -static void OnBtnPatchdetails( GtkWidget *widget, gpointer data ){
 -      Scene_PatchCapTexture_Selected( GlobalSceneGraph() );
+ void SurfaceInspector_FitTextureW(){
+       UndoableCommand undo( "textureAutoFitW" );
+       Select_FitTextureW( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical );
+ }
+ void SurfaceInspector_FitTextureH(){
+       UndoableCommand undo( "textureAutoFitH" );
+       Select_FitTextureH( getSurfaceInspector().m_fitHorizontal, getSurfaceInspector().m_fitVertical );
+ }
 +static void OnBtnPatchdetails( ui::Widget widget, gpointer data ){
 +      Patch_CapTexture();
  }
  
 -static void OnBtnPatchnatural( GtkWidget *widget, gpointer data ){
 -      Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() );
 +static void OnBtnPatchnatural( ui::Widget widget, gpointer data ){
 +      Patch_NaturalTexture();
  }
  
 -static void OnBtnPatchreset( GtkWidget *widget, gpointer data ){
 -      float fx, fy;
 -
 -      if ( DoTextureLayout( &fx, &fy ) == eIDOK ) {
 -              Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy );
 -      }
 +static void OnBtnPatchreset( ui::Widget widget, gpointer data ){
 +      Patch_ResetTexture();
  }
  
 -static void OnBtnPatchFit( GtkWidget *widget, gpointer data ){
 -      Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 );
 +static void OnBtnPatchFit( ui::Widget widget, gpointer data ){
 +      Patch_FitTexture();
  }
  
 -static void OnBtnAxial( GtkWidget *widget, gpointer data ){
 +static void OnBtnAxial( ui::Widget widget, gpointer data ){
  //globalOutputStream() << "--> [OnBtnAxial]...\n";
        UndoableCommand undo( "textureDefault" );
        TextureProjection projection;
@@@ -772,97 -850,127 +794,103 @@@ ui::Window SurfaceInspector::BuildDialo
                }
  
                {
 -                      GtkWidget* frame = gtk_frame_new( "Texturing" );
 -                      gtk_widget_show( frame );
 -                      gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( frame ), FALSE, FALSE, 0 );
 +                      auto frame = ui::Frame( "Texturing" );
 +                      frame.show();
 +                      vbox.pack_start( frame, FALSE, FALSE, 0 );
                        {
 -                              GtkWidget* table = gtk_table_new( 4, 4, FALSE );
 -                              gtk_widget_show( table );
 -                              gtk_container_add( GTK_CONTAINER( frame ), table );
 -                              gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
 -                              gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
 +                              auto table = ui::Table(4, 4, FALSE);
 +                              table.show();
 +                              frame.add(table);
 +                              gtk_table_set_row_spacings(table, 5);
 +                              gtk_table_set_col_spacings(table, 5);
                                gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
                                {
 -                                      GtkWidget* label = gtk_label_new( "Brush" );
 -                                      gtk_widget_show( label );
 -                                      gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 0, 1,
 -                                                                        (GtkAttachOptions) ( GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 +                                      ui::Widget label = ui::Label( "Brush" );
 +                                      label.show();
 +                                      table.attach(label, {0, 1, 0, 1}, {GTK_FILL, 0});
                                }
                                {
 -                                      GtkWidget* label = gtk_label_new( "Patch" );
 -                                      gtk_widget_show( label );
 -                                      gtk_table_attach( GTK_TABLE( table ), label, 0, 1, 2, 3,
 -                                                                        (GtkAttachOptions) ( GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 +                                      ui::Widget label = ui::Label( "Patch" );
 +                                      label.show();
 +                                      table.attach(label, {0, 1, 2, 3}, {GTK_FILL, 0});
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Width" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 0, 1,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 +                                      ui::Widget label = ui::Label( "Width" );
 +                                      label.show();
 +                                      table.attach(label, {2, 3, 0, 1}, {GTK_FILL, 0});
+                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                                                         G_CALLBACK( OnBtnFaceFitW ), 0 );
+                                       gtk_widget_set_usize( button, 60, -2 );
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Height" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 0, 1,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 +                                      ui::Widget label = ui::Label( "Height" );
 +                                      label.show();
 +                                      table.attach(label, {3, 4, 0, 1}, {GTK_FILL, 0});
+                                       g_signal_connect( G_OBJECT( button ), "clicked",
+                                                                         G_CALLBACK( OnBtnFaceFitH ), 0 );
+                                       gtk_widget_set_usize( button, 60, -2 );
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Axial" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 1, 2,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      g_signal_connect( G_OBJECT( button ), "clicked",
 +                                      ui::Widget button = ui::Button( "Axial" );
 +                                      button.show();
 +                                      table.attach(button, {0, 1, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 +                                      button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnAxial ), 0 );
 -                                      gtk_widget_set_usize( button, 60, -2 );
 +                    button.dimensions(60, -1);
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Fit" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 1, 2,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      g_signal_connect( G_OBJECT( button ), "clicked",
 +                                      ui::Widget button = ui::Button( "Fit" );
 +                                      button.show();
 +                                      table.attach(button, {1, 2, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 +                                      button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnFaceFit ), 0 );
 -                                      gtk_widget_set_usize( button, 60, -2 );
 +                    button.dimensions(60, -1);
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "CAP" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 0, 1, 3, 4,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      g_signal_connect( G_OBJECT( button ), "clicked",
 +                                      ui::Widget button = ui::Button( "CAP" );
 +                                      button.show();
 +                                      table.attach(button, {0, 1, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
 +                                      button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchdetails ), 0 );
 -                                      gtk_widget_set_usize( button, 60, -2 );
 +                    button.dimensions(60, -1);
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Set..." );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 1, 2, 3, 4,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      g_signal_connect( G_OBJECT( button ), "clicked",
 +                                      ui::Widget button = ui::Button( "Set..." );
 +                                      button.show();
 +                                      table.attach(button, {1, 2, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
 +                                      button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchreset ), 0 );
 -                                      gtk_widget_set_usize( button, 60, -2 );
 +                    button.dimensions(60, -1);
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Natural" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 2, 3, 3, 4,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      g_signal_connect( G_OBJECT( button ), "clicked",
 +                                      ui::Widget button = ui::Button( "Natural" );
 +                                      button.show();
 +                                      table.attach(button, {2, 3, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
 +                                      button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchnatural ), 0 );
 -                                      gtk_widget_set_usize( button, 60, -2 );
 +                    button.dimensions(60, -1);
                                }
                                {
 -                                      GtkWidget* button = gtk_button_new_with_label( "Fit" );
 -                                      gtk_widget_show( button );
 -                                      gtk_table_attach( GTK_TABLE( table ), button, 3, 4, 3, 4,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      g_signal_connect( G_OBJECT( button ), "clicked",
 +                                      ui::Widget button = ui::Button( "Fit" );
 +                                      button.show();
 +                                      table.attach(button, {3, 4, 3, 4}, {GTK_EXPAND | GTK_FILL, 0});
 +                                      button.connect( "clicked",
                                                                          G_CALLBACK( OnBtnPatchFit ), 0 );
 -                                      gtk_widget_set_usize( button, 60, -2 );
 +                    button.dimensions(60, -1);
                                }
                                {
 -                                      GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 );
 -                                      gtk_widget_show( spin );
 -                                      gtk_table_attach( GTK_TABLE( table ), spin, 2, 3, 1, 2,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      gtk_widget_set_usize( spin, 60, -2 );
 -                                      AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitHorizontal );
 +                                      auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 );
 +                                      spin.show();
 +                                      table.attach(spin, {2, 3, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 +                    spin.dimensions(60, -1);
 +                                      AddDialogData( spin, m_fitHorizontal );
                                }
                                {
 -                                      GtkWidget* spin = gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( 1, 0, 1 << 16, 1, 10, 0 ) ), 0, 6 );
 -                                      gtk_widget_show( spin );
 -                                      gtk_table_attach( GTK_TABLE( table ), spin, 3, 4, 1, 2,
 -                                                                        (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ),
 -                                                                        (GtkAttachOptions) ( 0 ), 0, 0 );
 -                                      gtk_widget_set_usize( spin, 60, -2 );
 -                                      AddDialogData( *GTK_SPIN_BUTTON( spin ), m_fitVertical );
 +                                      auto spin = ui::SpinButton( ui::Adjustment( 1, 0, 1 << 16, 1, 10, 0 ), 0, 6 );
 +                                      spin.show();
 +                                      table.attach(spin, {3, 4, 1, 2}, {GTK_EXPAND | GTK_FILL, 0});
 +                    spin.dimensions(60, -1);
 +                                      AddDialogData( spin, m_fitVertical );
                                }
                        }
                }
Simple merge
index f410226f9cb731ec1accb8f84163d5cc3b6b5062,f4c8188927ac385f897369aa25e2343e875533e6..7e92b1be77fa1e515ee7d319ce52abe28410eb80
@@@ -2795,9 -2795,9 +2815,10 @@@ int LightMain( int argc, char **argv )
                                }
                                else{
                                        Sys_Printf( "Disabling half lambert light angle attenuation\n" );
+                                       i++;
                                }
                        }
 +                      i++;
                }
                else if ( !strcmp( argv[ i ], "-nostyle" ) || !strcmp( argv[ i ], "-nostyles" ) ) {
                        noStyles = qtrue;
index c75dac2e55f5705029df32059d2eec071a09031d,df53d7edd42382968d3ace7f9b080478b3f160e9..6fe1ae159d17ea5e55274479cce24e47b4fe9ad6
@@@ -1764,8 -1765,8 +1764,8 @@@ static qboolean SubmapRawLuxel( rawLigh
                origin2 = SUPER_ORIGIN( x, y );
                //%     normal2 = SUPER_NORMAL( x, y );
        }
-       else {
+       else{
 -              Sys_Printf( "WARNING: Spurious lightmap T vector\n" );
 +              Sys_FPrintf( SYS_WRN, "WARNING: Spurious lightmap T vector\n" );
        }
  
        VectorSubtract( origin2, origin, originVecs[ 1 ] );
@@@ -2240,31 -2248,42 +2240,31 @@@ void IlluminateRawLightmap( int rawLigh
                                        normal = SUPER_NORMAL( x, y );
                                        flag = SUPER_FLAG( x, y );
  
 -#if 0
 -                                      ////////// 27's temp hack for testing edge clipping ////
 -                                      if ( origin[0] == 0 && origin[1] == 0 && origin[2] == 0 ) {
 -                                              lightLuxel[ 1 ] = 255;
 -                                              lightLuxel[ 3 ] = 1.0f;
 -                                              totalLighted++;
 -                                      }
 -                                      else
 -#endif
 -                                      {
 -                                              /* set contribution count */
 -                                              lightLuxel[ 3 ] = 1.0f;
 +                                      /* set contribution count */
 +                                      lightLuxel[ 3 ] = 1.0f;
  
 -                                              /* setup trace */
 -                                              trace.cluster = *cluster;
 -                                              VectorCopy( origin, trace.origin );
 -                                              VectorCopy( normal, trace.normal );
 +                                      /* setup trace */
 +                                      trace.cluster = *cluster;
 +                                      VectorCopy( origin, trace.origin );
 +                                      VectorCopy( normal, trace.normal );
  
 -                                              /* get light for this sample */
 -                                              LightContributionToSample( &trace );
 -                                              VectorCopy( trace.color, lightLuxel );
 +                                      /* get light for this sample */
 +                                      LightContributionToSample( &trace );
 +                                      VectorCopy( trace.color, lightLuxel );
  
 -                                              /* add the contribution to the deluxemap */
 -                                              if ( deluxemap ) {
 -                                                      VectorCopy( trace.directionContribution, lightDeluxel );
 -                                              }
 +                                      /* add the contribution to the deluxemap */
 +                                      if ( deluxemap ) {
 +                                              VectorCopy( trace.directionContribution, lightDeluxel );
 +                                      }
  
 -                                              /* check for evilness */
 -                                              if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) ) {
 -                                                      totalLighted++;
 -                                                      *flag |= FLAG_FORCE_SUBSAMPLING; /* force */
 -                                              }
 -                                              /* add to count */
 -                                              else if ( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] ) {
 -                                                      totalLighted++;
 -                                              }
 +                                      /* check for evilness */
-                                       if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) && luxelFilterRadius == 0 ) {
-                                                       totalLighted++;
++                                      if ( trace.forceSubsampling > 1.0f && ( lightSamples > 1 || lightRandomSamples ) ) {
++                                              totalLighted++;
 +                                              *flag |= FLAG_FORCE_SUBSAMPLING; /* force */
 +                                      }
 +                                      /* add to count */
 +                                      else if ( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] ) {
 +                                              totalLighted++;
                                        }
                                }
                        }
Simple merge
index 3a82d2cb614ab1d157a00d9896e5e78c7025e603,fe7eee412447ba39f9036839375e800708dce2ef..c21f228346b2bf8d40ea0d33713a973116a3fcd6
@@@ -93,6 -1451,520 +93,265 @@@ static void ExitQ3Map( void )
  }
  
  
 -/*
 -   PseudoCompileBSP()
 -   a stripped down ProcessModels
 - */
 -void PseudoCompileBSP( qboolean need_tree ){
 -      int models;
 -      char modelValue[10];
 -      entity_t *entity;
 -      face_t *faces;
 -      tree_t *tree;
 -      node_t *node;
 -      brush_t *brush;
 -      side_t *side;
 -      int i;
 -
 -      SetDrawSurfacesBuffer();
 -      mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
 -      memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
 -      numMapDrawSurfs = 0;
 -
 -      BeginBSPFile();
 -      models = 1;
 -      for ( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ )
 -      {
 -              /* get entity */
 -              entity = &entities[ mapEntityNum ];
 -              if ( entity->brushes == NULL && entity->patches == NULL ) {
 -                      continue;
 -              }
 -
 -              if ( mapEntityNum != 0 ) {
 -                      sprintf( modelValue, "*%d", models++ );
 -                      SetKeyValue( entity, "model", modelValue );
 -              }
 -
 -              /* process the model */
 -              Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels );
 -              BeginModel();
 -
 -              entity->firstDrawSurf = numMapDrawSurfs;
 -
 -              ClearMetaTriangles();
 -              PatchMapDrawSurfs( entity );
 -
 -              if ( mapEntityNum == 0 && need_tree ) {
 -                      faces = MakeStructuralBSPFaceList( entities[0].brushes );
 -                      tree = FaceBSP( faces );
 -                      node = tree->headnode;
 -              }
 -              else
 -              {
 -                      node = AllocNode();
 -                      node->planenum = PLANENUM_LEAF;
 -                      tree = AllocTree();
 -                      tree->headnode = node;
 -              }
 -
 -              /* a minimized ClipSidesIntoTree */
 -              for ( brush = entity->brushes; brush; brush = brush->next )
 -              {
 -                      /* walk the brush sides */
 -                      for ( i = 0; i < brush->numsides; i++ )
 -                      {
 -                              /* get side */
 -                              side = &brush->sides[ i ];
 -                              if ( side->winding == NULL ) {
 -                                      continue;
 -                              }
 -                              /* shader? */
 -                              if ( side->shaderInfo == NULL ) {
 -                                      continue;
 -                              }
 -                              /* save this winding as a visible surface */
 -                              DrawSurfaceForSide( entity, brush, side, side->winding );
 -                      }
 -              }
 -
 -              if ( meta ) {
 -                      ClassifyEntitySurfaces( entity );
 -                      MakeEntityDecals( entity );
 -                      MakeEntityMetaTriangles( entity );
 -                      SmoothMetaTriangles();
 -                      MergeMetaTriangles();
 -              }
 -              FilterDrawsurfsIntoTree( entity, tree );
 -
 -              FilterStructuralBrushesIntoTree( entity, tree );
 -              FilterDetailBrushesIntoTree( entity, tree );
 -
 -              EmitBrushes( entity->brushes, &entity->firstBrush, &entity->numBrushes );
 -              EndModel( entity, node );
 -      }
 -      EndBSPFile( qfalse );
 -}
 -
 -/*
 -   ConvertBSPMain()
 -   main argument processing function for bsp conversion
 - */
 -
 -int ConvertBSPMain( int argc, char **argv ){
 -      int i;
 -      int ( *convertFunc )( char * );
 -      game_t  *convertGame;
 -      char ext[1024];
 -      qboolean map_allowed, force_bsp, force_map;
 -
 -
 -      /* set default */
 -      convertFunc = ConvertBSPToASE;
 -      convertGame = NULL;
 -      map_allowed = qfalse;
 -      force_bsp = qfalse;
 -      force_map = qfalse;
 -
 -      /* arg checking */
 -      if ( argc < 1 ) {
 -              Sys_Printf( "Usage: q3map -convert [-format <ase|obj|map_bp|map>] [-shadersasbitmap|-lightmapsastexcoord|-deluxemapsastexcoord] [-readbsp|-readmap [-meta|-patchmeta]] [-v] <mapname>\n" );
 -              return 0;
 -      }
 -
 -      /* process arguments */
 -      for ( i = 1; i < ( argc - 1 ); i++ )
 -      {
 -              /* -format map|ase|... */
 -              if ( !strcmp( argv[ i ],  "-format" ) ) {
 -                      i++;
 -                      if ( !Q_stricmp( argv[ i ], "ase" ) ) {
 -                              convertFunc = ConvertBSPToASE;
 -                              map_allowed = qfalse;
 -                      }
 -                      else if ( !Q_stricmp( argv[ i ], "obj" ) ) {
 -                              convertFunc = ConvertBSPToOBJ;
 -                              map_allowed = qfalse;
 -                      }
 -                      else if ( !Q_stricmp( argv[ i ], "map_bp" ) ) {
 -                              convertFunc = ConvertBSPToMap_BP;
 -                              map_allowed = qtrue;
 -                      }
 -                      else if ( !Q_stricmp( argv[ i ], "map" ) ) {
 -                              convertFunc = ConvertBSPToMap;
 -                              map_allowed = qtrue;
 -                      }
 -                      else
 -                      {
 -                              convertGame = GetGame( argv[ i ] );
 -                              map_allowed = qfalse;
 -                              if ( convertGame == NULL ) {
 -                                      Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] );
 -                              }
 -                      }
 -              }
 -              else if ( !strcmp( argv[ i ],  "-ne" ) ) {
 -                      normalEpsilon = atof( argv[ i + 1 ] );
 -                      i++;
 -                      Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon );
 -              }
 -              else if ( !strcmp( argv[ i ],  "-de" ) ) {
 -                      distanceEpsilon = atof( argv[ i + 1 ] );
 -                      i++;
 -                      Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
 -              }
 -              else if ( !strcmp( argv[ i ],  "-shaderasbitmap" ) || !strcmp( argv[ i ],  "-shadersasbitmap" ) ) {
 -                      shadersAsBitmap = qtrue;
 -              }
 -              else if ( !strcmp( argv[ i ],  "-lightmapastexcoord" ) || !strcmp( argv[ i ],  "-lightmapsastexcoord" ) ) {
 -                      lightmapsAsTexcoord = qtrue;
 -              }
 -              else if ( !strcmp( argv[ i ],  "-deluxemapastexcoord" ) || !strcmp( argv[ i ],  "-deluxemapsastexcoord" ) ) {
 -                      lightmapsAsTexcoord = qtrue;
 -                      deluxemap = qtrue;
 -              }
 -              else if ( !strcmp( argv[ i ],  "-readbsp" ) ) {
 -                      force_bsp = qtrue;
 -              }
 -              else if ( !strcmp( argv[ i ],  "-readmap" ) ) {
 -                      force_map = qtrue;
 -              }
 -              else if ( !strcmp( argv[ i ],  "-meta" ) ) {
 -                      meta = qtrue;
 -              }
 -              else if ( !strcmp( argv[ i ],  "-patchmeta" ) ) {
 -                      meta = qtrue;
 -                      patchMeta = qtrue;
 -              }
 -      }
 -
 -      LoadShaderInfo();
 -
 -      /* clean up map name */
 -      strcpy( source, ExpandArg( argv[i] ) );
 -      ExtractFileExtension( source, ext );
 -
 -      if ( !map_allowed && !force_map ) {
 -              force_bsp = qtrue;
 -      }
 -
 -      if ( force_map || ( !force_bsp && !Q_stricmp( ext, "map" ) && map_allowed ) ) {
 -              if ( !map_allowed ) {
 -                      Sys_Printf( "WARNING: the requested conversion should not be done from .map files. Compile a .bsp first.\n" );
 -              }
 -              StripExtension( source );
 -              DefaultExtension( source, ".map" );
 -              Sys_Printf( "Loading %s\n", source );
 -              LoadMapFile( source, qfalse, convertGame == NULL );
 -              PseudoCompileBSP( convertGame != NULL );
 -      }
 -      else
 -      {
 -              StripExtension( source );
 -              DefaultExtension( source, ".bsp" );
 -              Sys_Printf( "Loading %s\n", source );
 -              LoadBSPFile( source );
 -              ParseEntities();
 -      }
 -
 -      /* bsp format convert? */
 -      if ( convertGame != NULL ) {
 -              /* set global game */
 -              game = convertGame;
 -
 -              /* write bsp */
 -              StripExtension( source );
 -              DefaultExtension( source, "_c.bsp" );
 -              Sys_Printf( "Writing %s\n", source );
 -              WriteBSPFile( source );
 -
 -              /* return to sender */
 -              return 0;
 -      }
 -
 -      /* normal convert */
 -      return convertFunc( source );
 -}
 -
 -
 -
+ /*
+    ShiftBSPMain()
+    shifts a map: works correctly only with axial faces, placed in positive half of axis
+    for testing physics with huge coordinates
+  */
+ int ShiftBSPMain( int argc, char **argv ){
+       int i, j;
+       float f, a;
+       vec3_t scale;
+       vec3_t vec;
+       char str[ 1024 ];
+       int uniform, axis;
+       qboolean texscale;
+       float *old_xyzst = NULL;
+       float spawn_ref = 0;
+       /* arg checking */
+       if ( argc < 3 ) {
+               Sys_Printf( "Usage: q3map [-v] -shift [-tex] [-spawn_ref <value>] <value> <mapname>\n" );
+               return 0;
+       }
+       texscale = qfalse;
+       for ( i = 1; i < argc - 2; ++i )
+       {
+               if ( !strcmp( argv[i], "-tex" ) ) {
+                       texscale = qtrue;
+               }
+               else if ( !strcmp( argv[i], "-spawn_ref" ) ) {
+                       spawn_ref = atof( argv[i + 1] );
+                       ++i;
+               }
+               else{
+                       break;
+               }
+       }
+       /* get scale */
+       // if(argc-2 >= i) // always true
+       scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
+       if ( argc - 3 >= i ) {
+               scale[1] = scale[0] = atof( argv[ argc - 3 ] );
+       }
+       if ( argc - 4 >= i ) {
+               scale[0] = atof( argv[ argc - 4 ] );
+       }
+       uniform = ( ( scale[0] == scale[1] ) && ( scale[1] == scale[2] ) );
+       /* do some path mangling */
+       strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
+       StripExtension( source );
+       DefaultExtension( source, ".bsp" );
+       /* load the bsp */
+       Sys_Printf( "Loading %s\n", source );
+       LoadBSPFile( source );
+       ParseEntities();
+       /* note it */
+       Sys_Printf( "--- ShiftBSP ---\n" );
+       Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
+       /* scale entity keys */
+       for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
+       {
+               /* scale origin */
+               GetVectorForKey( &entities[ i ], "origin", vec );
+               if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
+                       if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
+                               vec[2] += spawn_ref;
+                       }
+                       vec[0] += scale[0];
+                       vec[1] += scale[1];
+                       vec[2] += scale[2];
+                       if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
+                               vec[2] -= spawn_ref;
+                       }
+                       sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
+                       SetKeyValue( &entities[ i ], "origin", str );
+               }
+       }
+       /* scale models */
+       for ( i = 0; i < numBSPModels; i++ )
+       {
+               bspModels[ i ].mins[0] += scale[0];
+               bspModels[ i ].mins[1] += scale[1];
+               bspModels[ i ].mins[2] += scale[2];
+               bspModels[ i ].maxs[0] += scale[0];
+               bspModels[ i ].maxs[1] += scale[1];
+               bspModels[ i ].maxs[2] += scale[2];
+       }
+       /* scale nodes */
+       for ( i = 0; i < numBSPNodes; i++ )
+       {
+               bspNodes[ i ].mins[0] += scale[0];
+               bspNodes[ i ].mins[1] += scale[1];
+               bspNodes[ i ].mins[2] += scale[2];
+               bspNodes[ i ].maxs[0] += scale[0];
+               bspNodes[ i ].maxs[1] += scale[1];
+               bspNodes[ i ].maxs[2] += scale[2];
+       }
+       /* scale leafs */
+       for ( i = 0; i < numBSPLeafs; i++ )
+       {
+               bspLeafs[ i ].mins[0] += scale[0];
+               bspLeafs[ i ].mins[1] += scale[1];
+               bspLeafs[ i ].mins[2] += scale[2];
+               bspLeafs[ i ].maxs[0] += scale[0];
+               bspLeafs[ i ].maxs[1] += scale[1];
+               bspLeafs[ i ].maxs[2] += scale[2];
+       }
+ /*
+       if ( texscale ) {
+               Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
+               old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
+               for ( i = 0; i < numBSPDrawVerts; i++ )
+               {
+                       old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
+                       old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
+                       old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
+                       old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
+                       old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
+               }
+       }
+ */
+       /* scale drawverts */
+       for ( i = 0; i < numBSPDrawVerts; i++ )
+       {
+               bspDrawVerts[i].xyz[0] += scale[0];
+               bspDrawVerts[i].xyz[1] += scale[1];
+               bspDrawVerts[i].xyz[2] += scale[2];
+ //            bspDrawVerts[i].normal[0] /= scale[0];
+ //            bspDrawVerts[i].normal[1] /= scale[1];
+ //            bspDrawVerts[i].normal[2] /= scale[2];
+ //            VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
+       }
+ /*
+       if ( texscale ) {
+               for ( i = 0; i < numBSPDrawSurfaces; i++ )
+               {
+                       switch ( bspDrawSurfaces[i].surfaceType )
+                       {
+                       case SURFACE_FACE:
+                       case SURFACE_META:
+                               if ( bspDrawSurfaces[i].numIndexes % 3 ) {
+                                       Error( "Not a triangulation!" );
+                               }
+                               for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
+                               {
+                                       int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
+                                       bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
+                                       float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
+                                       // extrapolate:
+                                       //   a->xyz -> oa
+                                       //   b->xyz -> ob
+                                       //   c->xyz -> oc
+                                       ExtrapolateTexcoords(
+                                               &oa[0], &oa[3],
+                                               &ob[0], &ob[3],
+                                               &oc[0], &oc[3],
+                                               a->xyz, a->st,
+                                               b->xyz, b->st,
+                                               c->xyz, c->st );
+                               }
+                               break;
+                       }
+               }
+       }
+ */
+       /* scale planes */
+       for ( i = 0; i < numBSPPlanes; i++ )
+       {
+               if ( bspPlanes[ i ].dist > 0 ){
+                               if ( bspPlanes[ i ].normal[0] ){
+                                       bspPlanes[ i ].dist += scale[0];
+                                       continue;
+                               }
+                               else if ( bspPlanes[ i ].normal[1] ){
+                                       bspPlanes[ i ].dist += scale[1];
+                                       continue;
+                               }
+                               else if ( bspPlanes[ i ].normal[2] ){
+                                       bspPlanes[ i ].dist += scale[2];
+                                       continue;
+                               }
+               }
+               else{
+                               if ( bspPlanes[ i ].normal[0] ){
+                                       bspPlanes[ i ].dist -= scale[0];
+                                       continue;
+                               }
+                               else if ( bspPlanes[ i ].normal[1] ){
+                                       bspPlanes[ i ].dist -= scale[1];
+                                       continue;
+                               }
+                               else if ( bspPlanes[ i ].normal[2] ){
+                                       bspPlanes[ i ].dist -= scale[2];
+                                       continue;
+                               }
+               }
+       }
+ /*    if ( uniform ) {
+               for ( i = 0; i < numBSPPlanes; i++ )
+               {
+                       bspPlanes[ i ].dist += scale[0];
+               }
+       }
+       else
+       {
+               for ( i = 0; i < numBSPPlanes; i++ )
+               {
+ //                    bspPlanes[ i ].normal[0] /= scale[0];
+ //                    bspPlanes[ i ].normal[1] /= scale[1];
+ //                    bspPlanes[ i ].normal[2] /= scale[2];
+                       f = 1 / VectorLength( bspPlanes[i].normal );
+                       VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
+                       bspPlanes[ i ].dist *= f;
+               }
+       }*/
+       /* scale gridsize */
+       /*
+       GetVectorForKey( &entities[ 0 ], "gridsize", vec );
+       if ( ( vec[ 0 ] + vec[ 1 ] + vec[ 2 ] ) == 0.0f ) {
+               VectorCopy( gridSize, vec );
+       }
+       vec[0] *= scale[0];
+       vec[1] *= scale[1];
+       vec[2] *= scale[2];
+       sprintf( str, "%f %f %f", vec[ 0 ], vec[ 1 ], vec[ 2 ] );
+       SetKeyValue( &entities[ 0 ], "gridsize", str );
+ */
+       /* inject command line parameters */
+       InjectCommandLine( argv, 0, argc - 1 );
+       /* write the bsp */
+       UnparseEntities();
+       StripExtension( source );
+       DefaultExtension( source, "_sh.bsp" );
+       Sys_Printf( "Writing %s\n", source );
+       WriteBSPFile( source );
+       /* return to sender */
+       return 0;
+ }
  /*
     main()
     q3map mojo...
Simple merge
Simple merge
index 8200f01f1b3a8abea1c6feb1f5628e5ea6fb47c4,bd7c030ebfda67935dae006550713e62525fb070..bf1fee3deda57d822697c3c35e1b28e1dcc5a7cf
@@@ -1517,9 -1516,11 +1520,10 @@@ vec_t                       Random( voi
  char                        *Q_strncpyz( char *dst, const char *src, size_t len );
  char                        *Q_strcat( char *dst, size_t dlen, const char *src );
  char                        *Q_strncat( char *dst, size_t dlen, const char *src, size_t slen );
 -int                         BSPInfo( int count, char **fileNames );
 -int                         ScaleBSPMain( int argc, char **argv );
+ int                         ShiftBSPMain( int argc, char **argv );
 -int                         ConvertMain( int argc, char **argv );
  
 +/* help.c */
 +void                        HelpMain(const char* arg);
  
  /* path_init.c */
  game_t                      *GetGame( char *arg );
@@@ -2026,6 -2001,7 +2030,7 @@@ Q_EXTERN float jitters[ MAX_JITTERS ]
  
  
  /* commandline arguments */
 -Q_EXTERN qboolean                     nocmdline Q_ASSIGN( qfalse );
++Q_EXTERN qboolean nocmdline Q_ASSIGN( qfalse );
  Q_EXTERN qboolean verbose;
  Q_EXTERN qboolean verboseEntities Q_ASSIGN( qfalse );
  Q_EXTERN qboolean force Q_ASSIGN( qfalse );
@@@ -2244,7 -2222,8 +2251,8 @@@ Q_EXTERN qboolean keepLights Q_ASSIGN( 
  
  Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
  Q_EXTERN int minSampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_MIN_SAMPLE_SIZE );
 -Q_EXTERN float noVertexLighting Q_ASSIGN( 0.0f );
 +Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse );
+ Q_EXTERN qboolean nolm Q_ASSIGN( qfalse );
  Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse );
  
  Q_EXTERN qboolean noTrace Q_ASSIGN( qfalse );
Simple merge
Simple merge
Simple merge