/*********************************************************************

Name:		Raytracer
Author:		Kamil Szatkowski "Netrix" (C)
Website:	http://www.netrix.org.pl/
License:	GNU GPL

*********************************************************************/
#pragma once
#include "NLib/nMath.hpp"

namespace Regions
{
	enum ERegions
	{
		CENTER = 0x0,
		X_MIN = 0x1,
		X_MAX = 0x2,
		Y_MIN = 0x4,
		Y_MAX = 0x8,
		Z_MIN = 0x10,
		Z_MAX = 0x20
	};

	_NINLINE bool InRegion(NIne::NUint32 uRegionA, NIne::NUint32 uRegionB)
	{ 
		return (uRegionA & uRegionB) == 0; 
	}

	_NINLINE NIne::NUint32 GetRegion(const NIne::NMVector3f& vMin, const NIne::NMVector3f& vMax, const NIne::NMVector3f& vPoint)
	{
		NIne::NUint32 uRegion = 0;

		uRegion |= (vPoint.x < vMin.x) ? X_MIN : (vPoint.x > vMax.x ? X_MAX : 0);
		uRegion |= (vPoint.y < vMin.y) ? Y_MIN : (vPoint.y > vMax.y ? Y_MAX : 0);
		uRegion |= (vPoint.z < vMin.z) ? Z_MIN : (vPoint.z > vMax.z ? Z_MAX : 0);

		return uRegion;
	}
}