From d24a929267af94da4e4944861a41e272ab83c7a5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 17 Oct 2016 16:42:38 +1100 Subject: [PATCH] Core: Allow building up to 16 chunks per frame. --- ClassicalSharp/2D/Widgets/Widget.cs | 4 ++-- ClassicalSharp/Commands/CommandReader.cs | 10 ---------- ClassicalSharp/Entities/Components/PhysicsComponent.cs | 6 +++--- ClassicalSharp/Rendering/ChunkUpdater.cs | 10 +++++----- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/ClassicalSharp/2D/Widgets/Widget.cs b/ClassicalSharp/2D/Widgets/Widget.cs index 7f99c9c57..0d5a2371f 100644 --- a/ClassicalSharp/2D/Widgets/Widget.cs +++ b/ClassicalSharp/2D/Widgets/Widget.cs @@ -40,10 +40,10 @@ namespace ClassicalSharp.Gui.Widgets { public Anchor VerticalAnchor; /// Horizontal offset from the reference point in pixels. - public int XOffset = 0; + public int XOffset; /// Vertical offset from the reference point in pixels. - public int YOffset = 0; + public int YOffset; /// Width and height of widget in pixels. public Size Size { get { return new Size( Width, Height ); } } diff --git a/ClassicalSharp/Commands/CommandReader.cs b/ClassicalSharp/Commands/CommandReader.cs index f27e07b77..a058ef3a6 100644 --- a/ClassicalSharp/Commands/CommandReader.cs +++ b/ClassicalSharp/Commands/CommandReader.cs @@ -32,16 +32,6 @@ namespace ClassicalSharp.Commands { return arg; } - bool MoveNext() { - if( curOffset >= rawInput.Length ) return false; - int next = rawInput.IndexOf( ' ', curOffset ); - if( next == -1 ) { - next = rawInput.Length; - } - curOffset = next + 1; - return true; - } - public CommandReader( string input ) { rawInput = input.TrimEnd( ' ' ); curOffset = 1; // skip start / for the ocmmand diff --git a/ClassicalSharp/Entities/Components/PhysicsComponent.cs b/ClassicalSharp/Entities/Components/PhysicsComponent.cs index 31bc8c47c..f116f229f 100644 --- a/ClassicalSharp/Entities/Components/PhysicsComponent.cs +++ b/ClassicalSharp/Entities/Components/PhysicsComponent.cs @@ -164,15 +164,15 @@ namespace ClassicalSharp.Entities { if( hacks.FlyingUp || jumping ) entity.Velocity.Y += yVel; if( hacks.FlyingDown ) entity.Velocity.Y -= yVel; } - Move( xMoving, zMoving, factor, drag, gravity, yMul ); + Move( drag, gravity, yMul ); } void MoveNormal( float xMoving, float zMoving, float factor, Vector3 drag, float gravity, float yMul ) { AdjHeadingVelocity( zMoving, xMoving, factor ); - Move( xMoving, zMoving, factor, drag, gravity, yMul ); + Move( drag, gravity, yMul ); } - void Move( float xMoving, float zMoving, float factor, Vector3 drag, float gravity, float yMul ) { + void Move( Vector3 drag, float gravity, float yMul ) { entity.Velocity.Y *= yMul; if( !hacks.Noclip ) collisions.MoveAndWallSlide(); diff --git a/ClassicalSharp/Rendering/ChunkUpdater.cs b/ClassicalSharp/Rendering/ChunkUpdater.cs index d095ace09..193a7bc67 100644 --- a/ClassicalSharp/Rendering/ChunkUpdater.cs +++ b/ClassicalSharp/Rendering/ChunkUpdater.cs @@ -324,14 +324,14 @@ namespace ClassicalSharp.Renderers { public void UpdateChunks( double delta ) { int chunkUpdates = 0; chunksTarget += delta < targetTime ? 1 : -1; // build more chunks if 30 FPS or over, otherwise slowdown. - Utils.Clamp( ref chunksTarget, 4, 12 ); + Utils.Clamp( ref chunksTarget, 4, 16 ); LocalPlayer p = game.LocalPlayer; Vector3 cameraPos = game.CurrentCameraPos; bool samePos = cameraPos == lastCamPos && p.HeadYawDegrees == lastYaw && p.PitchDegrees == lastPitch; - renderer.renderCount = samePos ? UpdateChunksStill( delta, ref chunkUpdates ) : - UpdateChunksAndVisibility( delta, ref chunkUpdates ); + renderer.renderCount = samePos ? UpdateChunksStill( ref chunkUpdates ) : + UpdateChunksAndVisibility( ref chunkUpdates ); lastCamPos = cameraPos; lastYaw = p.HeadYawDegrees; lastPitch = p.PitchDegrees; @@ -341,7 +341,7 @@ namespace ClassicalSharp.Renderers { Vector3 lastCamPos; float lastYaw, lastPitch; - int UpdateChunksAndVisibility( double deltaTime, ref int chunkUpdates ) { + int UpdateChunksAndVisibility( ref int chunkUpdates ) { ChunkInfo[] chunks = renderer.chunks, render = renderer.renderChunks; int j = 0; int viewDistSqr = AdjustViewDist( game.ViewDistance ); @@ -367,7 +367,7 @@ namespace ClassicalSharp.Renderers { return j; } - int UpdateChunksStill( double deltaTime, ref int chunkUpdates ) { + int UpdateChunksStill( ref int chunkUpdates ) { ChunkInfo[] chunks = renderer.chunks, render = renderer.renderChunks; int j = 0; int viewDistSqr = AdjustViewDist( game.ViewDistance );