start moving to int vector impls where possible

This commit is contained in:
dfsek
2021-11-24 13:54:43 -07:00
parent ba7722ce45
commit b04f7cfc55
15 changed files with 196 additions and 31 deletions

View File

@@ -7,7 +7,7 @@
package com.dfsek.terra.api.block.state.properties.enums;
import com.dfsek.terra.api.structure.rotation.Rotation;
import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.generic.Construct;

View File

@@ -10,7 +10,7 @@ package com.dfsek.terra.api.structure;
import java.util.Random;
import com.dfsek.terra.api.structure.buffer.Buffer;
import com.dfsek.terra.api.structure.rotation.Rotation;
import com.dfsek.terra.api.util.Rotation;
import com.dfsek.terra.api.util.StringIdentifiable;
import com.dfsek.terra.api.util.vector.Vector3;
import com.dfsek.terra.api.world.Chunk;

View File

@@ -1,57 +0,0 @@
/*
* Copyright (c) 2020-2021 Polyhedral Development
*
* The Terra API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the common/api directory.
*/
package com.dfsek.terra.api.structure.rotation;
import net.jafama.FastMath;
public enum Rotation {
CW_90(90),
CW_180(180),
CCW_90(270),
NONE(0);
private final int degrees;
Rotation(int degrees) {
this.degrees = degrees;
}
public static Rotation fromDegrees(int deg) {
return switch(FastMath.floorMod(deg, 360)) {
case 0 -> Rotation.NONE;
case 90 -> Rotation.CW_90;
case 180 -> Rotation.CW_180;
case 270 -> Rotation.CCW_90;
default -> throw new IllegalArgumentException();
};
}
public Rotation inverse() {
return switch(this) {
case NONE -> NONE;
case CCW_90 -> CW_90;
case CW_90 -> CCW_90;
case CW_180 -> CW_180;
};
}
public Rotation rotate(Rotation rotation) {
return fromDegrees(this.getDegrees() + rotation.getDegrees());
}
public int getDegrees() {
return degrees;
}
public enum Axis {
X,
Y,
Z
}
}

View File

@@ -15,7 +15,6 @@ import com.dfsek.terra.api.block.state.properties.enums.Axis;
import com.dfsek.terra.api.block.state.properties.enums.RailShape;
import com.dfsek.terra.api.block.state.properties.enums.RedstoneConnection;
import com.dfsek.terra.api.block.state.properties.enums.WallHeight;
import com.dfsek.terra.api.structure.rotation.Rotation;
import com.dfsek.terra.api.util.vector.Vector2;