Skip to content
Snippets Groups Projects
Commit 5247c47e authored by bobarna's avatar bobarna
Browse files

particle class and other stuff

parent 26d75ac0
No related branches found
No related tags found
No related merge requests found
...@@ -110,5 +110,4 @@ void Application::run() { ...@@ -110,5 +110,4 @@ void Application::run() {
glLoadIdentity(); //load identity matrix glLoadIdentity(); //load identity matrix
camera->glSetupCamera(); camera->glSetupCamera();
scene->render(); scene->render();
} }
...@@ -32,6 +32,7 @@ class Application { ...@@ -32,6 +32,7 @@ class Application {
double time_since_last_frame; double time_since_last_frame;
std::shared_ptr<Camera> camera = std::make_shared<Camera>(); std::shared_ptr<Camera> camera = std::make_shared<Camera>();
// TODO // TODO
//boolean flag, indicates whether a screen capture event should be performed //boolean flag, indicates whether a screen capture event should be performed
//on the next display event. //on the next display event.
......
...@@ -9,6 +9,7 @@ Scene::~Scene() { ...@@ -9,6 +9,7 @@ Scene::~Scene() {
} }
void Scene::update(double dt) { void Scene::update(double dt) {
sph_simulaton
return; return;
} }
......
...@@ -10,7 +10,6 @@ class Scene { ...@@ -10,7 +10,6 @@ class Scene {
bool render; bool render;
bool use_emitter; bool use_emitter;
std::shared_ptr<Scene> scene = std::make_shared<Scene>();
public: public:
Scene(); Scene();
~Scene(); ~Scene();
......
#include "scene.h" #include "scene.h"
using namespace sph::Particl using namespace sph::Particle;
namespace sph {
Particle::Particle():
radius(1), //TODO
radius_sqr(1*1), //TODO
m(1),
rho(1),
p(0),
fixed(false)
{}
Particle::~Particle(){}
// will need these for hashing
Particle::point_type min() const {
return Particle::point_type(x - Particle::point_type(radius));
}
Particle::point_type max() const {
return Particle::point_type(x + Particle::point_type(radius));
}
// checks if two particles (actually two positions) are within an
// allowed radius.
bool check(const point_type& candidate_pos) const{
Particle::point_type diff(pos - candidate_pos);
return radius_sqrt >= diff*diff;
}
// Position
const point_type& position() const;
point_type& position();
//Old Position
const point_type& old_pos() const { return old_pos; }
point_type& old_pos() { return old_pos; }
// Velocity
const vector &velocity() const { return v; }
vector &velocity() { return v; }
// Acceleration
const vector &acceleration() const { return a; }
vector &acceleration() { return a; }
// Force
const vector &force() const { return f; }
vector &force() { return f; }
// Mass
const float &mass() const { return m; }
float &mass() { return m; }
// Density
const float &density() const { return rho; }
float &density() { return rho; }
// Pressure
const float &pressure() const { return p; }
float &pressure() { return p; }
// Normal vector of the surface
const vector &normal() const { return n; }
vector &normal() { return n; }
// Fixed flag of the particle
const bool &fixed() const { return fixed; }
bool &fixed() { return fixed; }
// Radius of the particle
const float &radius() const { return radius; }
}
#ifndef MADID_SCENE_H #ifndef MADID_SPH_PARTICLE
#define MADID_SCENE_H #define MADID_SPH_PARTICLE
#include <glm/glm.hpp> #include <glm/glm.hpp>
...@@ -37,6 +37,100 @@ namespace sph { ...@@ -37,6 +37,100 @@ namespace sph {
// get position // get position
point_type& position(); point_type& position();
/** Old Position (read only).
* @return const reference to the old position vector.
*/
const point_type& old_pos() const;
/** Old Position.
* @return reference to the old position vector.
*/
point_type& old_pos();
/** Velocity (read only).
* @return const reference to the velocity vector.
*/
const vector &velocity() const;
/** Velocity.
* @return reference to the velocity vector.
*/
vector &velocity();
/** Acceleration (read only).
* @return const reference to the acceleration vector.
*/
const vector &acceleration() const;
/** Acceleration.
* @return reference to the acceleration vector.
*/
vector &acceleration();
/** Force (read only).
* @return const reference to the external force vector.
*/
const vector &force() const;
/** Force.
* @return reference to the external force vector.
*/
vector &force();
/** Mass (read only).
* @return const reference to the mass scalar.
*/
const float &mass() const;
/** Mass.
* @return reference to the mass scalar.
*/
float &mass();
/** Density (read only).
* @return const reference to the density value.
*/
const float &density() const;
/** Density.
* @return reference to the density value.
*/
float &density();
/** Pressure (read only).
* @return const reference to the pressure value.
*/
const float &pressure() const;
/** Pressure.
* @return reference to the pressure value.
*/
float &pressure();
/** Normal (read only).
* @return const reference to the surface normal.
*/
const vector &normal() const;
/** Normal.
* @return reference to the surface normal.
*/
vector &normal();
/** Fixed (read only).
* @return const reference to the surface normal.
*/
const bool &fixed() const;
/** Fixed.
* @return reference to the surface normal.
*/
bool &fixed();
/** Fixed.
* @return reference to the surface normal.
*/
const float &radius() const;
} }
} }
......
#include "sph_system.h"
#ifndef MADID_SPH_SYSTEM
#define MADID_SPH_SYSTEM
#include <glm/glm.hpp>
#include "sph_particle.h"
namespace sph {
class System {
// particle container
// collision system
// l
}
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment