3d-viewer, make ortho projection zoom similar as prespective projection
Fixes #1843
Fixes reload of Raytracing when the projection button is pressed.
(cherry picked from commit 2c00540ad6
)
This commit is contained in:
parent
6ab9bdb346
commit
4205cb32c5
|
@ -163,7 +163,7 @@ void CCAMERA::rebuildProjection()
|
|||
|
||||
m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
|
||||
|
||||
m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f ) ;
|
||||
m_frustum.tang = glm::tan( glm::radians( m_frustum.angle ) * 0.5f );
|
||||
|
||||
m_focalLen.x = ( (float)m_windowSize.y / (float)m_windowSize.x ) / m_frustum.tang;
|
||||
m_focalLen.y = 1.0f / m_frustum.tang;
|
||||
|
@ -178,19 +178,21 @@ void CCAMERA::rebuildProjection()
|
|||
|
||||
m_frustum.nearD = -m_frustum.farD; // Use a symmetrical clip plane for ortho projection
|
||||
|
||||
const float orthoReductionFactor = m_zoom / 75.0f;
|
||||
// This formula was found by trial and error
|
||||
const float orthoReductionFactor = glm::length( m_camera_pos_init ) *
|
||||
m_zoom * m_zoom * 0.5f;
|
||||
|
||||
// Initialize Projection Matrix for Ortographic View
|
||||
m_projectionMatrix = glm::ortho( -m_windowSize.x * orthoReductionFactor,
|
||||
m_windowSize.x * orthoReductionFactor,
|
||||
-m_windowSize.y * orthoReductionFactor,
|
||||
m_windowSize.y * orthoReductionFactor,
|
||||
m_projectionMatrix = glm::ortho( -m_frustum.ratio * orthoReductionFactor,
|
||||
m_frustum.ratio * orthoReductionFactor,
|
||||
-orthoReductionFactor,
|
||||
orthoReductionFactor,
|
||||
m_frustum.nearD, m_frustum.farD );
|
||||
|
||||
m_projectionMatrixInv = glm::inverse( m_projectionMatrix );
|
||||
|
||||
m_frustum.nw = m_windowSize.x * orthoReductionFactor * 2.0f;
|
||||
m_frustum.nh = m_windowSize.y * orthoReductionFactor * 2.0f;
|
||||
m_frustum.nw = orthoReductionFactor * 2.0f * m_frustum.ratio;
|
||||
m_frustum.nh = orthoReductionFactor * 2.0f;
|
||||
m_frustum.fw = m_frustum.nw;
|
||||
m_frustum.fh = m_frustum.nh;
|
||||
|
||||
|
|
|
@ -369,7 +369,11 @@ void EDA_3D_VIEWER::Process_Special_Functions( wxCommandEvent &event )
|
|||
|
||||
case ID_ORTHO:
|
||||
m_settings.CameraGet().ToggleProjection();
|
||||
|
||||
if( m_settings.RenderEngineGet() == RENDER_ENGINE::OPENGL_LEGACY )
|
||||
m_canvas->Request_refresh();
|
||||
else
|
||||
m_canvas->RenderRaytracingRequest();
|
||||
return;
|
||||
|
||||
case ID_TOOL_SCREENCOPY_TOCLIBBOARD:
|
||||
|
|
Loading…
Reference in New Issue