]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/patchmanip.cpp
new funny option: -samplessearchboxsize, tunes the size of the search box of -samples...
[xonotic/netradiant.git] / radiant / patchmanip.cpp
index 421290654864996c02299e81fb8e0e90c71b8cc0..b8bccee63d735ad3c8bb40279880f08ca13d4624 100644 (file)
@@ -294,6 +294,24 @@ void Scene_PatchRedisperse_Selected(scene::Graph& graph, EMatrixMajor major)
   Scene_forEachVisibleSelectedPatch(PatchRedisperse(major));
 }
 
+class PatchSmooth
+{
+  EMatrixMajor m_major;
+public:
+  PatchSmooth(EMatrixMajor major) : m_major(major)
+  {
+  }
+  void operator()(Patch& patch) const
+  {
+    patch.Smooth(m_major);
+  }
+};
+
+void Scene_PatchSmooth_Selected(scene::Graph& graph, EMatrixMajor major)
+{
+  Scene_forEachVisibleSelectedPatch(PatchSmooth(major));
+}
+
 class PatchTransposeMatrix
 {
 public:
@@ -456,6 +474,13 @@ void Patch_Bevel()
   Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eBevel, GlobalXYWnd_getCurrentViewType());
 }
 
+void Patch_Sphere()
+{
+  UndoableCommand undo("patchCreateSphere");
+
+  Scene_PatchConstructPrefab(GlobalSceneGraph(), PatchCreator_getBounds(), TextureBrowser_GetSelectedShader(GlobalTextureBrowser()), eSphere, GlobalXYWnd_getCurrentViewType());
+}
+
 void Patch_SquareBevel()
 {
 }
@@ -547,7 +572,7 @@ void Patch_RedisperseRows()
 {
   UndoableCommand undo("patchRedisperseRows");
 
-  Scene_PatchRedisperse_Selected(GlobalSceneGraph(), COL);
+  Scene_PatchRedisperse_Selected(GlobalSceneGraph(), ROW);
 }
 
 void Patch_RedisperseCols()
@@ -557,6 +582,20 @@ void Patch_RedisperseCols()
   Scene_PatchRedisperse_Selected(GlobalSceneGraph(), COL);
 }
 
