Skip to content

Commit dab5ba1

Browse files
committed
docs: comments around debugclip
1 parent ff78240 commit dab5ba1

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,20 @@ public static void drawClipping() {
7272
for (int y = Math.max(0, tileY - clippingRenderDistance); y < Math.min(104, tileY + clippingRenderDistance); y++) {
7373
int data = Landscape.currentCollisionMap[Player.worldLevel].clippingData[x][y];
7474

75+
// center of tile to avoid needless projection calcs in next step
7576
Point2d screenPos = MovedStatics.getProjectedScreenPosition(0, y * 128 + 64, x * 128 + 64);
7677

7778
if (screenPos == null) {
7879
continue;
7980
}
8081

82+
// ground-level points to indicate walkability
8183
Point2d posSW = MovedStatics.getProjectedScreenPosition(0, y * 128, x * 128);
8284
Point2d posNW = MovedStatics.getProjectedScreenPosition(0, y * 128 + 128, x * 128);
8385
Point2d posSE = MovedStatics.getProjectedScreenPosition(0, y * 128, x * 128 + 128);
8486
Point2d posNE = MovedStatics.getProjectedScreenPosition(0, y * 128 + 128, x * 128 + 128);
8587

88+
// mid-level points to indicate projectile shootability
8689
Point2d posSWA = MovedStatics.getProjectedScreenPosition(100, y * 128, x * 128);
8790
Point2d posNWA = MovedStatics.getProjectedScreenPosition(100, y * 128 + 128, x * 128);
8891
Point2d posSEA = MovedStatics.getProjectedScreenPosition(100, y * 128, x * 128 + 128);
@@ -91,31 +94,31 @@ public static void drawClipping() {
9194
int blockWalkColor = 0xFF0000;
9295
int blockProjectileColor = 0x539FE9;
9396

94-
if ((data & 0x2) == 0x2) {
97+
if ((data & 0x2) == 0x2) { // north
9598
if (posNE != null && posNW != null) {
9699
Rasterizer.drawDiagonalLine(posNE.x, posNE.y, posNW.x, posNW.y, blockWalkColor);
97100
}
98101
}
99102

100-
if ((data & 0x8) == 0x8) {
103+
if ((data & 0x8) == 0x8) { // east
101104
if (posSE != null && posNE != null) {
102105
Rasterizer.drawDiagonalLine(posSE.x, posSE.y, posNE.x, posNE.y, blockWalkColor);
103106
}
104107
}
105108

106-
if ((data & 0x20) == 0x20) {
109+
if ((data & 0x20) == 0x20) { // south
107110
if (posSE != null && posSW != null) {
108111
Rasterizer.drawDiagonalLine(posSE.x, posSE.y, posSW.x, posSW.y, blockWalkColor);
109112
}
110113
}
111114

112-
if ((data & 0x80) == 0x80) {
115+
if ((data & 0x80) == 0x80) { // west
113116
if (posSW != null && posNW != null) {
114117
Rasterizer.drawDiagonalLine(posSW.x, posSW.y, posNW.x, posNW.y, blockWalkColor);
115118
}
116119
}
117120

118-
if ((data & 0x100) == 0x100) {
121+
if ((data & 0x100) == 0x100) { // total block
119122
if (posNE != null && posNW != null) {
120123
Rasterizer.drawDiagonalLine(posNE.x, posNE.y, posNW.x, posNW.y, blockWalkColor);
121124
}
@@ -130,7 +133,10 @@ public static void drawClipping() {
130133
}
131134
}
132135

133-
if ((data & 0x400) == 0x400) {
136+
// below this are projectiles. these draw more lines than the ground-level ones,
137+
// because there are vertical bars to join them to the ground
138+
139+
if ((data & 0x400) == 0x400) { // north (projectile)
134140
if (posNEA != null && posNWA != null) {
135141
Rasterizer.drawDiagonalLine(posNEA.x, posNEA.y, posNWA.x, posNWA.y, blockProjectileColor);
136142

@@ -144,25 +150,25 @@ public static void drawClipping() {
144150
}
145151
}
146152

147-
if ((data & 0x1000) == 0x1000) {
153+
if ((data & 0x1000) == 0x1000) { // east (projectile)
148154
if (posSEA != null && posNEA != null) {
149155
Rasterizer.drawDiagonalLine(posSEA.x, posSEA.y, posNEA.x, posNEA.y, blockProjectileColor);
150156
}
151157
}
152158

153-
if ((data & 0x4000) == 0x4000) {
159+
if ((data & 0x4000) == 0x4000) { // south (projectile)
154160
if (posSEA != null && posSWA != null) {
155161
Rasterizer.drawDiagonalLine(posSEA.x, posSEA.y, posSWA.x, posSWA.y, blockProjectileColor);
156162
}
157163
}
158164

159-
if ((data & 0x8000) == 0x8000) {
165+
if ((data & 0x10000) == 0x10000) { // west (projectile)
160166
if (posSWA != null && posNWA != null) {
161167
Rasterizer.drawDiagonalLine(posSWA.x, posSWA.y, posNWA.x, posNWA.y, blockProjectileColor);
162168
}
163169
}
164170

165-
if ((data & 0x20000) == 0x20000) {
171+
if ((data & 0x20000) == 0x20000) { // total block (projectile)
166172
if (posNEA != null && posNWA != null) {
167173
Rasterizer.drawDiagonalLine(posNEA.x, posNEA.y, posNWA.x, posNWA.y, blockProjectileColor);
168174

0 commit comments

Comments
 (0)