Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParticleEulerUpdater.cpp
Go to the documentation of this file.
1
2
6
7namespace Divide {
8
9namespace {
10 constexpr U32 g_partitionSize = 256;
11}
12
13void ParticleEulerUpdater::update(const U64 deltaTimeUS, ParticleData& p) {
14 F32 const dt = Time::MicrosecondsToSeconds<F32>(deltaTimeUS);
15 const vec4<F32> globalA(dt * _globalAcceleration, 0.0f);
16
17 const U32 endID = p.aliveCount();
18
19
20 ParallelForDescriptor descriptor = {};
21 descriptor._iterCount = endID;
22 descriptor._partitionSize = g_partitionSize;
23 Parallel_For( context().taskPool( TaskPoolType::HIGH_PRIORITY ), descriptor, [&p, dt, globalA](const Task*, const U32 start, const U32 end)
24 {
25 vector<vec4<F32>>& acceleration = p._acceleration;
26 for (U32 i = start; i < end; ++i) {
27 vec4<F32>& acc = acceleration[i];
28 acc.xyz = (acc + globalA).xyz;
29 }
30 vector<vec4<F32>>& velocity = p._velocity;
31 for (U32 i = start; i < end; ++i) {
32 vec4<F32>& vel = velocity[i];
33 vel.xyz = (vel + dt * acceleration[i]).xyz;
34 }
35
36 vector<vec4<F32>>& position = p._position;
37 for (U32 i = start; i < end; ++i) {
38 vec4<F32>& pos = position[i];
39 pos.xyz = (pos + dt * velocity[i]).xyz;
40 }
41 });
42}
43
44} //namespace Divide
Container to store data for a given set of particles.
Definition: ParticleData.h:59
vector< vec4< F32 > > _acceleration
x,y,z = _acceleration; w = weight;
Definition: ParticleData.h:72
vector< vec4< F32 > > _position
x,y,z = position; w = size
Definition: ParticleData.h:68
U32 aliveCount() const noexcept
Definition: ParticleData.h:117
vector< vec4< F32 > > _velocity
x,y,z = _velocity; w = angle;
Definition: ParticleData.h:70
void update(U64 deltaTimeUS, ParticleData &p) override
PlatformContext & context() noexcept
vec3< T > xyz
Definition: MathVectors.h:1374
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
eastl::vector< Type > vector
Definition: Vector.h:42
void Parallel_For(TaskPool &pool, const ParallelForDescriptor &descriptor, const DELEGATE< void, const Task *, U32, U32 > &cbk)
Definition: TaskPool.cpp:428
uint32_t U32
uint64_t U64
U32 _partitionSize
How many elements should we process per async task.
Definition: TaskPool.h:45
U32 _iterCount
For loop iteration count.
Definition: TaskPool.h:43