diff options
| author | Adrian Kummerlaender | 2019-02-24 13:19:27 +0100 | 
|---|---|---|
| committer | Adrian Kummerlaender | 2019-02-24 13:19:27 +0100 | 
| commit | ecaa33e25b42f945fa09dc21b6db53ef330f2cc2 (patch) | |
| tree | 65785ff265073a0e3231a52337c4ec607d60cd1d /src | |
| parent | 2d97364b3cdf1354e5b60807732d447217436523 (diff) | |
| download | compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.tar compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.tar.gz compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.tar.bz2 compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.tar.lz compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.tar.xz compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.tar.zst compustream-ecaa33e25b42f945fa09dc21b6db53ef330f2cc2.zip | |
Move geometry initialization into named function
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 22 | 
1 files changed, 12 insertions, 10 deletions
| diff --git a/src/main.cc b/src/main.cc index 2a3dd9b..aa2456e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -49,6 +49,17 @@ glm::mat4 getMVP(float world_width, float world_height) {  	return projection * view;  } +int setupGeometry(int x, int y) { +	if ( x == 0 || y == 0 || x == nX-1 || y == nY-1 ) { +		return 0; // disable end of world +	} +	if (   ((x == 1 || x == nX-2) && (y > 0 && y < nY-1)) +		|| ((y == 1 || y == nY-2) && (x > 0 && x < nX-1)) ) { +		return 2; // bounce back outer walls +	} +	return 1; // everything else shall be fluid +} +  int renderWindow() {  	Window window("compustream"); @@ -78,16 +89,7 @@ int renderWindow() {  		lattice_a = std::make_unique<LatticeCellBuffer>(nX, nY);  		lattice_b = std::make_unique<LatticeCellBuffer>(nX, nY); -		fluid     = std::make_unique<  FluidCellBuffer>(nX, nY, [](int x, int y) -> int { -			if ( x == 0 || y == 0 || x == nX-1 || y == nY-1 ) { -				return 0; // disable end of world -			} -			if (   ((x == 1 || x == nX-2) && (y > 0 && y < nY-1)) -			    || ((y == 1 || y == nY-2) && (x > 0 && x < nX-1)) ) { -				return 2; // bounce back outer walls -			} -			return 1; // everything shall be fluid -		}); +		fluid     = std::make_unique<  FluidCellBuffer>(nX, nY, setupGeometry);  		interact_shader = std::make_unique<ComputeShader>(INTERACT_SHADER_CODE);  		collide_shader  = std::make_unique<ComputeShader>(COLLIDE_SHADER_CODE); | 
