I’m struggling to figure how to leverage octrees when working with a lot of collision geometry.
Essentially, I have a starmap with ~30,000 vertices (using a point primitive). Currently, I am generating a node containing a collision sphere solid at each point so I can click on stars (using a ray from the mouse).
However, now I’m trying to make names of stars display when they are within a certain range of the camera. I have methods for creating/showing/hiding star names using TextNodes, and I trigger those methods by detecting collision between a sphere near the camera and the collision solids at each star. This work swell for small distances, but if I increase the size of the camera’s collision solid much, it slows down very quickly.
So, my question is twofold:
Is using a collision sphere at the camera like this a decent approach? If no, how might I approach differently?
If octrees might help speed up collision detection – how might I leverage them in this case? I’ve seen the various versions of treeform’s script; however, it seems to have errors (addVertices() takes 3, 4, or 5 arguments (2 given) … ). Could someone point me at some reading or example code that might help me build a collision octree?