controlPointsChanged();
}
+void Patch::Smooth(EMatrixMajor mt)
+{
+ std::size_t w, h, width, height, row_stride, col_stride;
+ bool wrap;
+ PatchControl* p1, * p2, * p3, * p2b;
+
+ 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;
+ }
+
+ wrap = true;
+ for(h=0;h<height;h++)
+ {
+ p1 = m_ctrl.data()+(h*row_stride);
+ p2 = p1+(2*width)*col_stride;
+ //globalErrorStream() << "compare " << p1->m_vertex << " and " << p2->m_vertex << "\n";
+ if(vector3_length_squared(vector3_subtracted(p1->m_vertex, p2->m_vertex)) > 1.0)
+ {
+ //globalErrorStream() << "too far\n";
+ wrap = false;
+ break;
+ }
+ }
+
+ 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;
+ }
+ if(wrap)
+ {
+ p1 = m_ctrl.data()+(h*row_stride)+(2*width-1)*col_stride;
+ p2 = m_ctrl.data()+(h*row_stride);
+ p2b = m_ctrl.data()+(h*row_stride)+(2*width)*col_stride;
+ p3 = m_ctrl.data()+(h*row_stride)+col_stride;
+ p2->m_vertex = p2b->m_vertex = vector3_mid(p1->m_vertex, p3->m_vertex);
+ }
+ }
+
+ controlPointsChanged();
+}
+
void Patch::InsertRemove(bool bInsert, bool bColumn, bool bFirst)
{
undoSave();
{
pCtrl->m_vertex[0] = vPos[1][0];
pCtrl->m_vertex[1] = vPos[1][1];
- pCtrl->m_vertex[2] = vPos[2][2];
+ pCtrl->m_vertex[2] = vPos[0][2];
}
}
{
pCtrl->m_vertex[2] = vPos[2][2];
}
}
+ break;
default:
ERROR_MESSAGE("this should be unreachable");
return;