mkafrin / PolyZone

PolyZone is a FiveM mod to define zones of different shapes and test whether a point is inside or outside of the zone
MIT License
204 stars 191 forks source link

Using KVP to cache PolyZone grid and grid lines #26

Closed mkafrin closed 4 years ago

mkafrin commented 4 years ago

Calculating the grid points and grid lines for PolyZones is incredibly expensive and never changes unless you move the points of the zone. Can this just be cached after the first calculation? Maybe using a JSON string stored in KVP or something similar? I'd guess most people are never moving their PolyZones around after creating them. The key could be a hash of the points in the zone.

mkafrin commented 4 years ago

Initial implementation here 51a42ab4d8817d996f4e8d32a9afb1b932b0c46b in separate branch. Not sure if it's worth merging this in, given it's complexity. Closing this for now, but may revisit in the future.