Jump to content

  • Log In with Google      Sign In   
  • Create Account


Octree Partition Setting


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 MrChrisnis   Members   -  Reputation: 340

Like
0Likes
Like

Posted 12 February 2013 - 08:37 AM

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

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



Sponsor:

#2 Josh Vega   Crossbones+   -  Reputation: 1178

Like
0Likes
Like

Posted 12 February 2013 - 07:10 PM

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)?

Some favourite quotes:
Spoiler




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS