Skip to content

Commit

Permalink
pixel indexing finally works
Browse files Browse the repository at this point in the history
  • Loading branch information
Goby56 committed Aug 10, 2024
1 parent 754eaf6 commit 7e4686f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/goby56/wakes/simulation/Brick.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,21 @@ public void updateAdjacency(Brick brick) {
public void populatePixels() {
for (int z = 0; z < dim; z++) {
for (int x = 0; x < dim; x++) {
WakeNode node = this.get(z, x);
WakeNode node = this.get(x, z);

int waterCol = node != null ? node.waterColor : 0;
float opacity = node != null ? (float) ((-Math.pow(node.t, 2) + 1) * WakesClient.CONFIG_INSTANCE.wakeOpacity) : 0;

long nodeOffset = 4L * (((long) z * dim * texRes) + (long) x * texRes);
long nodeOffset = texRes * 4L * (((long) z * dim * texRes) + (long) x);
for (int r = 0; r < texRes; r++) {
for (int c = 0; c < texRes; c++) {
float avg = 0;
if (node != null) {
avg += (node.u[0][r + 1][c + 1] + node.u[1][r + 1][c + 1] + node.u[2][r + 1][c + 1]) / 3;
}
int color = WakeColor.getColor(avg, waterCol, opacity);
int color = waterCol != 0 ? WakeColor.getColor(avg, waterCol, opacity) : 0;

long pixelOffset = 4L * (((long) r * texRes) + c);
long pixelOffset = 4L * (((long) r * dim * texRes) + c);

MemoryUtil.memPutInt(imgPtr + nodeOffset + pixelOffset, color);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/goby56/wakes/simulation/QuadTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.*;

public class QuadTree {
public static final int BRICK_WIDTH = 4;
public static final int BRICK_WIDTH = 16;
private static final int MAX_DEPTH = (int) (26 - Math.log(BRICK_WIDTH) / Math.log(2));
private static final int ROOT_X = (int) - Math.pow(2, 25);
private static final int ROOT_Z = (int) - Math.pow(2, 25);
Expand Down

0 comments on commit 7e4686f

Please sign in to comment.