hull_source: the silhouette is the zones' top view, what Rasterise reads

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-10-22 16:06:59 +02:00
commit fd1188a797
2 changed files with 6 additions and 6 deletions

View file

@ -18,7 +18,7 @@ with it (a hull that redefines or shadows an included language fails a check):
Frame: Ship Root, metres, nose -Y, starboard -X, up +Z. build() also takes the hull's HullData.HullType ("Ship",
"Station" or "Turret"), which the caller reads: the add-on from the bound package's ship.cc, the bench from its flag.
Schematic lines (HullBuild.lines): the top-view silhouette first (OpenSCAD projection() of every zone and anchor mesh,
Schematic lines (HullBuild.lines): the top-view silhouette first (OpenSCAD projection() of every zone mesh, the geometry Rasterise reads,
read from the SVG it exports), then the kit's lines, each with a fixed RGBA from LINE_STYLE. A kit part is placed with
lp_at so its line is emitted in the frame the geometry is; a source that echoes no lines has the silhouette alone.
A faction language's proportions judge Ship hulls only; every hull's zones must fit the layout grid (hull_grid.MAX_CELLS
@ -384,7 +384,7 @@ def over_silhouette(point, contours):
def build(runner, library, hull_type, projector):
"""Reads the hull source through runner (see Runner) and judges it against the languages library(faction) answers with
(the ECHO text of that faction's own language file). projector (see Projector) answers the top-view contours of every
zone and anchor mesh, which become the silhouette line. hull_type is the hull's HullData.HullType name, which the caller
zone mesh, which become the silhouette line. hull_type is the hull's HullData.HullType name, which the caller
reads; only a "Ship" is judged on the language's proportions. Raises HullSourceError, before reading anything, when
hull_type is not one of ship_cc.HULL_TYPE_NAMES, and when the source cannot be read at all; otherwise returns a
HullBuild whose failed() lists the checks it breaks."""
@ -412,7 +412,7 @@ def build(runner, library, hull_type, projector):
body_zone = f"{donor.faction}:{donor.body}" if donor else own.body
result = HullBuild(brief, {language.faction: language for language in owned}, zones, colours, anchors, anchor_meshes,
own.glow, own.radiator, body_zone, hull_type)
meshes = [m for m in list(zones.values()) + list(anchor_meshes.values()) if m.triangles]
meshes = [m for m in zones.values() if m.triangles] # the meshes Rasterise reads, so the underlay registers on the grid
if meshes:
top = max(v[2] for m in meshes for v in m.vertices)
result.lines = [SchematicLine("silhouette", True, tuple((x, y, top) for x, y in contour)) for contour in projector(meshes)]

View file

@ -750,7 +750,7 @@ class LineBuildTests(unittest.TestCase):
_, built = self.built(line("outline", ((-1, 0, 1), (1, 0, 1))))
self.assertEqual([l.layer for l in built.lines], ["silhouette", "outline"])
self.assertEqual({p[2] for p in built.lines[0].points}, {3.0})
self.assertEqual({p[:2] for p in built.lines[0].points}, {(-3.0, -5.0), (3.0, -5.0), (3.0, 5.1), (-3.0, 5.1)})
self.assertEqual({p[:2] for p in built.lines[0].points}, {(-3.0, -5.0), (3.0, -5.0), (3.0, 5.0), (-3.0, 5.0)})
def test_each_layer_carries_its_fixed_style(self):
kit = "".join(line(layer) for layer in hs.KIT_LAYERS)
@ -759,11 +759,11 @@ class LineBuildTests(unittest.TestCase):
self.assertEqual(len({l.rgba() for l in built.lines}), 5)
self.assertEqual(hs.LINE_STYLE["silhouette"], (1.0, 1.0, 1.0, 1.0))
def test_the_projector_is_given_every_zone_and_anchor_mesh_that_has_geometry(self):
def test_the_projector_is_given_every_zone_mesh_that_has_geometry_and_no_anchor_mesh(self):
fixture, given = Fixture(), []
hs.build(fixture.runner(), fixture.read_library, "Ship",
lambda meshes: given.append(len(meshes)) or fixture.projector(meshes))
self.assertEqual(given, [3]) # primary, secondary, emit:Th.A
self.assertEqual(given, [2]) # primary and secondary; the emitter mesh is not part of the layout's top view
def test_a_kit_line_off_the_hull_fails_the_over_the_top_view_check_and_nothing_else(self):
_, built = self.built(line(points=((0, 0, 2), (20, 0, 2))))