コード例 #1
0
ファイル: octreeSolid.cpp プロジェクト: pigoblock/TFYP
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);
				}
			}
		}	
	}

}
コード例 #2
0
ファイル: octreeSolid.cpp プロジェクト: pigoblock/TFYP
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);
				}
			}
		}	
	}
}