internal void CleanTree()
{
if (DirtyTreeArea == null)
return;
var area = DirtyTreeArea.Value;
DirtyTreeArea = null;
Program program = terrain.Program;
Device.FrameBuffer = terrain.FrameBuffer;
// Perform the horizontal reduction.
program.Uniforms["heightTexture"].Set(HeightTexture);
program.Uniforms["world"].Set(Matrix4f.Scale(16f / terrain.BlockSize, 0, 0));
program.Uniforms["view"].Set(new Matrix4f(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1));
terrain.FrameBuffer.Colors[0].Attach(terrain.NarrowHeightTexture);
Device.Blend = BlendState.Opaque;
terrain.DrawUnitRectangle("clean");
// Perform the vertical reduction.
program.Uniforms["HeightTexture"].Set(terrain.NarrowHeightTexture);
program.Uniforms["World"].Set(Matrix4d.Scale(0, 16.0 / terrain.BlockSize, 0));
program.Uniforms["View"].Set(Matrix4d.Identity);
terrain.FrameBuffer.Colors[0].Attach(terrain.SmallHeightTexture);
terrain.DrawUnitRectangle("clean");
Device.FrameBuffer = null;
terrain.SmallHeightTexture.Levels[0].Read(terrain.SmallHeightData);
treeRoot.Clean(ref area, terrain.SmallHeightData);
foreach (var module in terrain.Components)
module.OnHeightModified(this, ref area);
}