Exemplo n.º 1
0
bool octreeSolid::isColidWithBox(octreeSNode* node, Box &b)
{
	GeometricFunc geoF;
	if (geoF.collisionBtwBox(b, Box(node->leftDownTight, node->rightUpTight)))
	{
		if (node->bEnd)
		{
			if (geoF.isPointInBox(b.leftDown, b.rightUp, (node->leftDownTight+node->rightUpTight)/2))
			{	
				return true;
			}
			return false;
		}
		else
		{
			for (int i = 0; i < 8; i++)
			{
				if (node->children[i])
				{
					if (isColidWithBox(node->children[i], b))
					{
						return true;
					}
				}
			}
			return false;
		}

	}
	else
		return false;

}
Exemplo n.º 2
0
void octreeSolid::intersectWithBox(octreeSNode* node, Vec3f &ldf, Vec3f &ruf, arrayInt &idxs)
{
	if (!node)
	{
		return;
	}

	GeometricFunc geoFc;
	Box boxNode(node->leftDownTight, node->rightUpTight);
	if (geoFc.collisionBtwBox(Box(ldf, ruf), boxNode))
	{
		if (node->bEnd
			&& geoFc.isPointInBox(ldf, ruf, boxNode.center))
		{
			// Sine boxIn may slightly cover the node box, we check the center point
			idxs.push_back(node->idxInLeaf);
		}
		else
		{
			for (int i = 0; i < 8; i++)
			{
				intersectWithBox(node->children[i], ldf, ruf, idxs);
			}
		}
	}
}
Exemplo n.º 3
0
void octreeSolid::intersectWithBox(octreeSNode* node, Box boxIn, Box &intersectBox, float &volumeSide)
{
	if (!node)
		return;

	GeometricFunc geoFc;
	BOOL isInside;

	if (geoFc.isBoxInBox(boxIn.leftDown, boxIn.rightUp, node->leftDownTight, node->rightUpTight))
	{
		// Cover entirely. Fit intersect box
		volumeSide += node->volumef;
		geoFc.fitBoxToCoverBox(intersectBox, node->leftDownTight, node->rightUpTight);
	}
	else
	{
		Box boxNode(node->leftDownTight, node->rightUpTight);
		if(geoFc.collisionBtwBox(boxIn, boxNode))
		{
			if (node->bEnd
				&& geoFc.isPointInBox(boxIn.leftDown, boxIn.rightUp, boxNode.center))
			{
				// Sine boxIn may slightly cover the node box, we check the center point
				volumeSide += node->volumef;
				geoFc.fitBoxToCoverBox(intersectBox, node->leftDownTight, node->rightUpTight);
			}
			else
			{
				for (int i = 0; i < 8; i++)
				{
					intersectWithBox(node->children[i], boxIn, intersectBox, volumeSide);
				}
			}
		}	
	}

}
Exemplo n.º 4
0
void octreeSolid::intersectWithBox(octreeSNode* node, meshPiece &boxOut, meshPiece &boxIn)
{
	if (!node)
		return;

	GeometricFunc geoFc;
	BOOL isInside;

	if (geoFc.isBoxInBox(boxIn.leftDown, boxIn.rightUp, node->leftDownTight, node->rightUpTight))
	{
		// Cover entirely. Fit intersect box
		boxOut.volumef += node->volumef;
		enlargerToCoverBox(boxOut, node->leftDownTight, node->rightUpTight);
	}
	else
	{
		Box boxNode(node->leftDownTight, node->rightUpTight);
		if(geoFc.collisionBtwBox(Box(boxIn.leftDown, boxIn.rightUp), boxNode))
		{
			if (node->bEnd
				&& geoFc.isPointInBox(boxIn.leftDown, boxIn.rightUp, boxNode.center))
			{
				// Sine boxIn may slightly cover the node box, we check the center point
				boxOut.volumef += node->volumef;
				enlargerToCoverBox(boxOut, node->leftDownTight, node->rightUpTight);
			}
			else
			{
				for (int i = 0; i < 8; i++)
				{
					intersectWithBox(node->children[i], boxOut, boxIn);
				}
			}
		}	
	}
}