Toast Engine
Loading...
Searching...
No Matches
debris_simulation.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <glm/glm.hpp>
8#include <span>
10
11namespace example {
12
14class DebrisSimulation : public renderer::AsyncComputeTask {
15public:
16 static constexpr uint32_t k_max_particles = 65536;
17
18 DebrisSimulation();
19
21 void spawn(std::span<const glm::vec4> positions, std::span<const glm::vec4> velocities);
22
24 void step(float dt);
25
27 auto readPositions(std::span<glm::vec4> out) -> bool {
28 return read(m_positions, out);
29 }
30
32 [[nodiscard]]
33 auto positionsId() const -> BufferId {
34 return m_positions;
35 }
36
37private:
39 struct Params {
40 float dt;
41 uint32_t count;
42 };
43
44 BufferId m_positions = 0;
45 BufferId m_velocities = 0;
46 uint32_t m_count = 0;
47};
48
49}
auto positionsId() const -> BufferId
For the render pass. xyz position w radius.
Definition debris_simulation.hpp:33
void step(float dt)
Physics thread. Returns right away.
Definition debris_simulation.cpp:34
void spawn(std::span< const glm::vec4 > positions, std::span< const glm::vec4 > velocities)
Physics thread before the first step.
Definition debris_simulation.cpp:28
auto readPositions(std::span< glm::vec4 > out) -> bool
Physics thread. Newest finished positions and false until one exists.
Definition debris_simulation.hpp:27
Definition async_compute_task.hpp:33
auto read(BufferId id, std::span< std::byte > out) -> bool
Newest finished CPU copy of a ring buffer added with cpu_readback and false until one exists.
Definition async_compute_task.cpp:363