#ifndef DUST3D_MESH_GENERATOR_H #define DUST3D_MESH_GENERATOR_H #include #include #include #include #include #include #include #include "snapshot.h" #include "meshloader.h" #include "outcome.h" #include "positionmap.h" #include "combinemode.h" class GeneratedCacheContext { public: ~GeneratedCacheContext(); std::map>>> partBmeshVertices; std::map> partBmeshNodes; std::map>> partBmeshQuads; std::map componentCombinableMeshs; std::map> componentPositions; std::map>>> componentVerticesSources; std::map partMirrorIdMap; std::map>> componentInflateBalls; void updateComponentCombinableMesh(QString componentId, void *mesh); }; class MeshGenerator : public QObject { Q_OBJECT public: MeshGenerator(Snapshot *snapshot); ~MeshGenerator(); void setSharedContextWidget(QOpenGLWidget *widget); void addPartPreviewRequirement(const QUuid &partId); void setGeneratedCacheContext(GeneratedCacheContext *cacheContext); void setSmoothNormal(bool smoothNormal); void setWeldEnabled(bool weldEnabled); MeshLoader *takeResultMesh(); MeshLoader *takePartPreviewMesh(const QUuid &partId); const std::set &requirePreviewPartIds(); const std::set &generatedPreviewPartIds(); Outcome *takeOutcome(); void generate(); signals: void finished(); public slots: void process(); private: Snapshot *m_snapshot; MeshLoader *m_mesh; std::map m_partPreviewMeshMap; std::set m_requirePreviewPartIds; std::set m_generatedPreviewPartIds; QThread *m_thread; Outcome *m_outcome; QOpenGLWidget *m_sharedContextWidget; void *m_meshliteContext; GeneratedCacheContext *m_cacheContext; bool m_smoothNormal; bool m_weldEnabled; float m_mainProfileMiddleX; float m_sideProfileMiddleX; float m_mainProfileMiddleY; std::map> m_partNodeIds; std::map> m_partEdgeIds; std::set m_dirtyComponentIds; std::set m_dirtyPartIds; private: static bool m_enableDebug; static PositionMap *m_forMakePositionKey; private: void loadVertexSources(void *meshliteContext, int meshId, QUuid partId, const std::map &bmeshToNodeIdMap, std::vector>> &bmeshVertices, std::vector> &bmeshQuads); void loadGeneratedPositionsToOutcome(void *meshliteContext, int triangulatedMeshId); void collectParts(); void checkDirtyFlags(); bool checkIsComponentDirty(QString componentId); bool checkIsPartDirty(QString partId); void *combineComponentMesh(QString componentId, CombineMode *combineMode, std::vector> *inflateBalls); void *combinePartMesh(QString partId, std::vector> *balls=nullptr); }; #endif