Renderer API quads overloads for joml interfaces (#3875)

This commit is contained in:
SHsuperCM 2024-06-25 20:15:17 +03:00 committed by GitHub
parent 3dccd3438c
commit 0ae0b97da7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 0 deletions

View file

@ -18,7 +18,9 @@ package net.fabricmc.fabric.api.renderer.v1.mesh;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Vector2f; import org.joml.Vector2f;
import org.joml.Vector2fc;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3fc;
import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.Sprite; 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. * Same as {@link #pos(int, float, float, float)} but accepts vector type.
*/ */
default MutableQuadView pos(int vertexIndex, Vector3f pos) { 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()); 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); return uv(vertexIndex, uv.x, uv.y);
} }
/**
* Set texture coordinates.
*
* <p>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. * Assigns sprite atlas u,v coordinates to this quad for the given sprite.
* Can handle UV locking, rotation, interpolation, etc. Control this behavior * 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. * Same as {@link #normal(int, float, float, float)} but accepts vector type.
*/ */
default MutableQuadView normal(int vertexIndex, Vector3f normal) { 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()); return normal(vertexIndex, normal.x(), normal.y(), normal.z());
} }

View file

@ -18,7 +18,9 @@ package net.fabricmc.fabric.api.renderer.v1.mesh;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.joml.Vector2f; import org.joml.Vector2f;
import org.joml.Vector2fc;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3fc;
import net.minecraft.client.render.model.BakedQuad; import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.Sprite; import net.minecraft.client.texture.Sprite;
@ -50,6 +52,12 @@ public interface QuadEmitter extends MutableQuadView {
return this; return this;
} }
@Override
default QuadEmitter pos(int vertexIndex, Vector3fc pos) {
MutableQuadView.super.pos(vertexIndex, pos);
return this;
}
@Override @Override
QuadEmitter color(int vertexIndex, int color); QuadEmitter color(int vertexIndex, int color);
@ -68,6 +76,12 @@ public interface QuadEmitter extends MutableQuadView {
return this; return this;
} }
@Override
default QuadEmitter uv(int vertexIndex, Vector2fc uv) {
MutableQuadView.super.uv(vertexIndex, uv);
return this;
}
@Override @Override
QuadEmitter spriteBake(Sprite sprite, int bakeFlags); QuadEmitter spriteBake(Sprite sprite, int bakeFlags);
@ -97,6 +111,12 @@ public interface QuadEmitter extends MutableQuadView {
return this; return this;
} }
@Override
default QuadEmitter normal(int vertexIndex, Vector3fc normal) {
MutableQuadView.super.normal(vertexIndex, normal);
return this;
}
@Override @Override
QuadEmitter cullFace(@Nullable Direction face); QuadEmitter cullFace(@Nullable Direction face);