kronosaur / TranscendenceDev

Explore the farthest reaches of Human Space in this open-world space adventure.
https://transcendence.kronosaur.com
Other
31 stars 15 forks source link

Performance optimization for hitscan beams #87

Closed exinfinitum closed 2 years ago

exinfinitum commented 2 years ago

Currently, the continuousBeam search algorithm loops through all objects in an A x A bounding box, where A is the length of a single beam segment. Since A can be very large, this can involve a lot of objects that are unnecessarily looped through. This optimization breaks it down into a series of B x B bounding boxes, where B << A. By doing this, we avoid looping through a lot of objects that we may have otherwise looped through, resulting in a massive performance increase when using hitscan beam weapons with very long ranges.

Demonstration video: https://streamable.com/511kjz

gmoromisato commented 2 years ago

Love it! Thank you!