diff options
-rw-r--r-- | src/main.cc | 8 | ||||
-rw-r--r-- | src/shader/code/collide.glsl | 12 | ||||
-rw-r--r-- | src/shader/code/interact.glsl | 46 |
3 files changed, 35 insertions, 31 deletions
diff --git a/src/main.cc b/src/main.cc index f3f14ec..394248c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -213,11 +213,11 @@ int render() { if ( currMouseState != 0 || prevMouseState != 0 ) { auto guard = interact_shader->use(); - interact_shader->setUniform("influxRequested", currMouseState == 1); - interact_shader->setUniform("wallRequested", currMouseState == 2); + interact_shader->setUniform("wall_requested", currMouseState == 1); + interact_shader->setUniform("fluid_requested", currMouseState == 2); - interact_shader->setUniform("startOfLine", prevLatticeMouseX, prevLatticeMouseY); - interact_shader->setUniform("endOfLine", currLatticeMouseX, currLatticeMouseY); + interact_shader->setUniform("start", prevLatticeMouseX, prevLatticeMouseY); + interact_shader->setUniform("end", currLatticeMouseX, currLatticeMouseY); interact_shader->dispatch(nX, nY); } diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl index e2c3212..191204e 100644 --- a/src/shader/code/collide.glsl +++ b/src/shader/code/collide.glsl @@ -28,7 +28,7 @@ const float invCs2 = 1./3.; const float physCharLength = 1.0; const float physCharVelocity = 1.0; const float physViscosity = 0.01; -const float latticeCharVelocity = 0.1; +const float latticeCharVelocity = 0.005; /// Unit conversion @@ -148,14 +148,6 @@ bool isOutflowCell(int material) { return material == 6; } -float getExternalMassInflux(int material) { - if ( material == 4 ) { - return 1.5; - } else { - return 0.0; - } -}; - float getLocalKnudsenApproximation(uint x, uint y, float d, vec2 v) { float knudsen = 0.0; @@ -182,7 +174,7 @@ void main() { const int material = getMaterial(x,y); - float d = max(density(x,y), getExternalMassInflux(material)); + float d = density(x,y); vec2 v = velocity(x,y,d); if ( isBulkFluidCell(material) ) { diff --git a/src/shader/code/interact.glsl b/src/shader/code/interact.glsl index cb69333..613c4cd 100644 --- a/src/shader/code/interact.glsl +++ b/src/shader/code/interact.glsl @@ -10,11 +10,11 @@ uniform uint nY; /// External influence -uniform bool influxRequested; -uniform bool wallRequested; +uniform bool wall_requested; +uniform bool fluid_requested; -uniform vec2 startOfLine; -uniform vec2 endOfLine; +uniform vec2 start; +uniform vec2 end; /// Vector utilities @@ -39,10 +39,10 @@ float distanceToLineSegment(vec2 a, vec2 b, vec2 p) { } bool isNearLine(uint x, uint y, float eps) { - if ( startOfLine == endOfLine ) { - return norm(vec2(x,y) - endOfLine) < eps; + if ( start == end ) { + return norm(vec2(x,y) - end) < eps; } else { - return distanceToLineSegment(startOfLine, endOfLine, vec2(x,y)) < eps; + return distanceToLineSegment(start, end, vec2(x,y)) < eps; } } @@ -83,6 +83,16 @@ void disableWallInterior(uint x, uint y) { } } +void fixWallExterior(uint x, uint y) { + for ( int i = -1; i <= 1; ++i ) { + for ( int j = -1; j <= 1; ++j ) { + if ( getMaterial(x+i,y+j)== 0 ) { + setMaterial(x+i,y+j,3); + } + } + } +} + /// Actual interaction kernel void main() { @@ -97,24 +107,26 @@ void main() { if ( material == 1 ) { if ( isNearLine(x, y, 3) ) { - if ( influxRequested ) { - setMaterial(x,y,4); - return; - } - if ( wallRequested ) { + if ( wall_requested ) { setMaterial(x,y,3); return; } } } - if ( material == 3 ) { - disableWallInterior(x,y); + if ( material == 0 || material == 3 ) { + if ( fluid_requested ) { + if ( isNearLine(x, y, 3) ) { + setMaterial(x,y,1); + fixWallExterior(x,y); + return; + } + } } - if ( material == 4 ) { - // reset influx material after execution - setMaterial(x,y,1); + + if ( material == 3 ) { + disableWallInterior(x,y); } } )"; |