diff --git a/src/Camera.c b/src/Camera.c index f59fd950c..eb5f23979 100644 --- a/src/Camera.c +++ b/src/Camera.c @@ -39,7 +39,7 @@ static void PerspectiveCamera_GetView(struct Matrix* mat) { static void PerspectiveCamera_GetPickedBlock(struct RayTracer* t) { struct Entity* p = &LocalPlayer_Instance.Base; - Vec3 dir = Vec3_GetDirVector(p->Yaw * MATH_DEG2RAD, p->Pitch * MATH_DEG2RAD); + Vec3 dir = Vec3_GetDirVector(p->Yaw * MATH_DEG2RAD, p->Pitch * MATH_DEG2RAD + Camera.TiltPitch); Vec3 eyePos = Entity_GetEyePosition(p); float reach = LocalPlayer_Instance.ReachDistance; Picking_CalcPickedBlock(&eyePos, &dir, reach, t); @@ -110,8 +110,12 @@ static void PerspectiveCamera_CalcViewBobbing(float t, float velTiltScale) { struct Entity* e = &p->Base; struct Matrix tiltY, velX; - float vel; - if (!Game_ViewBobbing) { Camera.TiltM = Matrix_Identity; return; } + float vel, fall; + if (!Game_ViewBobbing) { + Camera.TiltM = Matrix_Identity; + Camera.TiltPitch = 0.0f; + return; + } Matrix_RotateZ(&Camera.TiltM, -p->Tilt.TiltX * e->Anim.BobStrength); Matrix_RotateX(&tiltY, Math_AbsF(p->Tilt.TiltY) * 3.0f * e->Anim.BobStrength); @@ -120,9 +124,12 @@ static void PerspectiveCamera_CalcViewBobbing(float t, float velTiltScale) { Camera.BobbingHor = (e->Anim.BobbingHor * 0.3f) * e->Anim.BobStrength; Camera.BobbingVer = (e->Anim.BobbingVer * 0.6f) * e->Anim.BobStrength; - vel = Math_Lerp(p->OldVelocity.Y + 0.08f, e->Velocity.Y + 0.08f, t); - Matrix_RotateX(&velX, -vel * 0.05f * p->Tilt.VelTiltStrength / velTiltScale); + vel = Math_Lerp(p->OldVelocity.Y + 0.08f, e->Velocity.Y + 0.08f, t); + fall = -vel * 0.05f * p->Tilt.VelTiltStrength / velTiltScale; + + Matrix_RotateX(&velX, fall); Matrix_MulBy(&Camera.TiltM, &velX); + if (!Game_ClassicMode) Camera.TiltPitch = fall; } diff --git a/src/Camera.h b/src/Camera.h index 80b86f475..ab981a55d 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -34,6 +34,8 @@ CC_VAR extern struct _CameraData { float Mass; /* Field of view of the camera */ int Fov, DefaultFov, ZoomFov; + + float TiltPitch; } Camera; struct Camera { diff --git a/src/Entity.c b/src/Entity.c index ae3c25487..2ece10738 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -478,7 +478,7 @@ static void Entity_CheckSkin(struct Entity* e) { if (!e->SkinFetchState) { first = Entity_FirstOtherWithSameSkinAndFetchedSkin(e); - flags = e == &LocalPlayer_Instance ? HTTP_FLAG_NOCACHE : 0; + flags = e == &LocalPlayer_Instance.Base ? HTTP_FLAG_NOCACHE : 0; if (!first) { e->_skinReqID = Http_AsyncGetSkin(&skin, flags); diff --git a/src/Window.h b/src/Window.h index fcbdf3414..c87ba40b4 100644 --- a/src/Window.h +++ b/src/Window.h @@ -63,8 +63,6 @@ CC_VAR extern struct _DisplayData { int Display_ScaleX(int x); /* Scales the given Y coordinate from 96 dpi to current display dpi. */ int Display_ScaleY(int y); -#define Display_CentreX(width) (DisplayInfo.X + (DisplayInfo.Width - width) / 2) -#define Display_CentreY(height) (DisplayInfo.Y + (DisplayInfo.Height - height) / 2) /* Data for the game/launcher window. */ CC_VAR extern struct _WinData { diff --git a/src/_WindowBase.h b/src/_WindowBase.h index f52890645..a3d4053b5 100644 --- a/src/_WindowBase.h +++ b/src/_WindowBase.h @@ -7,6 +7,9 @@ struct _DisplayData DisplayInfo; struct _WinData WindowInfo; +#define Display_CentreX(width) (DisplayInfo.X + (DisplayInfo.Width - width) / 2) +#define Display_CentreY(height) (DisplayInfo.Y + (DisplayInfo.Height - height) / 2) + int Display_ScaleX(int x) { return (int)(x * DisplayInfo.ScaleX); } int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); }