Adopted new Math and Widget changes

This commit is contained in:
Frank 2022-10-28 18:03:25 +02:00
parent e608bf21fe
commit ff77134ead
15 changed files with 62 additions and 51 deletions

View file

@ -1,17 +1,18 @@
package org.betterx.bclib.util;
import com.mojang.math.Vector3f;
import net.minecraft.core.Vec3i;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.levelgen.PositionalRandomFactory;
import org.joml.Vector3f;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class MHelper {
static class ThreadLocalRandomSource implements RandomSource {
ThreadLocalRandomSource(long seed) {
}
@Override
@ -230,28 +231,28 @@ public class MHelper {
}
public static Vector3f cross(Vector3f vec1, Vector3f vec2) {
float cx = vec1.y() * vec2.z() - vec1.z() * vec2.y();
float cy = vec1.z() * vec2.x() - vec1.x() * vec2.z();
float cz = vec1.x() * vec2.y() - vec1.y() * vec2.x();
float cx = vec1.y * vec2.z - vec1.z * vec2.y;
float cy = vec1.z * vec2.x - vec1.x * vec2.z;
float cz = vec1.x * vec2.y - vec1.y * vec2.x;
return new Vector3f(cx, cy, cz);
}
public static Vector3f normalize(Vector3f vec) {
float length = lengthSqr(vec.x(), vec.y(), vec.z());
float length = lengthSqr(vec.x, vec.y, vec.z);
if (length > 0) {
length = (float) Math.sqrt(length);
float x = vec.x() / length;
float y = vec.y() / length;
float z = vec.z() / length;
float x = vec.x / length;
float y = vec.y / length;
float z = vec.z / length;
vec.set(x, y, z);
}
return vec;
}
public static float angle(Vector3f vec1, Vector3f vec2) {
float dot = vec1.x() * vec2.x() + vec1.y() * vec2.y() + vec1.z() * vec2.z();
float length1 = lengthSqr(vec1.x(), vec1.y(), vec1.z());
float length2 = lengthSqr(vec2.x(), vec2.y(), vec2.z());
float dot = vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z;
float length1 = lengthSqr(vec1.x, vec1.y, vec1.z);
float length2 = lengthSqr(vec2.x, vec2.y, vec2.z);
return (float) Math.acos(dot / Math.sqrt(length1 * length2));
}

View file

@ -4,7 +4,6 @@ import org.betterx.bclib.sdf.SDF;
import org.betterx.bclib.sdf.operator.SDFUnion;
import org.betterx.bclib.sdf.primitive.SDFLine;
import com.mojang.math.Vector3f;
import net.minecraft.core.BlockPos;
import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.util.Mth;
@ -13,6 +12,7 @@ import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.block.state.BlockState;
import com.google.common.collect.Lists;
import org.joml.Vector3f;
import java.util.ArrayList;
import java.util.List;