Physics system consists of a few flaws. The biggest on which is how to properly collide with terrain. There are a few issues with the terrain. Our system from the beginning of the week does contain the terrain object, but the spatial partition does not recognize objects that are larger than the partition space and thus the terrain, regardless of size, gets its corners partitioned into the space but the center/insides of the terrain are ignored. This causes objects to not collide with the terrain’s center because the terrain does not exist in those partitioned space and thus collision is not checked.
I begin to implement a way for larger objects to be inputted into the spatial partition. If any dimension of the object is larger than partitioned unit size, it divides the object into sections that are partition sized and puts them into the spatial partition. This raises another issue. When this was implemented and tested, our game performance drops significantly to the point where it is almost non-functional. This problem comes from the way collision is being handled. As it was, the collision check function requests all objects inside each partitioned space. This becomes an issue with extremely large objects such as the terrain. The terrain occupies over a thousand partitioned units and therefore, each frame it iterates these thousand buckets for collision check.
Things like terrain are not moving, there is no reason to test collision between two static objects. To account for this and to fix the performance crash, I separated static and dynamic objects into their own pools. Static objects like terrain are no longer put inside the partition and instead all objects when checking against the static objects for collision. While it is not currently implemented, a further optimization is to own check the dynamic object against the static object if it is within a range.