Don't apply fall tilting when flying or noclip mode.

This commit is contained in:
UnknownShadow200 2016-06-25 20:35:04 +10:00
parent 513e330337
commit 6fe8991f33
2 changed files with 68 additions and 72 deletions

View file

@ -17,7 +17,7 @@ namespace ClassicalSharp.Entities {
public float legXRot, armXRot, armZRot; public float legXRot, armXRot, armZRot;
public float bobbingHor, bobbingVer, tiltX, tiltY; public float bobbingHor, bobbingVer, tiltX, tiltY;
public float walkTime, swing, intensity = 1; public float walkTime, swing, bobStrength = 1;
internal float walkTimeO, walkTimeN, swingO, swingN; internal float walkTimeO, walkTimeN, swingO, swingN;
internal float leftXRot, leftZRot, rightXRot, rightZRot; internal float leftXRot, leftZRot, rightXRot, rightZRot;
@ -63,10 +63,10 @@ namespace ClassicalSharp.Entities {
bobbingVer = (float)(Math.Abs( Math.Sin( walkTime ) ) * swing * (2.5f/16f)); bobbingVer = (float)(Math.Abs( Math.Sin( walkTime ) ) * swing * (2.5f/16f));
if( !game.ViewBobbing || !entity.onGround ) if( !game.ViewBobbing || !entity.onGround )
intensity *= 0.9f; bobStrength *= 0.9f;
else else
intensity += 0.1f; bobStrength += 0.1f;
Utils.Clamp( ref intensity, 0, 1 ); Utils.Clamp( ref bobStrength, 0, 1 );
tiltX = (float)Math.Cos( walkTime ) * swing * (0.15f * Utils.Deg2Rad); tiltX = (float)Math.Cos( walkTime ) * swing * (0.15f * Utils.Deg2Rad);
tiltY = (float)Math.Sin( walkTime ) * swing * (0.15f * Utils.Deg2Rad); tiltY = (float)Math.Sin( walkTime ) * swing * (0.15f * Utils.Deg2Rad);

View file

@ -112,21 +112,18 @@ namespace ClassicalSharp {
UpdateMouseRotation(); UpdateMouseRotation();
} }
protected void CalcVelocityTilt(double delta, float t) { protected void CalcViewBobbing( double delta, float t, bool velTilt ) {
LocalPlayer p = game.LocalPlayer; LocalPlayer p = game.LocalPlayer;
float tiltAmount = (-p.Velocity.Y - 0.08F); tiltM = Matrix4.RotateZ( -p.anim.tiltX * p.anim.bobStrength );
float tiltAmount2 = 0; tiltM = tiltM * Matrix4.RotateX( Math.Abs( p.anim.tiltY ) * 3 * p.anim.bobStrength );
tiltAmount2 = Utils.Lerp(p.OldVelocity.Y, player.Velocity.Y, t);
tiltM = tiltM * Matrix4.RotateX( (float)(-tiltAmount2 * 0.05F) ); bobbingHor = (p.anim.bobbingHor * 0.3f) * p.anim.bobStrength;
} bobbingVer = (p.anim.bobbingVer * 0.6f) * p.anim.bobStrength;
protected void CalcViewBobbing( double delta ) {
LocalPlayer p = game.LocalPlayer;
tiltM = Matrix4.RotateZ( -p.anim.tiltX * p.anim.intensity );
tiltM = tiltM * Matrix4.RotateX( Math.Abs( p.anim.tiltY ) * 3 * p.anim.intensity );
bobbingHor = (p.anim.bobbingHor * 0.3f) * p.anim.intensity; if( !velTilt || p.Hacks.Noclip || p.Hacks.Flying ) return;
bobbingVer = (p.anim.bobbingVer * 0.6f) * p.anim.intensity; float vel = Utils.Lerp( p.OldVelocity.Y + 0.08f, p.Velocity.Y + 0.08f, t );
Utils.Clamp( ref vel, -1, 1 );
tiltM = tiltM * Matrix4.RotateX( -vel * 0.05f );
} }
} }
@ -146,7 +143,7 @@ namespace ClassicalSharp {
} }
public override Matrix4 GetView( double delta, float t ) { public override Matrix4 GetView( double delta, float t ) {
CalcViewBobbing( delta ); CalcViewBobbing( delta, t, false );
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
eyePos.Y += bobbingVer; eyePos.Y += bobbingVer;
@ -183,7 +180,7 @@ namespace ClassicalSharp {
} }
public override Matrix4 GetView( double delta, float t ) { public override Matrix4 GetView( double delta, float t ) {
CalcViewBobbing( delta ); CalcViewBobbing( delta, t, false );
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
eyePos.Y += bobbingVer; eyePos.Y += bobbingVer;
@ -214,8 +211,7 @@ namespace ClassicalSharp {
} }
public override Matrix4 GetView( double delta, float t ) { public override Matrix4 GetView( double delta, float t ) {
CalcViewBobbing( delta ); CalcViewBobbing( delta, t, true );
CalcVelocityTilt( delta, t );
Vector3 eyePos = player.EyePosition; Vector3 eyePos = player.EyePosition;
eyePos.Y += bobbingVer; eyePos.Y += bobbingVer;
Vector3 cameraDir = Utils.GetDirVector( player.HeadYawRadians, Vector3 cameraDir = Utils.GetDirVector( player.HeadYawRadians,