branchrust_reboot/main/buildingprivilege_cachecancel
14 Commits over 0 Days - Infinitycph!
Fixed blocks registering with a 0 net id on the server when placed with the building plan
Fixed regression with player boat privs when using the cache
Cleaned up building priv cache vs vis tests
Reordered the check so bases with no TC are cheaper
Convared the vehicle and entity privilege changes under buildingmanager.privilegecache
Legacy shelters, vehicles and boat building stations no longer use Vis queries
Same base same spot:
GetVehicleBuildingPrivilege 0.34ms -> 0.01ms
GetEntityBuildingPrivilege 0.84ms -> ~0
Sort the cells oldest first
Store each blocks bound centre and net id in the grid so:
- blocks out of the query radius are skipped without a dictionary lookup
- the age check doesnt read every block from memory
Only run HasColliderWithinSphere when the block bounds aren't entirely inside the search sphere
Around 0.09ms for GetBuildingPrivilege in that same base, same spot
- Skip the bounds check for blocks that aren't older than the current best block
- Visit the cell you're standing in first
Skips a lot of work when standing in the core or middle of a base
Attempt at global building privilege cache, using a simple grid holding all the building blocks + a collider test on the winning block, because triangles and roofs have bounds larger than their colliders
Thats enough to remove the Vis Entities call and keep the same precision. Works on the client and the server
In a big base, 575 blocks around me:
4.60ms -> ~0.50ms