Fix first person a little and add pitch forcing
This commit is contained in:
parent
fe0c766e76
commit
60b9e43604
|
@ -593,6 +593,7 @@
|
||||||
--- @field public centerL boolean
|
--- @field public centerL boolean
|
||||||
--- @field public crouch number
|
--- @field public crouch number
|
||||||
--- @field public enabled boolean
|
--- @field public enabled boolean
|
||||||
|
--- @field public forcePitch boolean
|
||||||
--- @field public forceRoll boolean
|
--- @field public forceRoll boolean
|
||||||
--- @field public fov number
|
--- @field public fov number
|
||||||
--- @field public offset Vec3f
|
--- @field public offset Vec3f
|
||||||
|
|
|
@ -850,6 +850,7 @@
|
||||||
| centerL | `boolean` | |
|
| centerL | `boolean` | |
|
||||||
| crouch | `number` | |
|
| crouch | `number` | |
|
||||||
| enabled | `boolean` | read-only |
|
| enabled | `boolean` | read-only |
|
||||||
|
| forcePitch | `boolean` | |
|
||||||
| forceRoll | `boolean` | |
|
| forceRoll | `boolean` | |
|
||||||
| fov | `number` | |
|
| fov | `number` | |
|
||||||
| offset | [Vec3f](structs.md#Vec3f) | read-only |
|
| offset | [Vec3f](structs.md#Vec3f) | read-only |
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
struct FirstPersonCamera gFirstPersonCamera = {
|
struct FirstPersonCamera gFirstPersonCamera = {
|
||||||
.enabled = false,
|
.enabled = false,
|
||||||
.forceRoll = true,
|
.forceRoll = true,
|
||||||
|
.forcePitch = false,
|
||||||
.centerL = true,
|
.centerL = true,
|
||||||
.pitch = 0,
|
.pitch = 0,
|
||||||
.yaw = 0,
|
.yaw = 0,
|
||||||
|
@ -68,8 +69,10 @@ static void first_person_camera_update(void) {
|
||||||
|
|
||||||
if (mouse_relative_enabled) {
|
if (mouse_relative_enabled) {
|
||||||
// update pitch
|
// update pitch
|
||||||
|
if (!gFirstPersonCamera.forcePitch) {
|
||||||
gFirstPersonCamera.pitch -= sensY * (invY * m->controller->extStickY - 1.5f * mouse_y);
|
gFirstPersonCamera.pitch -= sensY * (invY * m->controller->extStickY - 1.5f * mouse_y);
|
||||||
gFirstPersonCamera.pitch = CLAMP(gFirstPersonCamera.pitch, -0x3F00, 0x3F00);
|
gFirstPersonCamera.pitch = CLAMP(gFirstPersonCamera.pitch, -0x3F00, 0x3F00);
|
||||||
|
}
|
||||||
|
|
||||||
// update yaw
|
// update yaw
|
||||||
if (m->controller->buttonPressed & L_TRIG && gFirstPersonCamera.centerL) {
|
if (m->controller->buttonPressed & L_TRIG && gFirstPersonCamera.centerL) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
struct FirstPersonCamera {
|
struct FirstPersonCamera {
|
||||||
bool enabled;
|
bool enabled;
|
||||||
bool forceRoll;
|
bool forceRoll;
|
||||||
|
bool forcePitch;
|
||||||
bool centerL;
|
bool centerL;
|
||||||
s16 pitch;
|
s16 pitch;
|
||||||
s16 yaw;
|
s16 yaw;
|
||||||
|
|
|
@ -676,11 +676,12 @@ static struct LuaObjectField sDjuiColorFields[LUA_DJUI_COLOR_FIELD_COUNT] = {
|
||||||
{ "r", LVT_U8, offsetof(struct DjuiColor, r), false, LOT_NONE },
|
{ "r", LVT_U8, offsetof(struct DjuiColor, r), false, LOT_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 8
|
#define LUA_FIRST_PERSON_CAMERA_FIELD_COUNT 9
|
||||||
static struct LuaObjectField sFirstPersonCameraFields[LUA_FIRST_PERSON_CAMERA_FIELD_COUNT] = {
|
static struct LuaObjectField sFirstPersonCameraFields[LUA_FIRST_PERSON_CAMERA_FIELD_COUNT] = {
|
||||||
{ "centerL", LVT_BOOL, offsetof(struct FirstPersonCamera, centerL), false, LOT_NONE },
|
{ "centerL", LVT_BOOL, offsetof(struct FirstPersonCamera, centerL), false, LOT_NONE },
|
||||||
{ "crouch", LVT_F32, offsetof(struct FirstPersonCamera, crouch), false, LOT_NONE },
|
{ "crouch", LVT_F32, offsetof(struct FirstPersonCamera, crouch), false, LOT_NONE },
|
||||||
{ "enabled", LVT_BOOL, offsetof(struct FirstPersonCamera, enabled), true, LOT_NONE },
|
{ "enabled", LVT_BOOL, offsetof(struct FirstPersonCamera, enabled), true, LOT_NONE },
|
||||||
|
{ "forcePitch", LVT_BOOL, offsetof(struct FirstPersonCamera, forcePitch), false, LOT_NONE },
|
||||||
{ "forceRoll", LVT_BOOL, offsetof(struct FirstPersonCamera, forceRoll), false, LOT_NONE },
|
{ "forceRoll", LVT_BOOL, offsetof(struct FirstPersonCamera, forceRoll), false, LOT_NONE },
|
||||||
{ "fov", LVT_F32, offsetof(struct FirstPersonCamera, fov), false, LOT_NONE },
|
{ "fov", LVT_F32, offsetof(struct FirstPersonCamera, fov), false, LOT_NONE },
|
||||||
{ "offset", LVT_COBJECT, offsetof(struct FirstPersonCamera, offset), true, LOT_VEC3F },
|
{ "offset", LVT_COBJECT, offsetof(struct FirstPersonCamera, offset), true, LOT_VEC3F },
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "game/ingame_menu.h"
|
#include "game/ingame_menu.h"
|
||||||
#include "game/first_person_cam.h"
|
#include "game/first_person_cam.h"
|
||||||
#include "game/envfx_snow.h"
|
#include "game/envfx_snow.h"
|
||||||
|
#include "engine/math_util.h"
|
||||||
|
|
||||||
#ifdef DISCORD_SDK
|
#ifdef DISCORD_SDK
|
||||||
#include "pc/discord/discord.h"
|
#include "pc/discord/discord.h"
|
||||||
|
@ -721,7 +722,11 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect
|
||||||
cnt->extStickY = 0;
|
cnt->extStickY = 0;
|
||||||
|
|
||||||
gFirstPersonCamera.enabled = false;
|
gFirstPersonCamera.enabled = false;
|
||||||
|
gFirstPersonCamera.forceRoll = false;
|
||||||
|
gFirstPersonCamera.forcePitch = false;
|
||||||
|
gFirstPersonCamera.centerL = true;
|
||||||
gFirstPersonCamera.fov = FIRST_PERSON_DEFAULT_FOV;
|
gFirstPersonCamera.fov = FIRST_PERSON_DEFAULT_FOV;
|
||||||
|
vec3f_set(gFirstPersonCamera.offset, 0, 0, 0);
|
||||||
first_person_reset();
|
first_person_reset();
|
||||||
|
|
||||||
extern void save_file_load_all(UNUSED u8 reload);
|
extern void save_file_load_all(UNUSED u8 reload);
|
||||||
|
|
Loading…
Reference in New Issue