Allow passing UV coordinates as Vec2f

Rotating UV coordinates using vector math becomes extremely annoying when every `sprite` call requires the individual `u` and `v` coordinates to be extracted again.

This change will allow passing UV coordinates in a container that will always be available.
This commit is contained in:
yyny 2020-12-23 16:08:49 +01:00 committed by GitHub
parent 73b29211a6
commit b0fe27e0d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,6 +19,7 @@ package net.fabricmc.fabric.api.renderer.v1.mesh;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.math.Vector3f;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec2f;
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
import net.fabricmc.fabric.api.renderer.v1.render.RenderContext;
@ -90,6 +91,10 @@ public interface QuadEmitter extends MutableQuadView {
@Override
QuadEmitter sprite(int vertexIndex, int spriteIndex, float u, float v);
default QuadEmitter sprite(int vertexIndex, int spriteIndex, Vec2f uv) {
return sprite(vertexIndex, spriteIndex, uv.x, uv.y);
}
default QuadEmitter spriteUnitSquare(int spriteIndex) {
sprite(0, spriteIndex, 0, 0);
sprite(1, spriteIndex, 0, 1);