From 576f9fe13e3af0796298d571d0e5e03bc54c664f Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Tue, 3 Feb 2026 23:02:24 -0800 Subject: [PATCH] Moved hidden state to lcObject. --- common/camera.cpp | 26 ++++---------------------- common/camera.h | 26 ++++++++++---------------- common/light.h | 1 - common/object.h | 1 + common/piece.h | 1 - 5 files changed, 15 insertions(+), 40 deletions(-) diff --git a/common/camera.cpp b/common/camera.cpp index 378bc29a..94f32f36 100644 --- a/common/camera.cpp +++ b/common/camera.cpp @@ -14,13 +14,9 @@ #define LC_CAMERA_SAVE_VERSION 7 // LeoCAD 0.80 lcCamera::lcCamera(bool Simple) - : lcObject(lcObjectType::Camera) + : lcObject(lcObjectType::Camera), mSimple(Simple) { - Initialize(); - - if (Simple) - mState |= LC_CAMERA_SIMPLE; - else + if (!Simple) { mPosition.SetValue(lcVector3(-250.0f, -250.0f, 75.0f)); mTargetPosition.SetValue(lcVector3(0.0f, 0.0f, 0.0f)); @@ -43,8 +39,6 @@ lcCamera::lcCamera(const lcVector3& Position, const lcVector3& TargetPosition) UpVector = lcCross(SideVector, FrontVector); UpVector.Normalize(); - Initialize(); - mPosition.SetValue(Position); mTargetPosition.SetValue(TargetPosition); mUpVector.SetValue(UpVector); @@ -118,14 +112,6 @@ lcViewpoint lcCamera::GetViewpoint(const QString& ViewpointName) return lcViewpoint::Count; } -void lcCamera::Initialize() -{ - m_fovy = 30.0f; - m_zNear = 25.0f; - m_zFar = 50000.0f; - mState = 0; -} - bool lcCamera::SetName(const QString& Name) { if (mName == Name) @@ -917,7 +903,7 @@ bool lcCamera::SaveUndoData(QDataStream& Stream, const lcModel* Model) const Stream << m_zFar; Stream << mName; Stream << mProjection; - Stream << (mState & LC_CAMERA_HIDDEN); + Stream << mHidden; return mPosition.SaveUndoData(Stream) && mTargetPosition.SaveUndoData(Stream) && mUpVector.SaveUndoData(Stream); } @@ -931,11 +917,7 @@ bool lcCamera::LoadUndoData(QDataStream& Stream, const lcModel* Model) Stream >> m_zFar; Stream >> mName; Stream >> mProjection; - - quint32 State; - Stream >> State; - - mState = (mState & ~LC_CAMERA_HIDDEN) | State; + Stream >> mHidden; return mPosition.LoadUndoData(Stream) && mTargetPosition.LoadUndoData(Stream) && mUpVector.LoadUndoData(Stream); } diff --git a/common/camera.h b/common/camera.h index 4fe75b46..9890a695 100644 --- a/common/camera.h +++ b/common/camera.h @@ -3,9 +3,6 @@ #include "object.h" #include "lc_math.h" -#define LC_CAMERA_HIDDEN 0x01 -#define LC_CAMERA_SIMPLE 0x02 - enum class lcViewpoint { Front, @@ -61,7 +58,7 @@ public: bool IsSimple() const { - return (mState & LC_CAMERA_SIMPLE) != 0; + return mSimple; } lcCameraProjection GetProjection() const @@ -122,19 +119,18 @@ public: public: bool IsVisible() const - { return (mState & LC_CAMERA_HIDDEN) == 0; } + { + return !mHidden; + } bool IsHidden() const { - return (mState & LC_CAMERA_HIDDEN) != 0; + return mHidden; } void SetHidden(bool Hidden) { - if (Hidden) - mState |= LC_CAMERA_HIDDEN; - else - mState &= ~LC_CAMERA_HIDDEN; + mHidden = Hidden; } void SetPosition(const lcVector3& Position, lcStep Step, bool AddKey) @@ -200,9 +196,9 @@ public: void GetAngles(float& Latitude, float& Longitude, float& Distance) const; void SetAngles(float Latitude, float Longitude, float Distance); - float m_fovy; - float m_zNear; - float m_zFar; + float m_fovy = 30.0f; + float m_zNear = 25.0f; + float m_zFar = 50000; lcMatrix44 mWorldView; lcObjectProperty mPosition = lcObjectProperty(lcVector3(0.0f, 0.0f, 0.0f)); @@ -210,9 +206,7 @@ public: lcObjectProperty mUpVector = lcObjectProperty(lcVector3(0.0f, 0.0f, 0.0f)); protected: - void Initialize(); - QString mName; - quint32 mState; + bool mSimple = false; lcCameraProjection mProjection = lcCameraProjection::Perspective; }; diff --git a/common/light.h b/common/light.h index a42cccc5..b766fb12 100644 --- a/common/light.h +++ b/common/light.h @@ -330,7 +330,6 @@ protected: lcObjectProperty mPOVRayAreaGridX = lcObjectProperty(2); lcObjectProperty mPOVRayAreaGridY = lcObjectProperty(2); - bool mHidden = false; lcVector3 mTargetMovePosition = lcVector3(0.0f, 0.0f, 0.0f); lcMatrix44 mWorldMatrix; diff --git a/common/object.h b/common/object.h index c69330f7..83d04bf5 100644 --- a/common/object.h +++ b/common/object.h @@ -148,6 +148,7 @@ private: lcObjectType mObjectType; protected: + bool mHidden = false; bool mSelected = false; quint32 mFocusedSection = LC_OBJECT_SECTION_INVALID; }; diff --git a/common/piece.h b/common/piece.h index 6f7cec52..9cb6309a 100644 --- a/common/piece.h +++ b/common/piece.h @@ -275,7 +275,6 @@ protected: lcStep mStepHide; bool mPivotPointValid = false; - bool mHidden = false; std::vector mControlPoints; std::vector mTrainTrackConnections; lcMesh* mMesh = nullptr;