mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-11 02:06:07 +00:00
Fix up issues with code
Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package com.dfsek.terra.procgen.math;
|
||||
/**
|
||||
* oh yeah
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class Vector2 implements Cloneable {
|
||||
private double x;
|
||||
private double z;
|
||||
@@ -58,36 +59,6 @@ public class Vector2 implements Cloneable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide X and Z components by a value.
|
||||
*
|
||||
* @param d Divisor
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 divide(double d) {
|
||||
x /= d;
|
||||
z /= d;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the squared length of this Vector
|
||||
*
|
||||
* @return squared length
|
||||
*/
|
||||
public double lengthSquared() {
|
||||
return x * x + z * z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of this Vector
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public double length() {
|
||||
return Math.sqrt(lengthSquared());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add this vector to another.
|
||||
*
|
||||
@@ -122,6 +93,36 @@ public class Vector2 implements Cloneable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide X and Z components by a value.
|
||||
*
|
||||
* @param d Divisor
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 divide(double d) {
|
||||
x /= d;
|
||||
z /= d;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of this Vector
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public double length() {
|
||||
return Math.sqrt(lengthSquared());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the squared length of this Vector
|
||||
*
|
||||
* @return squared length
|
||||
*/
|
||||
public double lengthSquared() {
|
||||
return x * x + z * z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance from this vector to another.
|
||||
*
|
||||
@@ -162,8 +163,12 @@ public class Vector2 implements Cloneable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + x + ", " + z + ")";
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector2)) {
|
||||
return false;
|
||||
}
|
||||
Vector2 other = (Vector2) obj;
|
||||
return other.x == this.x && other.z == this.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -174,4 +179,9 @@ public class Vector2 implements Cloneable {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + x + ", " + z + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.dfsek.terra.procgen.math.Vector2;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public abstract class Polygon {
|
||||
public abstract Set<Vector2> getContainedPixels();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.dfsek.terra.procgen.math.Vector2;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Rectangle extends Polygon {
|
||||
private final Vector2 min;
|
||||
private final Vector2 max;
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class VoxelGeometry {
|
||||
public List<Vector> geometry = new ArrayList<>();
|
||||
private final List<Vector> geometry = new ArrayList<>();
|
||||
|
||||
public static VoxelGeometry getBlank() {
|
||||
return new VoxelGeometry() {
|
||||
|
||||
Reference in New Issue
Block a user