Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions common/src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,55 @@ mod tests {
assert_eq!(graph.nodes[&other].depth, 2);
}

#[test]
fn edge_diagonal_has_both_carrier_parents_before_state_generation() {
let mut graph = Graph::new(1);
let a = graph.ensure_neighbor(NodeId::ROOT, Side::A);
let b = graph.ensure_neighbor(NodeId::ROOT, Side::B);
let ab_from_a = graph.ensure_neighbor(a, Side::B);
let ab_from_b = graph.ensure_neighbor(b, Side::A);

assert_eq!(ab_from_a, ab_from_b);
assert_eq!(
graph.parents(ab_from_a).collect::<Vec<_>>(),
vec![(Side::A, b), (Side::B, a)]
);
}

#[test]
fn vertex_diagonal_has_all_three_carrier_parents_before_state_generation() {

@patowen patowen Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these tests are needed. It should already be common knowledge in the code-base that if a NodeState exists, so do all of its ancestor NodeStates.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

About 1,000 lines are in the tests, while the actual implementation is about 550 lines in total, including the existing megatree code.

I can go through the newly added tests and remove the unnecessary ones if you want.

I understand that the implementation itself is still fairly large, so I'll also investigate whether the propagation logic can be simplified.

let [a_side, b_side, c_side] = crate::dodeca::Vertex::A.canonical_sides();
let permutations = [
[a_side, b_side, c_side],
[a_side, c_side, b_side],
[b_side, a_side, c_side],
[b_side, c_side, a_side],
[c_side, a_side, b_side],
[c_side, b_side, a_side],
];
let mut graph = Graph::new(1);
let mut targets = Vec::new();

for [first, second, third] in permutations {
let first_node = graph.ensure_neighbor(NodeId::ROOT, first);
let second_node = graph.ensure_neighbor(first_node, second);
targets.push(graph.ensure_neighbor(second_node, third));
}

let target = targets[0];
assert!(targets.into_iter().all(|candidate| candidate == target));
assert_eq!(graph.depth(target), 3);
let parents = graph.parents(target).collect::<Vec<_>>();
assert_eq!(parents.len(), 3);
assert!(parents.iter().all(|(_, parent)| graph.depth(*parent) == 2));
let a = graph.ensure_neighbor(NodeId::ROOT, a_side);
let b = graph.ensure_neighbor(NodeId::ROOT, b_side);
let ab = graph.ensure_neighbor(a, b_side);
let ac = graph.ensure_neighbor(a, c_side);
let bc = graph.ensure_neighbor(b, c_side);
assert_eq!(parents, vec![(a_side, bc), (b_side, ac), (c_side, ab)]);
}

#[test]
fn normalize_transform() {
let mut graph = Graph::new(1);
Expand Down
2 changes: 1 addition & 1 deletion common/src/worldgen/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl LineSegment {
};
let closest_point_on_segment =
(self.start.as_ref() + self.start_to_end * h).normalized_point();
(-closest_point_on_segment.mip(point)).acosh()
(-closest_point_on_segment.mip(point)).max(1.0).acosh()
}
}

Expand Down
Loading
Loading