feat(JOML): migrate Voronoi
*/
package org.terasology.utilities.procedural;
-import org.terasology.math.TeraMath;
-import org.terasology.math.geom.Vector2f;
+import org.joml.Math;
+import org.joml.RoundingMode;
+import org.joml.Vector2f;
import java.util.Random;
@@ -60,11 +61,11 @@ public static float standardDistanceFunction(Vector2f delta) {
result.distance = Float.MAX_VALUE;
}
- at.scale(DENSITY_ADJUSTMENT);
+ at.mul(DENSITY_ADJUSTMENT);
at.add(offset);
- int cellX = TeraMath.floorToInt(at.x);
- int cellY = TeraMath.floorToInt(at.y);
+ int cellX = Math.roundUsing(at.x, RoundingMode.FLOOR);
+ int cellY = Math.roundUsing(at.y, RoundingMode.FLOOR);
processCell(cellX, cellY, at, results);
@@ -103,7 +104,7 @@ public static float standardDistanceFunction(Vector2f delta) {
}
for (VoronoiResult result : results) {
- result.delta.scale(INVERSE_DENSITY_ADJUSTMENT);
+ result.delta.mul(INVERSE_DENSITY_ADJUSTMENT);
result.distance *= INVERSE_DENSITY_ADJUSTMENT * INVERSE_DENSITY_ADJUSTMENT;
}
