aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-02-18 09:00:39 +0100
committerAdrian Kummerlaender2019-02-18 09:00:42 +0100
commit823a9dade6e36760a827aae6ac841b8c582a7935 (patch)
treeb730153c892f30f1db1da46aef0b323596102577 /src
parent1fb15504b07bf78e1881d0a49b3548cba840c7a3 (diff)
downloadcompustream-823a9dade6e36760a827aae6ac841b8c582a7935.tar
compustream-823a9dade6e36760a827aae6ac841b8c582a7935.tar.gz
compustream-823a9dade6e36760a827aae6ac841b8c582a7935.tar.bz2
compustream-823a9dade6e36760a827aae6ac841b8c582a7935.tar.lz
compustream-823a9dade6e36760a827aae6ac841b8c582a7935.tar.xz
compustream-823a9dade6e36760a827aae6ac841b8c582a7935.tar.zst
compustream-823a9dade6e36760a827aae6ac841b8c582a7935.zip
Use same population indexing in collide and stream
Increases consistency and should help to avoid confusion
Diffstat (limited to 'src')
-rw-r--r--src/shader/code/collide.glsl2
-rw-r--r--src/shader/code/stream.glsl14
2 files changed, 13 insertions, 3 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 3510c4e..23e98f9 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -44,7 +44,7 @@ float norm(vec2 v) {
/// Array indexing
uint indexOfDirection(int i, int j) {
- return 3*(j+1) + (i+1);
+ return 3*(i+1) + (j+1);
}
uint indexOfLatticeCell(uint x, uint y) {
diff --git a/src/shader/code/stream.glsl b/src/shader/code/stream.glsl
index 9b77c85..1a2abe3 100644
--- a/src/shader/code/stream.glsl
+++ b/src/shader/code/stream.glsl
@@ -13,14 +13,24 @@ uniform uint nY;
const uint q = 9;
+// Array indexing
+
+uint indexOfDirection(int i, int j) {
+ return 3*(i+1) + (j+1);
+}
+
+uint indexOfLatticeCell(uint x, uint y) {
+ return q*nX*y + q*x;
+}
+
/// Data access
float get(uint x, uint y, int i, int j) {
- return collideCells[q*nX*y + q*x + (i+1)*3 + j+1];
+ return collideCells[indexOfLatticeCell(x,y) + indexOfDirection(i,j)];
}
void set(uint x, uint y, int i, int j, float v) {
- streamCells[q*nX*y + q*x + (i+1)*3 + j+1] = v;
+ streamCells[indexOfLatticeCell(x,y) + indexOfDirection(i,j)] = v;
}
/// Actual stream kernel