Particle System Oscillating & Circular Update Function problem

Hi all.

----The Briefing-----

I'm making a simple Particle system with the use of QT for a GUI.

I'm making 3 types of particle patterns:
Linear (particles move in a straight line)
Oscillating (particles move like a sine wave)
Circular (particles move in a circle)

When creating each particle pattern when QT is run from the C++ solution, one can also edit the position (x+y), spawn rate, life span (s), max particles and color of the particles created.
There are additional options for each individual pattern:

Linear (can adjust velocity)
Oscillating( can adjust particle speed (pixels/s) , Period and Amplitude)
Circular/Ellipsoid (can adjust particle speed and dimensions (h, w).


----The Problem----

All of these patterns work when created, but the oscillating and circular patterns are slower than i want them to be, and this is due to the update function.

Currently the update function is the same (or uses the same logic) for every pattern, and it's this:
every cpp file has it's respective header file, except for of course main.cpp

From linearparticle.cpp
1
2
3
4
5
6
7
void LinearParticle::update(float dt)
{
	Particle::update(dt);

	pos.setX(pos.x() + vel.x() * dt);
	pos.setY(pos.y() + vel.y() * dt);
}

From circularparticle.cpp
1
2
3
4
5
6
7
8
9
void CircularParticle::update(float dt)
{
	Particle::update(dt);

	pos.setX(pos.x() + sin(age));
	pos.setY(pos.y() + cos(age));


}

From oscillatingparticle.cpp
1
2
3
4
5
6
7
void OscillatingParticle::update(float dt)
{
	Particle::update ( dt);

	pos.setX(pos.x() + speed * dt);
	pos.setY(pos.y() + sin(age));
}


Note how the function differs depending on each pattern, but the logic is the same.

This function updates the particle from it's last generated position (imagine a line of dots, as this is what linear looks like).

---The solution----

To make the oscillating and circular patterns act faster, i need to change this update function so that it updates the particle from the point of origin, rather than it's last generated position.

If anyone may have the solution to this issue or needs any more information, don't hesistate to ask, as ideally i would like to have solved this within a week.

Seeing as posting the entire source code in this thread is kind of overkill, i will list all my current header and cpp files, i can also send you all the code if you wish:

circularparticle.h
linearparticle.h
oscillatingparticle.h
particle.h
particlecreator.h
particlesystem.h

circularparticle.cpp
linearparticle.cpp
oscillatingparticle.cpp
particle.cpp
particlecreator.cpp
particlesystem.cpp
main.cpp

I also have made a YUML diagram for the whole project too, so if you wish to see that to set some things straight , let me know,either PM'ing or responding to this thread will give me a notification!


Kind Regards,

JSleek.

> To make the oscillating and circular patterns act faster,
> i need to change this update function so that it updates the particle
> from the point of origin, rather than it's last generated position.
¿so?
to increase the speed you may want to use lookup tables
Topic archived. No new replies allowed.