ship crafter building animation makes game laggy #6

Closed
opened 2026-08-10 20:44:58 +00:00 by metaheavens · 1 comment
Owner
No description provided.
Author
Owner

Done.

Cause: every NeonDraw call is four antialiased polylines, and I had the crafter redrawing its entire yard every frame - reactor housing, radiator fins, truss spine, cradle ribs, crane rail - purely to advance a crane and some sparks. The structure is most of the drawing and none of the movement. The mothership had just picked up the same problem when it started animating. Roughly 128 polylines per frame for the crafter plus ~92 for the mothership, every frame, for two buildings.

Fix, two parts:

  1. Static/animated split. The unchanging structure now lives on a child layer that is drawn ONCE and then left alone; only the moving parts (assembly hull, crane, sparks, beacons, reactor pulse, orbiting satellites) redraw. That is roughly a 2.4x cut in per-frame drawing for the crafter and 2.5x for the mothership.
  2. Redraw cap. Animated buildings now redraw at 30Hz instead of every frame. Nothing here moves fast enough to need 60 - the satellites turn at 0.32 rad/s and the assembly cycle runs over 3.6s - and the redraw is the expensive part, not the arithmetic.

Combined, the per-frame drawing work for an animated building is down to roughly a fifth of what it was.

The command centre is unaffected: it has no animation, so it gets no extra layer at all.

Files: new BuildingStaticLayer.gd / .tscn, Building.gd (split _draw_crafter / _draw_mothership into static + animated halves, added the redraw cap).

Verified: new tests/test_building_redraw_cost.gd asserts the static layer is rasterised exactly ONCE across two seconds of animation while the crafter keeps animating - so it cannot be "fixed" by quietly freezing the animation - and that a non-animated building gets no pointless extra layer. Rendered the buildings before and after the split and compared: identical, nothing lost in the move. Full suite 38/38.

Worth a playtest on the device to confirm it actually feels smooth now - the measurement here is draw-call count, not frames per second on your phone.

Done. **Cause:** every NeonDraw call is four antialiased polylines, and I had the crafter redrawing its *entire* yard every frame - reactor housing, radiator fins, truss spine, cradle ribs, crane rail - purely to advance a crane and some sparks. The structure is most of the drawing and none of the movement. The mothership had just picked up the same problem when it started animating. Roughly 128 polylines per frame for the crafter plus ~92 for the mothership, every frame, for two buildings. **Fix, two parts:** 1. **Static/animated split.** The unchanging structure now lives on a child layer that is drawn ONCE and then left alone; only the moving parts (assembly hull, crane, sparks, beacons, reactor pulse, orbiting satellites) redraw. That is roughly a 2.4x cut in per-frame drawing for the crafter and 2.5x for the mothership. 2. **Redraw cap.** Animated buildings now redraw at 30Hz instead of every frame. Nothing here moves fast enough to need 60 - the satellites turn at 0.32 rad/s and the assembly cycle runs over 3.6s - and the redraw is the expensive part, not the arithmetic. Combined, the per-frame drawing work for an animated building is down to roughly a fifth of what it was. The command centre is unaffected: it has no animation, so it gets no extra layer at all. **Files:** new `BuildingStaticLayer.gd` / `.tscn`, `Building.gd` (split `_draw_crafter` / `_draw_mothership` into static + animated halves, added the redraw cap). **Verified:** new `tests/test_building_redraw_cost.gd` asserts the static layer is rasterised exactly ONCE across two seconds of animation while the crafter keeps animating - so it cannot be "fixed" by quietly freezing the animation - and that a non-animated building gets no pointless extra layer. Rendered the buildings before and after the split and compared: identical, nothing lost in the move. Full suite 38/38. Worth a playtest on the device to confirm it actually feels smooth now - the measurement here is draw-call count, not frames per second on your phone.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
metaheavens/spaceship#6
No description provided.