Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
Wavefield.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5 Copyright 2017-2020 Petr Ohlidal
6
7 For more information, see http://www.rigsofrods.org/
8
9 Rigs of Rods is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License version 3, as
11 published by the Free Software Foundation.
12
13 Rigs of Rods is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22#pragma once
23
24#include "ForwardDeclarations.h"
25#include "Vec3.h"
26
27namespace RoR {
28
31
33{
34public:
35 Wavefield(Vec3 terrn_size);
36
37 float GetStaticWaterHeight();
38 void SetStaticWaterHeight(float value);
39 void SetWavesHeight(float);
40 float CalcWavesHeight(Vec3 pos, float timeshift_sec = 0.f);
41 Vec3 CalcWavesVelocity(Vec3 pos, float timeshift_sec = 0.f);
42 void FrameStepWaveField(float dt);
43 bool IsUnderWater(Vec3 pos);
44 float GetWaveHeight(Vec3 pos);
45
46private:
47
48 struct WaveTrain
49 {
50 float amplitude;
51 float maxheight;
53 float wavespeed;
54 float direction;
55 float dir_sin;
56 float dir_cos;
57 };
58 std::vector<WaveTrain> m_wavetrain_defs;
59
61 float m_water_height = 0.f;
62 float m_waves_height = 0.f;
63 float m_bottom_height = 0.f;
64 float m_max_ampl = 0.f;
65 float m_sim_time_counter = 0.f;
67};
68
70
71} // namespace RoR
Global forward declarations.
< Water physics, see 'wavefield.cfg' in your config directory.
Definition Wavefield.h:33
Vec3 CalcWavesVelocity(Vec3 pos, float timeshift_sec=0.f)
bool IsUnderWater(Vec3 pos)
float m_bottom_height
Definition Wavefield.h:63
float CalcWavesHeight(Vec3 pos, float timeshift_sec=0.f)
Definition Wavefield.cpp:90
void SetStaticWaterHeight(float value)
Definition Wavefield.cpp:80
void SetWavesHeight(float)
Definition Wavefield.cpp:85
float m_waves_height
Definition Wavefield.h:62
float m_water_height
Definition Wavefield.h:61
void FrameStepWaveField(float dt)
float m_waterplane_mesh_scale
Definition Wavefield.h:60
std::vector< WaveTrain > m_wavetrain_defs
Definition Wavefield.h:58
float m_max_ampl
Definition Wavefield.h:64
float m_sim_time_counter
Elapsed simulation time in seconds.
Definition Wavefield.h:65
float GetStaticWaterHeight()
Returns static water level configured in 'terrn2'.
Definition Wavefield.cpp:75
float GetWaveHeight(Vec3 pos)
Designed to work smoothly with optimizations disabled.
Definition Vec3.h:29