//------------------------------------------------------------------------------------
// irr::core::recti wrappers
//------------------------------------------------------------------------------------

extern "C" 
{

	// defaults: x,y,z=0
	recti* IrrCore_Recti_newFromVals(s32 x1,s32 y1,s32 x2,s32 y2)
	{
		return new recti(x1,y1,x2,y2);
	}
	
	recti* IrrCore_Recti_new()
	{
		return new recti();
	}
	
	recti* IrrCore_Recti_newFromPos(position2d<s32>* upperLeft,position2d<s32>* lowerRight)
	{
		return new recti(*upperLeft,*lowerRight);
	}
	
	recti* IrrCore_Recti_newFromPosSize(position2d<s32>* pos,dimension2d<s32>* size)
	{
		return new recti(*pos,*size);
	}
	
	recti* IrrCore_Recti_newFromRect(recti* r)
	{
		return IrrCore_Recti_newFromPos(&r->UpperLeftCorner,&r->LowerRightCorner);
	}
	
	void IrrCore_Recti_del(recti* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	bool IrrCore_Recti_isPointInside(recti* r,position2d<s32>* pos)
	{
		bool lRetVal=false;
		
		if (r>0)
			lRetVal=r->isPointInside(*pos);
	
		return lRetVal;
	}
	
	bool IrrCore_Recti_isRectCollided(recti* r,recti* other)
	{
		bool lRetVal=false;
		
		if (r>0)
			lRetVal=r->isRectCollided(*other);
	
		return lRetVal;
	}
	
	void IrrCore_Recti_clipAgainst(recti* r,recti* other) 
	{
		if (r>0)
			r->clipAgainst(*other);
	}
	
	s32 IrrCore_Recti_getWidth(recti* r)
	{
		s32 nRetVal=0;
	
		if (r>0)
			nRetVal=r->getWidth();
	
		return nRetVal;
	}
	
	s32 IrrCore_Recti_getHeight(recti* r)
	{
		s32 nRetVal=0;
	
		if (r>0)
			nRetVal=r->getHeight();
	
		return nRetVal;
	}
	
	void IrrCore_Recti_repair(recti* r) 
	{
		if (r>0)
			r->repair();
	}
	
	bool IrrCore_Recti_isValid(recti* r)
	{
		bool lRetVal=false;
		
		if (r>0)
			lRetVal=r->isValid();
	
		return lRetVal;
	}
	
	position2d<s32>* IrrCore_Recti_getCenter(recti* r)
	{
		position2d<s32>* pRetVal=0;
	
		if (r>0)
			pRetVal=new position2d<s32>(r->getCenter());
	
		return pRetVal;
	}
	
	position2d<s32>* IrrCore_Recti_getUpperLeftCorner(recti* r)
	{
		position2d<s32>* pRetVal=0;
	
		if (r>0)
			pRetVal=&r->UpperLeftCorner;
	
		return pRetVal;
	}
	
	position2d<s32>* IrrCore_Recti_getLowerRightCorner(recti* r)
	{
		position2d<s32>* pRetVal=0;
	
		if (r>0)
			pRetVal=&r->LowerRightCorner;
	
		return pRetVal;
	}
	
	recti* IrrCore_Recti_PlusEq(recti* r,position2d<s32>* pos)
	{
		if (r>0) {
			*r+=*pos;
			return r;
		} else return 0;
	}
	
	recti* IrrCore_Recti_Plus(recti* r,position2d<s32>* pos)
	{
		return new recti((*r+*pos));
	}
	
	recti* IrrCore_Recti_Minus(recti* r,position2d<s32>* other)
	{
		return new recti((*r-*other));
	}
	
	recti* IrrCore_Recti_MinusEq(recti* r,position2d<s32>* other)
	{
		if (r>0) {
			*r-=*other;
			return r;
		} else return 0;
	}
		
	
	bool IrrCore_Recti_EqEq(recti* r,recti* other)
	{
		bool lRetVal=false;
		
		if (r>0)
			lRetVal=(*r==*other);
	
		return lRetVal;
	}
	
	bool IrrCore_Recti_NotEq(recti* r,recti* other)
	{
		bool lRetVal=false;
		
		if (r>0)
			lRetVal=(*r!=*other);
	
		return lRetVal;
	}
	
	// must delete ptr
	dimension2di* IrrCore_Recti_getSize(recti* r) 
	{
		dimension2di* retval=0;
		
		if (r>0)
			retval=new dimension2di(r->getSize());
	
		return retval;
	}
	
	void IrrCore_Recti_addInternalPointFromPos(recti* r,const position2d<s32>& p)
	{
		if (r)
			r->addInternalPoint(p);
	}
	
	void IrrCore_Recti_addInternalPoint(recti* r,s32 x, s32 y)
	{
		if (r)
			r->addInternalPoint(x,y);
	}

	s32 IrrCore_Recti_getArea(recti* r)
	{
		if (r)
			return r->getArea();
		else return 0;
	}

	bool IrrCore_Recti_constrainTo(recti* r,const recti& other)
	{
		if (r)
			return r->constrainTo(other);
		else return false;
	}		

	bool IrrCore_Recti_Less(recti* r,const recti& other)
	{
		if (r)
			return (*r < other);
		else return false;
	}	
	
}

