Birdoggydog's Builds

Stringing catenary cables between buildings at load

Each building lists its fixing points, and the game hangs solved catenaries between them in four states, with a sparking live end you can see from the street.

The buildings in Blobber now get cables. When a cell loads, the game strings spans between houses, drops from a pole to a wall and lines from pole to pole. They hang in a real catenary, and they come in four states: taut, slack, broken and fallen. A broken cable sparks at its free end, and you can see it from the street.

Taut lines on glass insulators, slack ones hanging lower, a broken span sparking at 7 m, the fallen state, then three other styles drawn on the same houses.

Why not paint them on?

I wanted cables to be wiring, not a growth, so nothing is painted on a building. Each building part lists its fixing points: a wall’s top, a service point, a pole’s insulator. The game works out the rest at load, so any building the recipe makes can carry cables.

How do you hang a cable between two different heights?

A cable between an eave and a lower anchor is a catenary with unequal ends. I solve for its curve so it passes through both ends, and I define the sag as the most it hangs below the straight line between them, as a share of the level length. That is a number you can ask for. A taut cable sags 2 to 4 percent, a slack one 5 to 10, and a broken or fallen one 6 to 12. The curve’s one parameter has no closed form for a given sag, so I find it by bisection, 64 steps. A test checks the sag of sampled curves, level and tilted, to within 0.0005.

Two checks follow. A span over the street keeps 5 m at its lowest point and anywhere else a drop keeps 3 m. And a span can’t pass through a building, which I test against every collision box with the slab method. A span that fails either check is dropped. The longest span is 30 m.

Why do the same cables break in every state?

The cables are picked from the mess number and the seed only, not the state. Changing state redraws the same cables. In the broken state 45 percent of the spans part at one end. The kept end hangs a tail to the ground and the other end gets a stub of half a meter to a meter. In the fallen state 55 percent of the spans lie on the ground under where they ran, 30 percent still hang live, and the pole is stripped of its lines. So the same spans break every time, whichever state you look at first.

All of a cell’s cables are one mesh with one shader, with no shadow, drawn out to 180 m. The shader does the sway with two sines per cable, and the sparks and the twitching. All of it counts the game clock’s play time, never real time.

Why did the first sparks fail?

My first version of the broken end was a 1 px line with a 4 to 6 px spark, and only some frames showed it. Nobody on the street would see a live wire. The fix was to make it loud. A spark is now twelve emissive streaks that spray to a meter on a burst, with 45 percent of 20 steps a second being bursts, and a crackling glow between them. The last 2.5 m of the tail jerks with the bursts. At 7 m in daylight the burst is 60 to 80 px tall.

What really sold it was a light. Each broken end carries an OmniLight with a 4.5 m range and no shadows, which throws a white pool on the paving. The light has to flash with the mesh, but the engine can’t read a vertex shader’s output, so I wrote the shader’s integer hash again in GDScript, bit for bit, and the light looks up the same step and phase. Only the first two broken ends in a cell get a light, so a broken street costs two lights. The lesson from the review was that at street distance a danger cue reads by light, not by shape.

What are the styles?

Styles are rows in wiring.json: radius, sides, color, how much glow and where, sag scale, sway, hangers and how often a pole stands. There are six. Steampunk is neat telegraph wire, cyberpunk is a tangle with neon strips along the spans, fantasy is bunting and lanterns, meat is red sinew cords that pulse, eldritch is knotted wandering tendrils, and house is flat bundles of three. Only steampunk has its own buildings so far, so the other five are tests drawn on its houses.

What is still wrong

A mess street of 12 houses has 379 cables from 653 fixing points, 25.7k triangles, and it takes about 215 ms to string, over the 50 to 100 ms a cell should cost. The stub at a broken end is too faint to see from the street, and the cables meet the house with no bracket or knob. Eldritch still looks like a cable. All of that is on the list.