summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjjesswan <jessica_wan@brown.edu>2024-05-10 03:41:20 -0400
committerjjesswan <jessica_wan@brown.edu>2024-05-10 03:41:20 -0400
commit7c0cd109b098b24279fb17b9a05ab846405d169b (patch)
tree3c7dcc4f098a83c5c14f5c4f42357a9ab6e1256e /src
parentc5ff8ed6e95b7de0876dc5e97a9cb606fd84be85 (diff)
particlesss
Diffstat (limited to 'src')
-rw-r--r--src/ocean/ocean_alt.cpp2
-rw-r--r--src/ocean/ocean_alt.h7
-rw-r--r--src/particlesystem.cpp29
-rw-r--r--src/particlesystem.h2
4 files changed, 26 insertions, 14 deletions
diff --git a/src/ocean/ocean_alt.cpp b/src/ocean/ocean_alt.cpp
index 9ead324..751fca5 100644
--- a/src/ocean/ocean_alt.cpp
+++ b/src/ocean/ocean_alt.cpp
@@ -386,6 +386,8 @@ void ocean_alt::update_ocean()
OceanSpray s;
s.height = v;
s.slope = norm;
+ s.slope_vector = Eigen::Vector2f(m_slopes_x[i][0], m_slopes_z[i][0]);
+ //std::cout << s.slope_vector << std::endl;
m_heights.push_back(s);
}
diff --git a/src/ocean/ocean_alt.h b/src/ocean/ocean_alt.h
index bbfce9a..7e293f9 100644
--- a/src/ocean/ocean_alt.h
+++ b/src/ocean/ocean_alt.h
@@ -30,6 +30,7 @@ struct FoamConstants{
struct OceanSpray{
Eigen::Vector3f height;
Eigen::Vector3f slope;
+ Eigen::Vector2f slope_vector;
};
@@ -79,8 +80,8 @@ private:
const double Lx = 512.0;
const double Lz = 512.0;
- const int num_rows = 128;
- const int num_cols = 128;
+ const int num_rows = 256;
+ const int num_cols = 256;
const int num_tiles_x = 1;
const int num_tiles_z = 1;
@@ -91,7 +92,7 @@ private:
const double lambda = .5; // how much displacement matters
const double spacing = 1.0; // spacing between grid points
- const double A = 100; // numeric constant for the Phillips spectrum
+ const double A = 10000; // numeric constant for the Phillips spectrum
const double V = 100; // wind speed
const double gravity = 9.81;
const double L = V*V/gravity;
diff --git a/src/particlesystem.cpp b/src/particlesystem.cpp
index b645929..566667f 100644
--- a/src/particlesystem.cpp
+++ b/src/particlesystem.cpp
@@ -35,6 +35,8 @@ float getRandomInRange(float max, float min){
float getRandomY(){
return getRandomInRange(.001,.2);
}
+
+
Eigen::Vector3f particlesystem::getRandomInitialVel(){
@@ -42,6 +44,16 @@ Eigen::Vector3f particlesystem::getRandomInitialVel(){
return factor*Eigen::Vector3f(r.first, getRandomY(), r.second);
}
+Eigen::Vector3f getInitVel(OceanSpray s){
+ float x = getRandomInRange(0,1);
+ float y = getRandomInRange(0.1, .9);
+ Eigen::Vector3f v = Eigen::Vector3f(s.slope_vector[0], y, s.slope_vector[1]) + Eigen::Vector3f(x,0,0);
+ return v*10.f;
+ //p.vel[1] = 0.1;
+
+
+}
+
void particlesystem::init(std::vector<OceanSpray> verts){
// make sure to set m_verts
setVerts(verts);
@@ -51,10 +63,10 @@ void particlesystem::init(std::vector<OceanSpray> verts){
for (auto v : m_verts){
Particle p;
p.pos = Eigen::Vector3f(v.height);
- p.vel = v.slope*factor;
+ p.life = getRandomInRange(.1,1);
+ // p.vel = v.slope*factor;
//p.vel = getRandomInitialVel();
- p.vel = getRandomInitialVel().asDiagonal() * v.slope;
- p.vel[1] = 0.1;
+ p.vel = getInitVel(v);
m_particles.push_back(p);
@@ -95,7 +107,7 @@ void particlesystem::update(double deltaTime){
// if particle is still alive, update pos
if (p.life >= 0.f){
- float r = getRandomInRange(.5, 1.f);
+ float r = getRandomInRange(.5, 1.6f);
p.vel += gravity*dt*r;
p.pos += p.vel * dt * 10.f;
// p.vel[1] -= (p.vel.dot(p.vel) / 2 + gravity[0]) * dt;
@@ -134,13 +146,10 @@ int particlesystem::getUnusedParticleIndex(){
return -1;
}
-void particlesystem::respawn_particle(Particle &p, OceanSpray new_pos){
+void particlesystem::respawn_particle(Particle &p, OceanSpray s){
- p.pos = Eigen::Vector3f(new_pos.height);
- p.vel = new_pos.slope*factor;
- //p.vel = getRandomInitialVel();
- p.vel = getRandomInitialVel().asDiagonal() * new_pos.slope;
- p.vel[1] = .01;
+ p.pos = Eigen::Vector3f(s.height);
+ p.vel = getInitVel(s);
// reset life
diff --git a/src/particlesystem.h b/src/particlesystem.h
index e2874dd..d3b0b8f 100644
--- a/src/particlesystem.h
+++ b/src/particlesystem.h
@@ -35,7 +35,7 @@ public:
void init(std::vector<OceanSpray> verts);
void setVerts(std::vector<OceanSpray> verts){
- std::cout << "VERTS SIZE:" << verts.size() << std::endl;
+ //std::cout << "VERTS SIZE:" << verts.size() << std::endl;
m_verts = verts;
}