Optimise lava animation slightly.

This commit is contained in:
UnknownShadow200 2016-07-07 22:01:36 +10:00
parent b135d484b3
commit 7236028106
3 changed files with 15 additions and 19 deletions

View file

@ -118,7 +118,6 @@ namespace ClassicalSharp.Entities {
/// <summary> Sets the user type of this user. This is used to control permissions for grass,
/// bedrock, water and lava blocks on servers that don't support CPE block permissions. </summary>
public void SetUserType( byte value ) {
value = 0x64;
UserType = value;
Inventory inv = game.Inventory;
inv.CanPlace[Block.Bedrock] = value == 0x64;

View file

@ -62,19 +62,19 @@ namespace ClassicalSharp.TexturePack {
/// <summary> Runs through all animations and if necessary updates the terrain atlas. </summary>
public unsafe void Tick( double delta ) {
if( animations.Count == 0 ) return;
if( useLavaAnim ) DrawAnimation( null, 30, 16 );
if( animations.Count == 0 ) return;
if( animsBuffer == null ) {
game.Chat.Add( "&cCurrent texture pack specifies it uses animations," );
game.Chat.Add( "&cbut is missing animations.png" );
animations.Clear();
return;
}
if( !validated ) ValidateAnimations();
if( !validated ) ValidateAnimations();
foreach( AnimationData anim in animations )
ApplyAnimation( anim );
if( useLavaAnim ) DrawAnimation( null, 30, 16 );
}
/// <summary> Reads a text file that contains a number of lines, with each line describing:<br/>
@ -148,7 +148,7 @@ namespace ClassicalSharp.TexturePack {
animPart.SetData( size, size, size * 4, (IntPtr)temp, false );
if( data == null )
lavaAnim.Tick( animPart );
lavaAnim.Tick( (int*)temp );
else
FastBitmap.MovePortion( data.FrameX + data.State * size,
data.FrameY, 0, 0, animsBuffer, animPart, size );

View file

@ -13,7 +13,7 @@ namespace ClassicalSharp {
float[] soupHeat = new float[size * size];
JavaRandom rnd = null;
public void Tick( FastBitmap output ) {
public unsafe void Tick( int* output ) {
if( rnd == null )
rnd = new JavaRandom( new Random().Next() );
Step();
@ -49,19 +49,16 @@ namespace ClassicalSharp {
}
}
void Output( FastBitmap output ) {
void Output( int* ptr ) {
int index = 0;
for( int y = 0; y < size; y++ ) {
int* row = output.GetRowPtr( y );
for( int x = 0; x < size; x++ ) {
float col = 2 * soupHeat[index];
Utils.Clamp( ref col, 0, 1 );
float r = col * 100 + 155;
float g = col * col * 255;
float b = col * col * col * col * 128;
row[x] = 255 << 24 | (byte)r << 16 | (byte)g << 8 | (byte)b;
index++;
}
for( int i = 0; i < soupHeat.Length; i++) {
float col = 2 * soupHeat[i];
Utils.Clamp( ref col, 0, 1 );
float r = col * 100 + 155;
float g = col * col * 255;
float b = col * col * col * col * 128;
*ptr = 255 << 24 | (byte)r << 16 | (byte)g << 8 | (byte)b;
ptr++;
}
}