From d7a6a64517f1ec25cd8d816a0c2be4f8e0c07fc1 Mon Sep 17 00:00:00 2001 From: Turky Mohammed <45469625+DelinWorks@users.noreply.github.com> Date: Thu, 29 Dec 2022 11:54:01 +0300 Subject: [PATCH] [BUG] Fix camera `applyZoom()` when window size changes and remove unnecessary projection code (#992) * Fix camera applyZoom when window size changes * Revert "Fix camera applyZoom when window size changes" This reverts commit 26154b5ff7149da5882f62784eb41f653ea50893. * Fix pr --- core/2d/CCCamera.cpp | 5 +++-- core/2d/CCCamera.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/2d/CCCamera.cpp b/core/2d/CCCamera.cpp index 22e6c1a1fb..62ff1ea746 100644 --- a/core/2d/CCCamera.cpp +++ b/core/2d/CCCamera.cpp @@ -188,7 +188,6 @@ void Camera::initDefault() { case Director::Projection::_2D: { - _zoomFactor = 1.0F; _fieldOfView = 60.0F; _nearPlane = -1024.0F; _farPlane = 1024.0F; @@ -201,7 +200,6 @@ void Camera::initDefault() case Director::Projection::_3D: { float zeye = _director->getZEye(); - _zoomFactor = 1.0F; _fieldOfView = 60.0F; _nearPlane = 0.5F; _farPlane = zeye + size.height / 2.0f; @@ -216,6 +214,9 @@ void Camera::initDefault() } setDepth(0); + + if (_zoomFactor != 1.0F) + applyZoom(); } void Camera::updateTransform() diff --git a/core/2d/CCCamera.h b/core/2d/CCCamera.h index 8d08aaf96a..70135bed59 100644 --- a/core/2d/CCCamera.h +++ b/core/2d/CCCamera.h @@ -381,7 +381,7 @@ protected: // with larger depth is drawn on top of camera with smaller depth float _eyeZdistance; // Z eye projection distance for 2D in 3D projection. - float _zoomFactor; // The zoom factor of the camera. 3D = (cameraZDistance * _zoomFactor), 2D = (cameraScale * _zoomFactor) + float _zoomFactor = 1.0F; // The zoom factor of the camera. 3D = (cameraZDistance * _zoomFactor), 2D = (cameraScale * _zoomFactor) float _zoomFactorFarPlane; float _zoomFactorNearPlane;