Skip to content

Commit 0bcefb0

Browse files
CensoredUsernamePhantomical
authored andcommitted
Small simplification of FlightIntergratorPerf.SetDragCubeDrag (#336)
Small simplification of FlightIntergratorPerf.SetDragCubeDrag: no need to normalize and immediately denormalize.
1 parent f2dd72b commit 0bcefb0

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

KSPCommunityFixes/Performance/FlightIntegratorPerf.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,12 @@ private static void SetDragCubeDrag(DragCubeList dragCubes, Vector3 direction)
757757
double weightedDrag = dragCubes.weightedDrag[i];
758758

759759
double dot = Vector3.Dot(direction, faceDir);
760-
double dotNormalized = (dot + 1.0) * 0.5;
761760
double drag; // = PhysicsGlobals.DragCurveValue(__instance.SurfaceCurves, dotNormalized, machNumber);
762761

763-
if (dotNormalized <= 0.5)
764-
drag = Numerics.Lerp(fiData.dragTail, fiData.dragSurf, dotNormalized * 2.0) * fiData.dragMult;
762+
if (dot <= 0.0)
763+
drag = Numerics.Lerp(fiData.dragSurf, fiData.dragTail, -dot) * fiData.dragMult;
765764
else
766-
drag = Numerics.Lerp(fiData.dragSurf, fiData.dragTip, (dotNormalized - 0.5) * 2.0) * fiData.dragMult;
765+
drag = Numerics.Lerp(fiData.dragSurf, fiData.dragTip, dot) * fiData.dragMult;
767766

768767
double areaOccludedByDrag = areaOccluded * drag;
769768
area += areaOccludedByDrag;

0 commit comments

Comments
 (0)