#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "constraints.hpp" #include using std::unique_ptr, std::make_unique; using std::vector; class SoftBody; class Instance; class Swapchain; class GraphicsPipeline; class Buffer; class CommandPool; class Image; class ComputePipeline; class Fence; class Semaphore; class Camera; class DescriptorPool; class Application { public: explicit Application(); void mainLoop(); ~Application(); private: void createSyncObjects(); unique_ptr imageAvailable; unique_ptr renderFinished; unique_ptr computeSemaphore; unique_ptr transferFinished; unique_ptr renderFence; unique_ptr computeFence; unique_ptr transferFence; std::mutex submitMutex; unique_ptr swapchain; unique_ptr descriptorPool; unique_ptr graphicsPipeline; unique_ptr uniformBuffer; unique_ptr camera; void createMeshBuffers(); size_t currentDrawVertexBuffer = 0; unique_ptr vertexBuffers[2]; unique_ptr faceBuffer; unique_ptr edgeBuffer; unique_ptr triangleBuffer; unique_ptr tetrahedronBuffer; ConstraintData constraintData {}; vector> softBodies; struct SizeInformation { uint32_t vertexCount; uint32_t faceCount; uint32_t edgeCount; uint32_t triangleCount; uint32_t tetrahedronCount; }; unique_ptr sizeInformationBuffer; struct Properties { glm::vec3 gravity; // Delta time in seconds float dt; uint32_t k; }; unique_ptr propertiesBuffer; Properties properties {}; void createComputePipelines(); unique_ptr pbdPipeline; unique_ptr normalPipeline; void updateUniformBuffer(); void recordDrawCommands(VkCommandBuffer cmdBuffer); void drawFrame(); void recordComputeCommands(VkCommandBuffer cmdBuffer); struct PBDPushData { uint32_t state; ConstraintData::Partition edgePartition; ConstraintData::Partition tetrahedronPartition; }; void update(); };