I'm making a game engine, and some components may want to interact with others based on distance. Currently, the component registers an update listener which runs on a loop, then it checks the distance for each object. This is obviously wrong.

I thought about creating a system just for spacial relations, where the component would ask every frame if there are objects within a radius to that system, and it would have something like an octree inside to accelerate the calculations. I can also just register a listener for when objects are closer than a radius, and it would update only when an object changed from one node to the other on the tree.

Is the octree appropriate or is it just better for static objects like terrain? What do physics engines use?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.