Derpius / VisTrace

Garry's Mod binary module for tracing meshes at high speed on the CPU (and much more)
https://derpius.github.io/VisTrace
MIT License
28 stars 1 forks source link

[bug] Ent ids are saved when building accel, but not verified after traverse #9

Closed Derpius closed 3 years ago

Derpius commented 3 years ago

Describe the bug When you build the acceleration structure, the entity ids are cached for lookup later (allowing the user to get information on the hit entity), however given the accel struct is not updated constantly, there is a high likelihood that an entity that was valid when building, is now invalid, or points to a completely different entity that just happens to have the same id.

To Reproduce Steps to reproduce the behaviour:

  1. Spawn a prop
  2. Build accel
  3. Remove prop and spawn another (which will get the id that was just freed)
  4. Hit prop with traversal and print the entity (it'll be the second prop, not the one we hit)

Expected behaviour Either a generic invalid entity would be given, the id would be given (allowing the user to cache the required entity data when building accel, then index that table with the id), or allow the user to pass a table along with the entity table, which would be indexed when a traversal hits an entity, and the contents at that index passed out through a new HitResult parameter, UserData.

Derpius commented 3 years ago

Fixed in 78ecd868fb0ae570bf49b4c0ae62440190fc0157