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:
@@ -181,24 +181,22 @@ public interface Actor extends Renderable
|
||||
* Gets the point at which an image should be drawn, relative to the
|
||||
* current location with the given z-axis offset.
|
||||
*
|
||||
* @param graphics engine graphics
|
||||
* @param image the image to draw
|
||||
* @param zOffset the z-axis offset
|
||||
* @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
|
||||
* current location with the given z-axis offset.
|
||||
*
|
||||
* @param graphics engine graphics
|
||||
* @param sprite the sprite to draw
|
||||
* @param zOffset the z-axis offset
|
||||
* @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
|
||||
|
||||
@@ -75,15 +75,14 @@ public class Perspective
|
||||
* their corresponding coordinates on the game screen.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param x ground coordinate on the x axis
|
||||
* @param y ground coordinate on the y axis
|
||||
* @param point ground coordinate
|
||||
* @param plane ground plane on the z axis
|
||||
* @return a {@link Point} on screen corresponding to the position in
|
||||
* 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.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param x ground coordinate on the x axis
|
||||
* @param y ground coordinate on the y axis
|
||||
* @param point ground coordinate
|
||||
* @param plane ground plane on the z axis
|
||||
* @param zOffset distance from ground on the z axis
|
||||
* @return a {@link Point} on screen corresponding to the position in
|
||||
* 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);
|
||||
return localToCanvas(client, x, y, tileHeight - zOffset);
|
||||
final int tileHeight = getTileHeight(client, point, plane);
|
||||
return localToCanvas(client, point.getX(), point.getY(), tileHeight - zOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,15 +152,14 @@ public class Perspective
|
||||
* their corresponding coordinates on the Minimap.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param x ground coordinate on the x axis
|
||||
* @param y ground coordinate on the y axis
|
||||
* @param point ground coordinate
|
||||
* @return a {@link Point} on screen corresponding to the position in
|
||||
* 3D-space
|
||||
*/
|
||||
@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.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param x ground coordinate on the x axis
|
||||
* @param y ground coordinate on the y axis
|
||||
* @param point ground coordinate
|
||||
* @param distance max distance from local player to minimap point
|
||||
* @return a {@link Point} on screen corresponding to the position in
|
||||
* 3D-space
|
||||
*/
|
||||
@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();
|
||||
x = x / 32 - localLocation.getX() / 32;
|
||||
y = y / 32 - localLocation.getY() / 32;
|
||||
int x = point.getX() / 32 - localLocation.getX() / 32;
|
||||
int y = point.getY() / 32 - localLocation.getY() / 32;
|
||||
|
||||
int dist = x * x + y * y;
|
||||
if (dist < distance)
|
||||
@@ -229,15 +225,14 @@ public class Perspective
|
||||
* Calculates the above ground height of a tile point.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param localX the ground coordinate on the x axis
|
||||
* @param localY the ground coordinate on the y axis
|
||||
* @param point the local ground coordinate
|
||||
* @param plane the client plane/ground level
|
||||
* @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 sceneY = localY >> LOCAL_COORD_BITS;
|
||||
int sceneX = point.getSceneX();
|
||||
int sceneY = point.getSceneY();
|
||||
if (sceneX >= 0 && sceneY >= 0 && sceneX < SCENE_SIZE && sceneY < SCENE_SIZE)
|
||||
{
|
||||
byte[][][] tileSettings = client.getTileSettings();
|
||||
@@ -249,8 +244,8 @@ public class Perspective
|
||||
z1 = plane + 1;
|
||||
}
|
||||
|
||||
int x = localX & (LOCAL_TILE_SIZE - 1);
|
||||
int y = localY & (LOCAL_TILE_SIZE - 1);
|
||||
int x = point.getX() & (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 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;
|
||||
@@ -388,7 +383,7 @@ public class Perspective
|
||||
|
||||
int plane = client.getPlane();
|
||||
|
||||
Point p = worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset);
|
||||
Point p = localToCanvas(client, localLocation, plane, zOffset);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
@@ -406,7 +401,6 @@ public class Perspective
|
||||
* Calculates image position and centers depending on image size.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param graphics the game graphics
|
||||
* @param localLocation local location of the tile
|
||||
* @param image image for size measurement
|
||||
* @param zOffset offset from ground plane
|
||||
@@ -415,14 +409,13 @@ public class Perspective
|
||||
*/
|
||||
public static Point getCanvasImageLocation(
|
||||
@Nonnull Client client,
|
||||
@Nonnull Graphics2D graphics,
|
||||
@Nonnull LocalPoint localLocation,
|
||||
@Nonnull BufferedImage image,
|
||||
int zOffset)
|
||||
{
|
||||
int plane = client.getPlane();
|
||||
|
||||
Point p = worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset);
|
||||
Point p = localToCanvas(client, localLocation, plane, zOffset);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
@@ -449,7 +442,7 @@ public class Perspective
|
||||
@Nonnull LocalPoint localLocation,
|
||||
@Nonnull BufferedImage image)
|
||||
{
|
||||
Point p = Perspective.worldToMiniMap(client, localLocation.getX(), localLocation.getY());
|
||||
Point p = Perspective.localToMinimap(client, localLocation);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
@@ -466,7 +459,6 @@ public class Perspective
|
||||
* Calculates sprite position and centers depending on sprite size.
|
||||
*
|
||||
* @param client the game client
|
||||
* @param graphics the game graphics
|
||||
* @param localLocation local location of the tile
|
||||
* @param sprite SpritePixel for size measurement
|
||||
* @param zOffset offset from ground plane
|
||||
@@ -474,14 +466,13 @@ public class Perspective
|
||||
*/
|
||||
public static Point getCanvasSpriteLocation(
|
||||
@Nonnull Client client,
|
||||
@Nonnull Graphics2D graphics,
|
||||
@Nonnull LocalPoint localLocation,
|
||||
@Nonnull SpritePixels sprite,
|
||||
int zOffset)
|
||||
{
|
||||
int plane = client.getPlane();
|
||||
|
||||
Point p = worldToCanvas(client, localLocation.getX(), localLocation.getY(), plane, zOffset);
|
||||
Point p = localToCanvas(client, localLocation, plane, zOffset);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
@@ -504,11 +495,10 @@ public class Perspective
|
||||
* @param client the game client
|
||||
* @param model the model to calculate a clickbox for
|
||||
* @param orientation the orientation of the model (0-2048, where 0 is north)
|
||||
* @param localX the x-axis coordinate of the tile
|
||||
* @param localY the y-axis coordinate of the tile
|
||||
* @param point the coordinate of the tile
|
||||
* @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)
|
||||
{
|
||||
@@ -523,8 +513,8 @@ public class Perspective
|
||||
.map(v -> v.rotate(orientation))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Area clickBox = get2DGeometry(client, triangles, orientation, localX, localY);
|
||||
Area visibleAABB = getAABB(client, vertices, orientation, localX, localY);
|
||||
Area clickBox = get2DGeometry(client, triangles, point);
|
||||
Area visibleAABB = getAABB(client, vertices, point);
|
||||
|
||||
if (visibleAABB == null || clickBox == null)
|
||||
{
|
||||
@@ -551,22 +541,20 @@ public class Perspective
|
||||
private static Area get2DGeometry(
|
||||
@Nonnull Client client,
|
||||
@Nonnull List<Triangle> triangles,
|
||||
int orientation,
|
||||
int localX,
|
||||
int localY
|
||||
@Nonnull LocalPoint point
|
||||
)
|
||||
{
|
||||
int radius = 5;
|
||||
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)
|
||||
{
|
||||
Vertex _a = triangle.getA();
|
||||
Point a = localToCanvas(client,
|
||||
localX - _a.getX(),
|
||||
localY - _a.getZ(),
|
||||
point.getX() - _a.getX(),
|
||||
point.getY() - _a.getZ(),
|
||||
tileHeight + _a.getY());
|
||||
if (a == null)
|
||||
{
|
||||
@@ -575,8 +563,8 @@ public class Perspective
|
||||
|
||||
Vertex _b = triangle.getB();
|
||||
Point b = localToCanvas(client,
|
||||
localX - _b.getX(),
|
||||
localY - _b.getZ(),
|
||||
point.getX() - _b.getX(),
|
||||
point.getY() - _b.getZ(),
|
||||
tileHeight + _b.getY());
|
||||
if (b == null)
|
||||
{
|
||||
@@ -585,8 +573,8 @@ public class Perspective
|
||||
|
||||
Vertex _c = triangle.getC();
|
||||
Point c = localToCanvas(client,
|
||||
localX - _c.getX(),
|
||||
localY - _c.getZ(),
|
||||
point.getX() - _c.getX(),
|
||||
point.getY() - _c.getZ(),
|
||||
tileHeight + _c.getY());
|
||||
if (c == null)
|
||||
{
|
||||
@@ -633,9 +621,7 @@ public class Perspective
|
||||
private static Area getAABB(
|
||||
@Nonnull Client client,
|
||||
@Nonnull List<Vertex> vertices,
|
||||
int orientation,
|
||||
int localX,
|
||||
int localY
|
||||
@Nonnull LocalPoint point
|
||||
)
|
||||
{
|
||||
int maxX = 0;
|
||||
@@ -697,15 +683,15 @@ public class Perspective
|
||||
extremeZ = 32;
|
||||
}
|
||||
|
||||
int x1 = localX - (centerX - extremeX);
|
||||
int x1 = point.getX() - (centerX - extremeX);
|
||||
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 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 p2 = localToCanvas(client, x1, z2, tileHeight + y1);
|
||||
@@ -770,7 +756,7 @@ public class Perspective
|
||||
@Nonnull LocalPoint localLocation,
|
||||
@Nonnull String text)
|
||||
{
|
||||
Point p = Perspective.worldToMiniMap(client, localLocation.getX(), localLocation.getY());
|
||||
Point p = Perspective.localToMinimap(client, localLocation);
|
||||
|
||||
if (p == null)
|
||||
{
|
||||
|
||||
@@ -130,7 +130,7 @@ public class BlastMineRockOverlay extends Overlay
|
||||
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)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ public class BlastMineRockOverlay extends Overlay
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -104,7 +104,7 @@ public class CannonSpotOverlay extends Overlay
|
||||
}
|
||||
|
||||
//Render icon
|
||||
Point imageLoc = Perspective.getCanvasImageLocation(client, graphics, point, image, 0);
|
||||
Point imageLoc = Perspective.getCanvasImageLocation(client, point, image, 0);
|
||||
|
||||
if (imageLoc != null)
|
||||
{
|
||||
|
||||
@@ -90,7 +90,7 @@ public class DemonicGorillaOverlay extends Overlay
|
||||
LocalPoint lp = gorilla.getNpc().getLocalLocation();
|
||||
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);
|
||||
if (point != null)
|
||||
{
|
||||
|
||||
@@ -135,9 +135,8 @@ public class SceneOverlay extends Overlay
|
||||
boolean first = true;
|
||||
for (int y = lp1.getY(); y <= lp2.getY(); y += LOCAL_TILE_SIZE)
|
||||
{
|
||||
Point p = Perspective.worldToCanvas(client,
|
||||
lp1.getX() - LOCAL_TILE_SIZE / 2,
|
||||
y - LOCAL_TILE_SIZE / 2,
|
||||
Point p = Perspective.localToCanvas(client,
|
||||
new LocalPoint(lp1.getX() - LOCAL_TILE_SIZE / 2, y - LOCAL_TILE_SIZE / 2),
|
||||
client.getPlane());
|
||||
if (p != null)
|
||||
{
|
||||
@@ -161,9 +160,8 @@ public class SceneOverlay extends Overlay
|
||||
boolean first = true;
|
||||
for (int x = lp1.getX(); x <= lp2.getX(); x += LOCAL_TILE_SIZE)
|
||||
{
|
||||
Point p = Perspective.worldToCanvas(client,
|
||||
x - LOCAL_TILE_SIZE / 2,
|
||||
lp1.getY() - LOCAL_TILE_SIZE / 2,
|
||||
Point p = Perspective.localToCanvas(client,
|
||||
new LocalPoint(x - LOCAL_TILE_SIZE / 2, lp1.getY() - LOCAL_TILE_SIZE / 2),
|
||||
client.getPlane());
|
||||
if (p != null)
|
||||
{
|
||||
@@ -202,9 +200,8 @@ public class SceneOverlay extends Overlay
|
||||
boolean first = true;
|
||||
for (int y = lp1.getY(); y <= lp2.getY(); y += LOCAL_TILE_SIZE)
|
||||
{
|
||||
Point p = Perspective.worldToCanvas(client,
|
||||
lp1.getX() - LOCAL_TILE_SIZE / 2,
|
||||
y - LOCAL_TILE_SIZE / 2,
|
||||
Point p = Perspective.localToCanvas(client,
|
||||
new LocalPoint(lp1.getX() - LOCAL_TILE_SIZE / 2, y - LOCAL_TILE_SIZE / 2),
|
||||
client.getPlane());
|
||||
if (p != null)
|
||||
{
|
||||
@@ -228,9 +225,8 @@ public class SceneOverlay extends Overlay
|
||||
boolean first = true;
|
||||
for (int x = lp1.getX(); x <= lp2.getX(); x += LOCAL_TILE_SIZE)
|
||||
{
|
||||
Point p = Perspective.worldToCanvas(client,
|
||||
x - LOCAL_TILE_SIZE / 2,
|
||||
lp1.getY() - LOCAL_TILE_SIZE / 2,
|
||||
Point p = Perspective.localToCanvas(client,
|
||||
new LocalPoint(x - LOCAL_TILE_SIZE / 2, lp1.getY() - LOCAL_TILE_SIZE / 2),
|
||||
client.getPlane());
|
||||
if (p != null)
|
||||
{
|
||||
@@ -376,7 +372,7 @@ public class SceneOverlay extends Overlay
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return;
|
||||
@@ -385,7 +381,7 @@ public class SceneOverlay extends Overlay
|
||||
int fsy = fs.getY() - INTERACTING_SHIFT;
|
||||
|
||||
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)
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -113,7 +113,7 @@ class FishingSpotOverlay extends Overlay
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -141,7 +141,7 @@ class FishingSpotOverlay extends Overlay
|
||||
BufferedImage fishImage = itemManager.getImage(spot.getFishSpriteId());;
|
||||
if (fishImage != null)
|
||||
{
|
||||
Point imageLocation = npc.getCanvasImageLocation(graphics, fishImage, npc.getLogicalHeight());
|
||||
Point imageLocation = npc.getCanvasImageLocation(fishImage, npc.getLogicalHeight());
|
||||
if (imageLocation != null)
|
||||
{
|
||||
OverlayUtil.renderImageLocation(graphics, imageLocation, fishImage);
|
||||
|
||||
@@ -141,7 +141,7 @@ public class TrapOverlay extends Overlay
|
||||
{
|
||||
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();
|
||||
|
||||
@@ -172,7 +172,7 @@ public class TrapOverlay extends Overlay
|
||||
{
|
||||
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();
|
||||
pie.setFill(fill);
|
||||
|
||||
@@ -106,7 +106,7 @@ class KourendLibraryOverlay extends Overlay
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -219,7 +219,7 @@ class KourendLibraryOverlay extends Overlay
|
||||
LocalPoint local = n.getLocalLocation();
|
||||
Polygon poly = getCanvasTilePoly(client, local);
|
||||
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)
|
||||
{
|
||||
g.drawImage(b.getIcon(), screen.getX() - (b.getIcon().getWidth() / 2), screen.getY() - b.getIcon().getHeight(), null);
|
||||
|
||||
@@ -438,6 +438,6 @@ public class MotherlodePlugin extends Plugin
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class MotherlodeRocksOverlay extends Overlay
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -384,7 +384,7 @@ public class AlchemyRoom extends MTARoom
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -131,7 +131,7 @@ public class NpcSceneOverlay extends Overlay
|
||||
final int textHeight = graphics.getFontMetrics().getAscent();
|
||||
|
||||
final Point canvasPoint = Perspective
|
||||
.worldToCanvas(client, centerLp.getX(), centerLp.getY(), respawnLocation.getPlane());
|
||||
.localToCanvas(client, centerLp, respawnLocation.getPlane());
|
||||
|
||||
if (canvasPoint != null)
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@ class PrayerBarOverlay extends Overlay
|
||||
|
||||
final int height = client.getLocalPlayer().getLogicalHeight() + 10;
|
||||
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
|
||||
final int barX = canvasPoint.getX() + client.getViewportXOffset() - 15;
|
||||
|
||||
@@ -101,7 +101,7 @@ public class TitheFarmPlantOverlay extends Overlay
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ public class OverlayUtil
|
||||
|
||||
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)
|
||||
{
|
||||
renderImageLocation(graphics, imageLocation, image);
|
||||
@@ -123,7 +123,7 @@ public class OverlayUtil
|
||||
renderPolygon(graphics, poly, color);
|
||||
}
|
||||
|
||||
Point imageLocation = actor.getCanvasImageLocation(graphics, image, zOffset);
|
||||
Point imageLocation = actor.getCanvasImageLocation(image, zOffset);
|
||||
if (imageLocation != null)
|
||||
{
|
||||
renderImageLocation(graphics, imageLocation, image);
|
||||
|
||||
@@ -163,23 +163,23 @@ public abstract class RSActorMixin implements RSActor
|
||||
|
||||
@Inject
|
||||
@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
|
||||
@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
|
||||
@Override
|
||||
public Point getMinimapLocation()
|
||||
{
|
||||
return Perspective.worldToMiniMap(client, getX(), getY());
|
||||
return Perspective.localToMinimap(client, getLocalLocation());
|
||||
}
|
||||
|
||||
@FieldHook("animation")
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class RSDecorativeObjectMixin implements RSDecorativeObject
|
||||
@Override
|
||||
public Area getClickbox()
|
||||
{
|
||||
return Perspective.getClickbox(client, getModel(), getOrientation(), getX(), getY());
|
||||
return Perspective.getClickbox(client, getModel(), getOrientation(), getLocalLocation());
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class RSGameObjectMixin implements RSGameObject
|
||||
@Override
|
||||
public Area getClickbox()
|
||||
{
|
||||
return Perspective.getClickbox(client, getModel(), getRsOrientation(), getX(), getY());
|
||||
return Perspective.getClickbox(client, getModel(), getRsOrientation(), getLocalLocation());
|
||||
}
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -80,6 +80,6 @@ public abstract class RSGroundObjectMixin implements RSGroundObject
|
||||
@Override
|
||||
public Area getClickbox()
|
||||
{
|
||||
return Perspective.getClickbox(client, getModel(), 0, getX(), getY());
|
||||
return Perspective.getClickbox(client, getModel(), 0, getLocalLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
@@ -250,9 +251,8 @@ public abstract class RSModelMixin implements RSModel
|
||||
for (Vertex v : vertices)
|
||||
{
|
||||
// Compute canvas location of vertex
|
||||
Point p = Perspective.worldToCanvas(client,
|
||||
localX - v.getX(),
|
||||
localY - v.getZ(),
|
||||
Point p = Perspective.localToCanvas(client,
|
||||
new LocalPoint(localX - v.getX(), localY - v.getZ()),
|
||||
client.getPlane(),
|
||||
-v.getY());
|
||||
if (p != null)
|
||||
|
||||
@@ -37,6 +37,7 @@ import static net.runelite.api.HeadIcon.SMITE;
|
||||
import net.runelite.api.Model;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
@@ -129,21 +130,18 @@ public abstract class RSPlayerMixin implements RSPlayer
|
||||
Vertex vy = triangle.getB();
|
||||
Vertex vz = triangle.getC();
|
||||
|
||||
Point x = Perspective.worldToCanvas(client,
|
||||
localX - vx.getX(),
|
||||
localY - vx.getZ(),
|
||||
Point x = Perspective.localToCanvas(client,
|
||||
new LocalPoint(localX - vx.getX(), localY - vx.getZ()),
|
||||
client.getPlane(),
|
||||
-vx.getY());
|
||||
|
||||
Point y = Perspective.worldToCanvas(client,
|
||||
localX - vy.getX(),
|
||||
localY - vy.getZ(),
|
||||
Point y = Perspective.localToCanvas(client,
|
||||
new LocalPoint(localX - vy.getX(), localY - vy.getZ()),
|
||||
client.getPlane(),
|
||||
-vy.getY());
|
||||
|
||||
Point z = Perspective.worldToCanvas(client,
|
||||
localX - vz.getX(),
|
||||
localY - vz.getZ(),
|
||||
Point z = Perspective.localToCanvas(client,
|
||||
new LocalPoint(localX - vz.getX(), localY - vz.getZ()),
|
||||
client.getPlane(),
|
||||
-vz.getY());
|
||||
|
||||
|
||||
@@ -101,8 +101,8 @@ public abstract class RSWallObjectMixin implements RSWallObject
|
||||
{
|
||||
Area clickbox = new Area();
|
||||
|
||||
Area clickboxA = Perspective.getClickbox(client, getModelA(), getOrientationA(), getX(), getY());
|
||||
Area clickboxB = Perspective.getClickbox(client, getModelB(), getOrientationB(), getX(), getY());
|
||||
Area clickboxA = Perspective.getClickbox(client, getModelA(), getOrientationA(), getLocalLocation());
|
||||
Area clickboxB = Perspective.getClickbox(client, getModelB(), getOrientationB(), getLocalLocation());
|
||||
|
||||
if (clickboxA == null && clickboxB == null)
|
||||
{
|
||||
|
||||
@@ -87,7 +87,7 @@ public abstract class TileObjectMixin implements TileObject
|
||||
@Inject
|
||||
public Point getCanvasLocation(int zOffset)
|
||||
{
|
||||
return Perspective.worldToCanvas(client, getX(), getY(), getPlane(), zOffset);
|
||||
return Perspective.localToCanvas(client, getLocalLocation(), getPlane(), zOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,6 +108,6 @@ public abstract class TileObjectMixin implements TileObject
|
||||
@Inject
|
||||
public Point getMinimapLocation()
|
||||
{
|
||||
return Perspective.worldToMiniMap(client, getX(), getY());
|
||||
return Perspective.localToMinimap(client, getLocalLocation());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user