Properly name Perspective methods, remove unused

- Properly rename world->local Perspective methods and force them to
accept LocalPoint to prevent confusion
- Remove unused params from Perspective methods

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2018-07-30 17:38:40 +02:00
parent 40637f8f92
commit 73dbea874a
24 changed files with 95 additions and 117 deletions

View File

@@ -181,24 +181,22 @@ public interface Actor extends Renderable
* Gets the point at which an image should be drawn, relative to the * Gets the point at which an image should be drawn, relative to the
* current location with the given z-axis offset. * current location with the given z-axis offset.
* *
* @param graphics engine graphics
* @param image the image to draw * @param image the image to draw
* @param zOffset the z-axis offset * @param zOffset the z-axis offset
* @return the image drawing location * @return the image drawing location
*/ */
Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset); Point getCanvasImageLocation(BufferedImage image, int zOffset);
/** /**
* Gets the point at which a sprite should be drawn, relative to the * Gets the point at which a sprite should be drawn, relative to the
* current location with the given z-axis offset. * current location with the given z-axis offset.
* *
* @param graphics engine graphics
* @param sprite the sprite to draw * @param sprite the sprite to draw
* @param zOffset the z-axis offset * @param zOffset the z-axis offset
* @return the sprite drawing location * @return the sprite drawing location
*/ */
Point getCanvasSpriteLocation(Graphics2D graphics, SpritePixels sprite, int zOffset); Point getCanvasSpriteLocation(SpritePixels sprite, int zOffset);
/** /**
* Gets a point on the canvas of where this actors mini-map indicator * Gets a point on the canvas of where this actors mini-map indicator

View File

@@ -75,15 +75,14 @@ public class Perspective
* their corresponding coordinates on the game screen. * their corresponding coordinates on the game screen.
* *
* @param client the game client * @param client the game client
* @param x ground coordinate on the x axis * @param point ground coordinate
* @param y ground coordinate on the y axis
* @param plane ground plane on the z axis * @param plane ground plane on the z axis
* @return a {@link Point} on screen corresponding to the position in * @return a {@link Point} on screen corresponding to the position in
* 3D-space * 3D-space
*/ */
public static Point worldToCanvas(@Nonnull Client client, int x, int y, int plane) public static Point localToCanvas(@Nonnull Client client, @Nonnull LocalPoint point, int plane)
{ {
return worldToCanvas(client, x, y, plane, 0); return localToCanvas(client, point, plane, 0);
} }
/** /**
@@ -91,17 +90,16 @@ public class Perspective
* their corresponding coordinates on the game screen. * their corresponding coordinates on the game screen.
* *
* @param client the game client * @param client the game client
* @param x ground coordinate on the x axis * @param point ground coordinate
* @param y ground coordinate on the y axis
* @param plane ground plane on the z axis * @param plane ground plane on the z axis
* @param zOffset distance from ground on the z axis * @param zOffset distance from ground on the z axis
* @return a {@link Point} on screen corresponding to the position in * @return a {@link Point} on screen corresponding to the position in
* 3D-space * 3D-space
*/ */
public static Point worldToCanvas(@Nonnull Client client, int x, int y, int plane, int zOffset) public static Point localToCanvas(@Nonnull Client client, @Nonnull LocalPoint point, int plane, int zOffset)
{ {
final int tileHeight = getTileHeight(client, x, y, plane); final int tileHeight = getTileHeight(client, point, plane);
return localToCanvas(client, x, y, tileHeight - zOffset); return localToCanvas(client, point.getX(), point.getY(), tileHeight - zOffset);
} }
/** /**
@@ -154,15 +152,14 @@ public class Perspective
* their corresponding coordinates on the Minimap. * their corresponding coordinates on the Minimap.
* *
* @param client the game client * @param client the game client
* @param x ground coordinate on the x axis * @param point ground coordinate
* @param y ground coordinate on the y axis
* @return a {@link Point} on screen corresponding to the position in * @return a {@link Point} on screen corresponding to the position in
* 3D-space * 3D-space
*/ */
@Nullable @Nullable
public static Point worldToMiniMap(@Nonnull Client client, int x, int y) public static Point localToMinimap(@Nonnull Client client, @Nonnull LocalPoint point)
{ {
return worldToMiniMap(client, x, y, 6400); return localToMinimap(client, point, 6400);
} }
/** /**
@@ -170,18 +167,17 @@ public class Perspective
* their corresponding coordinates on the Minimap. * their corresponding coordinates on the Minimap.
* *
* @param client the game client * @param client the game client
* @param x ground coordinate on the x axis * @param point ground coordinate
* @param y ground coordinate on the y axis
* @param distance max distance from local player to minimap point * @param distance max distance from local player to minimap point
* @return a {@link Point} on screen corresponding to the position in * @return a {@link Point} on screen corresponding to the position in
* 3D-space * 3D-space
*/ */
@Nullable @Nullable
public static Point worldToMiniMap(@Nonnull Client client, int x, int y, int distance) public static Point localToMinimap(@Nonnull Client client, @Nonnull LocalPoint point, int distance)
{ {
LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
x = x / 32 - localLocation.getX() / 32; int x = point.getX() / 32 - localLocation.getX() / 32;
y = y / 32 - localLocation.getY() / 32; int y = point.getY() / 32 - localLocation.getY() / 32;
int dist = x * x + y * y; int dist = x * x + y * y;
if (dist < distance) if (dist < distance)
@@ -229,15 +225,14 @@ public class Perspective
* Calculates the above ground height of a tile point. * Calculates the above ground height of a tile point.
* *
* @param client the game client * @param client the game client
* @param localX the ground coordinate on the x axis * @param point the local ground coordinate
* @param localY the ground coordinate on the y axis
* @param plane the client plane/ground level * @param plane the client plane/ground level
* @return the offset from the ground of the tile * @return the offset from the ground of the tile
*/ */
public static int getTileHeight(@Nonnull Client client, int localX, int localY, int plane) public static int getTileHeight(@Nonnull Client client, @Nonnull LocalPoint point, int plane)
{ {
int sceneX = localX >> LOCAL_COORD_BITS; int sceneX = point.getSceneX();
int sceneY = localY >> LOCAL_COORD_BITS; int sceneY = point.getSceneY();
if (sceneX >= 0 && sceneY >= 0 && sceneX < SCENE_SIZE && sceneY < SCENE_SIZE) if (sceneX >= 0 && sceneY >= 0 && sceneX < SCENE_SIZE && sceneY < SCENE_SIZE)
{ {
byte[][][] tileSettings = client.getTileSettings(); byte[][][] tileSettings = client.getTileSettings();
@@ -249,8 +244,8 @@ public class Perspective
z1 = plane + 1; z1 = plane + 1;
} }
int x = localX & (LOCAL_TILE_SIZE - 1); int x = point.getX() & (LOCAL_TILE_SIZE - 1);
int y = localY & (LOCAL_TILE_SIZE - 1); int y = point.getY() & (LOCAL_TILE_SIZE - 1);
int var8 = x * tileHeights[z1][sceneX + 1][sceneY] + (LOCAL_TILE_SIZE - x) * tileHeights[z1][sceneX][sceneY] >> LOCAL_COORD_BITS; int var8 = x * tileHeights[z1][sceneX + 1][sceneY] + (LOCAL_TILE_SIZE - x) * tileHeights[z1][sceneX][sceneY] >> LOCAL_COORD_BITS;
int var9 = tileHeights[z1][sceneX][sceneY + 1] * (LOCAL_TILE_SIZE - x) + x * tileHeights[z1][sceneX + 1][sceneY + 1] >> LOCAL_COORD_BITS; int var9 = tileHeights[z1][sceneX][sceneY + 1] * (LOCAL_TILE_SIZE - x) + x * tileHeights[z1][sceneX + 1][sceneY + 1] >> LOCAL_COORD_BITS;
return (LOCAL_TILE_SIZE - y) * var8 + y * var9 >> LOCAL_COORD_BITS; return (LOCAL_TILE_SIZE - y) * var8 + y * var9 >> LOCAL_COORD_BITS;
@@ -388,7 +383,7 @@ public class Perspective
int plane = client.getPlane(); int plane = client.getPlane();
Point p = worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset); Point p = localToCanvas(client, localLocation, plane, zOffset);
if (p == null) if (p == null)
{ {
@@ -406,7 +401,6 @@ public class Perspective
* Calculates image position and centers depending on image size. * Calculates image position and centers depending on image size.
* *
* @param client the game client * @param client the game client
* @param graphics the game graphics
* @param localLocation local location of the tile * @param localLocation local location of the tile
* @param image image for size measurement * @param image image for size measurement
* @param zOffset offset from ground plane * @param zOffset offset from ground plane
@@ -415,14 +409,13 @@ public class Perspective
*/ */
public static Point getCanvasImageLocation( public static Point getCanvasImageLocation(
@Nonnull Client client, @Nonnull Client client,
@Nonnull Graphics2D graphics,
@Nonnull LocalPoint localLocation, @Nonnull LocalPoint localLocation,
@Nonnull BufferedImage image, @Nonnull BufferedImage image,
int zOffset) int zOffset)
{ {
int plane = client.getPlane(); int plane = client.getPlane();
Point p = worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset); Point p = localToCanvas(client, localLocation, plane, zOffset);
if (p == null) if (p == null)
{ {
@@ -449,7 +442,7 @@ public class Perspective
@Nonnull LocalPoint localLocation, @Nonnull LocalPoint localLocation,
@Nonnull BufferedImage image) @Nonnull BufferedImage image)
{ {
Point p = Perspective.worldToMiniMap(client, localLocation.getX(), localLocation.getY()); Point p = Perspective.localToMinimap(client, localLocation);
if (p == null) if (p == null)
{ {
@@ -466,7 +459,6 @@ public class Perspective
* Calculates sprite position and centers depending on sprite size. * Calculates sprite position and centers depending on sprite size.
* *
* @param client the game client * @param client the game client
* @param graphics the game graphics
* @param localLocation local location of the tile * @param localLocation local location of the tile
* @param sprite SpritePixel for size measurement * @param sprite SpritePixel for size measurement
* @param zOffset offset from ground plane * @param zOffset offset from ground plane
@@ -474,14 +466,13 @@ public class Perspective
*/ */
public static Point getCanvasSpriteLocation( public static Point getCanvasSpriteLocation(
@Nonnull Client client, @Nonnull Client client,
@Nonnull Graphics2D graphics,
@Nonnull LocalPoint localLocation, @Nonnull LocalPoint localLocation,
@Nonnull SpritePixels sprite, @Nonnull SpritePixels sprite,
int zOffset) int zOffset)
{ {
int plane = client.getPlane(); int plane = client.getPlane();
Point p = worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset); Point p = localToCanvas(client, localLocation, plane, zOffset);
if (p == null) if (p == null)
{ {
@@ -504,11 +495,10 @@ public class Perspective
* @param client the game client * @param client the game client
* @param model the model to calculate a clickbox for * @param model the model to calculate a clickbox for
* @param orientation the orientation of the model (0-2048, where 0 is north) * @param orientation the orientation of the model (0-2048, where 0 is north)
* @param localX the x-axis coordinate of the tile * @param point the coordinate of the tile
* @param localY the y-axis coordinate of the tile
* @return the clickable area of the model * @return the clickable area of the model
*/ */
public static Area getClickbox(@Nonnull Client client, Model model, int orientation, int localX, int localY) public static Area getClickbox(@Nonnull Client client, Model model, int orientation, @Nonnull LocalPoint point)
{ {
if (model == null) if (model == null)
{ {
@@ -523,8 +513,8 @@ public class Perspective
.map(v -> v.rotate(orientation)) .map(v -> v.rotate(orientation))
.collect(Collectors.toList()); .collect(Collectors.toList());
Area clickBox = get2DGeometry(client, triangles, orientation, localX, localY); Area clickBox = get2DGeometry(client, triangles, point);
Area visibleAABB = getAABB(client, vertices, orientation, localX, localY); Area visibleAABB = getAABB(client, vertices, point);
if (visibleAABB == null || clickBox == null) if (visibleAABB == null || clickBox == null)
{ {
@@ -551,22 +541,20 @@ public class Perspective
private static Area get2DGeometry( private static Area get2DGeometry(
@Nonnull Client client, @Nonnull Client client,
@Nonnull List<Triangle> triangles, @Nonnull List<Triangle> triangles,
int orientation, @Nonnull LocalPoint point
int localX,
int localY
) )
{ {
int radius = 5; int radius = 5;
Area geometry = new Area(); Area geometry = new Area();
final int tileHeight = getTileHeight(client, localX, localY, client.getPlane()); final int tileHeight = getTileHeight(client, point, client.getPlane());
for (Triangle triangle : triangles) for (Triangle triangle : triangles)
{ {
Vertex _a = triangle.getA(); Vertex _a = triangle.getA();
Point a = localToCanvas(client, Point a = localToCanvas(client,
localX - _a.getX(), point.getX() - _a.getX(),
localY - _a.getZ(), point.getY() - _a.getZ(),
tileHeight + _a.getY()); tileHeight + _a.getY());
if (a == null) if (a == null)
{ {
@@ -575,8 +563,8 @@ public class Perspective
Vertex _b = triangle.getB(); Vertex _b = triangle.getB();
Point b = localToCanvas(client, Point b = localToCanvas(client,
localX - _b.getX(), point.getX() - _b.getX(),
localY - _b.getZ(), point.getY() - _b.getZ(),
tileHeight + _b.getY()); tileHeight + _b.getY());
if (b == null) if (b == null)
{ {
@@ -585,8 +573,8 @@ public class Perspective
Vertex _c = triangle.getC(); Vertex _c = triangle.getC();
Point c = localToCanvas(client, Point c = localToCanvas(client,
localX - _c.getX(), point.getX() - _c.getX(),
localY - _c.getZ(), point.getY() - _c.getZ(),
tileHeight + _c.getY()); tileHeight + _c.getY());
if (c == null) if (c == null)
{ {
@@ -633,9 +621,7 @@ public class Perspective
private static Area getAABB( private static Area getAABB(
@Nonnull Client client, @Nonnull Client client,
@Nonnull List<Vertex> vertices, @Nonnull List<Vertex> vertices,
int orientation, @Nonnull LocalPoint point
int localX,
int localY
) )
{ {
int maxX = 0; int maxX = 0;
@@ -697,15 +683,15 @@ public class Perspective
extremeZ = 32; extremeZ = 32;
} }
int x1 = localX - (centerX - extremeX); int x1 = point.getX() - (centerX - extremeX);
int y1 = centerY - extremeY; int y1 = centerY - extremeY;
int z1 = localY - (centerZ - extremeZ); int z1 = point.getY() - (centerZ - extremeZ);
int x2 = localX - (centerX + extremeX); int x2 = point.getX() - (centerX + extremeX);
int y2 = centerY + extremeY; int y2 = centerY + extremeY;
int z2 = localY - (centerZ + extremeZ); int z2 = point.getY() - (centerZ + extremeZ);
final int tileHeight = getTileHeight(client, localX, localY, client.getPlane()); final int tileHeight = getTileHeight(client, point, client.getPlane());
Point p1 = localToCanvas(client, x1, z1, tileHeight + y1); Point p1 = localToCanvas(client, x1, z1, tileHeight + y1);
Point p2 = localToCanvas(client, x1, z2, tileHeight + y1); Point p2 = localToCanvas(client, x1, z2, tileHeight + y1);
@@ -770,7 +756,7 @@ public class Perspective
@Nonnull LocalPoint localLocation, @Nonnull LocalPoint localLocation,
@Nonnull String text) @Nonnull String text)
{ {
Point p = Perspective.worldToMiniMap(client, localLocation.getX(), localLocation.getY()); Point p = Perspective.localToMinimap(client, localLocation);
if (p == null) if (p == null)
{ {

View File

@@ -130,7 +130,7 @@ public class BlastMineRockOverlay extends Overlay
return; return;
} }
Point loc = Perspective.getCanvasImageLocation(client, graphics, rock.getGameObject().getLocalLocation(), icon, 150); Point loc = Perspective.getCanvasImageLocation(client, rock.getGameObject().getLocalLocation(), icon, 150);
if (loc != null) if (loc != null)
{ {
@@ -145,7 +145,7 @@ public class BlastMineRockOverlay extends Overlay
return; return;
} }
Point loc = Perspective.worldToCanvas(client, rock.getGameObject().getX(), rock.getGameObject().getY(), client.getPlane(), 150); Point loc = Perspective.localToCanvas(client, rock.getGameObject().getLocalLocation(), rock.getGameObject().getPlane(), 150);
if (loc != null) if (loc != null)
{ {

View File

@@ -104,7 +104,7 @@ public class CannonSpotOverlay extends Overlay
} }
//Render icon //Render icon
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, point, image, 0); Point imageLoc = Perspective.getCanvasImageLocation(client, point, image, 0);
if (imageLoc != null) if (imageLoc != null)
{ {

View File

@@ -90,7 +90,7 @@ public class DemonicGorillaOverlay extends Overlay
LocalPoint lp = gorilla.getNpc().getLocalLocation(); LocalPoint lp = gorilla.getNpc().getLocalLocation();
if (lp != null) if (lp != null)
{ {
Point point = Perspective.worldToCanvas(client, lp.getX(), lp.getY(), client.getPlane(), Point point = Perspective.localToCanvas(client, lp, client.getPlane(),
gorilla.getNpc().getLogicalHeight() + 16); gorilla.getNpc().getLogicalHeight() + 16);
if (point != null) if (point != null)
{ {

View File

@@ -135,9 +135,8 @@ public class SceneOverlay extends Overlay
boolean first = true; boolean first = true;
for (int y = lp1.getY(); y <= lp2.getY(); y += LOCAL_TILE_SIZE) for (int y = lp1.getY(); y <= lp2.getY(); y += LOCAL_TILE_SIZE)
{ {
Point p = Perspective.worldToCanvas(client, Point p = Perspective.localToCanvas(client,
lp1.getX() - LOCAL_TILE_SIZE / 2, new LocalPoint(lp1.getX() - LOCAL_TILE_SIZE / 2, y - LOCAL_TILE_SIZE / 2),
y - LOCAL_TILE_SIZE / 2,
client.getPlane()); client.getPlane());
if (p != null) if (p != null)
{ {
@@ -161,9 +160,8 @@ public class SceneOverlay extends Overlay
boolean first = true; boolean first = true;
for (int x = lp1.getX(); x <= lp2.getX(); x += LOCAL_TILE_SIZE) for (int x = lp1.getX(); x <= lp2.getX(); x += LOCAL_TILE_SIZE)
{ {
Point p = Perspective.worldToCanvas(client, Point p = Perspective.localToCanvas(client,
x - LOCAL_TILE_SIZE / 2, new LocalPoint(x - LOCAL_TILE_SIZE / 2, lp1.getY() - LOCAL_TILE_SIZE / 2),
lp1.getY() - LOCAL_TILE_SIZE / 2,
client.getPlane()); client.getPlane());
if (p != null) if (p != null)
{ {
@@ -202,9 +200,8 @@ public class SceneOverlay extends Overlay
boolean first = true; boolean first = true;
for (int y = lp1.getY(); y <= lp2.getY(); y += LOCAL_TILE_SIZE) for (int y = lp1.getY(); y <= lp2.getY(); y += LOCAL_TILE_SIZE)
{ {
Point p = Perspective.worldToCanvas(client, Point p = Perspective.localToCanvas(client,
lp1.getX() - LOCAL_TILE_SIZE / 2, new LocalPoint(lp1.getX() - LOCAL_TILE_SIZE / 2, y - LOCAL_TILE_SIZE / 2),
y - LOCAL_TILE_SIZE / 2,
client.getPlane()); client.getPlane());
if (p != null) if (p != null)
{ {
@@ -228,9 +225,8 @@ public class SceneOverlay extends Overlay
boolean first = true; boolean first = true;
for (int x = lp1.getX(); x <= lp2.getX(); x += LOCAL_TILE_SIZE) for (int x = lp1.getX(); x <= lp2.getX(); x += LOCAL_TILE_SIZE)
{ {
Point p = Perspective.worldToCanvas(client, Point p = Perspective.localToCanvas(client,
x - LOCAL_TILE_SIZE / 2, new LocalPoint(x - LOCAL_TILE_SIZE / 2, lp1.getY() - LOCAL_TILE_SIZE / 2),
lp1.getY() - LOCAL_TILE_SIZE / 2,
client.getPlane()); client.getPlane());
if (p != null) if (p != null)
{ {
@@ -376,7 +372,7 @@ public class SceneOverlay extends Overlay
} }
LocalPoint fl = fa.getLocalLocation(); LocalPoint fl = fa.getLocalLocation();
Point fs = Perspective.worldToCanvas(client, fl.getX(), fl.getY(), client.getPlane(), fa.getLogicalHeight() / 2); Point fs = Perspective.localToCanvas(client, fl, client.getPlane(), fa.getLogicalHeight() / 2);
if (fs == null) if (fs == null)
{ {
return; return;
@@ -385,7 +381,7 @@ public class SceneOverlay extends Overlay
int fsy = fs.getY() - INTERACTING_SHIFT; int fsy = fs.getY() - INTERACTING_SHIFT;
LocalPoint tl = ta.getLocalLocation(); LocalPoint tl = ta.getLocalLocation();
Point ts = Perspective.worldToCanvas(client, tl.getX(), tl.getY(), client.getPlane(), ta.getLogicalHeight() / 2); Point ts = Perspective.localToCanvas(client, tl, client.getPlane(), ta.getLogicalHeight() / 2);
if (ts == null) if (ts == null)
{ {
return; return;

View File

@@ -113,7 +113,7 @@ class FishingSpotOverlay extends Overlay
} }
LocalPoint localPoint = npc.getLocalLocation(); LocalPoint localPoint = npc.getLocalLocation();
Point location = Perspective.worldToCanvas(client, localPoint.getX(), localPoint.getY(), client.getPlane()); Point location = Perspective.localToCanvas(client, localPoint, client.getPlane());
if (location != null) if (location != null)
{ {
@@ -141,7 +141,7 @@ class FishingSpotOverlay extends Overlay
BufferedImage fishImage = itemManager.getImage(spot.getFishSpriteId());; BufferedImage fishImage = itemManager.getImage(spot.getFishSpriteId());;
if (fishImage != null) if (fishImage != null)
{ {
Point imageLocation = npc.getCanvasImageLocation(graphics, fishImage, npc.getLogicalHeight()); Point imageLocation = npc.getCanvasImageLocation(fishImage, npc.getLogicalHeight());
if (imageLocation != null) if (imageLocation != null)
{ {
OverlayUtil.renderImageLocation(graphics, imageLocation, fishImage); OverlayUtil.renderImageLocation(graphics, imageLocation, fishImage);

View File

@@ -141,7 +141,7 @@ public class TrapOverlay extends Overlay
{ {
return; return;
} }
net.runelite.api.Point loc = Perspective.worldToCanvas(client, localLoc.getX(), localLoc.getY(), trap.getWorldLocation().getPlane()); net.runelite.api.Point loc = Perspective.localToCanvas(client, localLoc, client.getPlane());
double timeLeft = 1 - trap.getTrapTimeRelative(); double timeLeft = 1 - trap.getTrapTimeRelative();
@@ -172,7 +172,7 @@ public class TrapOverlay extends Overlay
{ {
return; return;
} }
net.runelite.api.Point loc = Perspective.worldToCanvas(client, localLoc.getX(), localLoc.getY(), trap.getWorldLocation().getPlane()); net.runelite.api.Point loc = Perspective.localToCanvas(client, localLoc, client.getPlane());
ProgressPieComponent pie = new ProgressPieComponent(); ProgressPieComponent pie = new ProgressPieComponent();
pie.setFill(fill); pie.setFill(fill);

View File

@@ -106,7 +106,7 @@ class KourendLibraryOverlay extends Overlay
{ {
continue; continue;
} }
Point screenBookcase = Perspective.worldToCanvas(client, localBookcase.getX(), localBookcase.getY(), caseLoc.getPlane(), 25); Point screenBookcase = Perspective.localToCanvas(client, localBookcase, caseLoc.getPlane(), 25);
if (screenBookcase != null) if (screenBookcase != null)
{ {
@@ -219,7 +219,7 @@ class KourendLibraryOverlay extends Overlay
LocalPoint local = n.getLocalLocation(); LocalPoint local = n.getLocalLocation();
Polygon poly = getCanvasTilePoly(client, local); Polygon poly = getCanvasTilePoly(client, local);
OverlayUtil.renderPolygon(g, poly, Color.WHITE); OverlayUtil.renderPolygon(g, poly, Color.WHITE);
Point screen = Perspective.worldToCanvas(client, local.getX(), local.getY(), client.getPlane(), n.getLogicalHeight()); Point screen = Perspective.localToCanvas(client, local, client.getPlane(), n.getLogicalHeight());
if (screen != null) if (screen != null)
{ {
g.drawImage(b.getIcon(), screen.getX() - (b.getIcon().getWidth() / 2), screen.getY() - b.getIcon().getHeight(), null); g.drawImage(b.getIcon(), screen.getX() - (b.getIcon().getWidth() / 2), screen.getY() - b.getIcon().getHeight(), null);

View File

@@ -438,6 +438,6 @@ public class MotherlodePlugin extends Plugin
*/ */
boolean isUpstairs(LocalPoint localPoint) boolean isUpstairs(LocalPoint localPoint)
{ {
return Perspective.getTileHeight(client, localPoint.getX(), localPoint.getY(), 0) < UPPER_FLOOR_HEIGHT; return Perspective.getTileHeight(client, localPoint, 0) < UPPER_FLOOR_HEIGHT;
} }
} }

View File

@@ -111,7 +111,7 @@ class MotherlodeRocksOverlay extends Overlay
private void renderVein(Graphics2D graphics, WallObject vein) private void renderVein(Graphics2D graphics, WallObject vein)
{ {
Point canvasLoc = Perspective.getCanvasImageLocation(client, graphics, vein.getLocalLocation(), miningIcon, 150); Point canvasLoc = Perspective.getCanvasImageLocation(client, vein.getLocalLocation(), miningIcon, 150);
if (canvasLoc != null) if (canvasLoc != null)
{ {

View File

@@ -384,7 +384,7 @@ public class AlchemyRoom extends MTARoom
} }
BufferedImage image = itemManager.getImage(alchemyItem.getId()); BufferedImage image = itemManager.getImage(alchemyItem.getId());
Point canvasLoc = Perspective.getCanvasImageLocation(client, graphics, object.getLocalLocation(), image, IMAGE_Z_OFFSET); Point canvasLoc = Perspective.getCanvasImageLocation(client, object.getLocalLocation(), image, IMAGE_Z_OFFSET);
if (canvasLoc != null) if (canvasLoc != null)
{ {

View File

@@ -131,7 +131,7 @@ public class NpcSceneOverlay extends Overlay
final int textHeight = graphics.getFontMetrics().getAscent(); final int textHeight = graphics.getFontMetrics().getAscent();
final Point canvasPoint = Perspective final Point canvasPoint = Perspective
.worldToCanvas(client, centerLp.getX(), centerLp.getY(), respawnLocation.getPlane()); .localToCanvas(client, centerLp, respawnLocation.getPlane());
if (canvasPoint != null) if (canvasPoint != null)
{ {

View File

@@ -77,7 +77,7 @@ class PrayerBarOverlay extends Overlay
final int height = client.getLocalPlayer().getLogicalHeight() + 10; final int height = client.getLocalPlayer().getLogicalHeight() + 10;
final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation();
final Point canvasPoint = Perspective.worldToCanvas(client, localLocation.getX(), localLocation.getY(), client.getPlane(), height); final Point canvasPoint = Perspective.localToCanvas(client, localLocation, client.getPlane(), height);
// Draw bar // Draw bar
final int barX = canvasPoint.getX() + client.getViewportXOffset() - 15; final int barX = canvasPoint.getX() + client.getViewportXOffset() - 15;

View File

@@ -101,7 +101,7 @@ public class TitheFarmPlantOverlay extends Overlay
continue; continue;
} }
final Point canvasLocation = Perspective.worldToCanvas(client, localLocation.getX(), localLocation.getY(), client.getPlane()); final Point canvasLocation = Perspective.localToCanvas(client, localLocation, client.getPlane());
if (viewport != null && canvasLocation != null) if (viewport != null && canvasLocation != null)
{ {

View File

@@ -85,7 +85,7 @@ public class OverlayUtil
public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset) public static void renderImageLocation(Client client, Graphics2D graphics, LocalPoint localPoint, BufferedImage image, int zOffset)
{ {
net.runelite.api.Point imageLocation = Perspective.getCanvasImageLocation(client, graphics, localPoint, image, zOffset); net.runelite.api.Point imageLocation = Perspective.getCanvasImageLocation(client, localPoint, image, zOffset);
if (imageLocation != null) if (imageLocation != null)
{ {
renderImageLocation(graphics, imageLocation, image); renderImageLocation(graphics, imageLocation, image);
@@ -123,7 +123,7 @@ public class OverlayUtil
renderPolygon(graphics, poly, color); renderPolygon(graphics, poly, color);
} }
Point imageLocation = actor.getCanvasImageLocation(graphics, image, zOffset); Point imageLocation = actor.getCanvasImageLocation(image, zOffset);
if (imageLocation != null) if (imageLocation != null)
{ {
renderImageLocation(graphics, imageLocation, image); renderImageLocation(graphics, imageLocation, image);

View File

@@ -163,23 +163,23 @@ public abstract class RSActorMixin implements RSActor
@Inject @Inject
@Override @Override
public Point getCanvasImageLocation(Graphics2D graphics, BufferedImage image, int zOffset) public Point getCanvasImageLocation(BufferedImage image, int zOffset)
{ {
return Perspective.getCanvasImageLocation(client, graphics, getLocalLocation(), image, zOffset); return Perspective.getCanvasImageLocation(client, getLocalLocation(), image, zOffset);
} }
@Inject @Inject
@Override @Override
public Point getCanvasSpriteLocation(Graphics2D graphics, SpritePixels sprite, int zOffset) public Point getCanvasSpriteLocation(SpritePixels sprite, int zOffset)
{ {
return Perspective.getCanvasSpriteLocation(client, graphics, getLocalLocation(), sprite, zOffset); return Perspective.getCanvasSpriteLocation(client, getLocalLocation(), sprite, zOffset);
} }
@Inject @Inject
@Override @Override
public Point getMinimapLocation() public Point getMinimapLocation()
{ {
return Perspective.worldToMiniMap(client, getX(), getY()); return Perspective.localToMinimap(client, getLocalLocation());
} }
@FieldHook("animation") @FieldHook("animation")

View File

@@ -86,7 +86,7 @@ public abstract class RSDecorativeObjectMixin implements RSDecorativeObject
@Override @Override
public Area getClickbox() public Area getClickbox()
{ {
return Perspective.getClickbox(client, getModel(), getOrientation(), getX(), getY()); return Perspective.getClickbox(client, getModel(), getOrientation(), getLocalLocation());
} }
@Inject @Inject

View File

@@ -80,7 +80,7 @@ public abstract class RSGameObjectMixin implements RSGameObject
@Override @Override
public Area getClickbox() public Area getClickbox()
{ {
return Perspective.getClickbox(client, getModel(), getRsOrientation(), getX(), getY()); return Perspective.getClickbox(client, getModel(), getRsOrientation(), getLocalLocation());
} }
@Inject @Inject

View File

@@ -80,6 +80,6 @@ public abstract class RSGroundObjectMixin implements RSGroundObject
@Override @Override
public Area getClickbox() public Area getClickbox()
{ {
return Perspective.getClickbox(client, getModel(), 0, getX(), getY()); return Perspective.getClickbox(client, getModel(), 0, getLocalLocation());
} }
} }

View File

@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow; import net.runelite.api.mixins.Shadow;
@@ -250,9 +251,8 @@ public abstract class RSModelMixin implements RSModel
for (Vertex v : vertices) for (Vertex v : vertices)
{ {
// Compute canvas location of vertex // Compute canvas location of vertex
Point p = Perspective.worldToCanvas(client, Point p = Perspective.localToCanvas(client,
localX - v.getX(), new LocalPoint(localX - v.getX(), localY - v.getZ()),
localY - v.getZ(),
client.getPlane(), client.getPlane(),
-v.getY()); -v.getY());
if (p != null) if (p != null)

View File

@@ -37,6 +37,7 @@ import static net.runelite.api.HeadIcon.SMITE;
import net.runelite.api.Model; import net.runelite.api.Model;
import net.runelite.api.Perspective; import net.runelite.api.Perspective;
import net.runelite.api.Point; import net.runelite.api.Point;
import net.runelite.api.coords.LocalPoint;
import net.runelite.api.mixins.Copy; import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
@@ -129,21 +130,18 @@ public abstract class RSPlayerMixin implements RSPlayer
Vertex vy = triangle.getB(); Vertex vy = triangle.getB();
Vertex vz = triangle.getC(); Vertex vz = triangle.getC();
Point x = Perspective.worldToCanvas(client, Point x = Perspective.localToCanvas(client,
localX - vx.getX(), new LocalPoint(localX - vx.getX(), localY - vx.getZ()),
localY - vx.getZ(),
client.getPlane(), client.getPlane(),
-vx.getY()); -vx.getY());
Point y = Perspective.worldToCanvas(client, Point y = Perspective.localToCanvas(client,
localX - vy.getX(), new LocalPoint(localX - vy.getX(), localY - vy.getZ()),
localY - vy.getZ(),
client.getPlane(), client.getPlane(),
-vy.getY()); -vy.getY());
Point z = Perspective.worldToCanvas(client, Point z = Perspective.localToCanvas(client,
localX - vz.getX(), new LocalPoint(localX - vz.getX(), localY - vz.getZ()),
localY - vz.getZ(),
client.getPlane(), client.getPlane(),
-vz.getY()); -vz.getY());

View File

@@ -101,8 +101,8 @@ public abstract class RSWallObjectMixin implements RSWallObject
{ {
Area clickbox = new Area(); Area clickbox = new Area();
Area clickboxA = Perspective.getClickbox(client, getModelA(), getOrientationA(), getX(), getY()); Area clickboxA = Perspective.getClickbox(client, getModelA(), getOrientationA(), getLocalLocation());
Area clickboxB = Perspective.getClickbox(client, getModelB(), getOrientationB(), getX(), getY()); Area clickboxB = Perspective.getClickbox(client, getModelB(), getOrientationB(), getLocalLocation());
if (clickboxA == null && clickboxB == null) if (clickboxA == null && clickboxB == null)
{ {

View File

@@ -87,7 +87,7 @@ public abstract class TileObjectMixin implements TileObject
@Inject @Inject
public Point getCanvasLocation(int zOffset) public Point getCanvasLocation(int zOffset)
{ {
return Perspective.worldToCanvas(client, getX(), getY(), getPlane(), zOffset); return Perspective.localToCanvas(client, getLocalLocation(), getPlane(), zOffset);
} }
@Override @Override
@@ -108,6 +108,6 @@ public abstract class TileObjectMixin implements TileObject
@Inject @Inject
public Point getMinimapLocation() public Point getMinimapLocation()
{ {
return Perspective.worldToMiniMap(client, getX(), getY()); return Perspective.localToMinimap(client, getLocalLocation());
} }
} }