Fix up issues with code

Signed-off-by: solonovamax <solonovamax@12oclockpoint.com>
This commit is contained in:
solonovamax
2020-11-06 22:26:57 -05:00
parent a362ed47ce
commit 0c8c0723ef
130 changed files with 1228 additions and 1059 deletions

View File

@@ -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 + ")";
}
}

View File

@@ -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();
}

View File

@@ -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;

View File

@@ -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() {