From 4e5ded0ba963d4cfcbec6c7a73f7038c0bb35b57 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 12 Dec 2023 15:18:04 -0800 Subject: [PATCH] plz --- libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp | 5 +++++ .../gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp | 9 +++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp index 421fef4334..bb79c9073f 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackend.cpp @@ -621,7 +621,12 @@ void GLBackend::do_restoreContextViewCorrection(const Batch& batch, size_t param } void GLBackend::do_setContextMirrorViewCorrection(const Batch& batch, size_t paramOffset) { + bool prevMirrorViewCorrection = _transform._mirrorViewCorrection; _transform._mirrorViewCorrection = batch._params[paramOffset + 1]._uint != 0; + if (prevMirrorViewCorrection != _transform._mirrorViewCorrection) { + static const mat4 flipXScale = glm::scale(glm::mat4(), glm::vec3(-1.0f, 1.0f, 1.0f)); + setCameraCorrection(_transform._correction.correction * flipXScale, _transform._correction.prevView); + } } void GLBackend::do_disableContextStereo(const Batch& batch, size_t paramOffset) { diff --git a/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp b/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp index b27175a545..d6ccdb52c9 100644 --- a/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp +++ b/libraries/gpu-gl-common/src/gpu/gl/GLBackendTransform.cpp @@ -108,14 +108,11 @@ void GLBackend::TransformStageState::preUpdate(size_t commandIndex, const Stereo if (_invalidView) { // Apply the correction - if (_viewIsCamera && (_viewCorrectionEnabled && _correction.correction != glm::mat4())) { + static const mat4 flipXScale = glm::scale(glm::mat4(), glm::vec3(-1.0f, 1.0f, 1.0f)); + if (_viewIsCamera && (_viewCorrectionEnabled && _correction.correction != (_mirrorViewCorrection ? flipXScale : glm::mat4()))) { // FIXME should I switch to using the camera correction buffer in Transform.slf and leave this out? Transform result; - glm::mat4 correction = _correction.correctionInverse; - if (_mirrorViewCorrection) { - correction = correction * glm::scale(glm::mat4(), glm::vec3(-1.0f, 1.0f, 1.0f)); - } - _view.mult(result, _view, correction); + _view.mult(result, _view, _correction.correctionInverse); if (_skybox) { result.setTranslation(vec3()); }