private void DrawOrbitInEditorFor(CelestialBody body) { int pointsCount = _simControl.SceneElementsDisplayParameters.OrbitPointsCount; if (body.isActiveAndEnabled) { if (!Application.isPlaying && body.AttractorRef != null && body.OrbitData.IsDirty) { if (body.AttractorRef.Mass <= 0) { body.AttractorRef.Mass = 1e-007;//to avoid div by zero } body.CalculateNewOrbitData(); } Handles.color = Color.white; Vector3d[] points = null; body.GetOrbitPointsNoAlloc(ref points, pointsCount, false, (float)_simControl.SceneElementsDisplayParameters.MaxOrbitDistance); for (int i = 1; i < points.Length; i++) { Handles.DrawLine((Vector3)points[i - 1], (Vector3)points[i]); } if (_simControl.SceneElementsDisplayParameters.DrawOrbitsEclipticProjection && points.Length > 0) { var point1 = points[0] - _simControl.EclipticNormal * CelestialBodyUtils.DotProduct(points[0], _simControl.EclipticNormal); var point2 = Vector3d.zero; Handles.color = Color.gray; for (int i = 1; i < points.Length; i++) { point2 = points[i] - _simControl.EclipticNormal * CelestialBodyUtils.DotProduct(points[i], _simControl.EclipticNormal); Handles.DrawLine((Vector3)point1, (Vector3)point2); point1 = point2; } } } }
private void DrawOrbit() { if (!LineRenderer) { CreateLineRend(); } if (LineRenderer.enabled) { LineRenderer.startWidth = Width; LineRenderer.endWidth = Width; _body.GetOrbitPointsNoAlloc(ref points, OrbitPointsCount, false, MaxOrbitPointsDistance); LineRenderer.positionCount = points.Length; for (int i = 0; i < points.Length; i++) { LineRenderer.SetPosition(i, points[i]); } LineRenderer.loop = _body.OrbitData.Eccentricity < 1.0; } }