• Advertisement
Sign in to follow this  

Octree Partition Setting

This topic is 1805 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,


I've been staring at this problem for a few hours now, so my brain is a bit bleh sad.png


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 smile.png




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

Share this post

Link to post
Share on other sites

Before I move on let me just ask two short questions:


  1. What do lowX/Y/Z and highX/Y/Z represent and what controls their value?
  2. How are you testing the use of this function (BinPart::contains)?

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement