Added comments and slightly refactored code for deletion of temp node

This commit is contained in:
2026-05-01 16:44:52 +02:00
parent 643712f529
commit afd7aa50c4
3 changed files with 14 additions and 5 deletions

View File

@@ -219,6 +219,7 @@ pub const Simulator = struct {
self.highlighted_entity = null;
}
/// Returns array of IntersectionData struct, containing pointers to roads that got intersected and exact position
fn getIntersectingRoads(self: *const Simulator, allocator: std.mem.Allocator, start: *const Node, end: *const Node) ![]st.IntersectionData {
var intersections: std.ArrayList(st.IntersectionData) = .empty;
var collision_point: rl.Vector2 = undefined;
@@ -286,6 +287,7 @@ pub const Simulator = struct {
return sorted_intersection;
}
/// Takes the data about intersections and adds new nodes there alongside with linking existing roads to them
fn splitRoadsByIntersections(self: *Simulator, intersections: []st.IntersectionData, start: *Node, end: *Node) void {
if (intersections.len == 0) {
self.road_man.addRoad(self.allocator, start, end) catch |err| {