-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFluid.h
More file actions
71 lines (58 loc) · 2.04 KB
/
Fluid.h
File metadata and controls
71 lines (58 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <vector>
#include <SFML/Graphics.hpp>
struct Fluid
{
float dt;
float diff;
float visc;
std::vector<float> s;
std::vector<float> density;
std::vector<float> Vx;
std::vector<float> Vy;
std::vector<float> Vx0;
std::vector<float> Vy0;
sf::VertexArray vertexArray;
/// <summary>
/// Constructor for the Fluid class.
/// </summary>
/// <param name="diffusion">Amount the fluid should diffuse</param>
/// <param name="viscosity">The viscosity of the fluid</param>
/// <param name="dt">The delta time</param>
Fluid(float diffusion, float viscosity, float dt);
/// <summary>
/// Add Density to the fluid at a given position.
/// </summary>
/// <param name="x">The x position in the grid</param>
/// <param name="y">The y position in the grid</param>
/// <param name="amount">Amount of density that should be added</param>
void AddDensity(int x, int y, float amount);
/// <summary>
/// Add velocity to the fluid at a given position.
/// </summary>
/// <param name="x">The x position in the grid</param>
/// <param name="y">The y position in the grid</param>
/// <param name="amountX">The amount of speed in the X direction</param>
/// <param name="amountY">The amount of speed in the Y direction</param>
void AddVelocity(int x, int y, float amountX, float amountY);
/// <summary>
/// Do all the physics related calculations.
/// </summary>
void Step();
/// <summary>
/// Render the fluid density on to the window.
/// </summary>
/// <param name="window">The current window to render onto</param>
void RenderDensity(sf::RenderWindow& window);
/// <summary>
/// Render the fluid velocity on to the window.
/// </summary>
/// <param name="window">The current window to render onto</param>
void RenderVelocity(sf::RenderWindow& window);
/// <summary>
/// Render the fluid on to the window.
/// </summary>
/// <param name="window">The current window to render onto</param>
void RenderDefault(sf::RenderWindow& window);
};
typedef struct Fluid Fluid;