
Adam Ruff
DAABB
Q. What is DAABB?
A. To put it simply it is just an implementation of Axis-Aligned Bounding Box or AABB.
Q. What does DAABB do differently?
A. Dimensions, it makes it so it can test for collision between objects regardless of what dimensions the bounding box is aligned to.
This is something I was going to develop when I was making the "2D and 3D" game that can be seen in past projects, but the time frame for that project didn't allow it so another solution was used at that time, but I wanted to make a general implementation. It would definitely be better to optimise it to only allow objects in a predefined dimensional alignment if you are going to use this method.
To start with a coordinate system is needed, my first thought was to have it so the coordinates are all in the maximum dimensional space for example if it was a 5D environment all coordinates would need 5 values, but this would have too much pointless data. To solve this is quite simple just let the bounding box deal with what dimensions the values represent and just only give it the number needed.
Example:
A 2D and a 3D object in 5D space, the 2D object is given the coordinates (1,2), and the 3D object is given (1,2,3) the shapes know what dimensions these numbers are used for so no other information is needed.
so only a simple class was needed.
(coord.h)
class coord
{
public:
coord(std::vector<float> P); // P is a vector of floats representing the point
std::vector<float> Point;
coord();
};
now that we can represent points before we move on to making the bounding boxes, we need to think about how the dimensions are going to be represented. A class could be made to represent dimensions by name such as 'x', 'y' and 'z'. This would be very readable but would lead to lots of extra code added to read which dimension the value is and there would always be the possibility of making a mistake such as 'x' being used in some cases and 'X' being used in others. So I figured the best way to do this would be to use bits, this way each bit represents a dimension and bitwise operations could be used on them.
while writing the code I figured 8 dimensions was a good number to use to test but I did want this to be generic so I made a file called "defines.h" with the following lines.
#define TOTALDIMENSIONS 8
#define DimensionBitSet std::bitset<TOTALDIMENSIONS>
What this does is allow you to change the number of total dimensions in the environment by changing the value of "TOTALDIMENSIONS" and because of DimensionBitSet it will make it so all the bitsets used to represent the dimensional space are correct.
The bounding box is not as simple as the coord class it only needs 3 variables the "DimensionBitSet" seen above, a coord to represent its position and a way to know how big the box is, if you only want it so all the sides are the same length then this can just be a float, but since I don't want that I have made this a vector of floats as different boxes are going to want this to be different lengths.