//------------------------------------------------------------------------------------
// irr::core::plane3di wrappers
//------------------------------------------------------------------------------------

extern "C" {

	plane3di* IrrCore_Plane3di_new()
	{
		return new plane3di();
	}

	plane3di* IrrCore_Plane3di_newFromVals(s32 px,s32 py,s32 pz,s32 nx,s32 ny,s32 nz)
	{
		return new plane3di(px,py,pz,nx,ny,nz);
	}

	plane3di* IrrCore_Plane3di_newFromPoints(vector3di* point1,vector3di* point2,vector3di* point3)
	{
		return new plane3di(*point1,*point2,*point3);
	}

	plane3di* IrrCore_Plane3di_newFromPlane(plane3di* other)
	{
		plane3di* plane = new plane3di();
		plane->setPlane(other->Normal,other->D);
		return plane;
	}

	plane3di* IrrCore_Plane3di_newFromPointNormal(vector3di* point,vector3di* normal)
	{
		return new plane3di(*point,*normal);
	}

	plane3di* IrrCore_Plane3di_newFromNormal(vector3di* normal, const s32 d)
	{
		return new plane3di(*normal, d);
	}

	void IrrCore_Plane3di_del(plane3di* pDel)
	{
		if (pDel>0)
			delete pDel;
		pDel=0;
	}

	void IrrCore_Plane3di_setPlaneFromPoints(plane3di* plane,vector3di* point1,vector3di* point2,vector3di* point3)
	{
		if (plane)
			plane->setPlane(*point1,*point2,*point3);
	}

	void IrrCore_Plane3di_setPlaneFromPointVect(plane3di* plane,vector3di* point,vector3di* vect)
	{
		if (plane)
			plane->setPlane(*point,*vect);
	}

	void IrrCore_Plane3di_setPlaneFromVectVal(plane3di* plane,vector3di* vect,s32 d)
	{
		if (plane)
			plane->setPlane(*vect,d);
	}

	bool IrrCore_Plane3di_getIntersectionWithLine (plane3di* plane,vector3di* linePoint,vector3di* lineVect,vector3di* outIntersection)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithLine(*linePoint,*lineVect,*outIntersection);

		return lRetVal;
	}

	bool IrrCore_Plane3di_getIntersectionWithLimitedLine(plane3di* plane,vector3di* linePoint1,vector3di* linePoint2,vector3di* outIntersection)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithLimitedLine(*linePoint1,*linePoint2,*outIntersection);

		return lRetVal;
	}

	s32 IrrCore_Plane3di_classifyPointRelation(plane3di* plane,vector3di* point)
	{
		s32 nRetVal=0;

		if (plane)
			nRetVal=plane->classifyPointRelation(*point);

		return nRetVal;
	}

	void IrrCore_Plane3di_recalculateD(plane3di* plane,vector3di* MPoint) 
	{
		if (plane)
			plane->recalculateD(*MPoint);
	}

	vector3di* IrrCore_Plane3di_getMemberPoint(plane3di* plane)
	{
		vector3di* pRetVal=0;
		
		if (plane)
			pRetVal=new vector3di(plane->getMemberPoint());

		return pRetVal;
	}

	bool IrrCore_Plane3di_existsIntersection(plane3di* plane,plane3di* other)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->existsIntersection(*other);

		return lRetVal;
	}

	bool IrrCore_Plane3di_getIntersectionWithPlane(plane3di* plane,plane3di* other,vector3di* outLinePoint,vector3di* outLineVect)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithPlane(*other,*outLinePoint,*outLineVect);

		return lRetVal;
	}

	bool IrrCore_Plane3di_getIntersectionWithPlanes(plane3di* plane,plane3di* o1,plane3di* o2,vector3di* outPoint)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithPlanes(*o1,*o2,*outPoint);

		return lRetVal;
	}

	bool IrrCore_Plane3di_isFrontFacing(plane3di* plane,vector3di* lookDirection)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->isFrontFacing(*lookDirection);

		return lRetVal;
	}


	s32 IrrCore_Plane3di_getDistanceTo(plane3di* plane,vector3di* point)
	{
		s32 nRetVal=0;
		
		if (plane)
			nRetVal=plane->getDistanceTo(*point);

		return nRetVal;
	}

	s32 IrrCore_Plane3di_getD(plane3di* plane)
	{
		s32 nRetVal=0;
		
		if (plane)
			nRetVal=plane->D;

		return nRetVal;
	}

	vector3di* IrrCore_Plane3di_getNormal(plane3di* plane)
	{
		vector3di* pRetVal=0;

		if (plane)
			pRetVal=&plane->Normal;

		return pRetVal;
	}

	bool IrrCore_Plane3di_EqEq(plane3di* plane,plane3di* other)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=(*plane==*other);

		return lRetVal;
	}

	bool IrrCore_Plane3di_NotEq(plane3di* plane,plane3di* other)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=(*plane!=*other);

		return lRetVal;
	}
}