Fixed splitting quirks when only one intersection is found and the intersection itself is origin node

This commit is contained in:
2026-05-01 20:46:09 +02:00
parent f7a1340500
commit fdf672de4b
2 changed files with 42 additions and 7 deletions

View File

@@ -3,7 +3,12 @@ const Vector2 = @import("raylib").Vector2;
const Road = @import("../infrastructure/road.zig").Road;
const Node = @import("../infrastructure/node.zig").Node;
/// Can point to either entity type (node, road, etc.)
/// This is a simple equivalent to something like abstract class, so the simulator class has only one variable
/// which tracks which object is highlighted and the logic that seeks to find the current highlighted class doesn't need
/// to figure out which highlighted entity has priority in case of overlap;
/// given that car can be on node and road, and node itself is on road(s)
///
/// TLDR: Can point to either entity type (node, road, etc.)
pub const Entity = union(enum) {
node: *Node,
road: *Road,
@@ -16,4 +21,11 @@ pub const IntersectionData = struct {
pos: Vector2,
/// Points to the road where the intersection occured
road: *Road,
/// Tracks whether this intersection is actually an origin point
/// (In simple terms this means whether the point/node that intersects is also the start/end node)
///
/// We do this because the referencing logic is very strict and will return an error
/// if we try to reference something that is already referenced, due to stricter approach helping with
/// earlier bug and error detection
origin: bool,
};