X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpatchmanip.cpp;h=909e3466311f966e23e11e9af66ddea22f221764;hb=9e2b92c51d00ba3a497ee88e60b4cb91ffde2c2e;hp=e42fdc37edce1823c24d8a04d838b2ee07d341cb;hpb=50a295176a1a8003725637837144880a271f3374;p=xonotic%2Fnetradiant.git diff --git a/radiant/patchmanip.cpp b/radiant/patchmanip.cpp index e42fdc37..909e3466 100644 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@ -67,6 +67,32 @@ void Scene_PatchConstructPrefab( scene::Graph& graph, const AABB aabb, const cha } } +void PatchAutoCapTexture( Patch& patch ) { + + AABB box = patch.localAABB(); + float x = box.extents.x(); + float y = box.extents.y(); + float z = box.extents.z(); + + int cap_direction = -1; + if ( x < y && x < z ) + cap_direction = 0; + else if ( y < x && y < z ) + cap_direction = 1; + else if ( z < x && z < x ) + cap_direction = 2; + + if ( cap_direction >= 0 ) + patch.ProjectTexture(cap_direction); + else + patch.NaturalTexture(); +} + +void Patch_AutoCapTexture(){ + UndoableCommand command( "patchAutoCapTexture" ); + Scene_forEachVisibleSelectedPatch( &PatchAutoCapTexture ); + SceneChangeNotify(); +} void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, const char* shader ){ if ( ( type == eCapEndCap || type == eCapIEndCap ) @@ -89,8 +115,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co NodeSmartReference cap( g_patchCreator->createPatch() ); Node_getTraversable( instance.path().parent() )->insert( cap ); - patch.MakeCap( Node_getPatch( cap ), type, ROW, true ); - Node_getPatch( cap )->SetShader( shader ); + Patch* cap_patch = Node_getPatch( cap ); + patch.MakeCap( cap_patch, type, ROW, true ); + cap_patch->SetShader( shader ); + PatchAutoCapTexture(*cap_patch); scene::Path path( instance.path() ); path.pop(); @@ -102,8 +130,10 @@ void Patch_makeCaps( Patch& patch, scene::Instance& instance, EPatchCap type, co NodeSmartReference cap( g_patchCreator->createPatch() ); Node_getTraversable( instance.path().parent() )->insert( cap ); - patch.MakeCap( Node_getPatch( cap ), type, ROW, false ); - Node_getPatch( cap )->SetShader( shader ); + Patch* cap_patch = Node_getPatch( cap ); + patch.MakeCap( cap_patch, type, ROW, false ); + cap_patch->SetShader( shader ); + PatchAutoCapTexture(*cap_patch); scene::Path path( instance.path() ); path.pop(); @@ -714,7 +744,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)", "cap_curve.png", "CapCurrentCurve" ); } void Patch_constructMenu( GtkMenu* menu ){ @@ -970,35 +1000,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 ),