mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
promising
This commit is contained in:
parent
4e5ded0ba9
commit
e0f3657032
3 changed files with 23 additions and 5 deletions
|
@ -349,6 +349,7 @@ void GLBackend::renderPassTransfer(const Batch& batch) {
|
||||||
case Batch::COMMAND_setViewTransform:
|
case Batch::COMMAND_setViewTransform:
|
||||||
case Batch::COMMAND_setProjectionTransform:
|
case Batch::COMMAND_setProjectionTransform:
|
||||||
case Batch::COMMAND_setProjectionJitter:
|
case Batch::COMMAND_setProjectionJitter:
|
||||||
|
case Batch::COMMAND_setContextMirrorViewCorrection:
|
||||||
{
|
{
|
||||||
CommandCall call = _commandCalls[(*command)];
|
CommandCall call = _commandCalls[(*command)];
|
||||||
(this->*(call))(batch, *offset);
|
(this->*(call))(batch, *offset);
|
||||||
|
@ -386,6 +387,7 @@ void GLBackend::renderPassDraw(const Batch& batch) {
|
||||||
case Batch::COMMAND_setModelTransform:
|
case Batch::COMMAND_setModelTransform:
|
||||||
case Batch::COMMAND_setViewTransform:
|
case Batch::COMMAND_setViewTransform:
|
||||||
case Batch::COMMAND_setProjectionTransform:
|
case Batch::COMMAND_setProjectionTransform:
|
||||||
|
case Batch::COMMAND_setContextMirrorViewCorrection:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Batch::COMMAND_draw:
|
case Batch::COMMAND_draw:
|
||||||
|
@ -411,6 +413,7 @@ void GLBackend::renderPassDraw(const Batch& batch) {
|
||||||
//case Batch::COMMAND_setModelTransform:
|
//case Batch::COMMAND_setModelTransform:
|
||||||
//case Batch::COMMAND_setViewTransform:
|
//case Batch::COMMAND_setViewTransform:
|
||||||
//case Batch::COMMAND_setProjectionTransform:
|
//case Batch::COMMAND_setProjectionTransform:
|
||||||
|
//case Batch::COMMAND_setContextMirrorViewCorrection:
|
||||||
case Batch::COMMAND_setProjectionJitter:
|
case Batch::COMMAND_setProjectionJitter:
|
||||||
case Batch::COMMAND_setViewportTransform:
|
case Batch::COMMAND_setViewportTransform:
|
||||||
case Batch::COMMAND_setDepthRangeTransform:
|
case Batch::COMMAND_setDepthRangeTransform:
|
||||||
|
@ -623,9 +626,23 @@ void GLBackend::do_restoreContextViewCorrection(const Batch& batch, size_t param
|
||||||
void GLBackend::do_setContextMirrorViewCorrection(const Batch& batch, size_t paramOffset) {
|
void GLBackend::do_setContextMirrorViewCorrection(const Batch& batch, size_t paramOffset) {
|
||||||
bool prevMirrorViewCorrection = _transform._mirrorViewCorrection;
|
bool prevMirrorViewCorrection = _transform._mirrorViewCorrection;
|
||||||
_transform._mirrorViewCorrection = batch._params[paramOffset + 1]._uint != 0;
|
_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));
|
if (_transform._correction.correction != glm::mat4()) {
|
||||||
setCameraCorrection(_transform._correction.correction * flipXScale, _transform._correction.prevView);
|
// If we were previously not flipped, take this opportunity to save our flipped and unflipped matrices.
|
||||||
|
if (!prevMirrorViewCorrection) {
|
||||||
|
_transform._unflippedCorrection = _transform._correction.correction;
|
||||||
|
quat flippedRotation = glm::quat_cast(_transform._unflippedCorrection);
|
||||||
|
flippedRotation.y *= -1.0f;
|
||||||
|
flippedRotation.z *= -1.0f;
|
||||||
|
vec3 flippedTranslation = _transform._unflippedCorrection[3];
|
||||||
|
flippedTranslation.x *= -1.0f;
|
||||||
|
_transform._flippedCorrection = glm::translate(glm::mat4_cast(flippedRotation), flippedTranslation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prevMirrorViewCorrection != _transform._mirrorViewCorrection) {
|
||||||
|
setCameraCorrection(_transform._mirrorViewCorrection ? _transform._flippedCorrection : _transform._unflippedCorrection, _transform._correction.prevView);
|
||||||
|
_transform._invalidView = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -434,6 +434,8 @@ protected:
|
||||||
Transform _view;
|
Transform _view;
|
||||||
CameraCorrection _correction;
|
CameraCorrection _correction;
|
||||||
bool _viewCorrectionEnabled{ true };
|
bool _viewCorrectionEnabled{ true };
|
||||||
|
mat4 _unflippedCorrection;
|
||||||
|
mat4 _flippedCorrection;
|
||||||
bool _mirrorViewCorrection{ false };
|
bool _mirrorViewCorrection{ false };
|
||||||
|
|
||||||
Mat4 _projection;
|
Mat4 _projection;
|
||||||
|
|
|
@ -108,8 +108,7 @@ void GLBackend::TransformStageState::preUpdate(size_t commandIndex, const Stereo
|
||||||
|
|
||||||
if (_invalidView) {
|
if (_invalidView) {
|
||||||
// Apply the correction
|
// Apply the correction
|
||||||
static const mat4 flipXScale = glm::scale(glm::mat4(), glm::vec3(-1.0f, 1.0f, 1.0f));
|
if (_viewIsCamera && (_viewCorrectionEnabled && _correction.correction != glm::mat4())) {
|
||||||
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?
|
// FIXME should I switch to using the camera correction buffer in Transform.slf and leave this out?
|
||||||
Transform result;
|
Transform result;
|
||||||
_view.mult(result, _view, _correction.correctionInverse);
|
_view.mult(result, _view, _correction.correctionInverse);
|
||||||
|
|
Loading…
Reference in a new issue