X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatchmanip.cpp;h=8d7d5f99cb85bbcf0721fe44f39eba66b7fa3b8c;hb=a62c7302d3930875aafdc56696f370dbdc5ed40e;hp=b2c0b2d6f32a49f2fb1be34f8a9ceb6865f0aa72;hpb=a59855266c41b68a8bfd063713c941eff7449181;p=xonotic%2Fnetradiant.git diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index b2c0b2d6..8d7d5f99 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -199,27 +199,27 @@ void Scene_PatchDeform( scene::Graph& graph, const int deform ) void Patch_thicken( Patch& patch, scene::Instance& instance, const float thickness, bool seams, const int axis ){ // Create a new patch node - NodeSmartReference node(g_patchCreator->createPatch()); + NodeSmartReference node( g_patchCreator->createPatch() ); // Insert the node into worldspawn - Node_getTraversable(Map_FindOrInsertWorldspawn(g_map))->insert(node); + Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node ); // Retrieve the contained patch from the node - Patch* targetPatch = Node_getPatch(node); + Patch* targetPatch = Node_getPatch( node ); // Create the opposite patch with the given thickness = distance bool no12 = true; bool no34 = true; - targetPatch->createThickenedOpposite(patch, thickness, axis, no12, no34); + targetPatch->createThickenedOpposite( patch, thickness, axis, no12, no34 ); // Now select the newly created patches { - scene::Path patchpath(makeReference(GlobalSceneGraph().root())); - patchpath.push(makeReference(*Map_GetWorldspawn(g_map))); - patchpath.push(makeReference(node.get())); - Instance_getSelectable(*GlobalSceneGraph().find(patchpath))->setSelected(true); + scene::Path patchpath( makeReference( GlobalSceneGraph().root() ) ); + patchpath.push( makeReference( *Map_GetWorldspawn( g_map ) ) ); + patchpath.push( makeReference( node.get() ) ); + Instance_getSelectable( *GlobalSceneGraph().find( patchpath ) )->setSelected( true ); } - if (seams && thickness != 0.0f) { + if( seams && thickness != 0.0f){ int i = 0; if ( no12 ){ i = 2; @@ -229,31 +229,31 @@ void Patch_thicken( Patch& patch, scene::Instance& instance, const float thickne iend = 2; } // Now create the four walls - for ( ; i < iend; i++ ) { + for ( ; i < iend; i++ ){ // Allocate new patch - NodeSmartReference node = NodeSmartReference(g_patchCreator->createPatch()); + NodeSmartReference node = NodeSmartReference( g_patchCreator->createPatch() ); // Insert each node into worldspawn - Node_getTraversable(Map_FindOrInsertWorldspawn(g_map))->insert(node); + Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->insert( node ); // Retrieve the contained patch from the node - Patch* wallPatch = Node_getPatch(node); + Patch* wallPatch = Node_getPatch( node ); // Create the wall patch by passing i as wallIndex - wallPatch->createThickenedWall( patch, *targetPatch, i); + wallPatch->createThickenedWall( patch, *targetPatch, i ); if( ( wallPatch->localAABB().extents[0] <= 0.00005 && wallPatch->localAABB().extents[1] <= 0.00005 ) || ( wallPatch->localAABB().extents[1] <= 0.00005 && wallPatch->localAABB().extents[2] <= 0.00005 ) || ( wallPatch->localAABB().extents[0] <= 0.00005 && wallPatch->localAABB().extents[2] <= 0.00005 ) ){ //globalOutputStream() << "Thicken: Discarding degenerate patch.\n"; - Node_getTraversable( Map_FindOrInsertWorldspawn(g_map) )->erase( node ); + Node_getTraversable( Map_FindOrInsertWorldspawn( g_map ) )->erase( node ); } else // Now select the newly created patches { - scene::Path patchpath(makeReference(GlobalSceneGraph().root())); - patchpath.push(makeReference(*Map_GetWorldspawn(g_map))); - patchpath.push(makeReference(node.get())); - Instance_getSelectable(*GlobalSceneGraph().find(patchpath))->setSelected(true); + scene::Path patchpath( makeReference( GlobalSceneGraph().root() ) ); + patchpath.push( makeReference( *Map_GetWorldspawn(g_map) ) ); + patchpath.push( makeReference( node.get() ) ); + Instance_getSelectable( *GlobalSceneGraph().find( patchpath ) )->setSelected( true ); } } } @@ -453,12 +453,28 @@ void operator()( Patch& patch ) const { } }; +namespace{ +bool DoingSearch( const char *repl ){ + return ( repl == NULL || ( strcmp( "textures/", repl ) == 0 ) ); +} +} void Scene_PatchFindReplaceShader( scene::Graph& graph, const char* find, const char* replace ){ - Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) ); + if( DoingSearch( replace ) ){ + Scene_forEachVisiblePatchInstance( PatchSelectByShader( find ) ); + } + else{ + Scene_forEachVisiblePatch( PatchFindReplaceShader( find, replace ) ); + } } void Scene_PatchFindReplaceShader_Selected( scene::Graph& graph, const char* find, const char* replace ){ - Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) ); + if( DoingSearch( replace ) ){ + //do nothing, because alternative is replacing to notex + //perhaps deselect ones with not matching shaders here? + } + else{ + Scene_forEachVisibleSelectedPatch( PatchFindReplaceShader( find, replace ) ); + } } @@ -687,6 +703,24 @@ void Patch_NaturalTexture(){ Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() ); } +void Patch_CapTexture(){ + UndoableCommand command( "patchCapTexture" ); + Scene_PatchCapTexture_Selected( GlobalSceneGraph() ); +} + +void Patch_ResetTexture(){ + float fx, fy; + if ( DoTextureLayout( &fx, &fy ) == eIDOK ) { + UndoableCommand command( "patchTileTexture" ); + Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy ); + } +} + +void Patch_FitTexture(){ + UndoableCommand command( "patchFitTexture" ); + Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 ); +} + void DoPatchDeformDlg(); void Patch_Deform(){ @@ -740,13 +774,15 @@ bool filter( const Patch& patch ) const { filter_patch_all g_filter_patch_all; -filter_patch_shader g_filter_patch_clip( "textures/common/clip" ); +filter_patch_flags g_filter_patch_clip( QER_CLIP ); +filter_patch_shader g_filter_patch_commonclip( "textures/common/clip" ); filter_patch_shader g_filter_patch_weapclip( "textures/common/weapclip" ); -filter_patch_flags g_filter_patch_translucent( QER_TRANS ); +filter_patch_flags g_filter_patch_translucent( QER_TRANS | QER_ALPHATEST ); void PatchFilters_construct(){ add_patch_filter( g_filter_patch_all, EXCLUDE_CURVES ); add_patch_filter( g_filter_patch_clip, EXCLUDE_CLIP ); + add_patch_filter( g_filter_patch_commonclip, EXCLUDE_CLIP ); add_patch_filter( g_filter_patch_weapclip, EXCLUDE_CLIP ); add_patch_filter( g_filter_patch_translucent, EXCLUDE_TRANSLUCENT ); } @@ -778,10 +814,6 @@ void PatchPreferences_construct(){ void Patch_registerCommands(){ GlobalCommands_insert( "InvertCurveTextureX", FreeCaller(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "InvertCurveTextureY", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "IncPatchColumn", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "IncPatchRow", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "DecPatchColumn", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "DecPatchRow", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "NaturalizePatch", FreeCaller(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PatchCylinder", FreeCaller() ); GlobalCommands_insert( "PatchDenseCylinder", FreeCaller() ); @@ -797,14 +829,14 @@ void Patch_registerCommands(){ GlobalCommands_insert( "PatchCone", FreeCaller() ); GlobalCommands_insert( "PatchSphere", FreeCaller() ); GlobalCommands_insert( "SimplePatchMesh", FreeCaller(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller() ); + GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller() ); - GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller() ); + GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "PatchInsertAddRow", FreeCaller() ); GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller() ); + GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller() ); + GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "InvertCurve", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "RedisperseRows", FreeCaller(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "RedisperseCols", FreeCaller(), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); @@ -820,7 +852,7 @@ void Patch_registerCommands(){ } void Patch_constructToolbar( GtkToolbar* toolbar ){ - toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.bmp", "CapCurrentCurve" ); + toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.png", "CapCurrentCurve" ); } void Patch_constructMenu( GtkMenu* menu ){ @@ -860,11 +892,11 @@ void Patch_constructMenu( GtkMenu* menu ){ if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } - create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" ); create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Columns", "PatchInsertAddColumn" ); + create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Columns", "PatchInsertInsertColumn" ); menu_separator( menu_in_menu ); - create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" ); create_menu_item_with_mnemonic( menu_in_menu, "Add (2) Rows", "PatchInsertAddRow" ); + create_menu_item_with_mnemonic( menu_in_menu, "Insert (2) Rows", "PatchInsertInsertRow" ); } { GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "Delete" ); @@ -1152,35 +1184,35 @@ EMessageBoxReturn DoCapDlg( ECapDialog* type ){ gtk_table_set_col_spacings( table, 5 ); { - GtkImage* image = new_local_image( "cap_bevel.bmp" ); + GtkImage* image = new_local_image( "cap_bevel.png" ); gtk_widget_show( GTK_WIDGET( image ) ); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 0, 1, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_endcap.bmp" ); + GtkImage* image = new_local_image( "cap_endcap.png" ); gtk_widget_show( GTK_WIDGET( image ) ); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 1, 2, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_ibevel.bmp" ); + GtkImage* image = new_local_image( "cap_ibevel.png" ); gtk_widget_show( GTK_WIDGET( image ) ); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 2, 3, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_iendcap.bmp" ); + GtkImage* image = new_local_image( "cap_iendcap.png" ); gtk_widget_show( GTK_WIDGET( image ) ); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 3, 4, (GtkAttachOptions) ( GTK_FILL ), (GtkAttachOptions) ( 0 ), 0, 0 ); } { - GtkImage* image = new_local_image( "cap_cylinder.bmp" ); + GtkImage* image = new_local_image( "cap_cylinder.png" ); gtk_widget_show( GTK_WIDGET( image ) ); gtk_table_attach( table, GTK_WIDGET( image ), 0, 1, 4, 5, (GtkAttachOptions) ( GTK_FILL ),