//------------------------------------------------------------------------------------
// irr::core::aabbox3di wrappers
//------------------------------------------------------------------------------------

extern "C" 
{

	aabbox3di* IrrCore_AABbox3di_new()
	{
		return new aabbox3di();
	}
	
	aabbox3di* IrrCore_AABbox3di_newFromBox(const aabbox3di& other)
	{
		return new aabbox3di(other);
	}
	
	aabbox3di* IrrCore_AABbox3di_newFromVect(vector3di* init)
	{
		return new aabbox3di(*init);
	}
	
	aabbox3di* IrrCore_AABbox3di_newFromVectWithMax(vector3di* init,vector3di* max)
	{
		return new aabbox3di(*init,*max);
	}
	
	aabbox3di* IrrCore_AABbox3di_newFromVals(s32 minx,s32 miny,s32 minz,s32 maxx,s32 maxy,s32 maxz)
	{
		return new aabbox3di(minx,miny,minz,maxx,maxy,maxz);
	}
	
	void IrrCore_AABbox3di_del(aabbox3di* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	void IrrCore_AABbox3di_addInternalPoint(aabbox3di* box,const vector3di& point)
	{
		if (box)
			box->addInternalPoint(point);
	}
	
	void IrrCore_AABbox3di_addInternalPointFromVals(aabbox3di* box,s32 x,s32 y,s32 z)
	{
		if (box)
			box->addInternalPoint(x,y,z);
	}
	
	void IrrCore_AABbox3di_addInternalBox(aabbox3di* box,aabbox3di* addbox)
	{
		if (box)
			box->addInternalBox(*addbox);
	}
	
	void IrrCore_AABbox3di_resetFromVals(aabbox3di* box,s32 x,s32 y,s32 z)
	{
		if (box)
			box->reset(x,y,z);
	}
	
	void IrrCore_AABbox3di_resetFromBox(aabbox3di* box,const aabbox3di& initvalue)
	{
		if (box)
			box->reset(initvalue);
	}
	
	void IrrCore_AABbox3di_resetFromVect(aabbox3di* box,const vector3di& initvalue)
	{
		if (box)
			box->reset(initvalue);
	}
	
	bool IrrCore_AABbox3di_isPointInside(aabbox3di* box,const vector3di& point)
	{
		if (box)
			return box->isPointInside(point);
		else
			return false;
	}
	
	bool IrrCore_AABbox3di_isPointTotalInside(aabbox3di* box,const vector3di& point)
	{
		if (box)
			return box->isPointTotalInside(point);
		else
			return false;
	}
	
	bool IrrCore_AABbox3di_intersectsWithBox(aabbox3di* box,const aabbox3di& other)
	{
		if (box)
			return box->intersectsWithBox(other);
		else
			return false;
	}
	
	bool IrrCore_AABbox3di_intersectsWithLine(aabbox3di* box,const line3d<s32>& line)
	{
		if (box)
			return box->intersectsWithLine(line);
		else
			return false;
	}
	
	bool IrrCore_AABbox3di_intersectsWithLineUsingVects(aabbox3di* box,const vector3di& linemiddle,const vector3di& linevect,s32 halflength)
	{
		if (box)
			return box->intersectsWithLine(linemiddle,linevect,halflength);
		else
			return false;
	}
	
	s32 IrrCore_AABbox3di_classifyPlaneRelation(aabbox3di* box,const plane3di& plane)
	{
		if (box)
			return box->classifyPlaneRelation(plane);
		else
			return 0;
	}
	
	vector3di* IrrCore_AABbox3di_getCenter(aabbox3di* box)
	{
		if (box)
			return new vector3di(box->getCenter());
		else
			return 0;
	}
	
	vector3di* IrrCore_AABbox3di_getExtent(aabbox3di* box)
	{
		if (box)
			return new vector3di(box->getExtent());
		else
			return 0;
	}
	
	vector3di* IrrCore_AABbox3di_getMinEdge(aabbox3di* box)
	{
		if (box)
			return &box->MinEdge;
		else
			return 0;
	}
	
	vector3di* IrrCore_AABbox3di_getMaxEdge(aabbox3di* box)
	{
		if (box)
			return &box->MaxEdge;
		else
			return 0;
	}
	
	void IrrCore_AABbox3di_repair(aabbox3di* box)
	{
		if (box)
			box->repair();
	}
	
	bool IrrCore_AABbox3di_EqEq(aabbox3di* box,const aabbox3di& other)
	{
		if (box)
			return (*box==other);
		else
			return false;
	}
	
	bool IrrCore_AABbox3di_NotEq(aabbox3di* box,const aabbox3di& other)
	{
		if (box)
			return (*box==other);
		else
			return true;
	}
	
	bool IrrCore_AABbox3di_isEmpty(aabbox3di* box)
	{
		if (box)
			return box->isEmpty();
		else return true;
	}
	
	// note, user array<vector3di> to get a pointer for the array
	void IrrCore_AABbox3di_getEdges(aabbox3di* box,vector3di** edges)
	{			
		if (box) {
			array<vector3di> theEdges(8);
			box->getEdges(theEdges.pointer());
			
			for (int i=0; i<8; i++) {
				edges[i]->set(theEdges[i]);
			}
		}	
	}
	
	aabbox3di* IrrCore_AABbox3di_getInterpolated(aabbox3di* box,aabbox3di* other,f32 d)
	{
		if (box)
			return new aabbox3di(box->getInterpolated(*other,d));
		else
			return 0;
	}

	bool IrrCore_AABbox3di_isFullInside(aabbox3di* box,const aabbox3di& other)
	{
		if (box)
			return box->isFullInside(other);
		else return false;
	}

	s32 IrrCore_AABbox3di_getVolume(aabbox3di* box) 
	{
		if (box)
			return box->getVolume();
		else return 0;
	}	

	s32 IrrCore_AABbox3di_getArea(aabbox3di* box)
	{
		if (box) 
			return box->getArea();
		else return 0;
	}	
}
