Skip to content

Commit e4ba0d7

Browse files
committed
Adjust normal vector direction based on rotation
1 parent f9e62b1 commit e4ba0d7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Source/RunActivity/Viewer3D/SuperElevation.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,17 @@ public override ShapePrimitive BuildPrimitive(Viewer viewer, int iLOD, int iLODI
722722
SuperElevationRoll = DetermineRotation();
723723

724724
Matrix displacement;
725+
Matrix rotation;
725726
float totLength;
726727

727728
if (DTrackData.IsCurved == 0)
728729
displacement = LinearGen(out totLength);
729730
else
730731
displacement = CircArcGen(out totLength);
731732

733+
rotation = displacement;
734+
rotation.Translation = Vector3.Zero;
735+
732736
foreach (Polyline pl in lodItem.Polylines)
733737
{
734738
uint plv = 0; // Polyline vertex index
@@ -764,7 +768,7 @@ public override ShapePrimitive BuildPrimitive(Viewer viewer, int iLOD, int iLODI
764768
// Move vertex to proper location in 3D space
765769
VertexList[VertexIndex].Position = Vector3.Transform(p, displacement);
766770
VertexList[VertexIndex].TextureCoordinate = v.TexCoord + pl.DeltaTexCoord * totLength;
767-
VertexList[VertexIndex].Normal = v.Normal;
771+
VertexList[VertexIndex].Normal = Vector3.Transform(v.Normal, rotation);
768772

769773
if (plv > 0 && VertexIndex > stride)
770774
{

0 commit comments

Comments
 (0)