Octree Partition Setting

Started by
0 comments, last by jsvcycling 11 years, 2 months ago

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

Advertisement

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:Never trust a computer you can't throw out a window.
- Steve Wozniak

The best way to prepare [to be a programmer] is to write programs, and to study great programs that other people have written.
- Bill Gates

There's always one more bug.
- Lubarsky's Law of Cybernetic Entomology

Think? Why think! We have computers to do that for us.
- Jean Rostand

Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
- Clifford Stoll

To err is human - and to blame it on a computer is even more so.
- Robert Orben

Computing is not about computers any more. It is about living.
- Nicholas Negroponte

This topic is closed to new replies.

Advertisement