ref: 14db5e0145e0942e5cf851d696aebd2347418087
parent: 68a1e8413c500f62f81c5a283de47bf404346edc
author: Simon Tatham <[email protected]>
date: Sun Jun 18 09:33:28 EDT 2023
spectre_adjacent: optionally report dst_edge. Previously, you'd ask this function 'What lies on the other side of edge #i of this Spectre tile?' and it would tell you the identity of another Spectre. Now it will also tell you which _edge_ of that Spectre adjoins the specified edge of the input one. This will be used in the extra spectre-test mode I'm about to add.
--- a/spectre-internal.h
+++ b/spectre-internal.h
@@ -243,7 +243,7 @@
* delivering both plane and combinatorial coordinates as they go */
Spectre *spectre_initial(SpectreContext *ctx);
Spectre *spectre_adjacent(SpectreContext *ctx, const Spectre *src_spec,
- unsigned src_edge);
+ unsigned src_edge, unsigned *dst_edge);
/* For extracting the point coordinates */
typedef struct Coord {
--- a/spectre.c
+++ b/spectre.c
@@ -154,7 +154,7 @@
}
Spectre *spectre_adjacent(SpectreContext *ctx, const Spectre *src_spec,
- unsigned src_edge)
+ unsigned src_edge, unsigned *dst_edge_out)
{
unsigned dst_edge;
Spectre *dst_spec = snew(Spectre);
@@ -162,6 +162,8 @@
spectrectx_step(ctx, dst_spec->sc, src_edge, &dst_edge);
spectre_place(dst_spec, src_spec->vertices[(src_edge+1) % 14],
src_spec->vertices[src_edge], dst_edge);
+ if (dst_edge_out)
+ *dst_edge_out = dst_edge;
return dst_spec;
}
@@ -454,7 +456,7 @@
for (edge = 0; edge < 14; edge++) {
Spectre *new_spec;
- new_spec = spectre_adjacent(ctx, spec, edge);
+ new_spec = spectre_adjacent(ctx, spec, edge, NULL);
if (find234(placed, new_spec, NULL)) {
spectre_free(new_spec);