From 3d1091492ecf4665d50357735a64edcec45c36e9 Mon Sep 17 00:00:00 2001 From: Leonardo Zide Date: Tue, 20 Oct 2026 21:31:31 -0700 Subject: [PATCH] Reduce asset header dependencies Keep library source storage details in the implementation and move the primitive constructor out of line so the library header no longer needs string helpers. Use shared forward declarations and asset types in loader and manager headers, keeping the full texture definition in its implementation. --- common/lc_assetloader.h | 6 ------ common/lc_global.h | 2 ++ common/lc_library.cpp | 32 ++++++++++++++++++++++++++++ common/lc_library.h | 41 ++---------------------------------- common/lc_piecedata.h | 5 ----- common/lc_texturemanager.cpp | 1 + common/lc_texturemanager.h | 2 +- common/lc_thumbnailmanager.h | 2 -- 8 files changed, 38 insertions(+), 53 deletions(-) diff --git a/common/lc_assetloader.h b/common/lc_assetloader.h index 6f83d01d..24968b0a 100644 --- a/common/lc_assetloader.h +++ b/common/lc_assetloader.h @@ -2,13 +2,7 @@ #include "lc_assettypes.h" -class lcPieceData; -class lcPiecesLibrary; -class lcPiece; struct lcPieceControlPoint; -class lcMesh; -class lcSynthInfo; -class lcTexture; // Owned by lcPiecesLibrary. Instance methods run on the UI thread and schedule private worker builds; // UI-thread completion processing resolves colors, uploads textures, and publishes meshes. diff --git a/common/lc_global.h b/common/lc_global.h index 2c6e28c7..1a42aee6 100644 --- a/common/lc_global.h +++ b/common/lc_global.h @@ -84,6 +84,8 @@ enum class lcLightAreaShape; class lcGroup; class lcModelHistory; class lcPieceData; +class lcSynthInfo; +class lcTrainTrackInfo; typedef std::map> lcPartsList; struct lcModelPartsEntry; struct lcMinifig; diff --git a/common/lc_library.cpp b/common/lc_library.cpp index 9d2f3006..11953941 100644 --- a/common/lc_library.cpp +++ b/common/lc_library.cpp @@ -39,6 +39,38 @@ enum class lcLibraryCacheFlag : quint32 Directory = 0x0002 }; +enum class lcLibrarySourceType +{ + Library, + StudStyle +}; + +struct lcLibrarySource +{ + lcLibrarySource() = default; + + lcLibrarySource(const lcLibrarySource&) = delete; + lcLibrarySource(lcLibrarySource&&) = delete; + lcLibrarySource& operator=(const lcLibrarySource&) = delete; + lcLibrarySource& operator=(lcLibrarySource&&) = delete; + + lcLibrarySourceType Type; + std::map> Primitives; +}; + +lcLibraryPrimitive::lcLibraryPrimitive(QString&& FileName, const char* Name, lcZipFileType ZipFileType, quint32 ZipFileIndex, bool Stud, bool StudStyle, bool SubFile) + : mFileName(std::move(FileName)) +{ + lcstrcpy(mName, Name); + + mZipFileType = ZipFileType; + mZipFileIndex = ZipFileIndex; + mState = lcPrimitiveState::NotLoaded; + mStud = Stud; + mStudStyle = StudStyle; + mSubFile = SubFile; +} + lcPiecesLibrary::lcPiecesLibrary(lcStudStyle StudStyle, bool StudCylinderColorEnabled) : mStudStyle(StudStyle), mStudCylinderColorEnabled(StudCylinderColorEnabled) { diff --git a/common/lc_library.h b/common/lc_library.h index c466fcd8..f984e5a7 100644 --- a/common/lc_library.h +++ b/common/lc_library.h @@ -1,20 +1,13 @@ #pragma once #include "lc_context.h" -#include "lc_math.h" #include "lc_meshloader.h" #include "lc_result.h" #include "lc_assettypes.h" -#include "lc_string.h" -class lcPieceData; -class lcPiece; -class lcMesh; -class lcTrainTrackInfo; struct lcTrainTrackConnectionType; class lcZipFile; -class lcLibraryMeshData; -struct lcEmbeddedData; +struct lcLibrarySource; enum class lcStudStyle { @@ -59,18 +52,7 @@ enum class lcPrimitiveState class lcLibraryPrimitive { public: - explicit lcLibraryPrimitive(QString&& FileName, const char* Name, lcZipFileType ZipFileType, quint32 ZipFileIndex, bool Stud, bool StudStyle, bool SubFile) - : mFileName(std::move(FileName)) - { - lcstrcpy(mName, Name); - - mZipFileType = ZipFileType; - mZipFileIndex = ZipFileIndex; - mState = lcPrimitiveState::NotLoaded; - mStud = Stud; - mStudStyle = StudStyle; - mSubFile = SubFile; - } + explicit lcLibraryPrimitive(QString&& FileName, const char* Name, lcZipFileType ZipFileType, quint32 ZipFileIndex, bool Stud, bool StudStyle, bool SubFile); void SetZipFile(lcZipFileType ZipFileType, quint32 ZipFileIndex) { @@ -97,25 +79,6 @@ public: QString mLoadError; }; -enum class lcLibrarySourceType -{ - Library, - StudStyle -}; - -struct lcLibrarySource -{ - lcLibrarySource() = default; - - lcLibrarySource(const lcLibrarySource&) = delete; - lcLibrarySource(lcLibrarySource&&) = delete; - lcLibrarySource& operator=(const lcLibrarySource&) = delete; - lcLibrarySource& operator=(lcLibrarySource&&) = delete; - - lcLibrarySourceType Type; - std::map> Primitives; -}; - // Coordinates asset sources, loading, settings and shared render buffers. // Piece/texture managers own identities and references; the loader owns pending work. // Acquisition, scheduling and publication run on the UI thread; workers use source snapshots. diff --git a/common/lc_piecedata.h b/common/lc_piecedata.h index 6f3ef287..ff665e54 100644 --- a/common/lc_piecedata.h +++ b/common/lc_piecedata.h @@ -1,6 +1,5 @@ #pragma once -#include #include "lc_assettypes.h" #include "lc_math.h" @@ -15,10 +14,6 @@ struct lcModelPartsEntry int ColorIndex; }; -class lcSynthInfo; -class lcTrainTrackInfo; -enum class lcZipFileType; - class lcPieceData { public: diff --git a/common/lc_texturemanager.cpp b/common/lc_texturemanager.cpp index 82281cb4..b2483d98 100644 --- a/common/lc_texturemanager.cpp +++ b/common/lc_texturemanager.cpp @@ -2,6 +2,7 @@ #include "lc_texturemanager.h" #include "lc_file.h" #include "lc_string.h" +#include "lc_texture.h" lcTextureManager::~lcTextureManager() { diff --git a/common/lc_texturemanager.h b/common/lc_texturemanager.h index 3788ae62..f1fd5600 100644 --- a/common/lc_texturemanager.h +++ b/common/lc_texturemanager.h @@ -1,6 +1,6 @@ #pragma once -#include "lc_texture.h" +#include "lc_assettypes.h" // Creates and reuses textures, tracks their references, and prepares image data. // The asset loader handles scheduling, OpenGL uploads, and retries. diff --git a/common/lc_thumbnailmanager.h b/common/lc_thumbnailmanager.h index d34579e6..a09cb799 100644 --- a/common/lc_thumbnailmanager.h +++ b/common/lc_thumbnailmanager.h @@ -2,8 +2,6 @@ #include "lc_assettypes.h" -class lcPiecesLibrary; - struct lcPartThumbnail { QPixmap Pixmap;