Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParticleAttractorUpdater.cpp
Go to the documentation of this file.
1
2
4
5namespace Divide {
6
7void ParticleAttractorUpdater::update( [[maybe_unused]] const U64 deltaTimeUS, ParticleData& p) {
8 const U32 endID = p.aliveCount();
9 const size_t countAttractors = _attractors.size();
10
11 vec4<F32> offset;
12 F32 dist = 0.0f;
13 size_t a = 0;
14 for (U32 i = 0; i < endID; ++i) {
15 for (a = 0; a < countAttractors; ++a) {
16 offset.set(_attractors[a].xyz - p._position[i].xyz, 0.0f);
17 dist = offset.dot(offset);
18
19 // if (!IS_ZERO(DIST)) {
20 dist = _attractors[a].w / dist;
21 p._acceleration[i] += offset * dist;
22 //}
23 }
24 }
25}
26
27} //namespace Divide
void update(U64 deltaTimeUS, ParticleData &p) override
vector< vec4< F32 > > _attractors
w = force
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
void set(const T *v) noexcept
set the 4 components of the vector manually using a source pointer to a (large enough) array
Definition: MathVectors.h:1241
T dot(const vec4 &v) const noexcept
calculate the dot product between this vector and the specified one
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint32_t U32
uint64_t U64