-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
491 changed files
with
39,653 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
common/src/api/java/dev/vexor/radium/compat/mojang/math/PoseStack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package dev.vexor.radium.compat.mojang.math; | ||
|
||
import com.google.common.collect.Queues; | ||
import java.util.Deque; | ||
|
||
import dev.vexor.radium.compat.mojang.Util; | ||
import org.joml.Matrix3f; | ||
import org.joml.Matrix4f; | ||
import org.joml.Quaternionf; | ||
|
||
public class PoseStack { | ||
private final Deque<Pose> poseStack = Util.make(Queues.newArrayDeque(), arrayDeque -> { | ||
Matrix4f matrix4f = new Matrix4f(); | ||
matrix4f.identity(); | ||
Matrix3f matrix3f = new Matrix3f(); | ||
matrix3f.identity(); | ||
arrayDeque.add(new Pose(matrix4f, matrix3f)); | ||
}); | ||
|
||
public void translate(double d, double d2, double d3) { | ||
Pose pose = this.poseStack.getLast(); | ||
pose.pose.translate((float)d, (float)d2, (float)d3); | ||
} | ||
|
||
public void scale(float f, float f2, float f3) { | ||
Pose pose = this.poseStack.getLast(); | ||
pose.pose.scale(f, f2, f3); | ||
if (f == f2 && f2 == f3) { | ||
if (f > 0.0f) { | ||
return; | ||
} | ||
pose.normal.scale(-1.0f); | ||
} | ||
float f4 = 1.0f / f; | ||
float f5 = 1.0f / f2; | ||
float f6 = 1.0f / f3; | ||
float f7 = Mth.fastInvCubeRoot(f4 * f5 * f6); | ||
pose.normal.scale(f7 * f4, f7 * f5, f7 * f6); | ||
} | ||
|
||
public void mulPose(Quaternionf quaternion) { | ||
Pose pose = this.poseStack.getLast(); | ||
pose.pose.rotate(quaternion); | ||
pose.normal.rotate(quaternion); | ||
} | ||
|
||
public void pushPose() { | ||
Pose pose = this.poseStack.getLast(); | ||
this.poseStack.addLast(new Pose(new Matrix4f(pose.pose), new Matrix3f(pose.normal))); | ||
} | ||
|
||
public void popPose() { | ||
this.poseStack.removeLast(); | ||
} | ||
|
||
public Pose last() { | ||
return this.poseStack.getLast(); | ||
} | ||
|
||
public boolean clear() { | ||
return this.poseStack.size() == 1; | ||
} | ||
|
||
public static final class Pose { | ||
private final Matrix4f pose; | ||
private final Matrix3f normal; | ||
|
||
private Pose(Matrix4f matrix4f, Matrix3f matrix3f) { | ||
this.pose = matrix4f; | ||
this.normal = matrix3f; | ||
} | ||
|
||
public Matrix4f pose() { | ||
return this.pose; | ||
} | ||
|
||
public Matrix3f normal() { | ||
return this.normal; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
common/src/shaders/java/kroppeb/stareval/element/AccessibleExpressionElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package kroppeb.stareval.element; | ||
|
||
public interface AccessibleExpressionElement extends ExpressionElement { | ||
} |
4 changes: 4 additions & 0 deletions
4
common/src/shaders/java/kroppeb/stareval/element/Element.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package kroppeb.stareval.element; | ||
|
||
public interface Element { | ||
} |
4 changes: 4 additions & 0 deletions
4
common/src/shaders/java/kroppeb/stareval/element/ExpressionElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package kroppeb.stareval.element; | ||
|
||
public interface ExpressionElement extends Element { | ||
} |
7 changes: 7 additions & 0 deletions
7
common/src/shaders/java/kroppeb/stareval/element/PriorityOperatorElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package kroppeb.stareval.element; | ||
|
||
public interface PriorityOperatorElement extends Element { | ||
int getPriority(); | ||
|
||
ExpressionElement resolveWith(ExpressionElement right); | ||
} |
16 changes: 16 additions & 0 deletions
16
common/src/shaders/java/kroppeb/stareval/element/token/BinaryOperatorToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package kroppeb.stareval.element.token; | ||
|
||
import kroppeb.stareval.parser.BinaryOp; | ||
|
||
public class BinaryOperatorToken extends Token { | ||
public final BinaryOp op; | ||
|
||
public BinaryOperatorToken(BinaryOp op) { | ||
this.op = op; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BinaryOp{" + this.op + "}"; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/shaders/java/kroppeb/stareval/element/token/IdToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package kroppeb.stareval.element.token; | ||
|
||
import kroppeb.stareval.element.AccessibleExpressionElement; | ||
|
||
public class IdToken extends Token implements AccessibleExpressionElement { | ||
private final String id; | ||
|
||
public IdToken(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Id{" + this.id + "}"; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/shaders/java/kroppeb/stareval/element/token/NumberToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package kroppeb.stareval.element.token; | ||
|
||
import kroppeb.stareval.element.ExpressionElement; | ||
|
||
public class NumberToken extends Token implements ExpressionElement { | ||
private final String number; | ||
|
||
public NumberToken(String number) { | ||
this.number = number; | ||
} | ||
|
||
public String getNumber() { | ||
return number; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Number{" + this.number + "}"; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
common/src/shaders/java/kroppeb/stareval/element/token/Token.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package kroppeb.stareval.element.token; | ||
|
||
import kroppeb.stareval.element.Element; | ||
|
||
public abstract class Token implements Element { | ||
@Override | ||
public abstract String toString(); | ||
} |
29 changes: 29 additions & 0 deletions
29
common/src/shaders/java/kroppeb/stareval/element/token/UnaryOperatorToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package kroppeb.stareval.element.token; | ||
|
||
import kroppeb.stareval.element.ExpressionElement; | ||
import kroppeb.stareval.element.PriorityOperatorElement; | ||
import kroppeb.stareval.element.tree.UnaryExpressionElement; | ||
import kroppeb.stareval.parser.UnaryOp; | ||
|
||
public class UnaryOperatorToken extends Token implements PriorityOperatorElement { | ||
private final UnaryOp op; | ||
|
||
public UnaryOperatorToken(UnaryOp op) { | ||
this.op = op; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "UnaryOp{" + this.op + "}"; | ||
} | ||
|
||
@Override | ||
public int getPriority() { | ||
return -1; | ||
} | ||
|
||
@Override | ||
public UnaryExpressionElement resolveWith(ExpressionElement right) { | ||
return new UnaryExpressionElement(this.op, right); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
common/src/shaders/java/kroppeb/stareval/element/tree/AccessExpressionElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package kroppeb.stareval.element.tree; | ||
|
||
import kroppeb.stareval.element.AccessibleExpressionElement; | ||
|
||
public class AccessExpressionElement implements AccessibleExpressionElement { | ||
private final AccessibleExpressionElement base; | ||
private final String index; | ||
|
||
public AccessExpressionElement(AccessibleExpressionElement base, String index) { | ||
this.base = base; | ||
this.index = index; | ||
} | ||
|
||
public AccessibleExpressionElement getBase() { | ||
return this.base; | ||
} | ||
|
||
public String getIndex() { | ||
return this.index; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Access{" + this.base + "[" + this.index + "]}"; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
common/src/shaders/java/kroppeb/stareval/element/tree/BinaryExpressionElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package kroppeb.stareval.element.tree; | ||
|
||
import kroppeb.stareval.element.ExpressionElement; | ||
import kroppeb.stareval.parser.BinaryOp; | ||
|
||
public class BinaryExpressionElement implements ExpressionElement { | ||
private final BinaryOp op; | ||
private final ExpressionElement left; | ||
private final ExpressionElement right; | ||
|
||
public BinaryExpressionElement(BinaryOp op, ExpressionElement left, ExpressionElement right) { | ||
this.op = op; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
public BinaryOp getOp() { | ||
return this.op; | ||
} | ||
|
||
public ExpressionElement getLeft() { | ||
return this.left; | ||
} | ||
|
||
public ExpressionElement getRight() { | ||
return this.right; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "BinaryExpr{ {" + this.left + "} " + this.op + " {" + this.right + "} }"; | ||
} | ||
} |
Oops, something went wrong.