-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
193 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "Utility.hpp" | ||
|
||
namespace Engine | ||
{ | ||
// ----- Public ----- | ||
|
||
glm::vec3 Utility::GetScienticColor(float value, const float min, const float max) | ||
{ | ||
value = fminf(fmaxf(value, min), max - 0.0001f); | ||
const float diff = max - min; | ||
value = diff == 0.0f ? 0.5f : (value - min) / diff; | ||
const float divider = 0.25f; | ||
const float number = floorf(value / divider); | ||
const float pos = (value - number * divider) / divider; | ||
|
||
glm::vec3 retVec{0.0f}; | ||
switch(number) | ||
{ | ||
case 0 : retVec.x = 0.0f; retVec.y = pos; retVec.z = 1.0f; break; | ||
case 1 : retVec.x = 0.0f; retVec.y = 1.0f; retVec.z = 1.0f - pos; break; | ||
case 2 : retVec.x = pos; retVec.y = 1.0f; retVec.z = 0.0f; break; | ||
case 3 : retVec.x = 1.0f; retVec.y = 1.0f; retVec.z = 0.0f; break; | ||
default: break; | ||
} | ||
|
||
return retVec; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include "glm.hpp" | ||
|
||
#include <cmath> | ||
|
||
namespace Engine | ||
{ | ||
class Utility | ||
{ | ||
public: | ||
Utility() = delete; | ||
static glm::vec3 GetScienticColor(float value, float min, float max); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "FluidSimulator.hpp" | ||
|
||
namespace Engine | ||
{ | ||
// ----- Private ----- | ||
|
||
/* Applies forces to the liquid - just gravity in our case */ | ||
void FluidSimulator::AddForces(float dt) | ||
{ | ||
|
||
} | ||
|
||
/* Projection calculates and applies the right amount of pressure to make the * | ||
* velocity field divergence-free and also enforces solid wall boundary conditions. */ | ||
void FluidSimulator::Project(float dt) | ||
{ | ||
|
||
} | ||
|
||
/* Advection moves the quantity, or molecules, or particles, along the velocity field. */ | ||
void FluidSimulator::AdvectVelocity(float dt) | ||
{ | ||
|
||
} | ||
|
||
/* To visualize the flow, we store a density or dye value at the center of each cell * | ||
* and advect it like the velocity field. */ | ||
void FluidSimulator::AdvectSmoke(float dt) | ||
{ | ||
|
||
} | ||
|
||
// ----- Public ----- | ||
|
||
FluidSimulator::FluidSimulator() | ||
{ | ||
|
||
} | ||
|
||
FluidSimulator::~FluidSimulator() | ||
{ | ||
|
||
} | ||
|
||
void FluidSimulator::TimeStep() | ||
{ | ||
float dt = (float)Window::GetDeltaTime(); | ||
AddForces(dt); | ||
Project(dt); | ||
AdvectVelocity(dt); | ||
AdvectSmoke(dt); | ||
} | ||
|
||
float* FluidSimulator::GetSmokeField() | ||
{ | ||
return &_smokeField[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "Window.hpp" | ||
#include "GlobalParams.hpp" | ||
|
||
#define at(x, y) ((x) * Liquiedfied::Params::SIMULATION_HEIGHT + (y)) | ||
|
||
namespace Engine | ||
{ | ||
class FluidSimulator | ||
{ | ||
private: | ||
float _gravity = -9.81f; | ||
float _velocityField[LiquiefiedParams::LIQUID_NUM_CELLS] = {0}; | ||
float _smokeField[LiquiefiedParams::LIQUID_NUM_CELLS] = {0}; | ||
|
||
void AddForces(float dt); | ||
void Project(float dt); | ||
void AdvectVelocity(float dt); | ||
void AdvectSmoke(float dt); | ||
|
||
public: | ||
FluidSimulator(); | ||
~FluidSimulator(); | ||
void TimeStep(); | ||
float* GetSmokeField(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.