|
@@ -13,6 +13,11 @@
|
|
|
#include <imgui_impl_sdl.h>
|
|
|
|
|
|
#include <physics/constants.h>
|
|
|
+#include <physics/particle.h>
|
|
|
+#include <physics/vec2.h>
|
|
|
+#include <physics/force.h>
|
|
|
+
|
|
|
+#include <SDL.h>
|
|
|
|
|
|
void application::parseParameters(int argc, char *argv[])
|
|
|
{
|
|
@@ -25,7 +30,13 @@ void application::setup()
|
|
|
this->millisecsPreviousFrame = SDL_GetTicks();
|
|
|
|
|
|
this->particles.push_back(new particle(50, 100, 1.0, 4));
|
|
|
- //this->particles.push_back(new particle(200, 100, 3.0, 12));
|
|
|
+ this->particles.push_back(new particle(200, 100, 3.0, 12));
|
|
|
+
|
|
|
+ this->liquid.x = 0;
|
|
|
+ this->liquid.y = graphics::height() / 2;
|
|
|
+ this->liquid.w = graphics::width();
|
|
|
+ this->liquid.h = graphics::height() / 2;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void application::input()
|
|
@@ -101,9 +112,17 @@ void application::update()
|
|
|
|
|
|
for (auto part:this->particles)
|
|
|
{
|
|
|
- part->addForce(wind);
|
|
|
+ //part->addForce(wind);
|
|
|
part->addForce(this->pushForce);
|
|
|
part->addForce(weight * part->mass);
|
|
|
+
|
|
|
+ // Apply drag if in liquid.
|
|
|
+ if (part->position.y >= this->liquid.y)
|
|
|
+ {
|
|
|
+ vec2 drag = force::generateDragForce(*part, 0.01);
|
|
|
+ part->addForce(drag);
|
|
|
+ }
|
|
|
+
|
|
|
part->integrate(deltaTime);
|
|
|
|
|
|
// check the particles position and keep the particle in the window.
|