mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
Allow passing UV coordinates as Vec2f (#1238)
* 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. * Revertb0fe27e0d7
* Allow Vec2f UVs in MutableQuadView This seems like the better place to put this. * Fix return type oops * Add override in QuadEmitter * Fix JavaDoc styling * Duplicate JavaDoc and function definition There is probably a way in Java to override the method while keeping the JavaDoc, but I can't be bothered, and this way, the user gets a more relevant JavaDoc anyway. * Remove Trailing Whitespace I'm pretty sure QuadEmitter allowed trailing whitespace, though... * Fix JavaDoc styling in QuadEmitter Also removes trailing whitespace (cherry picked from commit00f5b23648
)
This commit is contained in:
parent
ed5162f849
commit
35ad3817d3
2 changed files with 22 additions and 0 deletions
fabric-renderer-api-v1/src/main/java/net/fabricmc/fabric/api/renderer/v1/mesh
|
@ -22,6 +22,7 @@ import net.minecraft.client.render.model.BakedQuad;
|
|||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec2f;
|
||||
|
||||
import net.fabricmc.fabric.api.renderer.v1.Renderer;
|
||||
import net.fabricmc.fabric.api.renderer.v1.material.MaterialFinder;
|
||||
|
@ -247,6 +248,16 @@ public interface MutableQuadView extends QuadView {
|
|||
*/
|
||||
MutableQuadView sprite(int vertexIndex, int spriteIndex, float u, float v);
|
||||
|
||||
/**
|
||||
* Set sprite atlas coordinates. Behavior for {@code spriteIndex > 0} is currently undefined.
|
||||
*
|
||||
* <p>Only use this function if you already have a {@link Vec2f}.
|
||||
* Otherwise, see {@link MutableQuadView#sprite(int, int, float, float)}.
|
||||
*/
|
||||
default MutableQuadView sprite(int vertexIndex, int spriteIndex, Vec2f uv) {
|
||||
return sprite(vertexIndex, spriteIndex, 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
|
||||
|
|
|
@ -19,6 +19,7 @@ package net.fabricmc.fabric.api.renderer.v1.mesh;
|
|||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
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,16 @@ public interface QuadEmitter extends MutableQuadView {
|
|||
@Override
|
||||
QuadEmitter sprite(int vertexIndex, int spriteIndex, float u, float v);
|
||||
|
||||
/**
|
||||
* Set sprite atlas coordinates. Behavior for {@code spriteIndex > 0} is currently undefined.
|
||||
*
|
||||
* <p>Only use this function if you already have a {@link Vec2f}.
|
||||
* Otherwise, see {@link QuadEmitter#sprite(int, int, float, float)}.
|
||||
*/
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue