I've been working on an Octree rendering system for my game engine. Everything is going smoothly (or at least more than I thought it would). When creating new nodes, I only want it to create nodes if there is an object withen the node that would be created. This works, however it produces some odd results with two objects, creating nodes where there are no objects at all.

Heres my code for determining if an object lies within the boundries of a node:
Code:
	for(int i=0; i<num_objects; i++)
	{
		if(objectP[i].pos.x <= leaf->pos.x && objectP[i].pos.y <= leaf->pos.y && objectP[i].pos.z <= leaf->pos.z)
		{
			leaf->BBLactive = true;
		}
		if(objectP[i].pos.x >= leaf->pos.x && objectP[i].pos.y <= leaf->pos.y && objectP[i].pos.z <= leaf->pos.z)
		{
			leaf->BBRactive = true;
		}
		if(objectP[i].pos.x <= leaf->pos.x && objectP[i].pos.y <= leaf->pos.y && objectP[i].pos.z >= leaf->pos.z)
		{
			leaf->BFLactive = true;
		}
		if(objectP[i].pos.x >= leaf->pos.x && objectP[i].pos.y <= leaf->pos.y && objectP[i].pos.z >= leaf->pos.z)
		{
			leaf->BFRactive = true;
		}
		
		if(objectP[i].pos.x <= leaf->pos.x && objectP[i].pos.y >= leaf->pos.y && objectP[i].pos.z <= leaf->pos.z)
		{
			leaf->TBLactive = true;
		}
		if(objectP[i].pos.x >= leaf->pos.x && objectP[i].pos.y >= leaf->pos.y && objectP[i].pos.z <= leaf->pos.z)
		{
			leaf->TBRactive = true;
		}
		if(objectP[i].pos.x <= leaf->pos.x && objectP[i].pos.y >= leaf->pos.y && objectP[i].pos.z >= leaf->pos.z)
		{
			leaf->TFLactive = true;
		}
		if(objectP[i].pos.x >= leaf->pos.x && objectP[i].pos.y >= leaf->pos.y && objectP[i].pos.z >= leaf->pos.z)
		{
			leaf->TFRactive = true;
		}
	}
If more code is necessary, let me know. But i'm confident that this is the only thing that would cause a problem. All this code does, is test the object position in relation to the node positon, and return true if the node should be created.

thanx,
-psychopath