project: Mixins for recent changes
This commit is contained in:
@@ -35,6 +35,7 @@ import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Perspective;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import javax.swing.PopupFactory;
|
||||
|
||||
/**
|
||||
* Dummy popup factory for Java 8
|
||||
*/
|
||||
class MacOSPopupFactory extends PopupFactory
|
||||
{
|
||||
}
|
||||
@@ -51,6 +51,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.LookAndFeel;
|
||||
import javax.swing.PopupFactory;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.UIManager;
|
||||
@@ -112,6 +113,14 @@ public class SwingUtil
|
||||
try
|
||||
{
|
||||
UIManager.setLookAndFeel(laf);
|
||||
|
||||
if (OSType.getOSType() == OSType.MacOS)
|
||||
{
|
||||
// On MacOS Substance doesn't install its own popup factory, and the default one uses lightweight
|
||||
// components unless the Aqua LAF is used. Lightweight components do not render correctly over AWT
|
||||
// canvases on MacOS - so replace the popup factory one with that forces heavy components.
|
||||
PopupFactory.setSharedInstance(new MacOSPopupFactory());
|
||||
}
|
||||
}
|
||||
catch (UnsupportedLookAndFeelException ex)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import java.awt.Component;
|
||||
import javax.swing.Popup;
|
||||
import javax.swing.PopupFactory;
|
||||
|
||||
/**
|
||||
* Popup factory for Java 11 which forces heavyweight popups. Lightweight popups do not render correctly
|
||||
* over AWT canvases on OSX.
|
||||
*/
|
||||
class MacOSPopupFactory extends PopupFactory
|
||||
{
|
||||
@Override
|
||||
protected Popup getPopup(Component owner, Component contents, int x, int y, boolean isHeavyWeightPopup) throws IllegalArgumentException
|
||||
{
|
||||
return super.getPopup(owner, contents, x, y, true);
|
||||
}
|
||||
}
|
||||
@@ -41,10 +41,7 @@ public abstract class RSModelDataMixin implements RSModelData
|
||||
private static RSClient client;
|
||||
|
||||
@Inject
|
||||
private float[][] faceTextureUCoordinates;
|
||||
|
||||
@Inject
|
||||
private float[][] faceTextureVCoordinates;
|
||||
private float[] faceTextureUVCoordinates;
|
||||
|
||||
@Copy("toModel")
|
||||
@Replace("toModel")
|
||||
@@ -59,14 +56,13 @@ public abstract class RSModelDataMixin implements RSModelData
|
||||
return null;
|
||||
}
|
||||
|
||||
if (faceTextureUCoordinates == null)
|
||||
if (faceTextureUVCoordinates == null)
|
||||
{
|
||||
computeTextureUVCoordinates();
|
||||
}
|
||||
|
||||
RSModel rsModel = (RSModel) model;
|
||||
rsModel.setFaceTextureUCoordinates(faceTextureUCoordinates);
|
||||
rsModel.setFaceTextureVCoordinates(faceTextureVCoordinates);
|
||||
rsModel.setFaceTextureUVCoordinates(faceTextureUVCoordinates);
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -94,40 +90,35 @@ public abstract class RSModelDataMixin implements RSModelData
|
||||
final byte[] textureCoords = getTextureCoords();
|
||||
|
||||
int faceCount = getTriangleFaceCount();
|
||||
this.faceTextureUCoordinates = new float[faceCount][];
|
||||
this.faceTextureVCoordinates = new float[faceCount][];
|
||||
float[] faceTextureUCoordinates = new float[faceCount * 6];
|
||||
|
||||
for (int i = 0; i < faceCount; i++)
|
||||
{
|
||||
int trianglePointX = trianglePointsX[i];
|
||||
int trianglePointY = trianglePointsY[i];
|
||||
int trianglePointZ = trianglePointsZ[i];
|
||||
int textureCoordinate = textureCoords != null && textureCoords[i] != -1 ? textureCoords[i] & 255 : -1;
|
||||
|
||||
short textureIdx;
|
||||
textureIdx = faceTextures[i];
|
||||
short textureIdx = faceTextures[i];
|
||||
|
||||
if (textureIdx != -1)
|
||||
{
|
||||
float[] u = new float[3];
|
||||
float[] v = new float[3];
|
||||
|
||||
int triangleVertexIdx1;
|
||||
int triangleVertexIdx2;
|
||||
int triangleVertexIdx3;
|
||||
|
||||
if (textureCoordinate == -1)
|
||||
if (textureCoords != null && textureCoords[i] != -1)
|
||||
{
|
||||
int textureCoordinate = textureCoords[i] & 255;
|
||||
triangleVertexIdx1 = texTriangleX[textureCoordinate];
|
||||
triangleVertexIdx2 = texTriangleY[textureCoordinate];
|
||||
triangleVertexIdx3 = texTriangleZ[textureCoordinate];
|
||||
}
|
||||
else
|
||||
{
|
||||
triangleVertexIdx1 = trianglePointX;
|
||||
triangleVertexIdx2 = trianglePointY;
|
||||
triangleVertexIdx3 = trianglePointZ;
|
||||
}
|
||||
else
|
||||
{
|
||||
triangleVertexIdx1 = texTriangleX[textureCoordinate];
|
||||
triangleVertexIdx2 = texTriangleY[textureCoordinate];
|
||||
triangleVertexIdx3 = texTriangleZ[textureCoordinate];
|
||||
}
|
||||
|
||||
float triangleX = (float) vertexPositionsX[triangleVertexIdx1];
|
||||
float triangleY = (float) vertexPositionsY[triangleVertexIdx1];
|
||||
@@ -157,22 +148,29 @@ public abstract class RSModelDataMixin implements RSModelData
|
||||
float f_902_ = f_885_ * f_898_ - f_886_ * f_897_;
|
||||
float f_903_ = 1.0F / (f_900_ * f_882_ + f_901_ * f_883_ + f_902_ * f_884_);
|
||||
|
||||
u[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
|
||||
u[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
|
||||
u[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
|
||||
float u0 = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
|
||||
float u1 = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
|
||||
float u2 = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
|
||||
|
||||
f_900_ = f_883_ * f_899_ - f_884_ * f_898_;
|
||||
f_901_ = f_884_ * f_897_ - f_882_ * f_899_;
|
||||
f_902_ = f_882_ * f_898_ - f_883_ * f_897_;
|
||||
f_903_ = 1.0F / (f_900_ * f_885_ + f_901_ * f_886_ + f_902_ * f_887_);
|
||||
|
||||
v[0] = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
|
||||
v[1] = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
|
||||
v[2] = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
|
||||
float v0 = (f_900_ * f_888_ + f_901_ * f_889_ + f_902_ * f_890_) * f_903_;
|
||||
float v1 = (f_900_ * f_891_ + f_901_ * f_892_ + f_902_ * f_893_) * f_903_;
|
||||
float v2 = (f_900_ * f_894_ + f_901_ * f_895_ + f_902_ * f_896_) * f_903_;
|
||||
|
||||
this.faceTextureUCoordinates[i] = u;
|
||||
this.faceTextureVCoordinates[i] = v;
|
||||
int idx = i * 6;
|
||||
faceTextureUCoordinates[idx] = u0;
|
||||
faceTextureUCoordinates[idx + 1] = v0;
|
||||
faceTextureUCoordinates[idx + 2] = u1;
|
||||
faceTextureUCoordinates[idx + 3] = v1;
|
||||
faceTextureUCoordinates[idx + 4] = u2;
|
||||
faceTextureUCoordinates[idx + 5] = v2;
|
||||
}
|
||||
}
|
||||
|
||||
this.faceTextureUVCoordinates = faceTextureUCoordinates;
|
||||
}
|
||||
}
|
||||
@@ -61,51 +61,36 @@ public abstract class RSModelMixin implements RSModel
|
||||
private int rl$uvBufferOffset;
|
||||
|
||||
@Inject
|
||||
private float[][] rl$faceTextureUCoordinates;
|
||||
|
||||
@Inject
|
||||
private float[][] rl$faceTextureVCoordinates;
|
||||
private float[] rl$faceTextureUVCoordinates;
|
||||
|
||||
@MethodHook(value = "<init>", end = true)
|
||||
@Inject
|
||||
public void rl$init(RSModel[] models, int length)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < length; ++i)
|
||||
if (this.getFaceTextures() != null)
|
||||
{
|
||||
RSModel model = models[i];
|
||||
if (model != null)
|
||||
int count = this.getTrianglesCount();
|
||||
float[] uv = new float[count * 6];
|
||||
int idx = 0;
|
||||
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
count += model.getTrianglesCount();
|
||||
}
|
||||
}
|
||||
|
||||
float[][] u = new float[count][];
|
||||
float[][] v = new float[count][];
|
||||
int idx = 0;
|
||||
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
RSModel model = models[i];
|
||||
if (model != null)
|
||||
{
|
||||
float[][] modelU = model.getFaceTextureUCoordinates();
|
||||
float[][] modelV = model.getFaceTextureVCoordinates();
|
||||
|
||||
for (int j = 0; j < model.getTrianglesCount(); ++j)
|
||||
RSModel model = models[i];
|
||||
if (model != null)
|
||||
{
|
||||
if (modelU != null && modelV != null)
|
||||
float[] modelUV = model.getFaceTextureUVCoordinates();
|
||||
|
||||
if (modelUV != null)
|
||||
{
|
||||
u[idx] = modelU[j];
|
||||
v[idx] = modelV[j];
|
||||
System.arraycopy(modelUV, 0, uv, idx, model.getTrianglesCount() * 6);
|
||||
}
|
||||
++idx;
|
||||
|
||||
idx += model.getTrianglesCount() * 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setFaceTextureUCoordinates(u);
|
||||
setFaceTextureVCoordinates(v);
|
||||
setFaceTextureUVCoordinates(uv);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,8 +154,7 @@ public abstract class RSModelMixin implements RSModel
|
||||
if (model != null && model != this)
|
||||
{
|
||||
RSModel rsModel = (RSModel) model;
|
||||
rsModel.setFaceTextureUCoordinates(rl$faceTextureUCoordinates);
|
||||
rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates);
|
||||
rsModel.setFaceTextureUVCoordinates(rl$faceTextureUVCoordinates);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
@@ -192,8 +176,7 @@ public abstract class RSModelMixin implements RSModel
|
||||
{
|
||||
// Animated models are usually a shared Model instance that is global
|
||||
RSModel rsModel = (RSModel) sharedModel;
|
||||
rsModel.setFaceTextureUCoordinates(rl$faceTextureUCoordinates);
|
||||
rsModel.setFaceTextureVCoordinates(rl$faceTextureVCoordinates);
|
||||
rsModel.setFaceTextureUVCoordinates(rl$faceTextureUVCoordinates);
|
||||
}
|
||||
|
||||
@Inject
|
||||
@@ -385,29 +368,15 @@ public abstract class RSModelMixin implements RSModel
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public float[][] getFaceTextureUCoordinates()
|
||||
public float[] getFaceTextureUVCoordinates()
|
||||
{
|
||||
return rl$faceTextureUCoordinates;
|
||||
return rl$faceTextureUVCoordinates;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public void setFaceTextureUCoordinates(float[][] faceTextureUCoordinates)
|
||||
public void setFaceTextureUVCoordinates(float[] faceTextureUVCoordinates)
|
||||
{
|
||||
this.rl$faceTextureUCoordinates = faceTextureUCoordinates;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public float[][] getFaceTextureVCoordinates()
|
||||
{
|
||||
return rl$faceTextureVCoordinates;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public void setFaceTextureVCoordinates(float[][] faceTextureVCoordinates)
|
||||
{
|
||||
this.rl$faceTextureVCoordinates = faceTextureVCoordinates;
|
||||
this.rl$faceTextureUVCoordinates = faceTextureUVCoordinates;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
package net.runelite.mixins;
|
||||
|
||||
import java.awt.Polygon;
|
||||
import java.awt.Shape;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.NPCComposition;
|
||||
@@ -169,6 +170,22 @@ public abstract class RSNPCMixin implements RSNPC
|
||||
return composition;
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public Polygon getCanvasTilePoly()
|
||||
{
|
||||
NPCComposition transformedComposition = this.getTransformedComposition();
|
||||
if (transformedComposition == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int size = transformedComposition.getSize();
|
||||
return Perspective.getCanvasTileAreaPoly(client, this.getLocalLocation(), size);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
@Override
|
||||
public Shape getConvexHull()
|
||||
|
||||
@@ -169,9 +169,6 @@ public interface RSModel extends RSRenderable, Model
|
||||
*/
|
||||
Shape getConvexHull(int localX, int localY, int orientation, int tileHeight);
|
||||
|
||||
float[][] getFaceTextureUCoordinates();
|
||||
void setFaceTextureUCoordinates(float[][] rl$faceTextureUCoordinates);
|
||||
|
||||
float[][] getFaceTextureVCoordinates();
|
||||
void setFaceTextureVCoordinates(float[][] rl$faceTextureVCoordinates);
|
||||
float[] getFaceTextureUVCoordinates();
|
||||
void setFaceTextureUVCoordinates(float[] rl$faceTextureUVCoordinates);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user