/*For game material*/
#include "GMT/GmtHandl.h"
 
/*Include For "Sector.h"*/
#include "ACP_Base.h"
#include "MTH.h"
#include "GEO.h"	
#include "GLI.h"
#include "PCS.h"
#include "PO.h"
/*XB980821*/
#ifndef D_THROW_IPO
#include "IPO.h"
#include "ISI.h"
#endif /* D_THROW_IPO */
/*End XB*/
#undef extern /*for PO (and AI)*/
 
#include "SPO.h"
#include "LST.h"
 
/*For the sound*/
#include "SND.h"
 
#include "SCT.h"
 
#include "PRF.h"
 
/* Oliv' - 25/05/1999 */
#if defined(_U64_GLI_BENCH_)
	extern ACP_tdxBool GLIBENCH_g_bColMap;
	extern void GLIBENCH_SCT_fn_vSendCollisionSectorWhereIAmToViewport(
		MTH3D_tdstVector										*_p_stAbsolutePositionOfCamera,
		struct GLD_tdstViewportAttributes_	*_p_stVpt,
		HIE_tdxHandleToSuperObject					_hSprObjSector,
		long																_lDrawMask );
#endif /* _U64_GLI_BENCH_ */
/* EndOfOliv' */
 
/*Constants*/
#define SCT_C_xNbMaxOfMirrorsInVisibleSectors 6
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool		bViewingInMirror;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void AGO_vProcessAllParts(GLD_tdstViewportAttributes *_p_stViewport);
void SECT_fn_vSendFogToViewport(struct GLD_tdstViewportAttributes_	*_p_stVpt,HIE_tdxHandleToSuperObject _hSprObjSector);
void fn_vSendOneModuleToViewPort(GLD_tdxHandleToViewportAttributes _hVpt,HIE_tdxHandleToSuperObject   _hSprObj,long _lDrawMask);
 
#if !defined(U64)
/*Prototypes*/
void SCT_fn_vGetSymMatrixOfCameraInMirror(GEO_tdxHandleToMatrix	hMatrixOfCamera,
										 GEO_tdxHandleToMatrix	hMatrixOfSymCamera,
										 MTH3D_tdstVector		*pstGlobalPositionOfSymCamera,
										 MTH3D_tdstVector		*pstGlobalNormalOfMirror,
										 MTH3D_tdstVector		*pstGlobalPointOfMirror);
 
void SCT_fn_vFindAllMirrorsInVisibleSector(
										  struct GLD_tdstViewportAttributes_ *_p_stVpt,
										  HIE_tdxHandleToSuperObject _hSprObjSector,
										  HIE_tdxHandleToSuperObject *hHandleOfMirror,
										  ACP_tdxHandleOfObject	*p_hHandleOfGometricMirror,
										  HIE_tdxHandleToSuperObject *hSectorOfMirror,
										  short *shNbOfMirror);
 
