/// <summary>Draw gizmos for the graph</summary> public virtual void OnDrawGizmos(DrawingData gizmos, bool drawNodes, RedrawScope redrawScope) { if (!drawNodes) { return; } // This is a relatively slow default implementation. // subclasses of the base graph class may override // this method to draw gizmos in a more optimized way var hasher = new NodeHasher(active); GetNodes(node => hasher.HashNode(node)); // Update the gizmo mesh if necessary if (!gizmos.Draw(hasher, redrawScope)) { using (var helper = GraphGizmoHelper.GetGizmoHelper(gizmos, active, hasher, redrawScope)) { GetNodes((System.Action <GraphNode>)helper.DrawConnections); } } if (active.showUnwalkableNodes) { DrawUnwalkableNodes(gizmos, active.unwalkableNodeDebugSize, redrawScope); } }
// static Color ObstacleColor = new Color(255/255f, 60/255f, 15/255f, 1.0f); public override void DrawGizmos() { // Prevent interfering with scene view picking //if (Event.current.type != EventType.Repaint) return; #if FALSE if (drawObstacles && simulatorBurst != null && simulatorBurst.obstacles != null) { var hasher = DrawingData.Hasher.Create(this); var obstacles = simulatorBurst.obstacles; int numEdges = 0; for (int i = 0; i < obstacles.Count; i++) { var vertex = obstacles[i]; do { hasher.Add(vertex.position.GetHashCode() ^ vertex.height.GetHashCode()); numEdges++; vertex = vertex.next; } while (vertex != obstacles[i] && vertex != null); } if (!DrawingManager.instance.gizmos.Draw(hasher)) { Profiler.BeginSample("Rebuild RVO Obstacle Gizmos"); using (var helper = GraphGizmoHelper.GetGizmoHelper(DrawingManager.instance.gizmos, null, hasher, default)) { var up = movementPlane == MovementPlane.XY ? Vector3.back : Vector3.up; var vertices = new Vector3[numEdges * 6]; var colors = new Color[numEdges * 6]; int edgeIndex = 0; for (int i = 0; i < obstacles.Count; i++) { var start = obstacles[i]; var c = start; do { vertices[edgeIndex * 6 + 0] = c.position; vertices[edgeIndex * 6 + 1] = c.next.position; vertices[edgeIndex * 6 + 2] = c.next.position + up * c.next.height; vertices[edgeIndex * 6 + 3] = c.position; vertices[edgeIndex * 6 + 4] = c.next.position + up * c.next.height; vertices[edgeIndex * 6 + 5] = c.position + up * c.height; edgeIndex++; c = c.next; } while (c != start && c != null && c.next != null); } for (int i = 0; i < colors.Length; i++) { colors[i] = ObstacleColor; } helper.DrawTriangles(vertices, colors, numEdges * 2); } Profiler.EndSample(); } } #endif }