Open mattrdowney opened 6 years ago
There's a perhaps-more-substantial gain from removing false positive collisions between colliders (instead of returning a collision object and then determining there was no collision).
There's an insane speedup from removing virtual functions (or even union types) / storing a single type in a single array aka just using spheres everywhere. Additionally, there should be a speedup from the hard-coded radius=2.
The space partitioning algorithm used might also remove many false positive collisions, improving speed drastically.
The best space partitioning algorithm for dynamic objects might be a subdivided octahedral mesh algorithm (R&Ding it might take a while).
For static items, a bounding volume hierarchy might be fastest.
For static items: use a "planar wall algorithm", if the dot product of a point and a plane is greater than the radius (maybe a cached quasi-radius) then the collision is on that side.
(I think this is a specialized BSP with constraints, lol.)
For dynamic items:
Octrees seem like a good starting point, but instead using a quadtree with angle(x,z) +- flat_radius and y_min/y_max since quadtrees have a lot of hollow space.
It's worth noting that Unity's Entity-Component System could work really well with a custom collision system.
I can pretty much guarantee I have to do this, based on what I learned from working on Debris Noirs.
Since I am pretty certain I have to do this, I might as well start soon (maybe after getting .svg files working to improve my morale). The sooner I work on this optimization the better, since this is no longer within the realm of premature optimization.
Yes, I will hate my life while developing this, but at least it's not graphics/GPU programming.
Main advantage is that different Planetariums can be placed in different space partitions.
Otherwise, there might be an even-more-substantial gain from the removed overhead of OnTriggerStay -> on_xxx_yyy.
Additionally, Raycasts and continuous collisions become faster.