mirror of
https://github.com/XProger/OpenLara.git
synced 2025-01-17 21:09:00 +01:00
pause in spectator mode
This commit is contained in:
parent
2f788bd67e
commit
80bf5322a1
44
src/camera.h
44
src/camera.h
@ -69,6 +69,7 @@ struct Camera : ICamera {
|
||||
|
||||
spectator = false;
|
||||
specTimer = 0.0f;
|
||||
targetAngle = vec3(0.0f);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
@ -388,31 +389,33 @@ struct Camera : ICamera {
|
||||
}
|
||||
}
|
||||
|
||||
if (!firstPerson) {
|
||||
TR::CameraFrame *frameA = &level->cameraFrames[indexA];
|
||||
TR::CameraFrame *frameB = &level->cameraFrames[indexB];
|
||||
if (!spectator) {
|
||||
if (!firstPerson) {
|
||||
TR::CameraFrame *frameA = &level->cameraFrames[indexA];
|
||||
TR::CameraFrame *frameB = &level->cameraFrames[indexB];
|
||||
|
||||
const float maxDelta = 512 * 512;
|
||||
const float maxDelta = 512 * 512;
|
||||
|
||||
float dp = (vec3(frameA->pos) - vec3(frameB->pos)).length2();
|
||||
float dt = (vec3(frameA->target) - vec3(frameB->target)).length2();
|
||||
float dp = (vec3(frameA->pos) - vec3(frameB->pos)).length2();
|
||||
float dt = (vec3(frameA->target) - vec3(frameB->target)).length2();
|
||||
|
||||
if (dp > maxDelta || dt > maxDelta) {
|
||||
eye.pos = frameA->pos;
|
||||
target.pos = frameA->target;
|
||||
fov = frameA->fov / 32767.0f * 120.0f;
|
||||
} else {
|
||||
eye.pos = vec3(frameA->pos).lerp(frameB->pos, t);
|
||||
target.pos = vec3(frameA->target).lerp(frameB->target, t);
|
||||
fov = lerp(frameA->fov / 32767.0f * 120.0f, frameB->fov / 32767.0f * 120.0f, t);
|
||||
}
|
||||
if (dp > maxDelta || dt > maxDelta) {
|
||||
eye.pos = frameA->pos;
|
||||
target.pos = frameA->target;
|
||||
fov = frameA->fov / 32767.0f * 120.0f;
|
||||
} else {
|
||||
eye.pos = vec3(frameA->pos).lerp(frameB->pos, t);
|
||||
target.pos = vec3(frameA->target).lerp(frameB->target, t);
|
||||
fov = lerp(frameA->fov / 32767.0f * 120.0f, frameB->fov / 32767.0f * 120.0f, t);
|
||||
}
|
||||
|
||||
eye.pos = level->cutMatrix * eye.pos;
|
||||
target.pos = level->cutMatrix * target.pos;
|
||||
eye.pos = level->cutMatrix * eye.pos;
|
||||
target.pos = level->cutMatrix * target.pos;
|
||||
|
||||
mViewInv = mat4(eye.pos, target.pos, vec3(0, -1, 0));
|
||||
} else
|
||||
updateFirstPerson();
|
||||
mViewInv = mat4(eye.pos, target.pos, vec3(0, -1, 0));
|
||||
} else
|
||||
updateFirstPerson();
|
||||
}
|
||||
} else {
|
||||
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) {
|
||||
lookAngle = vec3(0.0f);
|
||||
@ -558,6 +561,7 @@ struct Camera : ICamera {
|
||||
if (specJoy.down[jkL] && specJoy.down[jkR]) {
|
||||
specTimer += Core::deltaTime;
|
||||
if (specTimer > SPECTATOR_TIMER) {
|
||||
firstPerson = false;
|
||||
spectator = !spectator;
|
||||
specTimer = 0.0f;
|
||||
specPos = eye.pos;
|
||||
|
51
src/level.h
51
src/level.h
@ -66,6 +66,7 @@ struct Level : IGame {
|
||||
bool needRenderInventory;
|
||||
bool showStats;
|
||||
bool skyIsVisible;
|
||||
bool paused;
|
||||
|
||||
TR::LevelID nextLevel;
|
||||
|
||||
@ -936,6 +937,8 @@ struct Level : IGame {
|
||||
//==============================
|
||||
|
||||
Level(Stream &stream) : level(stream), waitTrack(false), isEnded(false), cutsceneWaitTimer(0.0f), animTexTimer(0.0f), statsTimeDelta(0.0f) {
|
||||
paused = false;
|
||||
|
||||
level.simpleItems = Core::settings.detail.simple == 1;
|
||||
level.initModelIndices();
|
||||
|
||||
@ -2241,25 +2244,35 @@ struct Level : IGame {
|
||||
}
|
||||
}
|
||||
|
||||
params->time += Core::deltaTime;
|
||||
animTexTimer += Core::deltaTime;
|
||||
|
||||
float timeStep = ANIM_TEX_TIMESTEP;
|
||||
if (level.version & TR::VER_TR1)
|
||||
timeStep *= 0.5f;
|
||||
|
||||
if (animTexTimer > timeStep) {
|
||||
level.shiftAnimTex();
|
||||
animTexTimer -= timeStep;
|
||||
if (camera->spectator && Input::lastState[0] == cStart) {
|
||||
paused = !paused;
|
||||
}
|
||||
|
||||
updateEffect();
|
||||
if (!paused) {
|
||||
params->time += Core::deltaTime;
|
||||
animTexTimer += Core::deltaTime;
|
||||
|
||||
Controller *c = Controller::first;
|
||||
while (c) {
|
||||
Controller *next = c->next;
|
||||
c->update();
|
||||
c = next;
|
||||
float timeStep = ANIM_TEX_TIMESTEP;
|
||||
if (level.version & TR::VER_TR1)
|
||||
timeStep *= 0.5f;
|
||||
|
||||
if (animTexTimer > timeStep) {
|
||||
level.shiftAnimTex();
|
||||
animTexTimer -= timeStep;
|
||||
}
|
||||
|
||||
updateEffect();
|
||||
|
||||
Controller *c = Controller::first;
|
||||
while (c) {
|
||||
Controller *next = c->next;
|
||||
c->update();
|
||||
c = next;
|
||||
}
|
||||
} else {
|
||||
if (camera->spectator) {
|
||||
camera->update();
|
||||
}
|
||||
}
|
||||
|
||||
if (waterCache)
|
||||
@ -3405,7 +3418,7 @@ struct Level : IGame {
|
||||
|
||||
Core::resetLights();
|
||||
|
||||
if (!level.isCutsceneLevel()) {
|
||||
if (!level.isCutsceneLevel() && !camera->spectator) {
|
||||
// render health & oxygen bars
|
||||
vec2 size = vec2(180, 10);
|
||||
|
||||
@ -3442,7 +3455,9 @@ struct Level : IGame {
|
||||
UI::renderHelp();
|
||||
}
|
||||
|
||||
UI::renderSubs();
|
||||
if (!camera->spectator) {
|
||||
UI::renderSubs();
|
||||
}
|
||||
|
||||
UI::end();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user