Skip to content

Commit ff78240

Browse files
committed
feat: make clipping renderer radius-based rather than whole scene
1 parent 04f602c commit ff78240

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/main/java/org/runejs/client/frame/DebugTools.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,18 @@ public static void drawWalkPath() {
5858
}
5959
}
6060

61-
public static boolean clippingEnabled = false;
61+
public static int clippingRenderDistance = 0;
6262

6363
public static void drawClipping() {
64-
if (!clippingEnabled) {
64+
if (clippingRenderDistance == 0) {
6565
return;
6666
}
6767

68-
for (int x = 0; x < 104; x++) {
69-
for (int y = 0; y < 104; y++) {
68+
int tileX = Player.localPlayer.worldX >> 7;
69+
int tileY = Player.localPlayer.worldY >> 7;
70+
71+
for (int x = Math.max(0, tileX - clippingRenderDistance); x < Math.min(104, tileX + clippingRenderDistance); x++) {
72+
for (int y = Math.max(0, tileY - clippingRenderDistance); y < Math.min(104, tileY + clippingRenderDistance); y++) {
7073
int data = Landscape.currentCollisionMap[Player.worldLevel].clippingData[x][y];
7174

7275
Point2d screenPos = MovedStatics.getProjectedScreenPosition(0, y * 128 + 64, x * 128 + 64);

src/main/java/org/runejs/client/frame/console/Commands/DebugClippingCommand.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,26 @@ public DebugClippingCommand() {
1111

1212
@Override
1313
public void execute(Console console, String[] cmdInput) {
14-
DebugTools.clippingEnabled = !DebugTools.clippingEnabled;
15-
if(DebugTools.clippingEnabled) {
16-
console.log("<col=00FF00>Clipping is now drawn.</col> <col=FF0000>Red = blocks walk.</col> <col=539FE9>Blue = blocks projectiles.</col>");
17-
} else {
18-
console.log("<col=FF0000>Clipping is now hidden</col>");
14+
boolean radiusProvided = cmdInput.length == 2;
15+
int radius = radiusProvided ? Integer.parseInt(cmdInput[1]) : 10;
16+
17+
if (DebugTools.clippingRenderDistance != 0) {
18+
if (!radiusProvided) {
19+
console.log("<col=FF0000>Clipping is now hidden</col>");
20+
DebugTools.clippingRenderDistance = 0;
21+
return;
22+
}
23+
24+
DebugTools.clippingRenderDistance = radius;
25+
console.log("<col=FF0000>Radius updated to: " + radius + "</col>");
26+
return;
27+
}
28+
29+
DebugTools.clippingRenderDistance = radius;
30+
console.log("<col=00FF00>Clipping is now drawn.</col> <col=FF0000>Red = blocks walk.</col> <col=539FE9>Blue = blocks projectiles.</col>");
31+
32+
if (!radiusProvided) {
33+
console.log("Using default radius: " + radius + ". You can use e.g. `debugclip 15` to increase radius to 15.");
1934
}
2035
}
2136
}

0 commit comments

Comments
 (0)