<commit_before>package net.runelite.mixins;

import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSModel;

/**
 * Class to check clickboxes of models. Mostly refactored code from the client.
 */
@Mixin(RSClient.class)
public abstract class ClickboxMixin implements RSClient
{
	@Shadow("clientInstance")
	private static RSClient client;

	private static final int MAX_ENTITES_AT_MOUSE = 1000;
	private static final int CLICKBOX_CLOSE = 50;
	private static final int CLICKBOX_FAR = 3500;

	@Inject
	private static final int[] rl$modelViewportXs = new int[4700];

	@Inject
	private static final int[] rl$modelViewportYs = new int[4700];

	@Inject
	public void checkClickbox(Model rlModel, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int _x, int _y, int _z, long hash)
	{
		RSModel model = (RSModel) rlModel;
		boolean hasFlag = hash != 0L && (int) (hash >>> 16 & 1L) != 1;
		boolean viewportContainsMouse = client.getViewportContainsMouse();

		if (!hasFlag || !viewportContainsMouse || client.getOculusOrbState() != 0)
		{
			return;
		}

		boolean bb = boundingboxCheck(model, _x, _y, _z);
		if (!bb)
		{
			return;
		}

		// only need a boundingbox check?
		if (model.isClickable())
		{
			addHashAtMouse(hash);
			return;
		}

		// otherwise we must check if the mouse is in a triangle
		final int vertexCount = model.getVerticesCount();
		final int triangleCount = model.getTrianglesCount();

		final int[] vertexX = model.getVerticesX();
		final int[] vertexY = model.getVerticesY();
		final int[] vertexZ = model.getVerticesZ();<commit_msg>gpu: limit interaction distance from camera<commit_after>package net.runelite.mixins;

import net.runelite.api.Model;
import net.runelite.api.Perspective;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSModel;

/**
 * Class to check clickboxes of models. Mostly refactored code from the client.
 */
@Mixin(RSClient.class)
public abstract class ClickboxMixin implements RSClient
{
	@Shadow("clientInstance")
	private static RSClient client;

	private static final int MAX_ENTITES_AT_MOUSE = 1000;
	private static final int CLICKBOX_CLOSE = 50;
	private static final int CLICKBOX_FAR = 3500;
	private static final int OBJECT_INTERACTION_FAR = 35; // Max distance, in tiles, from camera

	@Inject
	private static final int[] rl$modelViewportXs = new int[4700];

	@Inject
	private static final int[] rl$modelViewportYs = new int[4700];

	@Inject
	public void checkClickbox(Model rlModel, int orientation, int pitchSin, int pitchCos, int yawSin, int yawCos, int _x, int _y, int _z, long hash)
	{
		RSModel model = (RSModel) rlModel;
		boolean hasFlag = hash != 0L && (int) (hash >>> 16 & 1L) != 1;
		boolean viewportContainsMouse = client.getViewportContainsMouse();

		if (!hasFlag || !viewportContainsMouse || client.getOculusOrbState() != 0)
		{
			return;
		}

		boolean bb = boundingboxCheck(model, _x, _y, _z);
		if (!bb)
		{
			return;
		}

		if (Math.sqrt(_x * _x + _z * _z) > OBJECT_INTERACTION_FAR * Perspective.LOCAL_TILE_SIZE)
		{
			return;
		}

		// only need a boundingbox check?
		if (model.isClickable())
		{
			addHashAtMouse(hash);
			return;
		}

		// otherwise we must check if the mouse is in a triangle
		final int vertexCount = model.getVerticesCount();
		final int triangleCount = model.getTrianglesCount();

		final int[] vertexX = model.getVerticesX();
		final int[] vertexY = model.getVerticesY();
		final int[] vertexZ = model.getVerticesZ();
{'fraction_non_alphanumeric': 0.10863213811420983, 'fraction_numerical': 0.013280212483399735, 'mean_word_length': 4.395415472779369, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3436894', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1279, 'n_words': 360}