}
-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();
}
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;
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 ){
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" );
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();
}
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() )
);
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 ){
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 );
/// \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();
// 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();
}
};
// 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
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 );
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;
}
{
- 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 );
}
}
}
}
else{
Sys_Printf( "Disabling half lambert light angle attenuation\n" );
+ i++;
}
}
+ i++;
}
else if ( !strcmp( argv[ i ], "-nostyle" ) || !strcmp( argv[ i ], "-nostyles" ) ) {
noStyles = qtrue;
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 ] );
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++;
}
}
}
}
-/*
- 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...
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 );
/* 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 );
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 );