+void Patch_SmoothRows()
+{
+  UndoableCommand undo("patchSmoothRows");
+
+  Scene_PatchSmooth_Selected(GlobalSceneGraph(), ROW);
+}
+
+void Patch_SmoothCols()
+{
+  UndoableCommand undo("patchSmoothColumns");
+
+  Scene_PatchSmooth_Selected(GlobalSceneGraph(), COL);
+}
+
 void Patch_Transpose()
 {
   UndoableCommand undo("patchTranspose");
@@ -712,6 +751,7 @@ void Patch_registerCommands()
   GlobalCommands_insert("PatchSquareBevel", FreeCaller<Patch_SquareBevel>());
   GlobalCommands_insert("PatchSquareEndcap", FreeCaller<Patch_SquareEndcap>());
   GlobalCommands_insert("PatchCone", FreeCaller<Patch_Cone>());
+  GlobalCommands_insert("PatchSphere", FreeCaller<Patch_Sphere>());
   GlobalCommands_insert("SimplePatchMesh", FreeCaller<Patch_Plane>(), Accelerator('P', (GdkModifierType)GDK_SHIFT_MASK));
   GlobalCommands_insert("PatchInsertInsertColumn", FreeCaller<Patch_InsertInsertColumn>());
   GlobalCommands_insert("PatchInsertAddColumn", FreeCaller<Patch_InsertAddColumn>());
@@ -724,6 +764,8 @@ void Patch_registerCommands()
   GlobalCommands_insert("InvertCurve", FreeCaller<Patch_Invert>(), Accelerator('I', (GdkModifierType)GDK_CONTROL_MASK));
   GlobalCommands_insert("RedisperseRows", FreeCaller<Patch_RedisperseRows>(), Accelerator('E', (GdkModifierType)GDK_CONTROL_MASK));
   GlobalCommands_insert("RedisperseCols", FreeCaller<Patch_RedisperseCols>(), Accelerator('E', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
+  GlobalCommands_insert("SmoothRows", FreeCaller<Patch_SmoothRows>(), Accelerator('W', (GdkModifierType)GDK_CONTROL_MASK));
+  GlobalCommands_insert("SmoothCols", FreeCaller<Patch_SmoothCols>(), Accelerator('W', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
   GlobalCommands_insert("MatrixTranspose", FreeCaller<Patch_Transpose>(), Accelerator('M', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
   GlobalCommands_insert("CapCurrentCurve", FreeCaller<Patch_Cap>(), Accelerator('C', (GdkModifierType)GDK_SHIFT_MASK));
   GlobalCommands_insert("CycleCapTexturePatch", FreeCaller<Patch_CycleProjection>(), Accelerator('N', (GdkModifierType)(GDK_SHIFT_MASK|GDK_CONTROL_MASK)));
@@ -759,6 +801,7 @@ void Patch_constructMenu(GtkMenu* menu)
   }
   menu_separator (menu);
   create_menu_item_with_mnemonic(menu, "Cone", "PatchCone");
+  create_menu_item_with_mnemonic(menu, "Sphere", "PatchSphere");
   menu_separator (menu);
   create_menu_item_with_mnemonic(menu, "Simple Patch Mesh...", "SimplePatchMesh");
   menu_separator (menu);
@@ -793,6 +836,11 @@ void Patch_constructMenu(GtkMenu* menu)
       menu_tearoff (menu_3);
     create_menu_item_with_mnemonic(menu_3, "Rows", "RedisperseRows");
     create_menu_item_with_mnemonic(menu_3, "Columns", "RedisperseCols");
+    GtkMenu* menu_4 = create_sub_menu_with_mnemonic (menu_in_menu, "Smooth");
+    if (g_Layout_enableDetachableMenus.m_value)
+      menu_tearoff (menu_4);
+    create_menu_item_with_mnemonic(menu_4, "Rows", "SmoothRows");
+    create_menu_item_with_mnemonic(menu_4, "Columns", "SmoothCols");
     create_menu_item_with_mnemonic(menu_in_menu, "Transpose", "MatrixTranspose");
   }
   menu_separator (menu);
@@ -861,6 +909,14 @@ void DoNewPatchDlg()
         gtk_combo_box_append_text(combo, "11");
         gtk_combo_box_append_text(combo, "13");
         gtk_combo_box_append_text(combo, "15");
+        gtk_combo_box_append_text(combo, "17");
+        gtk_combo_box_append_text(combo, "19");
+        gtk_combo_box_append_text(combo, "21");
+        gtk_combo_box_append_text(combo, "23");
+        gtk_combo_box_append_text(combo, "25");
+        gtk_combo_box_append_text(combo, "27");
+        gtk_combo_box_append_text(combo, "29");
+        gtk_combo_box_append_text(combo, "31"); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
         gtk_widget_show(GTK_WIDGET(combo));
         gtk_table_attach(table, GTK_WIDGET(combo), 1, 2, 0, 1,
                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
@@ -877,6 +933,14 @@ void DoNewPatchDlg()
         gtk_combo_box_append_text(combo, "11");
         gtk_combo_box_append_text(combo, "13");
         gtk_combo_box_append_text(combo, "15");
+        gtk_combo_box_append_text(combo, "17");
+        gtk_combo_box_append_text(combo, "19");
+        gtk_combo_box_append_text(combo, "21");
+        gtk_combo_box_append_text(combo, "23");
+        gtk_combo_box_append_text(combo, "25");
+        gtk_combo_box_append_text(combo, "27");
+        gtk_combo_box_append_text(combo, "29");
+        gtk_combo_box_append_text(combo, "31"); // MAX_PATCH_SIZE is 32, so we should be able to do 31...
         gtk_widget_show(GTK_WIDGET(combo));
         gtk_table_attach(table, GTK_WIDGET(combo), 1, 2, 1, 2,
                           (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),