mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
Adjust picked position to account for camera vertical fall tilt when not running in classic mode (Thanks Goodly)
This commit is contained in:
parent
20a40fea27
commit
3c9774fe4f
17
src/Camera.c
17
src/Camera.c
@ -39,7 +39,7 @@ static void PerspectiveCamera_GetView(struct Matrix* mat) {
|
|||||||
|
|
||||||
static void PerspectiveCamera_GetPickedBlock(struct RayTracer* t) {
|
static void PerspectiveCamera_GetPickedBlock(struct RayTracer* t) {
|
||||||
struct Entity* p = &LocalPlayer_Instance.Base;
|
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);
|
Vec3 eyePos = Entity_GetEyePosition(p);
|
||||||
float reach = LocalPlayer_Instance.ReachDistance;
|
float reach = LocalPlayer_Instance.ReachDistance;
|
||||||
Picking_CalcPickedBlock(&eyePos, &dir, reach, t);
|
Picking_CalcPickedBlock(&eyePos, &dir, reach, t);
|
||||||
@ -110,8 +110,12 @@ static void PerspectiveCamera_CalcViewBobbing(float t, float velTiltScale) {
|
|||||||
struct Entity* e = &p->Base;
|
struct Entity* e = &p->Base;
|
||||||
|
|
||||||
struct Matrix tiltY, velX;
|
struct Matrix tiltY, velX;
|
||||||
float vel;
|
float vel, fall;
|
||||||
if (!Game_ViewBobbing) { Camera.TiltM = Matrix_Identity; return; }
|
if (!Game_ViewBobbing) {
|
||||||
|
Camera.TiltM = Matrix_Identity;
|
||||||
|
Camera.TiltPitch = 0.0f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Matrix_RotateZ(&Camera.TiltM, -p->Tilt.TiltX * e->Anim.BobStrength);
|
Matrix_RotateZ(&Camera.TiltM, -p->Tilt.TiltX * e->Anim.BobStrength);
|
||||||
Matrix_RotateX(&tiltY, Math_AbsF(p->Tilt.TiltY) * 3.0f * 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.BobbingHor = (e->Anim.BobbingHor * 0.3f) * e->Anim.BobStrength;
|
||||||
Camera.BobbingVer = (e->Anim.BobbingVer * 0.6f) * 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);
|
vel = Math_Lerp(p->OldVelocity.Y + 0.08f, e->Velocity.Y + 0.08f, t);
|
||||||
Matrix_RotateX(&velX, -vel * 0.05f * p->Tilt.VelTiltStrength / velTiltScale);
|
fall = -vel * 0.05f * p->Tilt.VelTiltStrength / velTiltScale;
|
||||||
|
|
||||||
|
Matrix_RotateX(&velX, fall);
|
||||||
Matrix_MulBy(&Camera.TiltM, &velX);
|
Matrix_MulBy(&Camera.TiltM, &velX);
|
||||||
|
if (!Game_ClassicMode) Camera.TiltPitch = fall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ CC_VAR extern struct _CameraData {
|
|||||||
float Mass;
|
float Mass;
|
||||||
/* Field of view of the camera */
|
/* Field of view of the camera */
|
||||||
int Fov, DefaultFov, ZoomFov;
|
int Fov, DefaultFov, ZoomFov;
|
||||||
|
|
||||||
|
float TiltPitch;
|
||||||
} Camera;
|
} Camera;
|
||||||
|
|
||||||
struct Camera {
|
struct Camera {
|
||||||
|
@ -478,7 +478,7 @@ static void Entity_CheckSkin(struct Entity* e) {
|
|||||||
|
|
||||||
if (!e->SkinFetchState) {
|
if (!e->SkinFetchState) {
|
||||||
first = Entity_FirstOtherWithSameSkinAndFetchedSkin(e);
|
first = Entity_FirstOtherWithSameSkinAndFetchedSkin(e);
|
||||||
flags = e == &LocalPlayer_Instance ? HTTP_FLAG_NOCACHE : 0;
|
flags = e == &LocalPlayer_Instance.Base ? HTTP_FLAG_NOCACHE : 0;
|
||||||
|
|
||||||
if (!first) {
|
if (!first) {
|
||||||
e->_skinReqID = Http_AsyncGetSkin(&skin, flags);
|
e->_skinReqID = Http_AsyncGetSkin(&skin, flags);
|
||||||
|
@ -63,8 +63,6 @@ CC_VAR extern struct _DisplayData {
|
|||||||
int Display_ScaleX(int x);
|
int Display_ScaleX(int x);
|
||||||
/* Scales the given Y coordinate from 96 dpi to current display dpi. */
|
/* Scales the given Y coordinate from 96 dpi to current display dpi. */
|
||||||
int Display_ScaleY(int y);
|
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. */
|
/* Data for the game/launcher window. */
|
||||||
CC_VAR extern struct _WinData {
|
CC_VAR extern struct _WinData {
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
struct _DisplayData DisplayInfo;
|
struct _DisplayData DisplayInfo;
|
||||||
struct _WinData WindowInfo;
|
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_ScaleX(int x) { return (int)(x * DisplayInfo.ScaleX); }
|
||||||
int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); }
|
int Display_ScaleY(int y) { return (int)(y * DisplayInfo.ScaleY); }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user