Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParticleFloorUpdater.cpp
Go to the documentation of this file.
1
2
6
7namespace Divide {
8
9void ParticleFloorUpdater::update( [[maybe_unused]] const U64 deltaTimeUS, ParticleData& p) {
10 constexpr U32 s_particlesPerThread = 1024;
11 const U32 endID = p.aliveCount();
12
13 STUBBED("ToDo: add proper orientation support! -Ionut");
14
15 const F32 floorY = _floorY;
16 const F32 bounce = _bounceFactor;
17
18
19 ParallelForDescriptor descriptor = {};
20 descriptor._iterCount = endID;
21 descriptor._partitionSize = s_particlesPerThread;
22 Parallel_For( context().taskPool( TaskPoolType::HIGH_PRIORITY ), descriptor, [&p, floorY, bounce](const Task*, const U32 start, const U32 end)
23 {
24 for (U32 i = start; i < end; ++i) {
25 if (p._position[i].y - p._position[i].w / 2 < floorY) {
26 vec3<F32> force(p._acceleration[i]);
27
28 const F32 normalFactor = force.dot(WORLD_Y_AXIS);
29 if (normalFactor < 0.0f) {
30 force -= WORLD_Y_AXIS * normalFactor;
31 }
32 const F32 velFactor = p._velocity[i].xyz.dot(WORLD_Y_AXIS);
33 // if (velFactor < 0.0)
34 p._velocity[i] -= vec4<F32>(WORLD_Y_AXIS * (1.0f + bounce) * velFactor, 0.0f);
35 p._acceleration[i].xyz = force;
36 }
37 }
38 });
39}
40
41} //namespace Divide
#define STUBBED(x)
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
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
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
static const vec3< F32 > WORLD_Y_AXIS
Definition: MathVectors.h:1440
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