WASDQE to move Arrow keys to rotate hold Space to show the separation planes G to generate a random test scene with lots of intersecting planes T to view the BSP tree in a list H to hide the list
Ok so I randomly had this idea two days ago and I got really motivated to start making projects on here again. Hopefully it lasts long enough for me to actually make a game out of this :) This is a test for a new 3d rendering system. My goal is to create a 3d game that runs at 30fps in scratch even on my slow laptop. One of the biggest challenges to create 3d games in scratch is figuring out what order to draw the objects. This system uses a modified version of Binary Space Partitioning (aka BSP) to sort the objects by depth. BSP solves this challenge by creating a tree of objects, where each plane keeps track of the set of objects that are in front and behind it. The modification I made to the BSP algorithm was to keep track of a bounding box at each node of the tree, and only split the polygon if its bounding box intersects the bounding box of the splitting plane. In the case where the bounding boxes do not intersect, it is easy to generate a splitting plane that does not split either polygon. (I call this method BBBSP for Bounding Box BSP) My hope with this method was to reduce the number of slices, which would hopefully reduce the number of triangles we need to draw. (I haven't actually done any testing to confirm if/how much it actually helps) I made this only use axis aligned rectangles as the objects because it is a lot simpler to code, but I think I could pretty easily extend this method to work with any flat polygons in any orientation.