mirror of
https://github.com/overte-org/overte.git
synced 2025-04-06 11:52:47 +02:00
wild guess to handle view correction, hide portalExitID in create when mirrorMode != portal
This commit is contained in:
parent
6af7b9f772
commit
3e0c50e077
8 changed files with 32 additions and 1 deletions
|
@ -81,6 +81,7 @@ GLBackend::CommandCall GLBackend::_commandCalls[Batch::NUM_COMMANDS] =
|
|||
|
||||
(&::gpu::gl::GLBackend::do_disableContextViewCorrection),
|
||||
(&::gpu::gl::GLBackend::do_restoreContextViewCorrection),
|
||||
(&::gpu::gl::GLBackend::do_setContextMirrorViewCorrection),
|
||||
(&::gpu::gl::GLBackend::do_disableContextStereo),
|
||||
(&::gpu::gl::GLBackend::do_restoreContextStereo),
|
||||
|
||||
|
@ -619,6 +620,10 @@ void GLBackend::do_restoreContextViewCorrection(const Batch& batch, size_t param
|
|||
_transform._viewCorrectionEnabled = true;
|
||||
}
|
||||
|
||||
void GLBackend::do_setContextMirrorViewCorrection(const Batch& batch, size_t paramOffset) {
|
||||
_transform._mirrorViewCorrection = batch._params[paramOffset + 1]._uint != 0;
|
||||
}
|
||||
|
||||
void GLBackend::do_disableContextStereo(const Batch& batch, size_t paramOffset) {
|
||||
|
||||
}
|
||||
|
|
|
@ -211,6 +211,7 @@ public:
|
|||
|
||||
virtual void do_disableContextViewCorrection(const Batch& batch, size_t paramOffset) final;
|
||||
virtual void do_restoreContextViewCorrection(const Batch& batch, size_t paramOffset) final;
|
||||
virtual void do_setContextMirrorViewCorrection(const Batch& batch, size_t paramOffset) final;
|
||||
|
||||
virtual void do_disableContextStereo(const Batch& batch, size_t paramOffset) final;
|
||||
virtual void do_restoreContextStereo(const Batch& batch, size_t paramOffset) final;
|
||||
|
@ -433,6 +434,7 @@ protected:
|
|||
Transform _view;
|
||||
CameraCorrection _correction;
|
||||
bool _viewCorrectionEnabled{ true };
|
||||
bool _mirrorViewCorrection{ false };
|
||||
|
||||
Mat4 _projection;
|
||||
Vec4i _viewport{ 0, 0, 1, 1 };
|
||||
|
|
|
@ -111,7 +111,11 @@ void GLBackend::TransformStageState::preUpdate(size_t commandIndex, const Stereo
|
|||
if (_viewIsCamera && (_viewCorrectionEnabled && _correction.correction != glm::mat4())) {
|
||||
// FIXME should I switch to using the camera correction buffer in Transform.slf and leave this out?
|
||||
Transform result;
|
||||
_view.mult(result, _view, _correction.correctionInverse);
|
||||
glm::mat4 correction = _correction.correctionInverse;
|
||||
if (_mirrorViewCorrection) {
|
||||
correction = glm::scale(glm::mat4(), glm::vec3(-1.0f, 1.0f, 1.0f)) * correction;
|
||||
}
|
||||
_view.mult(result, _view, correction);
|
||||
if (_skybox) {
|
||||
result.setTranslation(vec3());
|
||||
}
|
||||
|
|
|
@ -464,6 +464,12 @@ void Batch::restoreContextViewCorrection() {
|
|||
ADD_COMMAND(restoreContextViewCorrection);
|
||||
}
|
||||
|
||||
void Batch::setContextMirrorViewCorrection(bool shouldMirror) {
|
||||
ADD_COMMAND(setContextMirrorViewCorrection);
|
||||
uint mirrorFlag = shouldMirror ? 1 : 0;
|
||||
_params.emplace_back(mirrorFlag);
|
||||
}
|
||||
|
||||
void Batch::disableContextStereo() {
|
||||
ADD_COMMAND(disableContextStereo);
|
||||
}
|
||||
|
|
|
@ -239,6 +239,7 @@ public:
|
|||
|
||||
void disableContextViewCorrection();
|
||||
void restoreContextViewCorrection();
|
||||
void setContextMirrorViewCorrection(bool shouldMirror);
|
||||
|
||||
void disableContextStereo();
|
||||
void restoreContextStereo();
|
||||
|
@ -340,6 +341,7 @@ public:
|
|||
|
||||
COMMAND_disableContextViewCorrection,
|
||||
COMMAND_restoreContextViewCorrection,
|
||||
COMMAND_setContextMirrorViewCorrection,
|
||||
|
||||
COMMAND_disableContextStereo,
|
||||
COMMAND_restoreContextStereo,
|
||||
|
|
|
@ -181,6 +181,7 @@ constexpr const char* COMMAND_NAMES[] = {
|
|||
|
||||
"disableContextViewCorrection",
|
||||
"restoreContextViewCorrection",
|
||||
"setContextMirrorViewCorrection",
|
||||
|
||||
"disableContextStereo",
|
||||
"restoreContextStereo",
|
||||
|
|
|
@ -307,6 +307,11 @@ public:
|
|||
args->_ignoreItem = portalExitID != Item::INVALID_ITEM_ID ? portalExitID : mirror.id;
|
||||
args->_mirrorDepth = _depth;
|
||||
|
||||
gpu::doInBatch("SetupMirrorTask::run", args->_context, [&](gpu::Batch& batch) {
|
||||
bool shouldMirror = _depth % 2 == (args->_renderMode != RenderArgs::MIRROR_RENDER_MODE);
|
||||
batch.setContextMirrorViewCorrection(shouldMirror);
|
||||
});
|
||||
|
||||
// Without calculating the bound planes, the mirror will use the same culling frustum as the main camera,
|
||||
// which is not what we want here.
|
||||
srcViewFrustum.calculate();
|
||||
|
@ -360,6 +365,11 @@ public:
|
|||
gpu::doInBatch("DrawMirrorTask::run", args->_context, [&](gpu::Batch& batch) {
|
||||
args->_batch = &batch;
|
||||
|
||||
if (cachedArgs) {
|
||||
bool shouldMirror = cachedArgs->_mirrorDepth % 2 == (args->_renderMode != RenderArgs::MIRROR_RENDER_MODE);
|
||||
batch.setContextMirrorViewCorrection(shouldMirror);
|
||||
}
|
||||
|
||||
batch.setFramebuffer(framebuffer);
|
||||
batch.setViewportTransform(args->_viewport);
|
||||
batch.setStateScissorRect(args->_viewport);
|
||||
|
|
|
@ -146,6 +146,7 @@ const GROUPS = [
|
|||
label: "Portal Exit",
|
||||
type: "string",
|
||||
propertyID: "portalExitID",
|
||||
showPropertyRule: { "mirrorMode": "portal" },
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue