diff --git a/README.md b/README.md index f363ce92..10caf2ae 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ User manual: http://www.viathinksoft.de/tmpe 1.8.13, 01/01/2017 - Bugfix: Timed traffic ligt data can become corrupt when upgrading a road segment next to a traffic light, leading to faulty UI behavior (thanks to @Brain for reporting this issue) - Bugfix: The position of the main menu button resets after switching to the free camera mode (thanks to @Impact and @gravage for reporting this issue) +- Bugfix: A division by zero exception can occur when calculating the average number of waiting/floating vehicles - Improved selection of overlay markers on underground roads (thanks to @Padi for reminding me of that issue) - Minor performance improvements diff --git a/TLM/TLM/Traffic/SegmentEnd.cs b/TLM/TLM/Traffic/SegmentEnd.cs index 4b8cd9ce..48a1f403 100644 --- a/TLM/TLM/Traffic/SegmentEnd.cs +++ b/TLM/TLM/Traffic/SegmentEnd.cs @@ -186,7 +186,9 @@ public Dictionary GetVehicleMetricGoingToSegment(bool includeStopp if (Options.simAccuracy <= 2) { uint avgSegmentLength = (uint)netManager.m_segments.m_buffer[SegmentId].m_averageLength; - uint normLength = Math.Min(100u, (uint)(state.TotalLength * 100u) / avgSegmentLength); + uint normLength = 100u; + if (avgSegmentLength > 0) + normLength = Math.Min(100u, (uint)(state.TotalLength * 100u) / avgSegmentLength); #if DEBUGMETRIC if (debug) diff --git a/TLM/TLM/UI/SubTools/LaneConnectorTool.cs b/TLM/TLM/UI/SubTools/LaneConnectorTool.cs index cdc37712..75855144 100644 --- a/TLM/TLM/UI/SubTools/LaneConnectorTool.cs +++ b/TLM/TLM/UI/SubTools/LaneConnectorTool.cs @@ -42,6 +42,7 @@ class NodeLaneMarker { internal ushort nodeId; internal bool startNode; internal Vector3 position; + internal Vector3 secondaryPosition; internal bool isSource; internal uint laneId; internal int innerSimilarLaneIndex; @@ -136,10 +137,13 @@ private void ShowOverlay(bool viewOnly, RenderManager.CameraInfo cameraInfo) { } private bool IsLaneMarkerHovered(NodeLaneMarker laneMarker, ref Ray mouseRay) { - - float y = Singleton.instance.SampleDetailHeightSmooth(laneMarker.position); Bounds bounds = new Bounds(Vector3.zero, Vector3.one); - bounds.center = new Vector3(laneMarker.position.x, y, laneMarker.position.z); + bounds.center = laneMarker.position; + if (bounds.IntersectRay(mouseRay)) + return true; + + bounds = new Bounds(Vector3.zero, Vector3.one); + bounds.center = laneMarker.secondaryPosition; return bounds.IntersectRay(mouseRay); } @@ -430,7 +434,7 @@ private List GetNodeMarkers(ushort nodeId) { pos = (Vector3)pos + offset; float terrainY = Singleton.instance.SampleDetailHeightSmooth(((Vector3)pos)); - Vector3 finalPos = new Vector3(((Vector3)pos).x, terrainY > ((Vector3)pos).y ? terrainY : ((Vector3)pos).y, ((Vector3)pos).z); + Vector3 finalPos = new Vector3(((Vector3)pos).x, terrainY, ((Vector3)pos).z); nodeMarkers.Add(new NodeLaneMarker() { segmentId = segmentId, @@ -438,6 +442,7 @@ private List GetNodeMarkers(ushort nodeId) { nodeId = nodeId, startNode = !isEndNode, position = finalPos, + secondaryPosition = (Vector3)pos, color = colors[nodeMarkers.Count], isSource = isSource, laneType = laneInfo.m_laneType,