mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Use MinBB/MaxBB in place of +0/+1, except for mesh builder.
This commit is contained in:
parent
00774ae6d2
commit
dacd6e4f44
@ -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 ) {
|
internal void RecalculateBB( int block, FastBitmap fastBmp ) {
|
||||||
int elemSize = fastBmp.Width / 16;
|
int elemSize = fastBmp.Width / 16;
|
||||||
int texId = GetTextureLoc( (byte)block, TileSide.Top );
|
int texId = GetTextureLoc( (byte)block, TileSide.Top );
|
||||||
@ -36,10 +38,8 @@ namespace ClassicalSharp {
|
|||||||
float leftX = GetSpriteBB_LeftX( elemSize, texId & 0x0F, texId >> 4, fastBmp );
|
float leftX = GetSpriteBB_LeftX( elemSize, texId & 0x0F, texId >> 4, fastBmp );
|
||||||
float rightX = GetSpriteBB_RightX( 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 )
|
MinBB[block] = Utils.RotateY( leftX - 0.5f, bottomY, 0, angle ) + centre;
|
||||||
+ new Vector3( 0.5f, 0, 0.5f );
|
MaxBB[block] = Utils.RotateY( rightX - 0.5f, topY, 0, angle ) + centre;
|
||||||
MaxBB[block] = Utils.RotateY( rightX - 0.5f, topY, 0, 45f * Utils.Deg2Rad )
|
|
||||||
+ new Vector3( 0.5f, 0, 0.5f );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe float GetSpriteBB_TopY( int size, int tileX, int tileY, FastBitmap fastBmp ) {
|
unsafe float GetSpriteBB_TopY( int size, int tileX, int tileY, FastBitmap fastBmp ) {
|
||||||
|
@ -25,8 +25,8 @@ namespace ClassicalSharp {
|
|||||||
bool GetBoundingBox( byte block, int x, int y, int z, ref BoundingBox box ) {
|
bool GetBoundingBox( byte block, int x, int y, int z, ref BoundingBox box ) {
|
||||||
if( info.CollideType[block] != BlockCollideType.Solid ) return false;
|
if( info.CollideType[block] != BlockCollideType.Solid ) return false;
|
||||||
|
|
||||||
box.Min = new Vector3( x, y, z );
|
box.Min = new Vector3( x, y, z ) + info.MinBB[block];
|
||||||
box.Max = new Vector3( x + 1, y + info.Height[block], z + 1 );
|
box.Max = new Vector3( x, y, z ) + info.MaxBB[block];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,13 +113,12 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CheckIsFree( PickedPos selected, byte newBlock ) {
|
bool CheckIsFree( PickedPos selected, byte newBlock ) {
|
||||||
|
Vector3 pos = (Vector3)selected.TranslatedPos;
|
||||||
if( !CannotPassThrough( newBlock ) ) return true;
|
if( !CannotPassThrough( newBlock ) ) return true;
|
||||||
if( IntersectsOtherPlayers( selected.TranslatedPos, newBlock ) ) return false;
|
if( IntersectsOtherPlayers( pos, newBlock ) ) return false;
|
||||||
|
|
||||||
Vector3I pos = selected.TranslatedPos;
|
BoundingBox blockBB = new BoundingBox( pos + game.BlockInfo.MinBB[newBlock],
|
||||||
float height = game.BlockInfo.Height[newBlock];
|
pos + game.BlockInfo.MaxBB[newBlock] );
|
||||||
BoundingBox blockBB = new BoundingBox( pos.X, pos.Y, pos.Z,
|
|
||||||
pos.X + 1, pos.Y + height, pos.Z + 1 );
|
|
||||||
BoundingBox localBB = game.LocalPlayer.CollisionBounds;
|
BoundingBox localBB = game.LocalPlayer.CollisionBounds;
|
||||||
|
|
||||||
if( game.LocalPlayer.noClip || !localBB.Intersects( blockBB ) ) return true;
|
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.
|
// Push player up if they are jumping and trying to place a block underneath them.
|
||||||
Vector3 p = game.LocalPlayer.Position;
|
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 );
|
LocationUpdate update = LocationUpdate.MakePos( p, false );
|
||||||
game.LocalPlayer.SetLocation( update, false );
|
game.LocalPlayer.SetLocation( update, false );
|
||||||
return true;
|
return true;
|
||||||
@ -178,10 +177,9 @@ namespace ClassicalSharp {
|
|||||||
return game.BlockInfo.CollideType[block] == BlockCollideType.Solid;
|
return game.BlockInfo.CollideType[block] == BlockCollideType.Solid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntersectsOtherPlayers( Vector3I pos, byte newType ) {
|
bool IntersectsOtherPlayers( Vector3 pos, byte newType ) {
|
||||||
float height = game.BlockInfo.Height[newType];
|
BoundingBox blockBB = new BoundingBox( pos + game.BlockInfo.MinBB[newType],
|
||||||
BoundingBox blockBB = new BoundingBox( pos.X, pos.Y, pos.Z,
|
pos + game.BlockInfo.MaxBB[newType] );
|
||||||
pos.X + 1, pos.Y + height, pos.Z + 1 );
|
|
||||||
|
|
||||||
for( int id = 0; id < 255; id++ ) {
|
for( int id = 0; id < 255; id++ ) {
|
||||||
Player player = game.Players[id];
|
Player player = game.Players[id];
|
||||||
|
@ -399,9 +399,9 @@ namespace ClassicalSharp.GraphicsAPI {
|
|||||||
chat.Add( "&cIntel graphics cards are known to have issues with the OpenGL build." );
|
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( "&cVSync may not work, and you may see disappearing clouds and map edges." );
|
||||||
chat.Add( " " );
|
chat.Add( " " );
|
||||||
chat.Add( "&cFor Windows, try downloading the Direct3D 9 build as it doesn't have these problems" );
|
chat.Add( "&cFor Windows, try downloading the Direct3D 9 build as it doesn't have" );
|
||||||
chat.Add( "&cAlternatively, the disappearing graphics can be partially fixed by " );
|
chat.Add( "&cthese problems. Alternatively, the disappearing graphics can be" );
|
||||||
chat.Add( "&ctyping \"/client rendertype legacy\" into chat." );
|
chat.Add( "&cpartially fixed by typing \"/client render legacy\" into chat." );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based on http://www.opentk.com/doc/graphics/save-opengl-rendering-to-disk
|
// Based on http://www.opentk.com/doc/graphics/save-opengl-rendering-to-disk
|
||||||
|
@ -29,10 +29,11 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
/// <summary> Mark this as having a selected block, and
|
/// <summary> Mark this as having a selected block, and
|
||||||
/// calculates the closest block face of the selected position. </summary>
|
/// calculates the closest block face of the selected position. </summary>
|
||||||
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;
|
Min = min;
|
||||||
Max = max;
|
Max = max;
|
||||||
BlockPos = Vector3I.Truncate( Min );
|
BlockPos = new Vector3I( x, y, z );
|
||||||
Valid = true;
|
Valid = true;
|
||||||
BlockType = block;
|
BlockType = block;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ namespace ClassicalSharp {
|
|||||||
float t0, t1;
|
float t0, t1;
|
||||||
if( Intersection.RayIntersectsBox( origin, dir, min, max, out t0, out t1 ) ) {
|
if( Intersection.RayIntersectsBox( origin, dir, min, max, out t0, out t1 ) ) {
|
||||||
Vector3 intersect = origin + dir * t0;
|
Vector3 intersect = origin + dir * t0;
|
||||||
pickedPos.SetAsValid( min, max, block, intersect );
|
pickedPos.SetAsValid( x, y, z, min, max, block, intersect );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,7 @@ namespace Launcher2 {
|
|||||||
public MainScreen( LauncherWindow game ) : base( game ) {
|
public MainScreen( LauncherWindow game ) : base( game ) {
|
||||||
textFont = new Font( "Arial", 16, FontStyle.Bold );
|
textFont = new Font( "Arial", 16, FontStyle.Bold );
|
||||||
widgets = new LauncherWidget[4];
|
widgets = new LauncherWidget[4];
|
||||||
}
|
buttonFont = textFont;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyDown( object sender, KeyboardKeyEventArgs e ) {
|
void KeyDown( object sender, KeyboardKeyEventArgs e ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user