Skip to content

Commit

Permalink
xform normals in meshtransforms.rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed May 16, 2018
1 parent c3cbf65 commit a7dfecd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mesh/MeshTransforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ public static Vector3d Rotate(Vector3d pos, Vector3d origin, Quaterniond rotatio
}
public static void Rotate(IDeformableMesh mesh, Vector3d origin, Quaterniond rotation)
{
bool bHasNormals = mesh.HasVertexNormals;
int NV = mesh.MaxVertexID;
for (int vid = 0; vid < NV; ++vid) {
if (mesh.IsVertex(vid)) {
Vector3d v = rotation * (mesh.GetVertex(vid) - origin) + origin;
mesh.SetVertex(vid, v);
if ( bHasNormals )
mesh.SetVertexNormal(vid, (Vector3f)(rotation * mesh.GetVertexNormal(vid)) );
}
}
}
Expand Down

0 comments on commit a7dfecd

Please sign in to comment.