Optimise lava animation algorithm.

This commit is contained in:
UnknownShadow200 2016-07-09 18:17:27 +10:00
parent 0160285b98
commit 35844e526d
2 changed files with 7 additions and 10 deletions

View File

@ -73,8 +73,8 @@ namespace ClassicalSharp.TexturePack {
}
if( !validated ) ValidateAnimations();
foreach( AnimationData anim in animations )
ApplyAnimation( anim );
for( int i = 0; i < animations.Count; i++ )
ApplyAnimation( animations[i] );
}
/// <summary> Reads a text file that contains a number of lines, with each line describing:<br/>

View File

@ -31,12 +31,13 @@ namespace ClassicalSharp {
for( int j = 0; j < 9; j++ ) {
int xx = x + (j % 3 - 1) + xOffset;
int yy = y + (j / 3 - 1) + yOffset;
localSoupHeat += soupHeat[Index( xx, yy )];
localSoupHeat += soupHeat[(yy & 0xF) << 4 | (xx & 0xF)];
}
float localPotHeat =
potHeat[Index( x, y )] + potHeat[Index( x, y + 1 )] +
potHeat[Index( x + 1, y )] + potHeat[Index( x + 1, y + 1 )];
float localPotHeat = potHeat[i]
+ potHeat[y << 4 | ((x + 1) & 0xF)] + // x + 1, y
+ potHeat[((y + 1) & 0xF) << 4 | x] + // x, y + 1
+ potHeat[((y + 1) & 0xF) << 4 | ((x + 1) & 0xF)];
soupHeat[i] = localSoupHeat / 10 + localPotHeat / 4 * 0.8f;
potHeat[i] += flameHeat[i] * 0.01f;
@ -62,9 +63,5 @@ namespace ClassicalSharp {
ptr++;
}
}
static int Index( int x, int y ) {
return (y & 0xF) << 4 | (x & 0xF);
}
}
}