/**********************************************************************************************/
/* Name: SCT_fn_vGetSymMatrixOfCameraInMirror*/
/* Goal: Compute the new matrix for the symetric camera*/
/* Code: Philippe Thiébaut*/
/* Verified: Yes*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void SCT_fn_vGetSymMatrixOfCameraInMirror
(
	GEO_tdxHandleToMatrix	hMatrixOfCamera,
	GEO_tdxHandleToMatrix	hMatrixOfSymCamera,
	MTH3D_tdstVector		*pstGlobalPositionOfSymCamera,
	MTH3D_tdstVector		*pstGlobalNormalOfMirror,
	MTH3D_tdstVector		*pstGlobalPointOfMirror
)
{
	POS_tdstCompletePosition stGlobalMatrixOfCamera;
	POS_tdstCompletePosition stMulMatrixScale;
	POS_tdstCompletePosition stTempMatrixForMultiplication;
	MTH3D_tdstVector		stTransVector;
	MTH_tdxReal				xTemp;
	MTH3D_tdstVector		stTransVectorOfCamera;
	MTH3D_tdstVector		pstModuleAxes[3];
	MTH_tdxReal				a11,a22,a33,a12,a13,a23;
 
	/*I get the global matrix of the camera*/
	POS_fn_vSetIdentityMatrix(&stGlobalMatrixOfCamera);
	POS_fn_vInvertMatrix(&stGlobalMatrixOfCamera, hMatrixOfCamera);
 
	/*I compute the matrix of the mirror transformation			*/
	POS_fn_vSetIdentityMatrix(&stMulMatrixScale);
	
	a11=MTH_M_xSub(MTH_C_ONE,MTH_M_xMul(MTH_C_2,MTH_M_xMul(pstGlobalNormalOfMirror->xX,pstGlobalNormalOfMirror->xX)));
	a22=MTH_M_xSub(MTH_C_ONE,MTH_M_xMul(MTH_C_2,MTH_M_xMul(pstGlobalNormalOfMirror->xY,pstGlobalNormalOfMirror->xY)));
	a33=MTH_M_xSub(MTH_C_ONE,MTH_M_xMul(MTH_C_2,MTH_M_xMul(pstGlobalNormalOfMirror->xZ,pstGlobalNormalOfMirror->xZ)));
	a12=MTH_M_xMul(MTH_C_Minus2,MTH_M_xMul(pstGlobalNormalOfMirror->xX,pstGlobalNormalOfMirror->xY));
	a13=MTH_M_xMul(MTH_C_Minus2,MTH_M_xMul(pstGlobalNormalOfMirror->xX,pstGlobalNormalOfMirror->xZ));
	a23=MTH_M_xMul(MTH_C_Minus2,MTH_M_xMul(pstGlobalNormalOfMirror->xY,pstGlobalNormalOfMirror->xZ));
		
	MTH3D_M_vSetVectorElements(&pstModuleAxes[0],a11,a12,a13);
	MTH3D_M_vSetVectorElements(&pstModuleAxes[1],a12,a22,a23);
	MTH3D_M_vSetVectorElements(&pstModuleAxes[2],a13,a23,a33);
	
	POS_fn_vSetRotationMatrix(&stMulMatrixScale,&pstModuleAxes[0],&pstModuleAxes[1],&pstModuleAxes[2]);
		  
	/*I compute the translation matrix of the mirror transformation*/
	POS_fn_vGetTranslationVector(&stGlobalMatrixOfCamera,&stTransVectorOfCamera);
	MTH3D_M_vSubVector(&stTransVector,&stTransVectorOfCamera,pstGlobalPointOfMirror);
 
	xTemp=MTH_M_xMul(MTH_C_Minus2,MTH3D_M_xDotProductVector(&stTransVector,pstGlobalNormalOfMirror));
		
	MTH3D_M_vMulScalarVector(&stTransVector, xTemp, pstGlobalNormalOfMirror);
 
	MTH3D_M_vAddVector(&stTransVector,&stTransVector,&stTransVectorOfCamera);
 
	/*I transform the matrix*/
/*	POS_fn_vInitPositionFlag(&stTempMatrixForMultiplication);*/
	 GEO_M_vCopyMatrix( &stTempMatrixForMultiplication,&stGlobalMatrixOfCamera)
	POS_fn_vMulMatrixMatrix(&stGlobalMatrixOfCamera,&stMulMatrixScale, &stTempMatrixForMultiplication);
 
	POS_fn_vSetTranslationVector(&stGlobalMatrixOfCamera,&stTransVector);
	MTH3D_M_vCopyVector(pstGlobalPositionOfSymCamera,&stTransVector);  
	
	/*I invert the matrix of the SymCamera*/
	POS_fn_vSetIdentityMatrix(hMatrixOfSymCamera);
	POS_fn_vInvertMatrix(hMatrixOfSymCamera,&stGlobalMatrixOfCamera);
 
}		  
 
