Skip to content

Commit

Permalink
Update to 1.19.3/Sodium 0.4.6 (#154)
Browse files Browse the repository at this point in the history
* 1.19.3

* 0.4.6 p1

* 0.4.6 p2
  • Loading branch information
IMS212 authored Dec 10, 2022
1 parent 86e62aa commit 3ae641a
Show file tree
Hide file tree
Showing 11 changed files with 49 additions and 52 deletions.
5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ dependencies {
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.

modImplementation "maven.modrinth:sodium:mc1.19.2-0.4.4"

// Transitive dependency of Sodium
implementation("org.joml:joml:1.10.2")
modImplementation "maven.modrinth:sodium:mc1.19.3-0.4.6"
}

processResources {
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.2
yarn_mappings=1.19.2+build.8
loader_version=0.14.9
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.2
loader_version=0.14.11
# Mod Properties
mod_version=1.0.9
maven_group=link.infra
archives_base_name=indium
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.60.0+1.19.2
fabric_version=0.68.1+1.19.3
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3f;
import org.joml.Vector3f;
import net.minecraft.world.BlockRenderView;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -280,11 +280,11 @@ private void blendedPartialFace(QuadViewImpl quad) {
}

/** used exclusively in irregular face to avoid new heap allocations each call. */
private final Vec3f vertexNormal = new Vec3f();
private final Vector3f vertexNormal = new Vector3f();

private void irregularFace(MutableQuadViewImpl quad) {
final Vec3f faceNorm = quad.faceNormal();
Vec3f normal;
final Vector3f faceNorm = quad.faceNormal();
Vector3f normal;
final float[] w = this.w;
final float[] aoResult = this.ao;
final int[] lightResult = this.light;
Expand All @@ -294,7 +294,7 @@ private void irregularFace(MutableQuadViewImpl quad) {
float ao = 0, sky = 0, block = 0, maxAo = 0;
int maxSky = 0, maxBlock = 0;

final float x = normal.getX();
final float x = normal.x();

if (!MathHelper.approximatelyEquals(0f, x)) {
final Direction face = x > 0 ? Direction.EAST : Direction.WEST;
Expand All @@ -312,7 +312,7 @@ private void irregularFace(MutableQuadViewImpl quad) {
maxBlock = b;
}

final float y = normal.getY();
final float y = normal.y();

if (!MathHelper.approximatelyEquals(0f, y)) {
final Direction face = y > 0 ? Direction.UP : Direction.DOWN;
Expand All @@ -330,7 +330,7 @@ private void irregularFace(MutableQuadViewImpl quad) {
maxBlock = Math.max(maxBlock, b);
}

final float z = normal.getZ();
final float z = normal.z();

if (!MathHelper.approximatelyEquals(0f, z)) {
final Direction face = z > 0 ? Direction.SOUTH : Direction.NORTH;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Direction.Axis;
import net.minecraft.util.math.Direction.AxisDirection;
import net.minecraft.util.math.Vec3f;
import org.joml.Vector3f;
import org.jetbrains.annotations.NotNull;

import static net.minecraft.util.math.MathHelper.approximatelyEquals;
Expand Down Expand Up @@ -191,16 +191,16 @@ private static boolean confirmSquareCorners(int aCoordinate, int bCoordinate, Qu
* <p>Derived from the quad face normal and expects convex quads with all points co-planar.
*/
public static Direction lightFace(QuadView quad) {
final Vec3f normal = quad.faceNormal();
final Vector3f normal = quad.faceNormal();
switch (GeometryHelper.longestAxis(normal)) {
case X:
return normal.getX() > 0 ? Direction.EAST : Direction.WEST;
return normal.x() > 0 ? Direction.EAST : Direction.WEST;

case Y:
return normal.getY() > 0 ? Direction.UP : Direction.DOWN;
return normal.y() > 0 ? Direction.UP : Direction.DOWN;

case Z:
return normal.getZ() > 0 ? Direction.SOUTH : Direction.NORTH;
return normal.z() > 0 ? Direction.SOUTH : Direction.NORTH;

default:
// handle WTF case
Expand Down Expand Up @@ -229,8 +229,8 @@ public static float max(float a, float b, float c, float d) {
/**
* @see #longestAxis(float, float, float)
*/
public static Axis longestAxis(Vec3f vec) {
return longestAxis(vec.getX(), vec.getY(), vec.getZ());
public static Axis longestAxis(Vector3f vec) {
return longestAxis(vec.x(), vec.y(), vec.z());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadView;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3f;
import org.joml.Vector3f;
import net.minecraft.util.math.Vec3i;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -48,8 +48,8 @@ public static int packNormal(float x, float y, float z, float w) {
/**
* Version of {@link #packNormal(float, float, float, float)} that accepts a vector type.
*/
public static int packNormal(Vec3f normal, float w) {
return packNormal(normal.getX(), normal.getY(), normal.getZ(), w);
public static int packNormal(Vector3f normal, float w) {
return packNormal(normal.x(), normal.y(), normal.z(), w);
}

/**
Expand All @@ -69,7 +69,7 @@ public static float getPackedNormalComponent(int packedNormal, int component) {
* <p>Will work with triangles also. Assumes counter-clockwise winding order, which is the norm.
* Expects convex quads with all points co-planar.
*/
public static void computeFaceNormal(@NotNull Vec3f saveTo, QuadView q) {
public static void computeFaceNormal(@NotNull Vector3f saveTo, QuadView q) {
final Direction nominalFace = q.nominalFace();

if (GeometryHelper.isQuadParallelToFace(nominalFace, q)) {
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/link/infra/indium/renderer/mesh/QuadViewImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadView;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3f;
import org.joml.Vector3f;

import static link.infra.indium.renderer.mesh.EncodingFormat.*;

Expand All @@ -36,7 +36,7 @@ public class QuadViewImpl implements QuadView {
protected Direction nominalFace;
/** True when geometry flags or light face may not match geometry. */
protected boolean isGeometryInvalid = true;
protected final Vec3f faceNormal = new Vec3f();
protected final Vector3f faceNormal = new Vector3f();
private boolean shade = true;

/** Size and where it comes from will vary in subtypes. But in all cases quad is fully encoded to array. */
Expand Down Expand Up @@ -138,7 +138,7 @@ public final Direction nominalFace() {
}

@Override
public final Vec3f faceNormal() {
public final Vector3f faceNormal() {
computeGeometry();
return faceNormal;
}
Expand All @@ -152,15 +152,15 @@ public void copyTo(MutableQuadView target) {
RenderMaterial material = quad.material();
System.arraycopy(data, baseIndex, quad.data, quad.baseIndex, EncodingFormat.TOTAL_STRIDE);
quad.material(material);
quad.faceNormal.set(faceNormal.getX(), faceNormal.getY(), faceNormal.getZ());
quad.faceNormal.set(faceNormal);
quad.nominalFace = this.nominalFace;
quad.isGeometryInvalid = false;
}

@Override
public Vec3f copyPos(int vertexIndex, Vec3f target) {
public Vector3f copyPos(int vertexIndex, Vector3f target) {
if (target == null) {
target = new Vec3f();
target = new Vector3f();
}

final int index = baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_X;
Expand Down Expand Up @@ -198,10 +198,10 @@ protected final int normalIndex(int vertexIndex) {
}

@Override
public Vec3f copyNormal(int vertexIndex, Vec3f target) {
public Vector3f copyNormal(int vertexIndex, Vector3f target) {
if (hasNormal(vertexIndex)) {
if (target == null) {
target = new Vec3f();
target = new Vector3f();
}

final int normal = data[normalIndex(vertexIndex)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Matrix3f;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
Expand All @@ -39,6 +37,8 @@
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadEmitter;
import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel;
import org.joml.Matrix3f;
import org.joml.Matrix4f;

/**
* Context for non-terrain block rendering.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3f;
import org.joml.Vector3f;
import net.minecraft.util.math.random.Random;

/**
Expand All @@ -67,7 +67,7 @@ public interface VanillaQuadHandler {

private final ItemColors colorMap;
private final Random random = Random.create();
private final Vec3f normalVec = new Vec3f();
private final Vector3f normalVec = new Vector3f();

private final Supplier<Random> randomSupplier = () -> {
random.setSeed(ITEM_RANDOM_SEED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package link.infra.indium.renderer.render;

import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Matrix3f;

abstract class MatrixRenderContext extends AbstractRenderContext {
protected Matrix4f matrix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.texture.Sprite;
import net.minecraft.util.math.Matrix3f;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.Vec3f;
import org.joml.Matrix3f;
import org.joml.Matrix4f;
import org.joml.Vector3f;

public abstract class VertexConsumerQuadBufferer implements BaseQuadRenderer.QuadBufferer {
protected final Function<RenderLayer, VertexConsumer> bufferFunc;
protected final Vec3f normalVec = new Vec3f();
protected final Vector3f normalVec = new Vector3f();

protected abstract Matrix4f matrix();

Expand All @@ -31,15 +31,15 @@ public void bufferQuad(MutableQuadViewImpl quad, RenderLayer renderLayer) {
bufferQuad(bufferFunc.apply(renderLayer), quad, matrix(), overlay(), normalMatrix(), normalVec);
}

public static void bufferQuad(VertexConsumer buff, MutableQuadViewImpl quad, Matrix4f matrix, int overlay, Matrix3f normalMatrix, Vec3f normalVec) {
public static void bufferQuad(VertexConsumer buff, MutableQuadViewImpl quad, Matrix4f matrix, int overlay, Matrix3f normalMatrix, Vector3f normalVec) {
final boolean useNormals = quad.hasVertexNormals();

if (useNormals) {
quad.populateMissingNormals();
} else {
final Vec3f faceNormal = quad.faceNormal();
normalVec.set(faceNormal.getX(), faceNormal.getY(), faceNormal.getZ());
normalVec.transform(normalMatrix);
final Vector3f faceNormal = quad.faceNormal();
normalVec.set(faceNormal.x(), faceNormal.y(), faceNormal.z());
normalMatrix.transform(normalVec);
}

for (int i = 0; i < 4; i++) {
Expand All @@ -52,10 +52,10 @@ public static void bufferQuad(VertexConsumer buff, MutableQuadViewImpl quad, Mat

if (useNormals) {
normalVec.set(quad.normalX(i), quad.normalY(i), quad.normalZ(i));
normalVec.transform(normalMatrix);
normalMatrix.transform(normalVec);
}

buff.normal(normalVec.getX(), normalVec.getY(), normalVec.getZ());
buff.normal(normalVec.x(), normalVec.y(), normalVec.z());
buff.next();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
],
"depends": {
"fabricloader": ">=0.8.0",
"minecraft": "~1.19",
"sodium": "0.4.4",
"minecraft": "~1.19.3",
"sodium": "0.4.6",
"fabric-renderer-api-v1": ">=0.3.0",
"fabric-resource-loader-v0": ">=0.4.0"
}
Expand Down

0 comments on commit 3ae641a

Please sign in to comment.