rl-api: use TileObjects' z for hulls/clickboxes/outlines

This commit is contained in:
Max Weber
2022-03-07 12:35:18 -07:00
parent 4f8991dc7e
commit 52c2061ccd
4 changed files with 24 additions and 38 deletions

View File

@@ -60,11 +60,9 @@ public interface GraphicsObject extends Renderable
int getLevel();
/**
* Gets the height of the graphic.
*
* @return the height
* Gets the z coordinate
*/
int getHeight();
int getZ();
/**
* Checks if this spotanim is done animating

View File

@@ -42,6 +42,7 @@ import net.runelite.api.geometry.SimplePolygon;
import net.runelite.api.model.Jarvis;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import org.jetbrains.annotations.ApiStatus;
/**
* A utility class containing methods to help with conversion between
@@ -677,21 +678,19 @@ 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 point the coordinate of the tile
* @param x x coord in local space
* @param z y coord in local space
* @return the clickable area of the model
*/
@Nullable
public static Shape getClickbox(@Nonnull Client client, Model model, int orientation, LocalPoint point)
@ApiStatus.Internal
public static Shape getClickbox(@Nonnull Client client, Model model, int orientation, int x, int y, int z)
{
if (model == null)
{
return null;
}
int x = point.getX();
int y = point.getY();
int z = getTileHeight(client, point, client.getPlane());
SimplePolygon bounds = calculateAABB(client, model, orientation, x, y, z);
if (bounds == null)

View File

@@ -53,6 +53,11 @@ public interface TileObject
*/
int getY();
/**
* Gets the vertical coordinate of this object
*/
int getZ();
/**
* Gets the plane of the tile that the object is on.
*/

View File

@@ -1016,15 +1016,13 @@ public class ModelOutlineRenderer
private void drawOutline(GameObject gameObject, int outlineWidth, Color color, int feather)
{
LocalPoint lp = gameObject.getLocalLocation();
Renderable renderable = gameObject.getRenderable();
if (renderable != null)
{
Model model = renderable instanceof Model ? (Model) renderable : renderable.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, gameObject.getPlane()),
drawModelOutline(model, gameObject.getX(), gameObject.getY(), gameObject.getZ(),
gameObject.getModelOrientation(), outlineWidth, color, feather);
}
}
@@ -1032,15 +1030,13 @@ public class ModelOutlineRenderer
private void drawOutline(GroundObject groundObject, int outlineWidth, Color color, int feather)
{
LocalPoint lp = groundObject.getLocalLocation();
Renderable renderable = groundObject.getRenderable();
if (renderable != null)
{
Model model = renderable instanceof Model ? (Model) renderable : renderable.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, client.getPlane()),
drawModelOutline(model, groundObject.getX(), groundObject.getY(), groundObject.getZ(),
0, outlineWidth, color, feather);
}
}
@@ -1048,16 +1044,13 @@ public class ModelOutlineRenderer
private void drawOutline(ItemLayer itemLayer, int outlineWidth, Color color, int feather)
{
LocalPoint lp = itemLayer.getLocalLocation();
Renderable bottomRenderable = itemLayer.getBottom();
if (bottomRenderable != null)
{
Model model = bottomRenderable instanceof Model ? (Model) bottomRenderable : bottomRenderable.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, itemLayer.getPlane()) - itemLayer.getHeight(),
drawModelOutline(model, itemLayer.getX(), itemLayer.getY(), itemLayer.getZ() - itemLayer.getHeight(),
0, outlineWidth, color, feather);
}
}
@@ -1068,8 +1061,7 @@ public class ModelOutlineRenderer
Model model = middleRenderable instanceof Model ? (Model) middleRenderable : middleRenderable.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, itemLayer.getPlane()) - itemLayer.getHeight(),
drawModelOutline(model, itemLayer.getX(), itemLayer.getY(), itemLayer.getZ() - itemLayer.getHeight(),
0, outlineWidth, color, feather);
}
}
@@ -1080,8 +1072,7 @@ public class ModelOutlineRenderer
Model model = topRenderable instanceof Model ? (Model) topRenderable : topRenderable.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, itemLayer.getPlane()) - itemLayer.getHeight(),
drawModelOutline(model, itemLayer.getX(), itemLayer.getY(), itemLayer.getZ() - itemLayer.getHeight(),
0, outlineWidth, color, feather);
}
}
@@ -1089,8 +1080,6 @@ public class ModelOutlineRenderer
private void drawOutline(DecorativeObject decorativeObject, int outlineWidth, Color color, int feather)
{
LocalPoint lp = decorativeObject.getLocalLocation();
Renderable renderable1 = decorativeObject.getRenderable();
if (renderable1 != null)
{
@@ -1098,9 +1087,9 @@ public class ModelOutlineRenderer
if (model != null)
{
drawModelOutline(model,
lp.getX() + decorativeObject.getXOffset(),
lp.getY() + decorativeObject.getYOffset(),
Perspective.getTileHeight(client, lp, decorativeObject.getPlane()),
decorativeObject.getX() + decorativeObject.getXOffset(),
decorativeObject.getY() + decorativeObject.getYOffset(),
decorativeObject.getZ(),
0, outlineWidth, color, feather);
}
}
@@ -1112,8 +1101,7 @@ public class ModelOutlineRenderer
if (model != null)
{
// Offset is not used for the second model
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, decorativeObject.getPlane()),
drawModelOutline(model, decorativeObject.getX(), decorativeObject.getY(), decorativeObject.getZ(),
0, outlineWidth, color, feather);
}
}
@@ -1121,16 +1109,13 @@ public class ModelOutlineRenderer
private void drawOutline(WallObject wallObject, int outlineWidth, Color color, int feather)
{
LocalPoint lp = wallObject.getLocalLocation();
Renderable renderable1 = wallObject.getRenderable1();
if (renderable1 != null)
{
Model model = renderable1 instanceof Model ? (Model) renderable1 : renderable1.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, wallObject.getPlane()),
drawModelOutline(model, wallObject.getX(), wallObject.getY(), wallObject.getZ(),
0, outlineWidth, color, feather);
}
}
@@ -1141,8 +1126,7 @@ public class ModelOutlineRenderer
Model model = renderable2 instanceof Model ? (Model) renderable2 : renderable2.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(),
Perspective.getTileHeight(client, lp, wallObject.getPlane()),
drawModelOutline(model, wallObject.getX(), wallObject.getY(), wallObject.getZ(),
0, outlineWidth, color, feather);
}
}
@@ -1180,7 +1164,7 @@ public class ModelOutlineRenderer
Model model = graphicsObject.getModel();
if (model != null)
{
drawModelOutline(model, lp.getX(), lp.getY(), graphicsObject.getHeight(),
drawModelOutline(model, lp.getX(), lp.getY(), graphicsObject.getZ(),
0, outlineWidth, color, feather);
}
}