From 0ae0b97da763f1f6290cdcb2652fb517581fdee3 Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Tue, 25 Jun 2024 20:15:17 +0300 Subject: [PATCH] Renderer API quads overloads for joml interfaces (#3875) --- .../api/renderer/v1/mesh/MutableQuadView.java | 26 +++++++++++++++++++ .../api/renderer/v1/mesh/QuadEmitter.java | 20 ++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java index da5ffbe2d..fa40d0769 100644 --- a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java +++ b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/MutableQuadView.java @@ -18,7 +18,9 @@ package net.fabricmc.fabric.api.renderer.v1.mesh; import org.jetbrains.annotations.Nullable; import org.joml.Vector2f; +import org.joml.Vector2fc; import org.joml.Vector3f; +import org.joml.Vector3fc; import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.texture.Sprite; @@ -111,6 +113,13 @@ public interface MutableQuadView extends QuadView { * Same as {@link #pos(int, float, float, float)} but accepts vector type. */ default MutableQuadView pos(int vertexIndex, Vector3f pos) { + return pos(vertexIndex, pos.x, pos.y, pos.z); + } + + /** + * Same as {@link #pos(int, float, float, float)} but accepts vector type. + */ + default MutableQuadView pos(int vertexIndex, Vector3fc pos) { return pos(vertexIndex, pos.x(), pos.y(), pos.z()); } @@ -145,6 +154,16 @@ public interface MutableQuadView extends QuadView { return uv(vertexIndex, uv.x, uv.y); } + /** + * Set texture coordinates. + * + *

Only use this function if you already have a {@link Vector2fc}. + * Otherwise, see {@link MutableQuadView#uv(int, float, float)}. + */ + default MutableQuadView uv(int vertexIndex, Vector2fc uv) { + return uv(vertexIndex, uv.x(), uv.y()); + } + /** * Assigns sprite atlas u,v coordinates to this quad for the given sprite. * Can handle UV locking, rotation, interpolation, etc. Control this behavior @@ -190,6 +209,13 @@ public interface MutableQuadView extends QuadView { * Same as {@link #normal(int, float, float, float)} but accepts vector type. */ default MutableQuadView normal(int vertexIndex, Vector3f normal) { + return normal(vertexIndex, normal.x, normal.y, normal.z); + } + + /** + * Same as {@link #normal(int, float, float, float)} but accepts vector type. + */ + default MutableQuadView normal(int vertexIndex, Vector3fc normal) { return normal(vertexIndex, normal.x(), normal.y(), normal.z()); } diff --git a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadEmitter.java b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadEmitter.java index 272ce9021..1616d8def 100644 --- a/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadEmitter.java +++ b/fabric-renderer-api-v1/src/client/java/net/fabricmc/fabric/api/renderer/v1/mesh/QuadEmitter.java @@ -18,7 +18,9 @@ package net.fabricmc.fabric.api.renderer.v1.mesh; import org.jetbrains.annotations.Nullable; import org.joml.Vector2f; +import org.joml.Vector2fc; import org.joml.Vector3f; +import org.joml.Vector3fc; import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.texture.Sprite; @@ -50,6 +52,12 @@ public interface QuadEmitter extends MutableQuadView { return this; } + @Override + default QuadEmitter pos(int vertexIndex, Vector3fc pos) { + MutableQuadView.super.pos(vertexIndex, pos); + return this; + } + @Override QuadEmitter color(int vertexIndex, int color); @@ -68,6 +76,12 @@ public interface QuadEmitter extends MutableQuadView { return this; } + @Override + default QuadEmitter uv(int vertexIndex, Vector2fc uv) { + MutableQuadView.super.uv(vertexIndex, uv); + return this; + } + @Override QuadEmitter spriteBake(Sprite sprite, int bakeFlags); @@ -97,6 +111,12 @@ public interface QuadEmitter extends MutableQuadView { return this; } + @Override + default QuadEmitter normal(int vertexIndex, Vector3fc normal) { + MutableQuadView.super.normal(vertexIndex, normal); + return this; + } + @Override QuadEmitter cullFace(@Nullable Direction face);