Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
ParticleFountainUpdater.cpp
Go to the documentation of this file.
2
3namespace Divide
4{
5
6void ParticleFountainUpdater::update( [[maybe_unused]] const U64 deltaTime, [[maybe_unused]] ParticleData& p) {
7 /*F32 delta = Time::MicrosecondsToSeconds<F32>(deltaTime);
8
9 F32 emissionVariance = random(-_emissionIntervalVariance, _emissionIntervalVariance);
10 I32 newParticles = _emissionInterval + emissionVariance;
11 newParticles = static_cast<I32>(newParticles * delta) / (p->lodLevel() + 1);
12
13 F32 velVariance = random(-_velocityVariance, _velocityVariance);
14 vec3<F32> mainDir = orientation * (WORLD_Y_AXIS * (_velocity + velVariance));
15
16 for (I32 i = 0; i < newParticles; ++i) {
17 ParticleDescriptor& currentParticle = _particles[findUnusedParticle()];
18 F32 lifetimeVariance = random(-_descriptor._lifetimeVariance, _descriptor._lifetimeVariance);
19 currentParticle.life = _descriptor._lifetime + Time::MillisecondsToSeconds(lifetimeVariance);
20 memcpy(currentParticle.pos, origin._v, 3 * sizeof(F32));
21 // Very bad way to generate a random direction;
22 // See for instance http://stackoverflow.com/questions/5408276/python-uniform-spherical-distribution instead,
23 // combined with some user-controlled parameters (main direction, spread, etc)
24 currentParticle.speed[0] = mainDir.x + (rand() % 2000 - 1000.0f) / 1000.0f * spread;
25 currentParticle.speed[1] = mainDir.y + (rand() % 2000 - 1000.0f) / 1000.0f * spread;
26 currentParticle.speed[2] = mainDir.z + (rand() % 2000 - 1000.0f) / 1000.0f * spread;
27 // Very bad way to generate a random color
28 memcpy(currentParticle.rgba, DefaultColors::RANDOM()._v, 3 * sizeof(U8));
29 currentParticle.rgba[3] = (rand() % 256) / 2;
30
31 currentParticle.size = (rand() % 1000) / 2000.0f + 0.1f;
32 }
33
34 // Simulate all particles
35 I32 particlesCount = 0;
36 vec3<F32> half_gravity = DEFAULT_GRAVITY * delta * 0.5f;
37 for (ParticleDescriptor& p : _particles) {
38 if (p.life > 0.0f) {
39 // Decrease life
40 p.life -= delta;
41 if (p.life > 0.0f) {
42 // Simulate simple physics : gravity only, no collisions
43 for (U8 i = 0; i < 3; ++i) {
44 p.speed[i] += half_gravity[i];
45 p.pos[i] += p.speed[i] * delta;
46 }
47 p.distanceToCameraSq = vec3<F32>(p.pos).distanceSquared(eyePos);
48
49
50 _particlePositionData[4 * particlesCount + 0] = p.pos[0];
51 _particlePositionData[4 * particlesCount + 1] = p.pos[1];
52 _particlePositionData[4 * particlesCount + 2] = p.pos[2];
53 _particlePositionData[4 * particlesCount + 3] = p.size;
54
55 _particleColorData[4 * particlesCount + 0] = p.rgba[0];
56 _particleColorData[4 * particlesCount + 1] = p.rgba[1];
57 _particleColorData[4 * particlesCount + 2] = p.rgba[2];
58 _particleColorData[4 * particlesCount + 3] = p.rgba[3];
59 } else {
60 // Particles that just died will be put at the end of the buffer in SortParticles();
61 p.distanceToCameraSq = -1.0f;
62 }
63
64 particlesCount++;
65 }
66 }
67 */
68}
69
70} //namespace Divide
Container to store data for a given set of particles.
Definition: ParticleData.h:59
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint64_t U64
void update(const U64 deltaTime, ParticleData &p) override