mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Fix Transformation loading PoseStack (#9083)
This commit is contained in:
1 parent
f043fbbc51
commit
97a9ca65f1
3 files changed
+62
-12
No files matched your search
@@ -0,0 +1,11 @@
|
||||
--- a/com/mojang/blaze3d/vertex/PoseStack.java
|
||||
+++ b/com/mojang/blaze3d/vertex/PoseStack.java
|
||||
@@ -11,7 +_,7 @@
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
-public class PoseStack {
|
||||
+public class PoseStack implements net.minecraftforge.client.extensions.IForgePoseStack {
|
||||
private final Deque<PoseStack.Pose> f_85834_ = Util.m_137469_(Queues.newArrayDeque(), (p_85848_) -> {
|
||||
Matrix4f matrix4f = new Matrix4f();
|
||||
matrix4f.m_27624_();
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.extensions;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link com.mojang.blaze3d.vertex.PoseStack}.
|
||||
*/
|
||||
public interface IForgePoseStack
|
||||
{
|
||||
private PoseStack self()
|
||||
{
|
||||
return (PoseStack) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes and applies the {@code transformation} to this pose stack. <br>
|
||||
* The effects of this method can be reversed by a corresponding {@link PoseStack#popPose()} call.
|
||||
*
|
||||
* @param transformation the transformation to push
|
||||
*/
|
||||
default void pushTransformation(Transformation transformation)
|
||||
{
|
||||
final PoseStack self = self();
|
||||
self.pushPose();
|
||||
|
||||
Vector3f trans = transformation.getTranslation();
|
||||
self.translate(trans.x(), trans.y(), trans.z());
|
||||
|
||||
self.mulPose(transformation.getLeftRotation());
|
||||
|
||||
Vector3f scale = transformation.getScale();
|
||||
self.scale(scale.x(), scale.y(), scale.z());
|
||||
|
||||
self.mulPose(transformation.getRightRotation());
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,13 @@ import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Transformation;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
/**
|
||||
* Extension interface for {@link Transformation}.
|
||||
*/
|
||||
// TODO - 1.20: Transformation is not client-only, move this extension outside the client package
|
||||
public interface IForgeTransformation
|
||||
{
|
||||
private Transformation self()
|
||||
@@ -37,22 +40,15 @@ public interface IForgeTransformation
|
||||
* Pushes and applies this transformation to the pose stack. The effects of this method can be reversed by a
|
||||
* corresponding {@link PoseStack#popPose()}.
|
||||
*
|
||||
* @deprecated Use {@linkplain PoseStack#pushTransformation(Transformation)}, as {@linkplain Transformation} can be present in common code.
|
||||
*
|
||||
* @param stack the pose stack to modify
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT) // TODO - 1.20: Remove in favour of client-only PoseStack extension
|
||||
@Deprecated(forRemoval = true, since = "1.19.2")
|
||||
default void push(PoseStack stack)
|
||||
{
|
||||
stack.pushPose();
|
||||
|
||||
Vector3f trans = self().getTranslation();
|
||||
stack.translate(trans.x(), trans.y(), trans.z());
|
||||
|
||||
stack.mulPose(self().getLeftRotation());
|
||||
|
||||
Vector3f scale = self().getScale();
|
||||
stack.scale(scale.x(), scale.y(), scale.z());
|
||||
|
||||
stack.mulPose(self().getRightRotation());
|
||||
|
||||
stack.pushTransformation(self());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user