mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 20:52:34 +00:00
Transform vertex normals as well as positions when generating quads (#5242)
This commit is contained in:
1 parent
f68fdcf703
commit
441a9c9024
10 files changed
+199
-141
No files matched your search
@@ -72,6 +72,8 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
private Vector3f scale;
|
||||
private Quat4f rightRot;
|
||||
|
||||
private Matrix3f normalTransform;
|
||||
|
||||
public TRSRTransformation(@Nullable Matrix4f matrix)
|
||||
{
|
||||
if(matrix == null)
|
||||
@@ -625,6 +627,29 @@ public final class TRSRTransformation implements IModelState, ITransformation
|
||||
return vertexIndex;
|
||||
}
|
||||
|
||||
public void transformPosition(Vector4f position)
|
||||
{
|
||||
matrix.transform(position);
|
||||
}
|
||||
|
||||
public void transformNormal(Vector3f normal)
|
||||
{
|
||||
checkNormalTransform();
|
||||
normalTransform.transform(normal);
|
||||
normal.normalize();
|
||||
}
|
||||
|
||||
private void checkNormalTransform()
|
||||
{
|
||||
if (normalTransform == null)
|
||||
{
|
||||
normalTransform = new Matrix3f();
|
||||
matrix.getRotationScale(normalTransform);
|
||||
normalTransform.invert();
|
||||
normalTransform.transpose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user