Skip to content

Commit 52e6948

Browse files
committed
refactor: move occluders to instance
1 parent 22a05ae commit 52e6948

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/main/java/org/runejs/client/Landscape.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ else if(s > 255)
613613
int i_72_ = 240;
614614
int i_73_ = -i_72_ + tile_height[i_68_][x][i_65_];
615615
int i_74_ = tile_height[i_67_][x][i_65_];
616-
Scene.createOccluder(plane, 1, 128 * x, 128 * x, 128 * i_65_, 128 + 128 * i_66_, i_73_, i_74_);
616+
Game.currentScene.createOccluder(plane, 1, 128 * x, 128 * x, 128 * i_65_, 128 + 128 * i_66_, i_73_, i_74_);
617617
for(int i_75_ = i_67_; i_75_ <= i_68_; i_75_++) {
618618
for(int i_76_ = i_65_; i_76_ <= i_66_; i_76_++)
619619
tileCullingBitsets[i_75_][x][i_76_] = BitUtils.bitWiseAND(tileCullingBitsets[i_75_][x][i_76_], renderRule1 ^ 0xffffffff);
@@ -652,7 +652,7 @@ else if(s > 255)
652652
int lowestOcclusionVertexHeight = tile_height[lowestOcclusionPlane][lowestOcclusionX][y];
653653
int highestOcclusionVertexHeightOffset = 240;
654654
int highestOcclusionVertexHeight = tile_height[highestOcclusionPlane][lowestOcclusionX][y] - highestOcclusionVertexHeightOffset;
655-
Scene.createOccluder(plane, 2, 128 * lowestOcclusionX, 128 * highestOcclusionX + 128, 128 * y, y * 128, highestOcclusionVertexHeight, lowestOcclusionVertexHeight);
655+
Game.currentScene.createOccluder(plane, 2, 128 * lowestOcclusionX, 128 * highestOcclusionX + 128, 128 * y, y * 128, highestOcclusionVertexHeight, lowestOcclusionVertexHeight);
656656
for(int occludedPlane = lowestOcclusionPlane; highestOcclusionPlane >= occludedPlane; occludedPlane++) {
657657
for(int occludedX = lowestOcclusionX; occludedX <= highestOcclusionX; occludedX++)
658658
tileCullingBitsets[occludedPlane][occludedX][y] = BitUtils.bitWiseAND(tileCullingBitsets[occludedPlane][occludedX][y], i_59_ ^ 0xffffffff);
@@ -688,7 +688,7 @@ else if(s > 255)
688688
}
689689
if((-i_89_ + i_90_ + 1) * (1 + i_92_ - i_91_) >= 4) {
690690
int i_95_ = tile_height[_plane][i_89_][i_91_];
691-
Scene.createOccluder(plane, 4, i_89_ * 128, i_90_ * 128 + 128, 128 * i_91_, i_92_ * 128 + 128, i_95_, i_95_);
691+
Game.currentScene.createOccluder(plane, 4, i_89_ * 128, i_90_ * 128 + 128, 128 * i_91_, i_92_ * 128 + 128, i_95_, i_95_);
692692
for(int i_96_ = i_89_; i_96_ <= i_90_; i_96_++) {
693693
for(int i_97_ = i_91_; i_92_ >= i_97_; i_97_++)
694694
tileCullingBitsets[_plane][i_96_][i_97_] = BitUtils.bitWiseAND(tileCullingBitsets[_plane][i_96_][i_97_], i_60_ ^ 0xffffffff);

src/main/java/org/runejs/client/scene/Scene.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,18 @@ public class Scene {
4646
public static int mapBoundsX;
4747
public static int currentPositionY;
4848
public static int cameraPosZ;
49-
public static int anInt90 = 4;
5049
public static int currentPositionX;
5150
public static int activeOccluderCount = 0;
5251
public static int cameraPosY;
5352
public static int renderCameraYawCosine;
5453
public static int cameraPositionTileY;
55-
public static int[] cullingClusterPointer = new int[anInt90];
5654
public static int renderCameraYawSine;
5755
public static InteractiveObject[] interactiveObjects = new InteractiveObject[100];
5856
public static SceneCluster[] processedCullingClusters = new SceneCluster[500];
5957
public static LinkedList tileList = new LinkedList();
6058
public static int anInt109 = 0;
6159
public static int renderCameraPitchCosine;
6260
public static int mapBoundsY;
63-
public static SceneCluster[][] cullingClusters = new SceneCluster[anInt90][500];
6461
public static int drawWidthMidpoint;
6562
public static int drawHeight;
6663
public static int drawHeightMidpoint;
@@ -108,6 +105,9 @@ public class Scene {
108105
public int mapSizeY = 104;
109106
public int mapSizeZ = 4;
110107

108+
private SceneCluster[][] cullingClusters = new SceneCluster[mapSizeZ][500];
109+
private int[] cullingClusterPointer = new int[mapSizeZ];
110+
111111
public Scene(int[][][] heightMap) {
112112
tileArray = new SceneTile[mapSizeZ][mapSizeX][mapSizeY];
113113
tileOcclusionCycles = new int[mapSizeZ][mapSizeX + 1][mapSizeY + 1];
@@ -255,7 +255,7 @@ public boolean isPointVisibleOnScreen(int x, int y, int z) {
255255
}
256256

257257

258-
public static void createOccluder(int z, int searchMask, int lowestX, int highestX, int lowestY, int highestY, int highestZ, int lowestZ) {
258+
public void createOccluder(int z, int searchMask, int lowestX, int highestX, int lowestY, int highestY, int highestZ, int lowestZ) {
259259
SceneCluster sceneCluster = new SceneCluster();
260260
sceneCluster.tileStartX = lowestX / 128;
261261
sceneCluster.tileEndX = highestX / 128;
@@ -568,7 +568,7 @@ public void initToNull() {
568568
}
569569
}
570570
}
571-
for (int i = 0; i < anInt90; i++) {
571+
for (int i = 0; i < mapSizeZ; i++) {
572572
for (int i_39_ = 0; i_39_ < cullingClusterPointer[i]; i_39_++) {
573573
cullingClusters[i][i_39_] = null;
574574
}

0 commit comments

Comments
 (0)