Only apply fog when exactly intersecting with the block.

This commit is contained in:
UnknownShadow200 2015-12-24 21:48:14 +11:00
parent 95bc4a3c03
commit c52534923f
2 changed files with 13 additions and 5 deletions

View File

@ -49,7 +49,7 @@ namespace ClassicalSharp {
legXRot = -(float)(Math.Cos( walkTime ) * swing * legMax);
armZRot = -idleZRot;
bobYOffset = (float)(Math.Abs( Math.Cos( walkTime ) ) * swing * (3/16f));
bobYOffset = (float)(Math.Abs( Math.Cos( walkTime ) ) * swing * (2.5f/16f));
tilt = (float)Math.Cos( walkTime ) * swing * (0.15f * Utils.Deg2Rad);
if( Model is PlayerModel )
CalcHumanAnim( idleXRot, idleZRot );

View File

@ -122,13 +122,21 @@ namespace ClassicalSharp.Renderers {
void ResetFog() {
if( map.IsNotLoaded ) return;
FastColour adjFogCol = FastColour.White;
Block headBlock = game.LocalPlayer.BlockAtHead;
BlockInfo info = game.BlockInfo;
BoundingBox pBounds = game.LocalPlayer.CollisionBounds;
if( info.FogDensity[(byte)headBlock] != 0 ) {
Vector3I headCoords = Vector3I.Floor( game.LocalPlayer.EyePosition );
Vector3 pos = (Vector3)headCoords;
byte headBlock = game.Map.SafeGetBlock( headCoords );
BoundingBox blockBB = new BoundingBox( pos + game.BlockInfo.MinBB[headBlock],
pos + game.BlockInfo.MaxBB[headBlock] );
BoundingBox localBB = game.LocalPlayer.CollisionBounds;
bool intersecting = blockBB.Intersects( localBB );
if( intersecting && info.FogDensity[headBlock] != 0 ) {
graphics.SetFogMode( Fog.Exp );
graphics.SetFogDensity( info.FogDensity[(byte)headBlock] );
adjFogCol = info.FogColour[(byte)headBlock];
graphics.SetFogDensity( info.FogDensity[headBlock] );
adjFogCol = info.FogColour[headBlock];
} else {
// Blend fog and sky together
float blend = (float)BlendFactor( game.ViewDistance );