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:
divverent
2009-07-21 17:18:11 +00:00
parent 5d6da89f89
commit 5429d1b989
3 changed files with 82 additions and 1 deletions
+41
View File
@@ -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();