runelite-api: move rotate() to Vertex
This commit is contained in:
@@ -128,24 +128,12 @@ public class Player extends Actor
|
|||||||
Vertex c = triangle.getC();
|
Vertex c = triangle.getC();
|
||||||
|
|
||||||
Triangle rotatedTriangle = new Triangle(
|
Triangle rotatedTriangle = new Triangle(
|
||||||
rotate(a, orientation),
|
a.rotate(orientation),
|
||||||
rotate(b, orientation),
|
b.rotate(orientation),
|
||||||
rotate(c, orientation)
|
c.rotate(orientation)
|
||||||
);
|
);
|
||||||
rotatedTriangles.add(rotatedTriangle);
|
rotatedTriangles.add(rotatedTriangle);
|
||||||
}
|
}
|
||||||
return rotatedTriangles;
|
return rotatedTriangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vertex rotate(Vertex vertex, int orientation)
|
|
||||||
{
|
|
||||||
int sin = Perspective.SINE[orientation];
|
|
||||||
int cos = Perspective.COSINE[orientation];
|
|
||||||
|
|
||||||
return new Vertex(
|
|
||||||
vertex.getX() * cos + vertex.getZ() * sin >> 16,
|
|
||||||
vertex.getY(),
|
|
||||||
vertex.getZ() * cos - vertex.getX() * sin >> 16
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.api.model;
|
package net.runelite.api.model;
|
||||||
|
|
||||||
|
import net.runelite.api.Perspective;
|
||||||
|
|
||||||
public class Vertex
|
public class Vertex
|
||||||
{
|
{
|
||||||
private final int x;
|
private final int x;
|
||||||
@@ -94,4 +96,21 @@ public class Vertex
|
|||||||
{
|
{
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rotate the vertex by the given orientation
|
||||||
|
* @param orientation
|
||||||
|
* @return the newly rotated vertex
|
||||||
|
*/
|
||||||
|
public Vertex rotate(int orientation)
|
||||||
|
{
|
||||||
|
int sin = Perspective.SINE[orientation];
|
||||||
|
int cos = Perspective.COSINE[orientation];
|
||||||
|
|
||||||
|
return new Vertex(
|
||||||
|
x * cos + z * sin >> 16,
|
||||||
|
y,
|
||||||
|
z * cos - x * sin >> 16
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user