/**********************************************************************************************/
/* Name: SCT_fn_vFindAllMirrorsInVisibleSector*/
/* Goal: Find all the mirrors in the current sector and in the visible sectors*/
/* Code: Philippe Thiébaut*/
/* Verified: No*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void SCT_fn_vFindAllMirrorsInVisibleSector
(
	struct GLD_tdstViewportAttributes_	*_p_stVpt,
	HIE_tdxHandleToSuperObject			_hSprObjSector,
	HIE_tdxHandleToSuperObject			*p_hHandleOfMirror,
	ACP_tdxHandleOfObject				*p_hHandleOfGometricMirror,
	HIE_tdxHandleToSuperObject			*p_hSectorOfMirror,
	short *p_shNbOfMirrors
)
{
	SECT_tdxHandleOfElementLstGraphicInteraction	hGraphicElement;
	short											xI, xJ , i, shTempNbOfMirrors;
	
	/*To get the list of characters*/
	SECT_tdxHandleOfSectorObject hSectorObject;
	SECT_tdxHandleOfElementLstCharacter hCharacter;
 
	(*p_shNbOfMirrors)=0;
	hSectorObject=(SECT_tdxHandleOfSectorObject)HIE_fn_hGetSuperObjectObject(_hSprObjSector);
 
	/*
	 *	I find all the mirrors in the current sector.
	 *-----------------------------------------------
	 */
 
	/*Static*/
	if(!(HIE_fn_lGetSuperObjectDrawMask(_hSprObjSector) & GLI_C_lHasNoMirror))
	{
		HIE_fn_hFindAllMirrorsInHierarchy
		(
			_p_stVpt,
			_hSprObjSector,
			p_hHandleOfMirror,
			p_hHandleOfGometricMirror,
			p_shNbOfMirrors,
			SCT_C_xNbMaxOfMirrorsInVisibleSectors
		);
	}
		 
	/*Dynamic	*/
	LST2_M_DynamicForEachElementOf(&(hSectorObject->stListOfCharacters), hCharacter, xI)
	{
		if(!(HIE_fn_lGetSuperObjectDrawMask(hCharacter->hPointerOfCharacter) & GLI_C_lHasNoMirror))
		{
			HIE_fn_hFindAllMirrorsInHierarchy
			(
				_p_stVpt,
				hCharacter->hPointerOfCharacter,
				p_hHandleOfMirror,
				p_hHandleOfGometricMirror,
				p_shNbOfMirrors,
				SCT_C_xNbMaxOfMirrorsInVisibleSectors
			);
		}
	}	
	
	for (i=0;i<(*p_shNbOfMirrors);i++)
	{
		/*I need the sector where is the mirror*/
		p_hSectorOfMirror[i]=_hSprObjSector;
	}
 
	/*
	 *	I find all the mirrors in the visible sectors.
	 *------------------------------------------------
	 */
	SECT_M_ForEachGraphicNodeInGraphicInteractionList(_hSprObjSector,hGraphicElement,xI) 
	{
		shTempNbOfMirrors=(*p_shNbOfMirrors);
		
		/*Static*/
		if(!(HIE_fn_lGetSuperObjectDrawMask(SECT_GetSectorInGraphicList(hGraphicElement)) & GLI_C_lHasNoMirror))
		{
			HIE_fn_hFindAllMirrorsInHierarchy
			(
				_p_stVpt,
				SECT_GetSectorInGraphicList(hGraphicElement),
				p_hHandleOfMirror,
				p_hHandleOfGometricMirror,
				p_shNbOfMirrors,
				SCT_C_xNbMaxOfMirrorsInVisibleSectors
			);
		}
 
		hSectorObject=(SECT_tdxHandleOfSectorObject)HIE_fn_hGetSuperObjectObject(SECT_GetSectorInGraphicList(hGraphicElement));
 
		/*Dynamic	*/
		LST2_M_DynamicForEachElementOf
		(
			&(hSectorObject->stListOfCharacters), 
			hCharacter, 
			xJ
		)
		{
			if(!(HIE_fn_lGetSuperObjectDrawMask(hCharacter->hPointerOfCharacter) & GLI_C_lHasNoMirror))
			{
				HIE_fn_hFindAllMirrorsInHierarchy
				(
					_p_stVpt,
					hCharacter->hPointerOfCharacter,
					p_hHandleOfMirror,
					p_hHandleOfGometricMirror,
					p_shNbOfMirrors,
					SCT_C_xNbMaxOfMirrorsInVisibleSectors
				);
			}
		}	
	
		for (i=shTempNbOfMirrors;i<(*p_shNbOfMirrors);i++)
		{
			/*I need the sector where is the mirror*/
			p_hSectorOfMirror[i]=SECT_GetSectorInGraphicList(hGraphicElement);
		}
	}
}
#endif /* U64 */
 
