remove buffer api

This commit is contained in:
dfsek
2021-12-20 00:01:04 -07:00
parent f088928483
commit 62d0f109b4
24 changed files with 217 additions and 185 deletions

View File

@@ -7,6 +7,8 @@
package com.dfsek.terra.api.util.vector;
import com.dfsek.terra.api.util.vector.integer.Vector3Int;
import net.jafama.FastMath;
import org.jetbrains.annotations.NotNull;
@@ -24,6 +26,10 @@ public class Vector3 implements Cloneable {
this.z = z;
}
public static Vector3 of(double x, double y, double z) {
return new Vector3(x, y, z);
}
public Vector3 multiply(double m) {
x *= m;
y *= m;
@@ -45,6 +51,13 @@ public class Vector3 implements Cloneable {
return this;
}
public Vector3 add(Vector3Int other) {
this.x += other.getX();
this.y += other.getY();
this.z += other.getZ();
return this;
}
public Vector3 add(Vector2 other) {
this.x += other.getX();
this.z += other.getZ();

View File

@@ -1,5 +1,8 @@
package com.dfsek.terra.api.util.vector.integer;
import com.dfsek.terra.api.util.vector.Vector3;
public class Vector3Int {
private static final Vector3Int ZERO = new Vector3Int(0, 0, 0);
private static final Vector3Int UNIT = new Vector3Int(0, 1, 0);
@@ -39,7 +42,10 @@ public class Vector3Int {
return new Mutable(x, y, z);
}
public Vector3 toVector3() {
return Vector3.of(x, y, z);
}
public static class Mutable {
private int x, y, z;
@@ -76,5 +82,16 @@ public class Vector3Int {
public Vector3Int immutable() {
return Vector3Int.of(x, y, z);
}
public Mutable add(int x, int y, int z) {
this.x += x;
this.y += y;
this.z += z;
return this;
}
public Vector3 toVector3() {
return Vector3.of(x, y, z);
}
}
}