summaryrefslogtreecommitdiff
path: root/src/ocean/ocean_alt.cpp
diff options
context:
space:
mode:
authorjjesswan <90643397+jjesswan@users.noreply.github.com>2024-05-10 03:41:50 -0400
committerGitHub <noreply@github.com>2024-05-10 03:41:50 -0400
commitb4ca8b708587c540233284beae8d42ff43092580 (patch)
tree05e7902207c5d22044a76d6374dd220a073c8f69 /src/ocean/ocean_alt.cpp
parent80650ec974d661652eceb08616e8659febe2140d (diff)
parent7c0cd109b098b24279fb17b9a05ab846405d169b (diff)
Merge pull request #4 from Seb-Park/new_parti
New parti
Diffstat (limited to 'src/ocean/ocean_alt.cpp')
-rw-r--r--src/ocean/ocean_alt.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ocean/ocean_alt.cpp b/src/ocean/ocean_alt.cpp
index 7523c94..751fca5 100644
--- a/src/ocean/ocean_alt.cpp
+++ b/src/ocean/ocean_alt.cpp
@@ -319,6 +319,7 @@ void ocean_alt::update_ocean()
// reset normals & vertices arrays for the single tile
m_vertices = std::vector<Eigen::Vector3f>(N);
m_normals = std::vector<Eigen::Vector3f>(N);
+ m_heights.clear();
for (int i = 0; i < N; i++){
Eigen::Vector2d horiz_pos = spacing*m_waveIndexConstants[i].base_horiz_pos;
Eigen::Vector2d amplitude = m_current_h[i];
@@ -357,15 +358,20 @@ void ocean_alt::update_ocean()
Eigen::Vector2d disp = lambda*Eigen::Vector2d(m_displacements_x[i][0], m_displacements_z[i][0])
+ Eigen::Vector2d(vertex_displacement, vertex_displacement); // set corner at 0,0 for retiling
+ Eigen::Vector3f v = Eigen::Vector3f(horiz_pos[0] + disp[0], height, horiz_pos[1] + disp[1]);
// for final vertex position, use the real number component of amplitude vector
- m_vertices[i] = {horiz_pos[0] + disp[0], height, horiz_pos[1] + disp[1]};
+ m_vertices[i] = v;
m_normals[i] = norm.normalized();//Eigen::Vector3f(-slope[0], 1.0, -slope[1]).normalized();
//std::cout << "normal: " << m_normals[i] << std::endl
Eigen::Vector2i m_n = index_1d_to_2d(i);
// m_foam_constants.wavelengths[i] = 2.f* M_PI * m_slopes[i].dot(m_slopes[i]) / Lx;
+// float h_0 = m_waveIndexConstants[i].h0_prime[0]; // min*.2f;
+// float h_max = max*.001f; // the smaller the constant, the more foam there is
+// float waveheight = (height - h_0 ) / (h_max - h_0);
+// m_foam_constants.wavelengths[i] = waveheight;
float h_0 = 0; // min*.2f;
float h_max = max*.35f; // the smaller the constant, the more foam there is
m_foam_constants.wavelengths[i] = (height - h_0 ) / (h_max - h_0);
@@ -375,6 +381,15 @@ void ocean_alt::update_ocean()
// std::cout << m_foam_constants.wavelengths[i] << std::endl;
// }
+ if (m_foam_constants.wavelengths[i] >= height_threshold){
+ //std::cout << "push" << std::endl;
+ 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);
+ }
}