mirror of
https://github.com/XProger/OpenLara.git
synced 2025-07-31 10:20:27 +02:00
fix free camera control
fix RB/LB for Switch
This commit is contained in:
16
src/camera.h
16
src/camera.h
@@ -418,7 +418,7 @@ struct Camera : ICamera {
|
|||||||
float d = 3.0f * Core::deltaTime;
|
float d = 3.0f * Core::deltaTime;
|
||||||
|
|
||||||
vec2 L = Input::joy[cameraIndex].L;
|
vec2 L = Input::joy[cameraIndex].L;
|
||||||
if (L.length() < JOY_DEAD_ZONE) L = vec2(0.0f);
|
L = L.normal() * max(0.0f, L.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK);
|
||||||
|
|
||||||
lookAngle.x += L.y * d;
|
lookAngle.x += L.y * d;
|
||||||
lookAngle.y += L.x * d;
|
lookAngle.y += L.x * d;
|
||||||
@@ -539,7 +539,7 @@ struct Camera : ICamera {
|
|||||||
viewTarget = NULL;
|
viewTarget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Input::Joystick &specJoy = Input::joy[cameraIndex];
|
Input::Joystick &specJoy = Input::joy[Core::settings.controls[cameraIndex].joyIndex];
|
||||||
|
|
||||||
if (specJoy.down[jkL] && specJoy.down[jkR]) {
|
if (specJoy.down[jkL] && specJoy.down[jkR]) {
|
||||||
specTimer += Core::deltaTime;
|
specTimer += Core::deltaTime;
|
||||||
@@ -564,6 +564,11 @@ struct Camera : ICamera {
|
|||||||
float U = specJoy.RT;
|
float U = specJoy.RT;
|
||||||
float D = specJoy.LT;
|
float D = specJoy.LT;
|
||||||
|
|
||||||
|
L = L.normal() * max(0.0f, L.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK);
|
||||||
|
R = R.normal() * max(0.0f, R.length() - INPUT_JOY_DZ_STICK) / (1.0f - INPUT_JOY_DZ_STICK);
|
||||||
|
U = max(0.0f, U - INPUT_JOY_DZ_TRIGGER) / (1.0f - INPUT_JOY_DZ_TRIGGER);
|
||||||
|
D = max(0.0f, D - INPUT_JOY_DZ_TRIGGER) / (1.0f - INPUT_JOY_DZ_TRIGGER);
|
||||||
|
|
||||||
// apply dead zone
|
// apply dead zone
|
||||||
if (L.length() < 0.05f) L = vec2(0.0f);
|
if (L.length() < 0.05f) L = vec2(0.0f);
|
||||||
if (R.length() < 0.05f) R = vec2(0.0f);
|
if (R.length() < 0.05f) R = vec2(0.0f);
|
||||||
@@ -591,16 +596,15 @@ struct Camera : ICamera {
|
|||||||
mViewInv.rotateX(specRotSmooth.x);
|
mViewInv.rotateX(specRotSmooth.x);
|
||||||
mViewInv.rotateZ(specRotSmooth.z);
|
mViewInv.rotateZ(specRotSmooth.z);
|
||||||
|
|
||||||
level->getSector(specRoom, specPos);
|
|
||||||
/*
|
|
||||||
for (int i = 0; i < level->roomsCount; i++) {
|
for (int i = 0; i < level->roomsCount; i++) {
|
||||||
TR::Room &room = level->rooms[i];
|
TR::Room &room = level->rooms[i];
|
||||||
if (room.contains(specPos)) {
|
if (room.contains(specPos)) {
|
||||||
eye.room = i;
|
specRoom = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
level->getSector(specRoom, specPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR)
|
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR)
|
||||||
|
@@ -1244,7 +1244,7 @@ namespace GAPI {
|
|||||||
support.VAO = GLES3 || extSupport(ext, "_vertex_array_object");
|
support.VAO = GLES3 || extSupport(ext, "_vertex_array_object");
|
||||||
support.depthTexture = GLES3 || extSupport(ext, "_depth_texture");
|
support.depthTexture = GLES3 || extSupport(ext, "_depth_texture");
|
||||||
support.shadowSampler = _GL_EXT_shadow_samplers || _GL_ARB_shadow;
|
support.shadowSampler = _GL_EXT_shadow_samplers || _GL_ARB_shadow;
|
||||||
support.discardFrame = extSupport(ext, "_discard_framebuffer") && (glDiscardFramebufferEXT != NULL);
|
support.discardFrame = extSupport(ext, "_discard_framebuffer");
|
||||||
support.texNPOT = GLES3 || extSupport(ext, "_texture_npot") || extSupport(ext, "_texture_non_power_of_two");
|
support.texNPOT = GLES3 || extSupport(ext, "_texture_npot") || extSupport(ext, "_texture_non_power_of_two");
|
||||||
support.texRG = GLES3 || extSupport(ext, "_texture_rg "); // hope that isn't last extension in string ;)
|
support.texRG = GLES3 || extSupport(ext, "_texture_rg "); // hope that isn't last extension in string ;)
|
||||||
support.texMaxLevel = GLES3 || extSupport(ext, "_texture_max_level");
|
support.texMaxLevel = GLES3 || extSupport(ext, "_texture_max_level");
|
||||||
|
@@ -4,9 +4,11 @@
|
|||||||
#include "core.h"
|
#include "core.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#define INPUT_JOY_COUNT 4
|
#define MAX_PLAYERS COUNT(Core::settings.controls)
|
||||||
#define MAX_PLAYERS COUNT(Core::settings.controls)
|
|
||||||
#define JOY_DEAD_ZONE 0.3f
|
#define INPUT_JOY_COUNT 4
|
||||||
|
#define INPUT_JOY_DZ_STICK 0.2f
|
||||||
|
#define INPUT_JOY_DZ_TRIGGER 0.01f
|
||||||
|
|
||||||
namespace Input {
|
namespace Input {
|
||||||
InputKey lastKey;
|
InputKey lastKey;
|
||||||
|
@@ -3109,7 +3109,7 @@ struct Lara : Character {
|
|||||||
|
|
||||||
vec2 L = joy.L;
|
vec2 L = joy.L;
|
||||||
|
|
||||||
if (L.length() < JOY_DEAD_ZONE) L = vec2(0.0f); // dead zone
|
if (L.length() < INPUT_JOY_DZ_STICK) L = vec2(0.0f); // dead zone
|
||||||
|
|
||||||
if (!((state == STATE_STOP || state == STATE_SURF_TREAD || state == STATE_HANG) && fabsf(L.x) < 0.5f && fabsf(L.y) < 0.5f)) {
|
if (!((state == STATE_STOP || state == STATE_SURF_TREAD || state == STATE_HANG) && fabsf(L.x) < 0.5f && fabsf(L.y) < 0.5f)) {
|
||||||
bool moving = state == STATE_RUN || state == STATE_WALK || state == STATE_BACK || state == STATE_FAST_BACK || state == STATE_SURF_SWIM || state == STATE_SURF_BACK || state == STATE_FORWARD_JUMP;
|
bool moving = state == STATE_RUN || state == STATE_WALK || state == STATE_BACK || state == STATE_FAST_BACK || state == STATE_SURF_SWIM || state == STATE_SURF_BACK || state == STATE_FORWARD_JUMP;
|
||||||
|
@@ -211,7 +211,7 @@ void joyInit() {
|
|||||||
void joyUpdate() {
|
void joyUpdate() {
|
||||||
const static u64 keys[jkMAX] = { 0,
|
const static u64 keys[jkMAX] = { 0,
|
||||||
KEY_B, KEY_A, KEY_Y, KEY_X, KEY_L, KEY_R, KEY_PLUS, KEY_MINUS,
|
KEY_B, KEY_A, KEY_Y, KEY_X, KEY_L, KEY_R, KEY_PLUS, KEY_MINUS,
|
||||||
0, 0, KEY_ZL, KEY_ZR,
|
KEY_LSTICK, KEY_RSTICK, KEY_ZL, KEY_ZR,
|
||||||
KEY_DLEFT, KEY_DRIGHT, KEY_DUP, KEY_DDOWN,
|
KEY_DLEFT, KEY_DRIGHT, KEY_DUP, KEY_DDOWN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user