public void Apply(VoxelStencil stencil)
{
int xStart = stencil.XStart;
int xEnd = stencil.XEnd;
int yStart = stencil.YStart;
int yEnd = stencil.YEnd;
if (xStart < 0)
{
xStart = 0;
}
if (xEnd >= m_resolution)
{
xEnd = m_resolution - 1;
}
if (yStart < 0)
{
yStart = 0;
}
if (yEnd >= m_resolution)
{
yEnd = m_resolution - 1;
}
for (int y = yStart; y <= yEnd; y++)
{
int i = y * m_resolution + xStart;
for (int x = xStart; x <= xEnd; x++, i++)
{
m_voxels[i].m_state = stencil.Apply(x, y, m_voxels[i].m_state);
}
}
Refresh();
}