Hey guys,
I've been staring at this problem for a few hours now, so my brain is a bit bleh
I have a program with cubes with collision spheres inside of a game domain. I am using an Octree to perform the collision checking however I seem to have run into a "bug" with the way I have implemented it. If any of the cube's collision spheres overlap on any of the axes (have a 0 for any of their axial position values) then that cube is pushed back up to the root and left there as it cannot filter down to lower partitions while it is on the axis. This is causing the number of objects in the root of my Octree to be abnormally high for what I am expecting to be the outcome.
I *THINK* that I have narrowed the "bug" down to the following piece of code:
bool BinPart::contains(Cube3D* obj) {
float lX = obj->getPos().x - obj->getColRadius();
float hX = obj->getPos().x + obj->getColRadius();
float lY = obj->getPos().y - obj->getColRadius();
float hY = obj->getPos().y + obj->getColRadius();
float lZ = obj->getPos().z - obj->getColRadius();
float hZ = obj->getPos().z + obj->getColRadius();
return(lX > lowX && hX < highX && lY > lowY && hY < highY && lZ > lowZ && hZ < highZ);
}
It seems that the return statement in that function will never return true if an object is on any axis, however I fail to see how I could change this so that only objects that are touching (0, 0, 0) will be in the root, while objects that are only on one axis are placed into parent nodes.
Any help would be greatly appreciated
Thanks
Chris
P.S - Sorry if the code doesn't come out properly. Couldn't remember how to correctly add C++ code in with the colour formatting and everything