#pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "constraints.hpp" #include #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 Grabber; class Application { public: explicit Application(); void mainLoop(); ~Application(); private: void createSyncObjects(); unique_ptr imageAvailable; unique_ptr renderSemaphore; unique_ptr computeSemaphore; unique_ptr transferSemaphore; unique_ptr renderFence; unique_ptr computeFence; unique_ptr transferFence; std::mutex submitMutex; unique_ptr swapchain; unique_ptr descriptorPool; unique_ptr graphicsPipeline; unique_ptr cameraUniformBuffer; unique_ptr camera; unique_ptr grabber; unique_ptr grabBuffer; 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; unique_ptr sizeInformationBuffer; struct SimulationUniformData { glm::vec3 gravity; // Delta time in seconds float dt; uint32_t k; }; unique_ptr propertiesBuffer; SimulationUniformData simulationUniformData {}; void createComputePipelines(); unique_ptr grabPipeline; unique_ptr pbdPipeline; unique_ptr normalPipeline; void updateCameraBuffer(); void recordDrawCommands(VkCommandBuffer cmdBuffer); void drawFrame(float dt); void recordGrabCommands(VkCommandBuffer cmdBuffer); void recordPBDCommands(VkCommandBuffer cmdBuffer); void recordNormalCommands(VkCommandBuffer cmdBuffer); void update(); static uint32_t GetGroupCount(uint32_t threads, uint32_t blockSize); };