ludic.physics, ludic.character, ludic.vehicles: fact records reused, and phys_sink allocates nothing
The per-frame sweep over physics, character, vehicles and nav found three fact makers that made a record per fact: contacts and splashes, the character's and the vehicles'. Each keeps a pool now, as wildlife's and npc's do (q_unheld). phys_sink, asked on every removal, built two new lists each time; it filters into a kept spare pair and swaps. ludic.nav's paths and crowds already allocate nothing, and none of the four builds a string per call. What remains at load, reset or a world swap is not per frame. vehicle_feed takes its state mut. vehicles_test: 1000 fed facts, drained turn by turn, use at most 4 records. All packages 421. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fe2d2bacd7
commit
fffedf71d0
10 changed files with 92 additions and 11 deletions
|
|
@ -375,4 +375,17 @@ program VehiclesTest {
|
|||
expect_eq(len(vehicles_all(vehicles_st)), 0)
|
||||
expect(vehicle_by_nid(vehicles_st, b.nid) == null)
|
||||
}
|
||||
|
||||
test "a fed fact a turn, drained each turn, makes a few records and then reuses them" (vehicles_st: mut VehiclesState, vehicles_test_st: mut VehiclesTestState) {
|
||||
fresh(vehicles_st, vehicles_test_st)
|
||||
vehicle_call_for(vehicles_st, 0, VEHICLE_HORSE, 0)
|
||||
let h = vehicle_find(vehicles_st, VEHICLE_HORSE)
|
||||
var fed = 0
|
||||
for k in 0 .. 1000 {
|
||||
vehicle_feed(vehicles_st, h, 1.0)
|
||||
fed += count(facts(vehicles_st), VEHICLE_FED)
|
||||
}
|
||||
expect_eq(fed, 1000)
|
||||
expect(vehicle_fact_records(vehicles_st) <= 4)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue