1
DF Dwarf Mode Discussion / Re: Pathfinding is not a major cause of FPS death
« on: December 13, 2022, 05:58:26 pm »
What's the (software) caching of LOS like? AFAICT, whether Urist McAlice can see Urist McBob can change if either of them move, if Urist McAlice gets her eyes stabbed out etc. or if some bit of the environment that affects LOS changes.
So you could have an nxn matrix for your n units used as a cache. Whenever a unit moves, its row and column are wiped. Whenever something in the world changes e.g. a tree is felled so you can see through where the trunk used to be, the whole matrix is wiped (or maybe you can find a way to only wipe a subset of it). World LOS changes don't seem to happen that often unless something weird is happening like obsidian is being formed so you'd usually only have to recalculate LOS relating to entities that moved last tick.
Sorry if this is a bad suggestion I seldom stray this close to bare metal. IDK if it would play nice with the crazy optimisations CPUs do nowadays.
So you could have an nxn matrix for your n units used as a cache. Whenever a unit moves, its row and column are wiped. Whenever something in the world changes e.g. a tree is felled so you can see through where the trunk used to be, the whole matrix is wiped (or maybe you can find a way to only wipe a subset of it). World LOS changes don't seem to happen that often unless something weird is happening like obsidian is being formed so you'd usually only have to recalculate LOS relating to entities that moved last tick.
Sorry if this is a bad suggestion I seldom stray this close to bare metal. IDK if it would play nice with the crazy optimisations CPUs do nowadays.