fix: breaking: Spatial hashing interest management resolution formula fixed. this is why spatial hashing visibility range always seemed a bit lower than with distance interest management.

This commit is contained in:
vis2k 2022-07-11 23:40:37 +08:00
parent 97fe2764bc
commit 5f4a03109d

View File

@ -12,8 +12,17 @@ public class SpatialHashingInterestManagement : InterestManagement
[Tooltip("The maximum range that objects will be visible at.")]
public int visRange = 30;
// if we see 8 neighbors then 1 entry is visRange/3
public int resolution => visRange / 3;
// we use a 9 neighbour grid.
// so we always see in a distance of 2 grids.
// for example, our own grid and then one on top / below / left / right.
//
// this means that grid resolution needs to be distance / 2.
// so for example, for distance = 30 we see 2 cells = 15 * 2 distance.
//
// on first sight, it seems we need distance / 3 (we see left/us/right).
// but that's not the case.
// resolution would be 10, and we only see 1 cell far, so 10+10=20.
public int resolution => visRange / 2;
[Tooltip("Rebuild all every 'rebuildInterval' seconds.")]
public float rebuildInterval = 1;