mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Improve first person camera
This commit is contained in:
parent
a801dfe19f
commit
c99e6426d7
6 changed files with 10 additions and 9 deletions
|
@ -3648,7 +3648,7 @@ void zoom_out_if_paused_and_outside(struct GraphNodeCamera *camera) {
|
|||
areaMaskIndex = 0;
|
||||
areaBit = 0;
|
||||
}
|
||||
if (gCameraMovementFlags & CAM_MOVE_PAUSE_SCREEN && !gDjuiInPlayerMenu) {
|
||||
if (gCameraMovementFlags & CAM_MOVE_PAUSE_SCREEN && !gDjuiInPlayerMenu && !get_first_person_enabled()) {
|
||||
if (sFramesPaused >= 2) {
|
||||
if (sZoomOutAreaMasks[areaMaskIndex] & areaBit) {
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ bool get_first_person_enabled(void) {
|
|||
}
|
||||
|
||||
void set_first_person_enabled(bool enable) {
|
||||
if (gFirstPersonCamera.enabled && !enable) { gFOVState.fov = 45.0f; }
|
||||
gFirstPersonCamera.enabled = enable;
|
||||
}
|
||||
|
||||
|
@ -66,7 +65,7 @@ static void first_person_camera_update(void) {
|
|||
s16 invX = camera_config_is_x_inverted() ? 1 : -1;
|
||||
s16 invY = camera_config_is_y_inverted() ? 1 : -1;
|
||||
|
||||
if (gMenuMode == -1 && !gDjuiChatBoxFocus && !gDjuiConsoleFocus) {
|
||||
if (mouse_relative_enabled) {
|
||||
// update pitch
|
||||
gFirstPersonCamera.pitch -= sensY * (invY * m->controller->extStickY - 1.5f * mouse_y);
|
||||
gFirstPersonCamera.pitch = CLAMP(gFirstPersonCamera.pitch, -0x3F00, 0x3F00);
|
||||
|
@ -139,8 +138,6 @@ static void first_person_camera_update(void) {
|
|||
gLakituState.focHSpeed = 0;
|
||||
gLakituState.focVSpeed = 0;
|
||||
vec3s_set(gLakituState.shakeMagnitude, 0, 0, 0);
|
||||
|
||||
gFOVState.fov = gFirstPersonCamera.fov;
|
||||
}
|
||||
|
||||
void first_person_update(void) {
|
||||
|
|
|
@ -237,7 +237,7 @@ void patch_mtx_interpolated(f32 delta) {
|
|||
u16 perspNorm;
|
||||
f32 fovInterpolated = delta_interpolate_f32(sPerspectiveNode->prevFov, sPerspectiveNode->fov, delta);
|
||||
f32 near = MIN(sPerspectiveNode->near, gProjectionMaxNearValue);
|
||||
guPerspective(sPerspectiveMtx, &perspNorm, not_zero(fovInterpolated, gOverrideFOV), sPerspectiveAspect, get_first_person_enabled() ? 1 : not_zero(near, gOverrideNear), not_zero(sPerspectiveNode->far, gOverrideFar), 1.0f);
|
||||
guPerspective(sPerspectiveMtx, &perspNorm, get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(fovInterpolated, gOverrideFOV), sPerspectiveAspect, get_first_person_enabled() ? 1 : not_zero(near, gOverrideNear), not_zero(sPerspectiveNode->far, gOverrideFar), 1.0f);
|
||||
gSPMatrix(sPerspectivePos, VIRTUAL_TO_PHYSICAL(sPerspectiveNode), G_MTX_PROJECTION | G_MTX_LOAD | G_MTX_NOPUSH);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ u32 mouse_window_buttons;
|
|||
s32 mouse_window_x;
|
||||
s32 mouse_window_y;
|
||||
|
||||
static bool mouse_relative_enabled;
|
||||
bool mouse_relative_enabled;
|
||||
|
||||
void controller_mouse_read_window(void) {
|
||||
if (!mouse_init_ok) { return; }
|
||||
|
|
|
@ -14,6 +14,8 @@ extern u32 mouse_window_buttons;
|
|||
extern s32 mouse_window_x;
|
||||
extern s32 mouse_window_y;
|
||||
|
||||
extern bool mouse_relative_enabled;
|
||||
|
||||
void controller_mouse_read_window(void);
|
||||
void controller_mouse_read_relative(void);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "game/camera.h"
|
||||
#include "game/hud.h"
|
||||
#include "game/rendering_graph_node.h"
|
||||
#include "game/first_person_cam.h"
|
||||
#include "pc/lua/smlua.h"
|
||||
|
||||
#include "engine/math_util.h"
|
||||
|
@ -592,8 +593,9 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, Vec3f out) {
|
|||
out[1] *= 256.0f / out[2];
|
||||
|
||||
// fov of 45.0 is the default fov
|
||||
f32 fovDefault = tanf(not_zero(45.0f, gOverrideFOV) * ((f32)M_PI / 360.0f));
|
||||
f32 fovCurrent = tanf((gFOVState.fov + gFOVState.fovOffset) * ((f32)M_PI / 360.0f));
|
||||
f32 fov = get_first_person_enabled() ? gFirstPersonCamera.fov : not_zero(45.0f, gOverrideFOV);
|
||||
f32 fovDefault = tanf(fov * ((f32)M_PI / 360.0f));
|
||||
f32 fovCurrent = tanf((fov + gFOVState.fovOffset) * ((f32)M_PI / 360.0f));
|
||||
|
||||
f32 fovDifference = (fovDefault / fovCurrent) * 1.13f;
|
||||
|
||||
|
|
Loading…
Reference in a new issue