@@ -184,17 +184,17 @@ private void ShowOverlay(bool viewOnly, RenderManager.CameraInfo cameraInfo) {
184184
185185 foreach ( NodeLaneMarker targetLaneMarker in laneMarker . ConnectedMarkers ) {
186186 // render lane connection from laneMarker to targetLaneMarker
187- if ( ! Constants . ServiceFactory . NetService . IsLaneValid (
188- targetLaneMarker . LaneId ) ) {
187+ if ( ! Constants . ServiceFactory . NetService . IsLaneValid ( targetLaneMarker . LaneId ) ) {
189188 continue ;
190189 }
191190
192- RenderLane (
191+ DrawLaneCurve (
193192 cameraInfo ,
194193 laneMarker . Position ,
195194 targetLaneMarker . Position ,
196195 NetManager . instance . m_nodes . m_buffer [ nodeId ] . m_position ,
197- laneMarker . Color ) ;
196+ laneMarker . Color ,
197+ Color . black ) ;
198198 }
199199
200200 if ( viewOnly || ( nodeId != SelectedNodeId ) ) {
@@ -235,22 +235,30 @@ bool drawMarker
235235 }
236236
237237 if ( markerIsHovered ) {
238- // if (hoveredMarker != sourceLaneMarker)
239- // Log._Debug($"Marker @ lane {sourceLaneMarker.laneId} hovered");
240238 hoveredMarker = laneMarker ;
241239 }
242240
241+ var circleColor = laneMarker . IsTarget ? Color . white : laneMarker . Color ;
242+
243243 if ( drawMarker ) {
244- // DrawLaneMarker(laneMarker, cameraInfo);
245244 RenderManager . instance . OverlayEffect . DrawCircle (
246245 cameraInfo ,
247- laneMarker . Color ,
246+ circleColor ,
248247 laneMarker . Position ,
249248 laneMarker . Radius ,
250- laneMarker . Position . y - 100f ,
249+ laneMarker . Position . y - 100f , // through all the geometry -100..100
251250 laneMarker . Position . y + 100f ,
252251 false ,
253252 true ) ;
253+ RenderManager . instance . OverlayEffect . DrawCircle (
254+ cameraInfo ,
255+ Color . black ,
256+ laneMarker . Position ,
257+ laneMarker . Radius * 0.75f , // inner black
258+ laneMarker . Position . y - 100f , // through all the geometry -100..100
259+ laneMarker . Position . y + 100f ,
260+ false ,
261+ false ) ;
254262 }
255263 } // end foreach lanemarker in node markers
256264 } // end for node in all nodes
@@ -288,13 +296,15 @@ public override void RenderOverlay(RenderManager.CameraInfo cameraInfo) {
288296 NetManager . instance . m_nodes . m_buffer [ SelectedNodeId ] . m_position ;
289297
290298 ToolBase . RaycastOutput output ;
299+ // Draw a currently dragged curve
291300 if ( RayCastSegmentAndNode ( out output ) ) {
292- RenderLane (
301+ DrawLaneCurve (
293302 cameraInfo ,
294303 selectedMarker . Position ,
295304 output . m_hitPos ,
296305 selNodePos ,
297- selectedMarker . Color ) ;
306+ Color . Lerp ( selectedMarker . Color , Color . white , 0.33f ) ,
307+ Color . white ) ;
298308 }
299309 }
300310
@@ -641,6 +651,7 @@ private List<NodeLaneMarker> GetNodeMarkers(ushort nodeId, ref NetNode node) {
641651 }
642652
643653 List < NodeLaneMarker > nodeMarkers = new List < NodeLaneMarker > ( ) ;
654+ int nodeMarkerColorIndex = 0 ;
644655 LaneConnectionManager connManager = LaneConnectionManager . Instance ;
645656
646657 int offsetMultiplier = node . CountSegments ( ) <= 2 ? 3 : 1 ;
@@ -675,17 +686,19 @@ private List<NodeLaneMarker> GetNodeMarkers(ushort nodeId, ref NetNode node) {
675686 laneInfo ,
676687 out bool isSource ,
677688 out bool isTarget ,
678- out Vector3 ? pos ) ) {
679- pos = ( Vector3 ) pos + offset ;
689+ out Vector3 ? pos ) )
690+ {
691+ pos = pos . Value + offset ;
680692
681693 float terrainY =
682- Singleton < TerrainManager > . instance . SampleDetailHeightSmooth (
683- ( ( Vector3 ) pos ) ) ;
694+ Singleton < TerrainManager > . instance . SampleDetailHeightSmooth ( pos . Value ) ;
695+
696+ var finalPos = new Vector3 ( pos . Value . x , terrainY , pos . Value . z ) ;
684697
685- Vector3 finalPos = new Vector3 (
686- ( ( Vector3 ) pos ) . x ,
687- terrainY ,
688- ( ( Vector3 ) pos ) . z ) ;
698+ Color32 nodeMarkerColor
699+ = isSource
700+ ? COLOR_CHOICES [ nodeMarkerColorIndex % COLOR_CHOICES . Length ]
701+ : default ; // or black (not used while rendering)
689702
690703 nodeMarkers . Add (
691704 new NodeLaneMarker {
@@ -695,7 +708,7 @@ private List<NodeLaneMarker> GetNodeMarkers(ushort nodeId, ref NetNode node) {
695708 StartNode = ! isEndNode ,
696709 Position = finalPos ,
697710 SecondaryPosition = ( Vector3 ) pos ,
698- Color = ColorChoices [ nodeMarkers . Count % ColorChoices . Length ] ,
711+ Color = nodeMarkerColor ,
699712 IsSource = isSource ,
700713 IsTarget = isTarget ,
701714 LaneType = laneInfo . m_laneType ,
@@ -707,6 +720,10 @@ private List<NodeLaneMarker> GetNodeMarkers(ushort nodeId, ref NetNode node) {
707720 laneInfo . m_similarLaneIndex - 1 ,
708721 SegmentIndex = i
709722 } ) ;
723+
724+ if ( isSource ) {
725+ nodeMarkerColorIndex ++ ;
726+ }
710727 }
711728 }
712729
@@ -789,12 +806,23 @@ private bool CheckSegmentsTurningAngle(ushort sourceSegmentId,
789806 return true ;
790807 }
791808
792- private void RenderLane ( RenderManager . CameraInfo cameraInfo ,
793- Vector3 start ,
794- Vector3 end ,
795- Vector3 middlePoint ,
796- Color color ,
797- float size = 0.1f ) {
809+ /// <summary>
810+ /// Draw a bezier curve from `start` to `end` and bent towards `middlePoint` with `color`
811+ /// </summary>
812+ /// <param name="cameraInfo">The camera to use</param>
813+ /// <param name="start">Where the bezier to begin</param>
814+ /// <param name="end">Where the bezier to end</param>
815+ /// <param name="middlePoint">Where the bezier is bent towards</param>
816+ /// <param name="color">The inner curve color</param>
817+ /// <param name="outlineColor">The outline color</param>
818+ /// <param name="size">The thickness</param>
819+ private void DrawLaneCurve ( RenderManager . CameraInfo cameraInfo ,
820+ Vector3 start ,
821+ Vector3 end ,
822+ Vector3 middlePoint ,
823+ Color color ,
824+ Color outlineColor ,
825+ float size = 0.1f ) {
798826 Bezier3 bezier ;
799827 bezier . a = start ;
800828 bezier . d = end ;
@@ -809,6 +837,19 @@ private void RenderLane(RenderManager.CameraInfo cameraInfo,
809837 out bezier . b ,
810838 out bezier . c ) ;
811839
840+ // Draw black outline
841+ RenderManager . instance . OverlayEffect . DrawBezier (
842+ cameraInfo ,
843+ outlineColor ,
844+ bezier ,
845+ size * 1.5f ,
846+ 0 ,
847+ 0 ,
848+ - 1f ,
849+ 1280f ,
850+ false ,
851+ false ) ;
852+ // Inside the outline draw colored bezier
812853 RenderManager . instance . OverlayEffect . DrawBezier (
813854 cameraInfo ,
814855 color ,
@@ -836,56 +877,40 @@ private bool RayCastSegmentAndNode(out ToolBase.RaycastOutput output) {
836877 return MainTool . DoRayCast ( input , out output ) ;
837878 }
838879
839- private static readonly Color32 [ ] ColorChoices
880+ /// <summary>
881+ /// Generated with http://phrogz.net/css/distinct-colors.html
882+ /// HSV Value start 84%, end 37% (cutting away too bright and too dark).
883+ /// The colors are slightly reordered to create some variety
884+ /// </summary>
885+ private static readonly Color32 [ ] COLOR_CHOICES
840886 = {
841- new Color32 ( 161 , 64 , 206 , 255 ) ,
842- new Color32 ( 79 , 251 , 8 , 255 ) ,
843- new Color32 ( 243 , 96 , 44 , 255 ) ,
844- new Color32 ( 45 , 106 , 105 , 255 ) ,
845- new Color32 ( 253 , 165 , 187 , 255 ) ,
846- new Color32 ( 90 , 131 , 14 , 255 ) ,
847- new Color32 ( 58 , 20 , 70 , 255 ) ,
848- new Color32 ( 248 , 246 , 183 , 255 ) ,
849- new Color32 ( 255 , 205 , 29 , 255 ) ,
850- new Color32 ( 91 , 50 , 18 , 255 ) ,
851- new Color32 ( 76 , 239 , 155 , 255 ) ,
852- new Color32 ( 241 , 25 , 130 , 255 ) ,
853- new Color32 ( 125 , 197 , 240 , 255 ) ,
854- new Color32 ( 57 , 102 , 187 , 255 ) ,
855- new Color32 ( 160 , 27 , 61 , 255 ) ,
856- new Color32 ( 167 , 251 , 107 , 255 ) ,
857- new Color32 ( 165 , 94 , 3 , 255 ) ,
858- new Color32 ( 204 , 18 , 161 , 255 ) ,
859- new Color32 ( 208 , 136 , 237 , 255 ) ,
860- new Color32 ( 232 , 211 , 202 , 255 ) ,
861- new Color32 ( 45 , 182 , 15 , 255 ) ,
862- new Color32 ( 8 , 40 , 47 , 255 ) ,
863- new Color32 ( 249 , 172 , 142 , 255 ) ,
864- new Color32 ( 248 , 99 , 101 , 255 ) ,
865- new Color32 ( 180 , 250 , 208 , 255 ) ,
866- new Color32 ( 126 , 25 , 77 , 255 ) ,
867- new Color32 ( 243 , 170 , 55 , 255 ) ,
868- new Color32 ( 47 , 69 , 126 , 255 ) ,
869- new Color32 ( 50 , 105 , 70 , 255 ) ,
870- new Color32 ( 156 , 49 , 1 , 255 ) ,
871- new Color32 ( 233 , 231 , 255 , 255 ) ,
872- new Color32 ( 107 , 146 , 253 , 255 ) ,
873- new Color32 ( 127 , 35 , 26 , 255 ) ,
874- new Color32 ( 240 , 94 , 222 , 255 ) ,
875- new Color32 ( 58 , 28 , 24 , 255 ) ,
876- new Color32 ( 165 , 179 , 240 , 255 ) ,
877- new Color32 ( 239 , 93 , 145 , 255 ) ,
878- new Color32 ( 47 , 110 , 138 , 255 ) ,
879- new Color32 ( 57 , 195 , 101 , 255 ) ,
880- new Color32 ( 124 , 88 , 213 , 255 ) ,
881- new Color32 ( 252 , 220 , 144 , 255 ) ,
882- new Color32 ( 48 , 106 , 224 , 255 ) ,
883- new Color32 ( 90 , 109 , 28 , 255 ) ,
884- new Color32 ( 56 , 179 , 208 , 255 ) ,
885- new Color32 ( 239 , 73 , 177 , 255 ) ,
886- new Color32 ( 84 , 60 , 2 , 255 ) ,
887- new Color32 ( 169 , 104 , 238 , 255 ) ,
888- new Color32 ( 97 , 201 , 238 , 255 ) ,
887+ new Color32 ( 240 , 30 , 30 , 255 ) ,
888+ new Color32 ( 80 , 214 , 0 , 255 ) ,
889+ new Color32 ( 30 , 30 , 214 , 255 ) ,
890+ new Color32 ( 214 , 136 , 107 , 255 ) ,
891+ new Color32 ( 120 , 189 , 94 , 255 ) ,
892+ new Color32 ( 106 , 41 , 163 , 255 ) ,
893+ new Color32 ( 54 , 118 , 214 , 255 ) ,
894+ new Color32 ( 163 , 57 , 41 , 255 ) ,
895+ new Color32 ( 54 , 161 , 214 , 255 ) ,
896+ new Color32 ( 107 , 214 , 193 , 255 ) ,
897+ new Color32 ( 214 , 161 , 175 , 255 ) ,
898+ new Color32 ( 214 , 0 , 171 , 255 ) ,
899+ new Color32 ( 151 , 178 , 201 , 255 ) ,
900+ new Color32 ( 189 , 101 , 0 , 255 ) ,
901+ new Color32 ( 154 , 142 , 189 , 255 ) ,
902+ new Color32 ( 189 , 186 , 142 , 255 ) ,
903+ new Color32 ( 176 , 88 , 147 , 255 ) ,
904+ new Color32 ( 163 , 41 , 73 , 255 ) ,
905+ new Color32 ( 150 , 140 , 0 , 255 ) ,
906+ new Color32 ( 0 , 140 , 150 , 255 ) ,
907+ new Color32 ( 0 , 0 , 138 , 255 ) ,
908+ new Color32 ( 0 , 60 , 112 , 255 ) ,
909+ new Color32 ( 112 , 86 , 56 , 255 ) ,
910+ new Color32 ( 88 , 112 , 84 , 255 ) ,
911+ new Color32 ( 0 , 99 , 53 , 255 ) ,
912+ new Color32 ( 75 , 75 , 99 , 255 ) ,
913+ new Color32 ( 99 , 75 , 85 , 255 )
889914 } ;
890915 }
891916}
0 commit comments