private void UpdateTexture( byte freezeAmount )
{
mTexBuf.Lock( BufferLocking.Discard );
IntPtr dataPtr = mTexBuf.CurrentLock.Data;
// get access to raw texel data
int temperature;
Real sqrDistToBrush;
int dataIdx = 0;
unsafe
{
byte* data = (byte*)dataPtr.ToPointer();
{
// go through every texel...
for ( int y = 0; y < TEXTURE_SIZE; y++ )
{
for ( int x = 0; x < TEXTURE_SIZE; x++ )
{
if ( freezeAmount != 0 )
{
// gradually refreeze anything that isn't completely frozen
temperature = 0xff - data[ dataIdx ];
if ( temperature > freezeAmount )
data[ dataIdx ] += freezeAmount;
else
data[ dataIdx ] = 0xff;
}
if ( mWiping )
{
// wipe frost from under the cursor
sqrDistToBrush = Math.Utility.Sqr( x - mBrushPos.x ) + Math.Utility.Sqr( y - mBrushPos.y );
if ( sqrDistToBrush <= SQR_BRUSH_RADIUS )
data[ dataIdx ] = (byte)Math.Utility.Min( sqrDistToBrush / SQR_BRUSH_RADIUS * 0xff, data[ dataIdx ] );
}
dataIdx++;
}
}
}
}
mTexBuf.Unlock();
}
/// <summary>