Add utility functions for rectangle conversion to JomlUtil
import org.joml.Matrix3f;
import org.joml.Matrix3fc;
-import org.joml.Matrix4f;
import org.joml.Matrix4fc;
import org.joml.Quaternionf;
import org.joml.Quaternionfc;
-import org.joml.Vector2f;
+import org.joml.Rectanglef;
+import org.joml.Rectanglei;
import org.joml.Vector2fc;
import org.joml.Vector2ic;
import org.joml.Vector3fc;
import org.terasology.math.geom.BaseMatrix4f;
import org.terasology.math.geom.BaseQuat4f;
import org.terasology.math.geom.BaseVector2f;
+import org.terasology.math.geom.BaseVector2i;
import org.terasology.math.geom.BaseVector3f;
import org.terasology.math.geom.BaseVector3i;
import org.terasology.math.geom.BaseVector4f;
import org.terasology.math.geom.Quat4f;
+import org.terasology.math.geom.Rect2f;
+import org.terasology.math.geom.Rect2i;
public class JomlUtil {
@@ -99,6 +102,10 @@ public static Matrix3f from(BaseMatrix3f mat) {
return new org.joml.Vector2f(vec.x(), vec.y());
}
+ public static org.joml.Vector2i from (BaseVector2i vec) {
+ return new org.joml.Vector2i(vec.x(), vec.y());
+ }
+
public static org.joml.Vector3i from(BaseVector3i vec) {
return new org.joml.Vector3i(vec.x(), vec.y(), vec.z());
}
@@ -110,4 +117,28 @@ public static Quat4f from(Quaternionfc quat) {
public static Quaternionf from(BaseQuat4f quat) {
return new Quaternionf(quat.getX(), quat.getY(), quat.getZ(), quat.getW());
}
+
+ public static Rectanglei from(Rect2i rect) {
+ return new Rectanglei(rect.minX(), rect.minY(), rect.maxX(), rect.maxY());
+ }
+
+ public static Rect2i from(Rectanglei rect) {
+ return Rect2i.createFromMinAndMax(rect.minX, rect.minY, rect.maxX, rect.maxY);
+ }
+
+ public static Rectanglef from(Rect2f rect) {
+ return new Rectanglef(rect.minX(), rect.minY(), rect.maxX(), rect.maxY());
+ }
+
+ public static Rect2f from(Rectanglef rect) {
+ return Rect2f.createFromMinAndMax(rect.minX, rect.minY, rect.maxX, rect.maxY);
+ }
+
+ public static Rectanglei rectangleiFromMinAndSize(int minX, int minY, int width, int height) {
+ return new Rectanglei(minX, minY, minX + width, minY + height);
+ }
+
+ public static Rectanglef rectanglefFromMinAndSize(float minX, float minY, float width, float height) {
+ return new Rectanglef(minX, minY, minX + width, minY + height);
+ }
}
