Remove default zoom level from camera constructor

Initial distance should be sufficient to determine default zoom.
This commit is contained in:
Mikolaj Wielgus 2021-09-16 00:01:24 +02:00 committed by Jon Evans
parent 5475303ec2
commit afccea34a5
7 changed files with 16 additions and 29 deletions

View File

@ -86,7 +86,7 @@ EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER( wxWindow* aParent, const int* aAttribL
S3D_CACHE* aCacheManager ) :
HIDPI_GL_CANVAS( aParent, wxID_ANY, aAttribList, wxDefaultPosition, wxDefaultSize,
wxFULL_REPAINT_ON_RESIZE ),
m_trackBallCamera( RANGE_SCALE_3D * 2.0f, 0.38f ),
m_trackBallCamera( RANGE_SCALE_3D * 4.0f ),
m_cacheManager( aCacheManager )
{
wxLogTrace( m_logTrace, wxT( "EDA_3D_MODEL_VIEWER::EDA_3D_MODEL_VIEWER" ) );

View File

@ -48,16 +48,14 @@ const wxChar *CAMERA::m_logTrace = wxT( "KI_TRACE_CAMERA" );
#define MIN_ZOOM 0.10f
#define MAX_ZOOM 1.25f
#define MAX_ZOOM 2.00f
CAMERA::CAMERA( float aRangeScale, float aDefaultZoom )
CAMERA::CAMERA( float aInitialDistance )
{
wxLogTrace( m_logTrace, wxT( "CAMERA::CAMERA" ) );
m_range_scale = aRangeScale;
m_default_zoom = aDefaultZoom;
m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -(aRangeScale * 2.0f ) );
m_camera_pos_init = SFVEC3F( 0.0f, 0.0f, -aInitialDistance );
m_board_lookat_pos_init = SFVEC3F( 0.0f );
m_windowSize = SFVEC2I( 0, 0 );
m_projectionType = PROJECTION_TYPE::PERSPECTIVE;
@ -76,9 +74,9 @@ void CAMERA::Reset()
m_rotationMatrixAux = glm::mat4( 1.0f );
m_lastPosition = wxPoint( 0, 0 );
m_zoom = m_default_zoom;
m_zoom_t0 = m_default_zoom;
m_zoom_t1 = m_default_zoom;
m_zoom = 1.0f;
m_zoom_t0 = 1.0f;
m_zoom_t1 = 1.0f;
m_camera_pos = m_camera_pos_init;
m_camera_pos_t0 = m_camera_pos_init;
m_camera_pos_t1 = m_camera_pos_init;
@ -102,7 +100,7 @@ void CAMERA::Reset()
void CAMERA::Reset_T1()
{
m_camera_pos_t1 = m_camera_pos_init;
m_zoom_t1 = m_default_zoom;
m_zoom_t1 = 1.0f;
m_rotate_aux_t1 = SFVEC3F( 0.0f );
m_lookat_pos_t1 = m_board_lookat_pos_init;

View File

@ -80,11 +80,9 @@ public:
/**
* Initialize a camera.
*
* @param aRangeScale it will be expected that the board will have a
* -aRangeScale/2 to +aRangeScale/2. It will initialize the
* Z position with aRangeScale.
* @param aInitialDistance Initial Z-distance to the board
*/
explicit CAMERA( float aRangeScale, float aDefaultZoom );
explicit CAMERA( float aInitialDistance );
virtual ~CAMERA()
{
@ -245,17 +243,8 @@ protected:
void updateRotationMatrix();
/**
* The nominal range expected to be used in the camera.
*
* It will be used to initialize the Z position
* 3D zoom value -- Z-distance is scaled by it
*/
float m_range_scale;
/**
* 3D zoom value (Min 0.0 ... Max 1.0)
*/
float m_default_zoom;
float m_zoom;
float m_zoom_t0;
float m_zoom_t1;

View File

@ -34,8 +34,8 @@
#include <wx/log.h>
TRACK_BALL::TRACK_BALL( float aRangeScale, float aDefaultZoom ) :
CAMERA( aRangeScale, aDefaultZoom )
TRACK_BALL::TRACK_BALL( float aInitialDistance ) :
CAMERA( aInitialDistance )
{
wxLogTrace( m_logTrace, wxT( "TRACK_BALL::TRACK_BALL" ) );

View File

@ -36,7 +36,7 @@
class TRACK_BALL : public CAMERA
{
public:
explicit TRACK_BALL( float aRangeScale, float aDefaultZoom );
explicit TRACK_BALL( float aInitialDistance );
virtual ~TRACK_BALL()
{

View File

@ -90,7 +90,7 @@ EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY *aKiway, PCB_BASE_FRAME *aParent
m_mainToolBar( nullptr ),
m_canvas( nullptr ),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( RANGE_SCALE_3D, 0.66f )
m_trackBallCamera( 2 * RANGE_SCALE_3D )
{
wxLogTrace( m_logTrace, "EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME %s", aTitle );

View File

@ -49,7 +49,7 @@ PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL( wxWindow* aParent, PCB_BASE_FRAM
m_infobar( nullptr ),
m_boardAdapter(),
m_currentCamera( m_trackBallCamera ),
m_trackBallCamera( RANGE_SCALE_3D, 0.85f )
m_trackBallCamera( 2 * RANGE_SCALE_3D )
{
m_userUnits = aFrame->GetUserUnits();