aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils/render/MatrixHelper.java
blob: 220dbf866ebe613273a0cd9083c2399983f5ec53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package de.hysky.skyblocker.utils.render;

import org.joml.Matrix4f;

import net.minecraft.client.util.math.MatrixStack;

/**
 * Matrix helper methods
 */
public interface MatrixHelper {

	/**
	 * Copies the {@code matrix} into a new {@link Matrix4f}. This is necessary otherwise
	 * any transformations applied will affect other uses of the same matrix.
	 */
	static Matrix4f copyOf(Matrix4f matrix) {
		return new Matrix4f(matrix);
	}

	/**
	 * Creates a blank {@link MatrixStack} and sets it's position matrix to the supplied
	 * {@code positionMatrix}.
	 */
	static MatrixStack toStack(Matrix4f positionMatrix) {
		MatrixStack matrices = new MatrixStack();
		matrices.peek().getPositionMatrix().set(positionMatrix);

		return matrices;
	}
}