From 0481de1222aa52b49eaeffb45a8b5252529c1ba0 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+Agent-11@users.noreply.github.com> Date: Sat, 2 Dec 2023 19:54:40 -0500 Subject: [PATCH] Add forceRoll field to first person camera --- autogen/lua_definitions/structs.lua | 1 + docs/lua/structs.md | 1 + src/game/first_person_cam.c | 4 ++++ src/game/first_person_cam.h | 1 + src/pc/lua/smlua_cobject_autogen.c | 13 +++++++------ 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 9cb2c9dfa..4658382d0 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -593,6 +593,7 @@ --- @class FirstPersonCamera --- @field public crouch number --- @field public enabled boolean +--- @field public forceRoll boolean --- @field public fov number --- @field public pitch integer --- @field public yaw integer diff --git a/docs/lua/structs.md b/docs/lua/structs.md index a6c2ff9ca..536b9e02f 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -848,6 +848,7 @@ | ----- | ---- | ------ | | crouch | `number` | | | enabled | `boolean` | read-only | +| forceRoll | `boolean` | | | fov | `number` | | | pitch | `integer` | | | yaw | `integer` | | diff --git a/src/game/first_person_cam.c b/src/game/first_person_cam.c index f5cb268a7..aa091a400 100644 --- a/src/game/first_person_cam.c +++ b/src/game/first_person_cam.c @@ -22,6 +22,7 @@ struct FirstPersonCamera gFirstPersonCamera = { .enabled = false, + .forceRoll = true, .pitch = 0, .yaw = 0, .crouch = 0, @@ -131,6 +132,9 @@ void first_person_camera_update(void) { vec3f_copy(gLakituState.goalFocus, gLakituState.focus); // set other values + if (gFirstPersonCamera.forceRoll) { + gLakituState.roll = 0; + } gLakituState.posHSpeed = 0; gLakituState.posVSpeed = 0; gLakituState.focHSpeed = 0; diff --git a/src/game/first_person_cam.h b/src/game/first_person_cam.h index 4146c6b51..ff159bf15 100644 --- a/src/game/first_person_cam.h +++ b/src/game/first_person_cam.h @@ -7,6 +7,7 @@ struct FirstPersonCamera { bool enabled; + bool forceRoll; s16 pitch; s16 yaw; f32 crouch; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 774cb8e3d..a24172ab5 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -674,13 +674,14 @@ static struct LuaObjectField sDjuiColorFields[LUA_DJUI_COLOR_FIELD_COUNT] = { { "r", LVT_U8, offsetof(struct DjuiColor, r), false, LOT_NONE }, }; -#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 5 +#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 6 static struct LuaObjectField sFirstPersonCameraFields[LUA_FIRST_PERSON_CAMERA_FIELD_COUNT] = { - { "crouch", LVT_F32, offsetof(struct FirstPersonCamera, crouch), false, LOT_NONE }, - { "enabled", LVT_BOOL, offsetof(struct FirstPersonCamera, enabled), true, LOT_NONE }, - { "fov", LVT_F32, offsetof(struct FirstPersonCamera, fov), false, LOT_NONE }, - { "pitch", LVT_S16, offsetof(struct FirstPersonCamera, pitch), false, LOT_NONE }, - { "yaw", LVT_S16, offsetof(struct FirstPersonCamera, yaw), false, LOT_NONE }, + { "crouch", LVT_F32, offsetof(struct FirstPersonCamera, crouch), false, LOT_NONE }, + { "enabled", LVT_BOOL, offsetof(struct FirstPersonCamera, enabled), true, LOT_NONE }, + { "forceRoll", LVT_BOOL, offsetof(struct FirstPersonCamera, forceRoll), false, LOT_NONE }, + { "fov", LVT_F32, offsetof(struct FirstPersonCamera, fov), false, LOT_NONE }, + { "pitch", LVT_S16, offsetof(struct FirstPersonCamera, pitch), false, LOT_NONE }, + { "yaw", LVT_S16, offsetof(struct FirstPersonCamera, yaw), false, LOT_NONE }, }; #define LUA_FLOOR_GEOMETRY_FIELD_COUNT 4