#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 computeFinished; unique_ptr renderInFlight; unique_ptr computeInFlight; unique_ptr swapchain; unique_ptr descriptorPool; unique_ptr graphicsPipeline; unique_ptr uniformBuffer; unique_ptr camera; void createMeshBuffers(); unique_ptr vertexBuffer; 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; float dt; uint32_t k; }; unique_ptr propertiesBuffer; Properties properties {}; void createComputePipelines(); unique_ptr pbdPipeline; unique_ptr normalPipeline; void updateUniformBuffer(); void recordGraphicsCommandBuffer(uint32_t imageIndex); void recordDrawCommands(); void drawFrame(); void recordComputeCommands(VkCommandBuffer cmdBuffer); struct PBDPushData { uint32_t state; ConstraintData::Partition edgePartition; ConstraintData::Partition tetrahedronPartition; }; void update(); };