diff options
author | Adrian Kummerlaender | 2019-04-24 22:37:49 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2019-04-24 22:37:49 +0200 |
commit | 15f33fd09cffe05e82f5a1008cbfc2b2b12c8187 (patch) | |
tree | 8671c3d1e1237b10210038d8e11a8ac50a139fab /src/shader | |
parent | 34566b28a82869cbf004d91c6d658ba71d40ed97 (diff) | |
download | compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.tar compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.tar.gz compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.tar.bz2 compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.tar.lz compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.tar.xz compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.tar.zst compustream-15f33fd09cffe05e82f5a1008cbfc2b2b12c8187.zip |
Add support for erasing walls
Diffstat (limited to 'src/shader')
-rw-r--r-- | src/shader/code/collide.glsl | 12 | ||||
-rw-r--r-- | src/shader/code/interact.glsl | 46 |
2 files changed, 31 insertions, 27 deletions
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); } } )"; |