driema / euler-fluid-cpp Goto Github PK
View Code? Open in Web Editor NEWEuler fluid simulated with CPP and SFML
License: MIT License
Euler fluid simulated with CPP and SFML
License: MIT License
class Container {
private:
Physics physics;
int size;
float dt;
float diff;
float visc;
float* px;
float* py;
float* x;
float* y;
float* previousDensity;
float* density;
void InitArr(float* arr, int size);
public:
Container();
Container(float dt, float diff, float visc);
~Container();
void AddDensity(float x, float y, float amount);
void AddVelocity(float x, float y, float px, float py);
void Step();
void Render(sf::RenderWindow& win);
void FadeDensity(int size);
};
to
extern const int SIZE;
extern const int SCALE;
class Container {
private:
Physics physics;
int size;
float dt;
float diff;
float visc;
float px[SIZE*SIZE];
float py[SIZE*SIZE];
float x[SIZE*SIZE];
float y[SIZE*SIZE];
float previousDensity[SIZE*SIZE];
float density[SIZE*SIZE];
void InitArr(float* arr, int size);
public:
Container();
Container(float dt, float diff, float visc);
~Container();
void AddDensity(float x, float y, float amount);
void AddVelocity(float x, float y, float px, float py);
void Step();
void Render(sf::RenderWindow& win);
void FadeDensity(int size);
};
Hello.
First; I want to congratulate you for your contribution. It is great!!
Second; I am considering a project where I want to simulate volcanic lava running down the slope of a mountain (in 2D).
I don't know if it is possible to do it with this approach. The first question I have is whether it is possible to simulate the effect of the lava going around obstacles it may encounter on its way, such as houses (rectangles). Do you have an opinion on how to implement this?
In other words, I wonder how this "fluid" will work interacting with rigid objects/bodies. I guess, as it is not a particle system per se there are no collisions to detect. :-D
Thanks!
DJuego
Seem to be getting an odd error on line 6 of Sim.cpp
Sim::Sim() : options(Options()), container(Container(0.2f, 0, 0.0000001f)), win(sf::RenderWindow(sf::VideoMode(SIZE* SCALE, SIZE* SCALE), "Euler fluid simulation - Github: https://github.com/driema/euler-fluid-cpp", sf::Style::Titlebar | sf::Style::Close)) {}
Severity Code Description Project File Line Suppression State
Error C2280 'sf::RenderWindow::RenderWindow(const sf::RenderWindow &)': attempting to reference a deleted function Euler C:\VSProjects\Euler\sim.cpp 6
Any solutions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.