private void FindTangent(TrackGeometry component, TrackWaypoint waypoint) { var next = component.Next(waypoint); var previous = component.Previous(waypoint); var normal0 = next.position - waypoint.position; var normal1 = waypoint.position - previous.position; var tangent0 = Vector3.Cross(normal0, waypoint.up).normalized; var tangent1 = Vector3.Cross(normal1, waypoint.up).normalized; var tangent = Vector3.Lerp(tangent0, tangent1, 0.5f).normalized; waypoint.tangent = tangent; }
static void DrawGizmoForWaypointsEditor(TrackGeometry component, GizmoType gizmoType) { Profiler.BeginSample("Draw Waypoints Editor"); foreach (var waypoint in component.waypoints) { var size = 1f; if (waypoint.index == 0) { size = 2f; } Gizmos.color = Color.green; if (waypoint.nospawn) { Gizmos.color = new Color(1f, 0.8f, 1f, 1); } if (waypoint.jump) { Gizmos.color = new Color(0.5f, 0.5f, 1f, 1); } Gizmos.DrawWireSphere(waypoint.position, size); } Gizmos.color = Color.yellow; foreach (var waypoint in component.highlighted) { Gizmos.DrawWireSphere(waypoint.position, 1f); } Gizmos.color = Color.red; foreach (var waypoint in component.selected) { Gizmos.DrawWireSphere(waypoint.position, 1f); } Gizmos.color = Color.green; for (int i = 0; i < component.waypoints.Count; i++) { var waypoint = component.waypoints[i]; var next = component.Next(waypoint); Gizmos.DrawLine(waypoint.position, next.position); Gizmos.DrawLine(waypoint.left, waypoint.right); Gizmos.DrawLine(waypoint.left, next.left); Gizmos.DrawLine(waypoint.right, next.right); } if (createWaypoints) { Gizmos.color = Color.yellow; if (component.highlightedPoint != null && component.lastSelected != null) { Gizmos.DrawLine(component.lastSelected.position, component.highlightedPoint.Value); Gizmos.DrawLine(component.lastSelected.position, component.Next(component.lastSelected).position); } } Profiler.EndSample(); if (component.broadphase1d == null) { component.InitialiseBroadphase(); } //component.broadphase.OnDrawGizmos(); }