/**********************************************************************************************/
/* Name: SCT_fn_vSendSectorWhereIAmToViewportWithMirror*/
/* Goal: Draw the sector with mirrors*/
/* Code: Philippe Thiébaut*/
/* Verified: No*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
/*this is the function called from exterior*/
void SCT_fn_vSendSectorWhereIAmToViewportWithMirror
(
	MTH3D_tdstVector			*_p_stAbsolutePositionOfCamera,
	GLD_tdhDevice				_hDevice,
	GLD_tdhViewport				_hViewport,
	struct						GLD_tdstViewportAttributes_ *_p_stVpt,
	HIE_tdxHandleToSuperObject  _hSprObjSector ,
	long						_lDrawMask
)												
{
#if !defined(U64)	/* No Mirror for Nintendo 64*/
	HIE_tdxHandleToSuperObject	hHandleOfMirror[SCT_C_xNbMaxOfMirrorsInVisibleSectors];
	HIE_tdxHandleToSuperObject	hSectorOfMirror[SCT_C_xNbMaxOfMirrorsInVisibleSectors];
	short						shNbOfMirror;
	ACP_tdxBool					p_bIDrawTheMirror[SCT_C_xNbMaxOfMirrorsInVisibleSectors];
	short						i;
/*	ACP_tdxIndex				xTempIndex[3];*/
	ACP_tdxHandleOfObject		p_hHandleOfGometricMirror[SCT_C_xNbMaxOfMirrorsInVisibleSectors];
	MTH3D_tdstVector			stNormalOfMirror;
	MTH3D_tdstVector			stPointOfMirror;
	GEO_tdxHandleToMatrix		p_hGlobalMatrixOfMirror[SCT_C_xNbMaxOfMirrorsInVisibleSectors];
	MTH3D_tdstVector			stI, stJ, stK;
	MTH3D_tdstVector			stGlobalPositionOfSymCamera;
	POS_tdstCompletePosition	stTransMatrix;
	struct GLI_tdstCamera_		stSymCam;
	struct GLI_tdstCamera_		*p_stCpyCam;
	/* This the radius of visibility for all mirrors */
	/*MTH_tdxReal					xDistanceOfActivationOfMirror=50.0f;  // DANGER !!!!!!!!!!!!*/
	/*MTH_tdxReal					xDistanceFromCameraToMirror;*/
	/* For clipping by water */
	MTH_tdxReal					xWaterDistance;
	/* For clipping by a window */
	long						lXMin, lXMax, lYMin, lYMax;
	unsigned long lXMinA,lXMaxA,lYMinA,lYMaxA;
	GLD_tdstDeviceAttributes stDevAttrib ;
#endif /* U64*/
 
#if !defined(U64)	/* No Mirror for Nintendo 64*/
	GEO_fn_vComputeCameraParametersForCulling( _p_stVpt,  fn_xGetSectorZFar( _hSprObjSector ) );
	SCT_fn_vFindAllMirrorsInVisibleSector(_p_stVpt,_hSprObjSector,hHandleOfMirror,p_hHandleOfGometricMirror, hSectorOfMirror,&shNbOfMirror);
 
	/* if there's a global fog set it now.*/
	if(GLI_cGlobalFogIsOn) {
		GLI_vSetFog2( GLI_xFogBlendNear, GLI_xFogNear, GLI_xFogBlendFar, GLI_xFogFar, GLI_xFogInfinite, &GLI_stFogColor );
		GLI_vFogOn();
	}
 
	if ( shNbOfMirror != 0 ) {
		/*There is a mirror in the scene so i make some initializations*/
 
 
		/*I save the clip window of the viewport*/
		lXMin=_p_stVpt->dwClipLeftInPix;
		lXMax=_p_stVpt->dwClipRightInPix;
		lYMin=_p_stVpt->dwClipTopInPix;
		lYMax=_p_stVpt->dwClipBottomInPix;
 
		lXMinA=65536;
		lXMaxA=0;
		lYMinA=65536;
		lYMaxA=0;
 
 
		GLD_bGetDeviceAttributes( _hDevice, &stDevAttrib ) ;
 
		for (i=0;i<shNbOfMirror;i++)
		{
			MTH3D_tdstVector stTempVectorForMultiplication;
 
			p_bIDrawTheMirror[i]=1;
			
			p_hGlobalMatrixOfMirror[i]=HIE_fn_hGetSuperObjectGlobalMatrix(hHandleOfMirror[i]);
			
			/*I get the first point of the first face of the object mirror*/
			/*GEO_vGetFaceOfIndexedTriangles(p_hHandleOfGometricMirror[i],0,0,&xTempIndex[0],&xTempIndex[1],&xTempIndex[2]);*/
			/*GEO_vGetPointOfObject(p_hHandleOfGometricMirror[i],&stTempVectorForMultiplication,xTempIndex[0]);*/
			GEO_vGetPointOfObject(p_hHandleOfGometricMirror[i],&stTempVectorForMultiplication,0);
			POS_fn_vMulMatrixVertex( &stPointOfMirror,p_hGlobalMatrixOfMirror[i],&stTempVectorForMultiplication) ;
			
			/*I get the normal of the first face of the object mirror*/
			GEO_vGetNormalOfGeometricObjectElement(p_hHandleOfGometricMirror[i],0,0,&stTempVectorForMultiplication);
			POS_fn_vGetRotationMatrix(p_hGlobalMatrixOfMirror[i],&stI,&stJ,&stK);
			POS_fn_vSetIdentityMatrix(&stTransMatrix);
			POS_fn_vSetRotationMatrix (&stTransMatrix ,&stI ,&stJ,&stK );
			POS_fn_vMulMatrixVector(&stNormalOfMirror,&stTransMatrix,&stTempVectorForMultiplication);
			
			/*I compute the distance between the mirror and the camera*/
			MTH3D_M_vSubVector(&stI,_p_stAbsolutePositionOfCamera,&stPointOfMirror);
			/*xDistanceFromCameraToMirror=MTH3D_M_xNormVector(&stI);*/
			
			/*if(MTH_M_bGreater(xDistanceFromCameraToMirror,xDistanceOfActivationOfMirror)) p_bIDrawTheMirror[i]=0;*/
			if (MTH_M_bLess(MTH3D_M_xDotProductVector(&stI,&stNormalOfMirror),MTH_C_ZERO)) p_bIDrawTheMirror[i]=0;
			
			if (p_bIDrawTheMirror[i]) {
				/*Do a copy of the camera*/
				GLI_xGetViewportCamera(_hDevice, _hViewport, &p_stCpyCam);
				
				/*Init the symetric camera*/
				GLI_vCopyCamera ( &stSymCam ,p_stCpyCam);
				GLI_xGetCameraMatrix (&stSymCam, &stTransMatrix ) ;
 
				SCT_fn_vGetSymMatrixOfCameraInMirror(&stTransMatrix,&stTransMatrix,
					&stGlobalPositionOfSymCamera,&stNormalOfMirror,&stPointOfMirror);
				GLI_xSetCameraMatrix (&stSymCam, &stTransMatrix) ;
				
				/*Set the symetric camera as camera of viewport*/
				GLI_xSetViewportCamera ( _hDevice, _hViewport, &stSymCam ) ;
				
				if (!GLI_vAdjustCameraToMirror(p_hHandleOfGometricMirror[i],p_hGlobalMatrixOfMirror[i],&stTransMatrix ,&stSymCam,_p_stVpt,_lDrawMask))
					p_bIDrawTheMirror[i]=FALSE;
 
				GLI_xAdjustCameraToViewport2 ( &stDevAttrib, _p_stVpt, &stSymCam );
				GEO_fn_vComputeCameraParametersForCulling( _p_stVpt,  fn_xGetSectorZFar( _hSprObjSector ) );
				
				if (p_bIDrawTheMirror[i])
				{
					SECT_tdxHandleOfSectorObject hSectorObject;
					hSectorObject=(SECT_tdxHandleOfSectorObject)HIE_fn_hGetSuperObjectObject(hSectorOfMirror[i]);
					
					/*
					 * Init the plan clipping.
					 * If xNbElements!=1 the mirror is optimized without clipping.
					 */
					if (p_hHandleOfGometricMirror[i]->xNbElements!=1) 
						GLI_vSetWaterplaneOff();
					else 
					{
						xWaterDistance=MTH3D_M_xDotProductVector(&stPointOfMirror,&stNormalOfMirror);
						GLI_vSetWaterplane(_p_stVpt,&stNormalOfMirror,xWaterDistance);
					}
					
					/* I draw the symetric sector */
					if (hSectorObject->xVirtual) {
						SCT_fn_vSendSectorWhereIAmToViewport(
							&stGlobalPositionOfSymCamera,
							_p_stVpt,
							_hSprObjSector ,
							_lDrawMask - GLI_C_lIsNotDrawingInMirror - GLI_C_lNotHideWhatIsUnderWater);
					}
					else {
						/* Drawing the normal objects */
						SCT_fn_vSendSectorWhereIAmToViewport(	
							&stGlobalPositionOfSymCamera,
							_p_stVpt,hSectorOfMirror[i],
							_lDrawMask - GLI_C_lIsNotDrawingInMirror - GLI_C_lNotHideWhatIsUnderWater);
					}
 
 
					if(lXMinA>_p_stVpt->dwClipLeftInPix) lXMinA=_p_stVpt->dwClipLeftInPix;
					if(lYMinA>_p_stVpt->dwClipTopInPix) lYMinA=_p_stVpt->dwClipTopInPix;
					if(lXMaxA<_p_stVpt->dwClipRightInPix) lXMaxA=_p_stVpt->dwClipRightInPix;
					if(lYMaxA<_p_stVpt->dwClipBottomInPix) lYMaxA=_p_stVpt->dwClipBottomInPix;
 
					/* I restore the clip window */
					_p_stVpt->dwClipLeftInPix=lXMin;
					_p_stVpt->dwClipRightInPix=lXMax;
					_p_stVpt->dwClipTopInPix=lYMin;
					_p_stVpt->dwClipBottomInPix=lYMax;
 
 
					/* I restore the clipping mode */
					if (p_hHandleOfGometricMirror[i]->xNbElements!=1) 
						GLI_vSetWaterplaneOn();				
				
					/* Draw transparent faces and Clear Zbuffer Before drawing mirror surfaces*/
					/* Transparent faces are send when all symetric worlds are drawn*/
					GLI_xSendListToViewport (_p_stVpt ) ;
					GLI_xClearViewingList () ;
 
					/* I restore the camera */
					GLI_xSetViewportCamera ( _hDevice, _hViewport, p_stCpyCam ) ;			
 
					/* -------------------------------------------------------------------*/
					/* Draw mirror surface*/
					bViewingInMirror = TRUE;
					GLI_vWaterplaneDisable2DSinus(); 
					HIE_fn_bInitCameraMatrixStack(_p_stVpt);
					HIE_fn_vPushMatrix (hHandleOfMirror[i]);
					HIE_fn_vPushOnCameraMatrixStack(hHandleOfMirror[i]);
 
					/* Send Light and fog*/
					SECT_fn_vSendDynamicLightsFromWhereIAmToViewport(_p_stVpt,hSectorOfMirror[i]);
					SECT_fn_vSendFogToViewport(_p_stVpt,hSectorOfMirror[i]);
 
					fn_vSendOneModuleToViewPort(_p_stVpt,hHandleOfMirror[i],_lDrawMask);
 
					/* Clear all lights of viewport*/
					GLI_vClearListOfLightInViewport (_p_stVpt);
 
					HIE_fn_vPopMatrix();
					HIE_fn_vPopOnCameraMatrixStack();
					bViewingInMirror = FALSE;
					/* -------------------------------------------------------------------*/
				}
 
			}
		}
	}
#endif /* U64 */
 
	/* I draw the normal sector */
	GEO_fn_vComputeCameraParametersForCulling( _p_stVpt,  fn_xGetSectorZFar( _hSprObjSector ) );
 
/* Oliv' - to see collision Map with collision sector interaction - 25/05/1999 */
#if defined(_U64_GLI_BENCH_)
	if( GLIBENCH_g_bColMap )
	{
		GLIBENCH_SCT_fn_vSendCollisionSectorWhereIAmToViewport(
			_p_stAbsolutePositionOfCamera,
			_p_stVpt,
			_hSprObjSector,
			_lDrawMask);
	}
	else
#endif /* _U64_GLI_BENCH_ */
	{
	SCT_fn_vSendSectorWhereIAmToViewport(
		_p_stAbsolutePositionOfCamera,
		_p_stVpt,
		_hSprObjSector,
		_lDrawMask);
	} 
/* EndOfOliv' */
	AGO_vProcessAllParts(_p_stVpt);
}
  
#ifndef U64
/**********************************************************************************************/
/* Name: SCT_fn_vInitMirrorFlagForAllSectors*/
/* Goal: Search mirror in each sector to set the flag GLI_C_lHasNoMirror*/
/* Code: Carlos Torres*/
/* Verified: No*/
/* OPTIMMIZED : No*/
/**********************************************************************************************/
void SCT_fn_vInitMirrorFlagForAllSectors(HIE_tdxHandleToSuperObject _hStaticRoot) {
	int i;
	HIE_tdxHandleToSuperObject hSector;
 
	/* If find a mirror in sector set is DrawFlag*/
	HIE_M_ForEachChildOf(_hStaticRoot,hSector,i) {
		if (HIE_fn_bFindMirrorInHierarchy(hSector))
			HIE_fn_vSetSuperObjectDrawMask(hSector,HIE_fn_lGetSuperObjectDrawMask(hSector) & ~GLI_C_lHasNoMirror);
	}
}
 
#endif /* U64 */
