new feature to smooth patches
git-svn-id: svn://svn.icculus.org/netradiant/trunk@387 61c419a2-8eb2-4b30-bcec-8cead039b335
This commit is contained in:
parent
5d6da89f89
commit
5429d1b989
|
|
@ -396,6 +396,47 @@ void Patch::Redisperse(EMatrixMajor mt)
|
|||
controlPointsChanged();
|
||||
}
|
||||
|
||||
void Patch::Smooth(EMatrixMajor mt)
|
||||
{
|
||||
std::size_t w, h, width, height, row_stride, col_stride;
|
||||
PatchControl* p1, * p2, * p3;
|
||||
|
||||
undoSave();
|
||||
|
||||
switch(mt)
|
||||
{
|
||||
case COL:
|
||||
width = (m_width-1)>>1;
|
||||
height = m_height;
|
||||
col_stride = 1;
|
||||
row_stride = m_width;
|
||||
break;
|
||||
case ROW:
|
||||
width = (m_height-1)>>1;
|
||||
height = m_width;
|
||||
col_stride = m_width;
|
||||
row_stride = 1;
|
||||
break;
|
||||
default:
|
||||
ERROR_MESSAGE("neither row-major nor column-major");
|
||||
return;
|
||||
}
|
||||
|
||||
for(h=0;h<height;h++)
|
||||
{
|
||||
p1 = m_ctrl.data()+(h*row_stride)+col_stride;
|
||||
for(w=0;w<width-1;w++)
|
||||
{
|
||||
p2 = p1+col_stride;
|
||||
p3 = p2+col_stride;
|
||||
p2->m_vertex = vector3_mid(p1->m_vertex, p3->m_vertex);
|
||||
p1 = p3;
|
||||
}
|
||||
}
|
||||
|
||||
controlPointsChanged();
|
||||
}
|
||||
|
||||
void Patch::InsertRemove(bool bInsert, bool bColumn, bool bFirst)
|
||||
{
|
||||
undoSave();
|
||||
|
|
|
|||
|
|
@ -973,6 +973,7 @@ public:
|
|||
void InvertMatrix();
|
||||
void TransposeMatrix();
|
||||
void Redisperse(EMatrixMajor mt);
|
||||
void Smooth(EMatrixMajor mt);
|
||||
void InsertRemove(bool bInsert, bool bColumn, bool bFirst);
|
||||
Patch* MakeCap(Patch* patch, EPatchCap eType, EMatrixMajor mt, bool bFirst);
|
||||
void ConstructSeam(EPatchCap eType, Vector3* p, std::size_t width);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
@ -547,7 +565,7 @@ void Patch_RedisperseRows()
|
|||
{
|
||||
UndoableCommand undo("patchRedisperseRows");
|
||||
|
||||
Scene_PatchRedisperse_Selected(GlobalSceneGraph(), COL);
|
||||
Scene_PatchRedisperse_Selected(GlobalSceneGraph(), ROW);
|
||||
}
|
||||
|
||||
void Patch_RedisperseCols()
|
||||
|
|
@ -557,6 +575,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");
|
||||
|
|
@ -724,6 +756,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)));
|
||||
|
|
@ -793,6 +827,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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user