Skip to content

Commit

Permalink
Renderer API quads overloads for joml interfaces (#3875)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0ae0b97)
  • Loading branch information
SHsuperCM authored and modmuss50 committed Jun 25, 2024
1 parent 7fc4b35 commit 81dac6a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

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;
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -145,6 +154,16 @@ default MutableQuadView uv(int vertexIndex, Vector2f uv) {
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.
* Can handle UV locking, rotation, interpolation, etc. Control this behavior
Expand Down Expand Up @@ -190,6 +209,13 @@ default MutableQuadView lightmap(int b0, int b1, int b2, int b3) {
* 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

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;
Expand Down Expand Up @@ -50,6 +52,12 @@ default QuadEmitter pos(int vertexIndex, Vector3f pos) {
return this;
}

@Override
default QuadEmitter pos(int vertexIndex, Vector3fc pos) {
MutableQuadView.super.pos(vertexIndex, pos);
return this;
}

@Override
QuadEmitter color(int vertexIndex, int color);

Expand All @@ -68,6 +76,12 @@ default QuadEmitter uv(int vertexIndex, Vector2f uv) {
return this;
}

@Override
default QuadEmitter uv(int vertexIndex, Vector2fc uv) {
MutableQuadView.super.uv(vertexIndex, uv);
return this;
}

@Override
QuadEmitter spriteBake(Sprite sprite, int bakeFlags);

Expand Down Expand Up @@ -97,6 +111,12 @@ default QuadEmitter normal(int vertexIndex, Vector3f normal) {
return this;
}

@Override
default QuadEmitter normal(int vertexIndex, Vector3fc normal) {
MutableQuadView.super.normal(vertexIndex, normal);
return this;
}

@Override
QuadEmitter cullFace(@Nullable Direction face);

Expand Down

0 comments on commit 81dac6a

Please sign in to comment.