
extern "C" 
{

//------------------------------------------------------------------------------------
// irr::scene::ISceneCollisionManager wrappers
//------------------------------------------------------------------------------------

	bool IrrScene_ISceneCollisionManager_getCollisionPoint(ISceneCollisionManager* cm,line3d<f32>* ray, ITriangleSelector* selector,vector3df* outCollisionPoint,triangle3df* outTriangle, const ISceneNode*& outNode)
	{
		if (cm)
			return cm->getCollisionPoint(*ray,selector,*outCollisionPoint,*outTriangle, outNode);
		else return false;
	}
	
	vector3df* IrrScene_ISceneCollisionManager_getCollisionResultPosition(ISceneCollisionManager* cm,
		ITriangleSelector* selector,vector3df* ellipsoidPosition,vector3df* ellipsoidRadius,
		vector3df* ellipsoidDirectionAndSpeed,triangle3df* triout,vector3df& hitPosition, bool *outFalling, const ISceneNode*& outNode, f32 slidingSpeed=0.0005f,
		vector3df* gravityDirectionAndSpeed=0)
	{
		vector3df* pRetVal=0;
	
		bool delG=false;
		if (!gravityDirectionAndSpeed) {gravityDirectionAndSpeed=new vector3df(0.0f, 0.0f, 0.0f); delG=true;}
	
		if (cm)
			pRetVal=new vector3df(cm->getCollisionResultPosition(selector,*ellipsoidPosition,*ellipsoidRadius,*ellipsoidDirectionAndSpeed,*triout, hitPosition, *outFalling, outNode, slidingSpeed,*gravityDirectionAndSpeed));
		if (delG) delete gravityDirectionAndSpeed;
	
		return pRetVal;
	}
	
	line3d<f32>* IrrScene_ISceneCollisionManager_getRayFromScreenCoordinates(ISceneCollisionManager* cm,position2d<s32>* pos,ICameraSceneNode* camera=0)
	{
		if (cm)
			return new line3d<f32>(cm->getRayFromScreenCoordinates(*pos,camera));
		else return 0;
	}
	
	ISceneNode* IrrScene_ISceneCollisionManager_getSceneNodeFromCameraBB(ISceneCollisionManager* cm,ICameraSceneNode* camera,s32 idBitMask=0,bool bNoDebugObjects=false)
	{
		if (cm)
			return cm->getSceneNodeFromCameraBB(camera,idBitMask,bNoDebugObjects);
		else return 0;
	}
	
	ISceneNode* IrrScene_ISceneCollisionManager_getSceneNodeFromRayBB(ISceneCollisionManager* cm,line3d<f32>* ray,s32 idBitMask=0,bool bNoDebugObjects=false, ISceneNode* root=0)
	{
		if (cm)
			return cm->getSceneNodeFromRayBB(*ray,idBitMask,bNoDebugObjects);
		else return 0;
	}
	
	ISceneNode* IrrScene_ISceneCollisionManager_getSceneNodeFromScreenCoordinatesBB(ISceneCollisionManager* cm,position2d<s32>* pos,s32 idBitMask=0,bool bNoDebugObjects=false, ISceneNode* root=0)
	{
		if (cm)
			return cm->getSceneNodeFromScreenCoordinatesBB(*pos,idBitMask,bNoDebugObjects,root);
		else return 0;
	}
	
	position2d<s32>* IrrScene_ISceneCollisionManager_getScreenCoordinatesFrom3DPosition(ISceneCollisionManager* cm,vector3df* pos,ICameraSceneNode* camera=0)
	{
		if (cm)
			return new position2d<s32>(cm->getScreenCoordinatesFrom3DPosition(*pos,camera));
		else return 0;
	}

	ISceneNode* IrrScene_ISceneCollisionManager_getSceneNodeAndCollisionPointFromRay(ISceneCollisionManager* cm, 
							core::line3df* ray,
							core::vector3df & outCollisionPoint,
							core::triangle3df & outTriangle,
							s32 idBitMask = 0,
							ISceneNode * collisionRootNode = 0,
							bool noDebugObjects = false) 
	{
		if (cm)
			return cm->getSceneNodeAndCollisionPointFromRay(*ray, outCollisionPoint, outTriangle, idBitMask, collisionRootNode, noDebugObjects);
	}


	bool IrrScene_ISceneCollisionManager_drop(ISceneCollisionManager* unk)
	{
		if (unk)
			return unk->drop();
		else return 0;
	}
	
	const c8* IrrScene_ISceneCollisionManager_getDebugName(ISceneCollisionManager* unk)
	{
		if (unk)
			return unk->getDebugName();
		else return "";
	}
	
	void IrrScene_ISceneCollisionManager_grab(ISceneCollisionManager* unk)
	{
		if (unk)
			unk->grab();
	}
	
}
