Revert camera changes to fix crashing plugins

This commit is contained in:
UnknownShadow200 2024-06-03 07:45:26 +10:00
parent d639c66cf5
commit 018d8f8769
7 changed files with 22 additions and 17 deletions

View file

@ -42,15 +42,17 @@ static void PerspectiveCamera_GetProjection(struct Matrix* proj) {
Gfx_CalcPerspectiveMatrix(proj, fovy, aspectRatio, (float)Game_ViewDistance);
}
static void PerspectiveCamera_GetView(struct LocalPlayer* p, struct Matrix* mat) {
static void PerspectiveCamera_GetView(struct Matrix* mat) {
Vec3 pos = Camera.CurrentPos;
Vec2 rot = Camera.Active->GetOrientation(p);
Vec2 rot = Camera.Active->GetOrientation();
Matrix_LookRot(mat, pos, rot);
Matrix_MulBy(mat, &Camera.TiltM);
}
static void PerspectiveCamera_GetPickedBlock(struct LocalPlayer* p, struct RayTracer* t) {
struct Entity* e = &p->Base;
static void PerspectiveCamera_GetPickedBlock(struct RayTracer* t) {
struct LocalPlayer* p = Entities.CurPlayer;
struct Entity* e = &p->Base;
Vec3 dir = Vec3_GetDirVector(e->Yaw * MATH_DEG2RAD, e->Pitch * MATH_DEG2RAD + Camera.TiltPitch);
Vec3 eyePos = Entity_GetEyePosition(e);
Picking_CalcPickedBlock(&eyePos, &dir, p->ReachDistance, t);
@ -146,8 +148,10 @@ static void PerspectiveCamera_CalcViewBobbing(struct LocalPlayer* p, float t, fl
/*########################################################################################################################*
*---------------------------------------------------First person camera---------------------------------------------------*
*#########################################################################################################################*/
static Vec2 FirstPersonCamera_GetOrientation(struct LocalPlayer* p) {
static Vec2 FirstPersonCamera_GetOrientation(void) {
struct LocalPlayer* p = Entities.CurPlayer;
struct Entity* e = &p->Base;
Vec2 v;
v.x = e->Yaw * MATH_DEG2RAD;
v.y = e->Pitch * MATH_DEG2RAD;
@ -185,8 +189,10 @@ static struct Camera cam_FirstPerson = {
#define DEF_ZOOM 3.0f
static float dist_third = DEF_ZOOM, dist_forward = DEF_ZOOM;
static Vec2 ThirdPersonCamera_GetOrientation(struct LocalPlayer* p) {
static Vec2 ThirdPersonCamera_GetOrientation(void) {
struct LocalPlayer* p = Entities.CurPlayer;
struct Entity* e = &p->Base;
Vec2 v;
v.x = e->Yaw * MATH_DEG2RAD;
v.y = e->Pitch * MATH_DEG2RAD;
@ -216,7 +222,7 @@ static Vec3 ThirdPersonCamera_GetPosition(float t) {
target = Entity_GetEyePosition(e);
target.y += Camera.BobbingVer;
rot = Camera.Active->GetOrientation(p);
rot = Camera.Active->GetOrientation();
dir = Vec3_GetDirVector(rot.x, rot.y);
Vec3_Negate(&dir, &dir);

View file

@ -46,10 +46,10 @@ struct Camera {
/* Calculates the current projection matrix of this camera. */
void (*GetProjection)(struct Matrix* proj);
/* Calculates the current modelview matrix of this camera. */
void (*GetView)(struct LocalPlayer* p, struct Matrix* view);
void (*GetView)(struct Matrix* view);
/* Returns the current orientation of the camera. */
Vec2 (*GetOrientation)(struct LocalPlayer* p);
Vec2 (*GetOrientation)(void);
/* Returns the current interpolated position of the camera. */
Vec3 (*GetPosition)(float t);
@ -64,7 +64,7 @@ struct Camera {
void (*LoseFocus)(void);
/* Calculates selected block in the world, based on camera's current state */
void (*GetPickedBlock)(struct LocalPlayer* p, struct RayTracer* t);
void (*GetPickedBlock)(struct RayTracer* t);
/* Zooms the camera in or out when scrolling mouse wheel. */
cc_bool (*Zoom)(float amount);

View file

@ -326,7 +326,7 @@ void EnvRenderer_RenderSkybox(void) {
/* Rotate around camera */
pos = Camera.CurrentPos;
Vec3_Set(Camera.CurrentPos, 0,0,0);
Camera.Active->GetView(Entities.CurPlayer, &view);
Camera.Active->GetView(&view);
Matrix_MulBy(&m, &view);
Camera.CurrentPos = pos;

View file

@ -483,7 +483,7 @@ void Game_SetFpsLimit(int method) {
}
static void UpdateViewMatrix(void) {
Camera.Active->GetView(Entities.CurPlayer, &Gfx.View);
Camera.Active->GetView(&Gfx.View);
FrustumCulling_CalcFrustumEquations(&Gfx.Projection, &Gfx.View);
}
@ -607,7 +607,7 @@ static CC_INLINE void Game_DrawFrame(float delta, float t) {
UpdateViewMatrix();
if (!Gui_GetBlocksWorld()) {
Camera.Active->GetPickedBlock(Entities.CurPlayer, &Game_SelectedPos); /* TODO: only pick when necessary */
Camera.Active->GetPickedBlock(&Game_SelectedPos); /* TODO: only pick when necessary */
Camera_KeyLookUpdate(delta);
InputHandler_Tick();

View file

@ -20,7 +20,8 @@ void Queue_Clear(struct Queue* queue) {
}
static void Queue_Resize(struct Queue* queue) {
cc_uint8* entries;
int i, idx, capacity, headToEndSize, byteOffsetToHead;
int idx, capacity, headToEndSize, byteOffsetToHead;
if (queue->capacity >= (Int32_MaxValue / 4)) {
Chat_AddRaw("&cToo many generic queue entries, clearing");
Queue_Clear(queue);

View file

@ -289,8 +289,6 @@ size_t cc_strlen(const char* a) {
}
char* cc_strstr(const char* str, const char* substr) {
const char* a;
const char* b;
if (!substr[0]) return (char*)str;
for (; *str; str++)

View file

@ -449,7 +449,7 @@ void SceneListSubmit(Vertex* v3, int n) {
*PVR_LMMODE1 = 0;
//Set QACR registers
QACR[1] = QACR[0] = 0x10;
QACR[1] = QACR[0] = 0x11;
#if CLIP_DEBUG
Vertex* vertex = (Vertex*) src;