diff --git a/ClassicalSharp/Blocks/BlockInfo.BoundingBox.cs b/ClassicalSharp/Blocks/BlockInfo.BoundingBox.cs index 8c34657b6..78e9e6ebd 100644 --- a/ClassicalSharp/Blocks/BlockInfo.BoundingBox.cs +++ b/ClassicalSharp/Blocks/BlockInfo.BoundingBox.cs @@ -28,6 +28,8 @@ namespace ClassicalSharp { } } + const float angle = 45f * Utils.Deg2Rad; + static readonly Vector3 centre = new Vector3( 0.5f, 0, 0.5f ); internal void RecalculateBB( int block, FastBitmap fastBmp ) { int elemSize = fastBmp.Width / 16; int texId = GetTextureLoc( (byte)block, TileSide.Top ); @@ -36,10 +38,8 @@ namespace ClassicalSharp { float leftX = GetSpriteBB_LeftX( elemSize, texId & 0x0F, texId >> 4, fastBmp ); float rightX = GetSpriteBB_RightX( elemSize, texId & 0x0F, texId >> 4, fastBmp ); - MinBB[block] = Utils.RotateY( leftX - 0.5f, bottomY, 0, 45f * Utils.Deg2Rad ) - + new Vector3( 0.5f, 0, 0.5f ); - MaxBB[block] = Utils.RotateY( rightX - 0.5f, topY, 0, 45f * Utils.Deg2Rad ) - + new Vector3( 0.5f, 0, 0.5f ); + MinBB[block] = Utils.RotateY( leftX - 0.5f, bottomY, 0, angle ) + centre; + MaxBB[block] = Utils.RotateY( rightX - 0.5f, topY, 0, angle ) + centre; } unsafe float GetSpriteBB_TopY( int size, int tileX, int tileY, FastBitmap fastBmp ) { diff --git a/ClassicalSharp/Entities/PhysicsEntity.cs b/ClassicalSharp/Entities/PhysicsEntity.cs index 2b7c74008..f3cdfc0f9 100644 --- a/ClassicalSharp/Entities/PhysicsEntity.cs +++ b/ClassicalSharp/Entities/PhysicsEntity.cs @@ -25,8 +25,8 @@ namespace ClassicalSharp { bool GetBoundingBox( byte block, int x, int y, int z, ref BoundingBox box ) { if( info.CollideType[block] != BlockCollideType.Solid ) return false; - box.Min = new Vector3( x, y, z ); - box.Max = new Vector3( x + 1, y + info.Height[block], z + 1 ); + box.Min = new Vector3( x, y, z ) + info.MinBB[block]; + box.Max = new Vector3( x, y, z ) + info.MaxBB[block]; return true; } diff --git a/ClassicalSharp/Game/InputHandler.cs b/ClassicalSharp/Game/InputHandler.cs index b48cf9c7a..6c984a114 100644 --- a/ClassicalSharp/Game/InputHandler.cs +++ b/ClassicalSharp/Game/InputHandler.cs @@ -113,13 +113,12 @@ namespace ClassicalSharp { } bool CheckIsFree( PickedPos selected, byte newBlock ) { + Vector3 pos = (Vector3)selected.TranslatedPos; if( !CannotPassThrough( newBlock ) ) return true; - if( IntersectsOtherPlayers( selected.TranslatedPos, newBlock ) ) return false; + if( IntersectsOtherPlayers( pos, newBlock ) ) return false; - Vector3I pos = selected.TranslatedPos; - float height = game.BlockInfo.Height[newBlock]; - BoundingBox blockBB = new BoundingBox( pos.X, pos.Y, pos.Z, - pos.X + 1, pos.Y + height, pos.Z + 1 ); + BoundingBox blockBB = new BoundingBox( pos + game.BlockInfo.MinBB[newBlock], + pos + game.BlockInfo.MaxBB[newBlock] ); BoundingBox localBB = game.LocalPlayer.CollisionBounds; if( game.LocalPlayer.noClip || !localBB.Intersects( blockBB ) ) return true; @@ -132,7 +131,7 @@ namespace ClassicalSharp { // Push player up if they are jumping and trying to place a block underneath them. Vector3 p = game.LocalPlayer.Position; - p.Y = pos.Y + height + Entity.Adjustment; + p.Y = pos.Y + game.BlockInfo.Height[newBlock] + Entity.Adjustment; LocationUpdate update = LocationUpdate.MakePos( p, false ); game.LocalPlayer.SetLocation( update, false ); return true; @@ -178,10 +177,9 @@ namespace ClassicalSharp { return game.BlockInfo.CollideType[block] == BlockCollideType.Solid; } - bool IntersectsOtherPlayers( Vector3I pos, byte newType ) { - float height = game.BlockInfo.Height[newType]; - BoundingBox blockBB = new BoundingBox( pos.X, pos.Y, pos.Z, - pos.X + 1, pos.Y + height, pos.Z + 1 ); + bool IntersectsOtherPlayers( Vector3 pos, byte newType ) { + BoundingBox blockBB = new BoundingBox( pos + game.BlockInfo.MinBB[newType], + pos + game.BlockInfo.MaxBB[newType] ); for( int id = 0; id < 255; id++ ) { Player player = game.Players[id]; diff --git a/ClassicalSharp/GraphicsAPI/OpenGLApi.cs b/ClassicalSharp/GraphicsAPI/OpenGLApi.cs index 935038ab8..5ba253731 100644 --- a/ClassicalSharp/GraphicsAPI/OpenGLApi.cs +++ b/ClassicalSharp/GraphicsAPI/OpenGLApi.cs @@ -399,9 +399,9 @@ namespace ClassicalSharp.GraphicsAPI { chat.Add( "&cIntel graphics cards are known to have issues with the OpenGL build." ); chat.Add( "&cVSync may not work, and you may see disappearing clouds and map edges." ); chat.Add( " " ); - chat.Add( "&cFor Windows, try downloading the Direct3D 9 build as it doesn't have these problems" ); - chat.Add( "&cAlternatively, the disappearing graphics can be partially fixed by " ); - chat.Add( "&ctyping \"/client rendertype legacy\" into chat." ); + chat.Add( "&cFor Windows, try downloading the Direct3D 9 build as it doesn't have" ); + chat.Add( "&cthese problems. Alternatively, the disappearing graphics can be" ); + chat.Add( "&cpartially fixed by typing \"/client render legacy\" into chat." ); } // Based on http://www.opentk.com/doc/graphics/save-opengl-rendering-to-disk diff --git a/ClassicalSharp/Physics/PickedPos.cs b/ClassicalSharp/Physics/PickedPos.cs index 90c572d95..be4e8005e 100644 --- a/ClassicalSharp/Physics/PickedPos.cs +++ b/ClassicalSharp/Physics/PickedPos.cs @@ -29,10 +29,11 @@ namespace ClassicalSharp { /// Mark this as having a selected block, and /// calculates the closest block face of the selected position. - public void SetAsValid( Vector3 min, Vector3 max, byte block, Vector3 intersect ) { + public void SetAsValid( int x, int y, int z, Vector3 min, Vector3 max, + byte block, Vector3 intersect ) { Min = min; Max = max; - BlockPos = Vector3I.Truncate( Min ); + BlockPos = new Vector3I( x, y, z ); Valid = true; BlockType = block; diff --git a/ClassicalSharp/Physics/Picking.cs b/ClassicalSharp/Physics/Picking.cs index 261f85a0b..dcff861e8 100644 --- a/ClassicalSharp/Physics/Picking.cs +++ b/ClassicalSharp/Physics/Picking.cs @@ -73,7 +73,7 @@ namespace ClassicalSharp { float t0, t1; if( Intersection.RayIntersectsBox( origin, dir, min, max, out t0, out t1 ) ) { Vector3 intersect = origin + dir * t0; - pickedPos.SetAsValid( min, max, block, intersect ); + pickedPos.SetAsValid( x, y, z, min, max, block, intersect ); return; } } diff --git a/Launcher2/Gui/Screens/MainScreen.cs b/Launcher2/Gui/Screens/MainScreen.cs index df720330e..04a738a96 100644 --- a/Launcher2/Gui/Screens/MainScreen.cs +++ b/Launcher2/Gui/Screens/MainScreen.cs @@ -10,20 +10,7 @@ namespace Launcher2 { public MainScreen( LauncherWindow game ) : base( game ) { textFont = new Font( "Arial", 16, FontStyle.Bold ); widgets = new LauncherWidget[4]; - } - - protected override void UnselectWidget( LauncherWidget widget ) { - LauncherButtonWidget button = (LauncherButtonWidget)widget; - button.Active = false; - button.Redraw( drawer, button.Text, textFont ); - Dirty = true; - } - - protected override void SelectWidget( LauncherWidget widget ) { - LauncherButtonWidget button = (LauncherButtonWidget)widget; - button.Active = true; - button.Redraw( drawer, button.Text, textFont ); - Dirty = true; + buttonFont = textFont; } void KeyDown( object sender, KeyboardKeyEventArgs e ) {