Transform vertex normals as well as positions when generating quads (#5242)

This commit is contained in:
Ben Staddon authored and tterrag committed 2019-04-25 18:29:12 -04:00
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()
{