/* (c) Ubi Studios 1996*/
/* See Vincent Greco for any comment or question*/
 
#include "ACP_base.h"
 
#include "GEO.h"
#include "GLI.h"
 
#include "LST.h"
#include "SPO/HieMtStk.h"
 
#include "SPO/HieConst.h"	/*constants*/
#define __HIE_GLOBALS
#include "SPO/HieSpObj.h"	/*structures and access macros*/
#include "SPO/HieHand.h"	/*handle definitions*/
#include "SPO/HieExt.h"
#include "SPO/HieDef.h"		/*macros for the macros ...*/
 
extern HIE_tdxHandleToSuperObject	gd_hFixSPO[HIE_C_MaxNumberOfSPOInTheFix] ;
extern HIE_tdxHandleToSuperObject	gd_hFixSPOSave[HIE_C_MaxNumberOfSPOInTheFix] ;
extern ACP_tdxIndex g_xFixIndex;
extern ACP_tdxIndex g_xFixIndexSave;
unsigned char gd_ucContextOfSPOSave[HIE_C_MaxNumberOfSPOInTheFix] ;
unsigned char g_ucContext = 0 ;
 
/*function accessors definition*/
ACP_tdxBool HIE_fn_bIsSuperObjectValid(HIE_tdxHandleToSuperObject hSuperObject)
{
	return (hSuperObject)!=HIE_C_InvalidSuperObject;
}
void HIE_fn_vSetSuperObjectObjectAndType(HIE_tdxHandleToSuperObject _hSprObj, HIE_tdxHandleToVoid _hObj, unsigned long _ulType)
{
	if(_hObj==NULL)
		_ulType=HIE_C_ulSuperObject;/* if the linked object does not exist do not try to process it*/
	
	HIE_M_vSetSuperObjectMember(_hSprObj, ulTypeOfLinkedObject, _ulType);
	HIE_M_vSetSuperObjectMember(_hSprObj, hLinkedObject.p_Void, _hObj);
}
 
/*****************************************************************************************************
 * superimposed 
 *****************************************************************************************************/
void SPO_ReinitSuperimposedArray(void) {
  ACP_tdxIndex xIndex ;
  for ( xIndex = 0 ; xIndex < g_xFixIndex ; xIndex ++ ) {
    gd_hFixSPO[xIndex]->ulFlags &= ~(HIE_C_Flag_ulSuperimposed | HIE_C_Flag_ulNotPickable );
  }
  g_xFixIndex = 0 ;
  g_ucContext = 0 ;
  g_xFixIndexSave = 0 ;
}
HIE_tdxHandleToSuperObject HIE_fn_hGetElementFormFixViewport ( ACP_tdxIndex xIndex ) {
  if ( xIndex < g_xFixIndex ) {
    return ( gd_hFixSPO[xIndex] ) ;
  }
  else
    return NULL ;
}
 
void  HIE_fn_SO_vSetSuperimposedFlag (HIE_tdxHandleToSuperObject _hSO)
{
	if ( (_hSO->ulFlags & HIE_C_Flag_ulSuperimposed ) == HIE_C_Flag_ulSuperimposed )
		return ;
	/*
	 * set the flag for this SPO
	 */
	_hSO->ulFlags |= (HIE_C_Flag_ulSuperimposed | HIE_C_Flag_ulNotPickable );
 
	/*
	 * register the SPO
	 */
	if ( g_xFixIndex < HIE_C_MaxNumberOfSPOInTheFix ) {
		gd_hFixSPO[g_xFixIndex] = _hSO ;
		g_xFixIndex ++ ;
	}
 
}
 
void HIE_fn_SO_vClearSuperimposedFlag(HIE_tdxHandleToSuperObject _hSO)
{
	ACP_tdxIndex xIndex;
 
	if ( (_hSO->ulFlags & HIE_C_Flag_ulSuperimposed ) != HIE_C_Flag_ulSuperimposed )
		return ;
	/*
	 * clear the flag for this SPO
	 */
	_hSO->ulFlags &= ~(HIE_C_Flag_ulSuperimposed | HIE_C_Flag_ulNotPickable );
 
	if (g_xFixIndex == 0)
		return;
	/*
	 * unregister the SPO
	 */
	for ( xIndex = 0; xIndex < HIE_C_MaxNumberOfSPOInTheFix; xIndex ++ )
	{
		if ( gd_hFixSPO[xIndex] == _hSO ) /* scan until we find it*/
		{
			/* fill the gap by moving the last SO in the array into the hole we just create*/
			g_xFixIndex --;
			if (g_xFixIndex != 0)
				gd_hFixSPO[xIndex] = gd_hFixSPO[g_xFixIndex];
			gd_hFixSPO[g_xFixIndex] = NULL;
			break;
		}
	}
}

/*AR9902 Bug corrected : must test gd_ucContextOfSPOSave[g_xFixIndexSave-1] instead of gd_ucContextOfSPOSave[g_xFixIndexSave]*/
void HIE_fn_SO_SwitchSuperImposedTab (long lParam) 
{
	int i ;

	if ( lParam ) 
	{
		/* lparam = 1 -> show menu */
		if ( g_xFixIndex ) 
		{
			for ( i=0 ; i<g_xFixIndex ; i++ ) 
			{
				gd_hFixSPOSave[g_xFixIndexSave++] = gd_hFixSPO[i] ;
				gd_ucContextOfSPOSave[i] = g_ucContext ;
			}
			g_xFixIndex = 0 ;
		}    
		g_ucContext ++ ;
	}
	else 
	{
		/* lparam = 0 -> show normal fix viewport */
		unsigned char fn_ucStdGameCheckValidity(HIE_tdxHandleToSuperObject _h_SprObj) ;
		g_ucContext -- ;
		if ( g_xFixIndexSave ) 
		{
			g_xFixIndex = 0 ;
			for ( ; (g_xFixIndexSave>0) && (gd_ucContextOfSPOSave[g_xFixIndexSave-1] == g_ucContext) ; g_xFixIndexSave-- ) 
			{
				if ( fn_ucStdGameCheckValidity(gd_hFixSPOSave[g_xFixIndexSave-1])) 
				{
					gd_hFixSPO[g_xFixIndex++] = gd_hFixSPOSave[g_xFixIndexSave-1] ;
				}
			}
		}
	}
}

/******************************************************************************************************/
 
void HIE_fn_vSetSuperObjectExcluLight(HIE_tdxHandleToSuperObject _hSprObj,unsigned char _bExcluLight)
{
	if( _bExcluLight )
		_hSprObj->ulFlags |= HIE_C_Flag_ExcluLight;
	else
		_hSprObj->ulFlags &= ~HIE_C_Flag_ExcluLight;
}
 
 
/*---------------------------------------------------------------*/
/*for Francois DO NOT USE THESEe FUNCTIONS*/
void HIE_fn_vIsolate(HIE_tdxHandleToSuperObject _hSprObj)
{
	HIE_M_vIsolate(_hSprObj);
}
 
/*---------------------------------------------------------------*/
void HIE_fn_vPseudoIsolate(HIE_tdxHandleToSuperObject _hSprObj)
{
	HIE_tdxHandleToSuperObject hNext;

	hNext = LST2_M_DynamicGetNextElement(_hSprObj);

	HIE_M_vIsolate(_hSprObj);

	LST2_M_DynamicSetNextElement(_hSprObj,hNext);
}

#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void HIE_fn_vInitParent(HIE_tdxHandleToSuperObject _hSprObj)
{
	LST2_M_DynamicInitAnchor(_hSprObj);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*--------------------------------------------------------------------------------------*/
/*  Name        : HIE_fn_vGetParallelBoxFromBoundingVolume*/
/*  Author      : Thierry QUERE*/
/*  Date        : 16/02/98*/
/*  Description :*/
/*  Optimized ? : No*/
/*--------------------------------------------------------------------------------------*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void HIE_fn_vGetParallelBoxFromBoundingVolume(MTH3D_tdstVector * _p_stMaxBoxPoint,
											  MTH3D_tdstVector * _p_stMinBoxPoint,
											  ACP_tdxHandleOfObject _hBoundingVolume)
{
	_p_stMaxBoxPoint = GEO_fn_pGetMaxPointOfParallelBox ((GEO_tdstParallelBox*) _hBoundingVolume);
	_p_stMinBoxPoint = GEO_fn_pGetMinPointOfParallelBox ((GEO_tdstParallelBox*) _hBoundingVolume);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
 
HIE_tdxHandleToSuperObject HIE_fn_hCreateSuperObject(void)
{
	HIE_tdxHandleToSuperObject hNewSuperObject;
 
	MMG_fn_vAddMemoryInfo( MMG_C_lTypeSuperObject , MMG_C_lSubTypeSuperObject , 0 );
	GEO_M_CPAMalloc( hNewSuperObject,
					 HIE_tdxHandleToSuperObject,
					 sizeof(struct HIE_tdstSuperObject_),
					 E_uwGEONotEnoughtMemory);
 
	LST2_M_DynamicInitAnchor(hNewSuperObject);
	LST2_M_DynamicInitElement(hNewSuperObject);
	HIE_fn_vSetSuperObjectObjectAndType(hNewSuperObject,NULL,HIE_C_ulSuperObject);
	HIE_fn_vSetSuperObjectBoundingVolume(hNewSuperObject, NULL);
	HIE_fn_vSetSuperObjectDrawMask(hNewSuperObject, GLI_C_lAllIsEnable/*&(~GLI_C_lIsNotDrawCollideInformation)*/);
	HIE_M_vSetSuperObjectMember(hNewSuperObject,hGlobalMatrix,GEO_fn_hCreateMatrix());
	POS_fn_vSetIdentityMatrix(HIE_M_xGetSuperObjectMember(hNewSuperObject,hGlobalMatrix));
 
	HIE_fn_vInvalidateOneGlobalMatrix(hNewSuperObject);
 
	HIE_M_vSetSuperObjectMember( hNewSuperObject,fTransparenceLevel,255.0f );
 
	HIE_fn_vSetSuperObjectExcluLight ( hNewSuperObject,0);
 
	return hNewSuperObject;
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void HIE_fn_vCopySuperObject(HIE_tdxHandleToSuperObject _hDst,HIE_tdxHandleToSuperObject _hSrc)
{
	HIE_fn_vSetSuperObjectObjectAndType
		(_hDst,
		HIE_fn_hGetSuperObjectObject(_hSrc),
		HIE_fn_ulGetSuperObjectType(_hSrc));
	HIE_fn_vSetSuperObjectDrawMask(_hDst, HIE_fn_lGetSuperObjectDrawMask(_hSrc));
	HIE_fn_vSetSuperObjectMatrix(_hDst, HIE_fn_hGetSuperObjectMatrix(_hSrc));
	GEO_M_vCopyMatrix(HIE_fn_hGetSuperObjectGlobalMatrix(_hDst),HIE_fn_hGetSuperObjectGlobalMatrix(_hSrc));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
#ifndef _FIRE_DEADCODE_U64_
HIE_tdxHandleToSuperObject HIE_fn_hDuplicateSuperObject(HIE_tdxHandleToSuperObject _hSuperObject)
{
	HIE_tdxHandleToSuperObject hNewSuperObject;
	hNewSuperObject=HIE_fn_hCreateSuperObject();
	HIE_fn_vCopySuperObject(hNewSuperObject,_hSuperObject);
    return hNewSuperObject;
}
#endif /* _FIRE_DEADCODE_U64_ */
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void HIE_fn_vDestroySuperObject(HIE_tdxHandleToSuperObject hOldSuperObject)
{
	GEO_fn_vDestroyMatrix(HIE_M_xGetSuperObjectMember(hOldSuperObject,hGlobalMatrix));
	GEO_M_CPAFree(hOldSuperObject);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
/*!!! no DestroySuperObjectTab !*/
HIE_tdxHandleToSuperObjectTab HIE_fn_p_stCreateSuperObjectTab(long lSize)
{
	struct HIE_tdstSuperObject_* hNewSuperObjectTab;
	struct HIE_tdstSuperObject_* hNewSuperObject;
	long lIndex;
 
	MMG_fn_vAddMemoryInfo( MMG_C_lTypeSuperObject , MMG_C_lSubTypeSuperObjectTable , 0 );
	GEO_M_CPAMalloc(hNewSuperObjectTab, HIE_tdxHandleToSuperObject, sizeof(struct HIE_tdstSuperObject_)*lSize, E_uwGEONotEnoughtMemory);
	for(hNewSuperObject=hNewSuperObjectTab,lIndex=0;lIndex<lSize;hNewSuperObject++,lIndex++)
	{
		LST2_M_DynamicInitAnchor(hNewSuperObject);
		LST2_M_DynamicInitElement(hNewSuperObject);
		HIE_fn_vSetSuperObjectObjectAndType(hNewSuperObject,NULL,0);
		HIE_fn_vSetSuperObjectBoundingVolume(hNewSuperObject, NULL);
		HIE_fn_vSetSuperObjectDrawMask(hNewSuperObject, GLI_C_lAllIsEnable);
 
		HIE_M_vSetSuperObjectMember(hNewSuperObject,hGlobalMatrix,GEO_fn_hCreateMatrix());
		POS_fn_vSetIdentityMatrix(HIE_M_xGetSuperObjectMember(hNewSuperObject,hGlobalMatrix));
 
		HIE_fn_vInvalidateOneGlobalMatrix(hNewSuperObject);
   		HIE_M_vSetSuperObjectMember( hNewSuperObject,fTransparenceLevel,255.0f );
 
		HIE_fn_vSetSuperObjectExcluLight( hNewSuperObject,0);
	}
    return hNewSuperObjectTab;
}
 
 
 
HIE_tdxHandleToSuperObject HIE_fn_hForceGetSuperObjectNextBrother(HIE_tdxHandleToSuperObject _hSprObj)
{
	if(HIE_fn_bIsSuperObjectValid(_hSprObj))
		return HIE_M_hNextChild(_hSprObj);
	else
		return _hSprObj;/*i.e. Invalid*/
}
 
HIE_tdxHandleToSuperObject HIE_fn_hForceGetSuperObjectPrevBrother(HIE_tdxHandleToSuperObject _hSprObj)
{
	if(HIE_fn_bIsSuperObjectValid(_hSprObj))
		return HIE_M_hPrevChild(_hSprObj);
	else
		return _hSprObj;/*i.e. Invalid*/
}
 
HIE_tdxHandleToSuperObject HIE_fn_hGetChildNumber(HIE_tdxHandleToSuperObject _hParent, long _lNumber)
{
	HIE_tdxHandleToSuperObject hChild;
	ACP_tdxIndex i;
 
	LST2_M_DynamicGetElementNumber(_hParent, hChild, _lNumber, i);
	return hChild;
}
 
#ifndef _FIRE_DEADCODE_U64_
long HIE_fn_lGetNumberOfElement(HIE_tdxHandleToSuperObject _hParent, HIE_tdxHandleToSuperObject _hChild)
{
	long lResult;
	HIE_tdxHandleToSuperObject hChild;
 
	LST2_M_DynamicWhatElementNumber(_hChild, hChild, lResult);
	return lResult;
}
#endif /* _FIRE_DEADCODE_U64_ */
 
 
void HIE_fn_vInvalidateAllGlobalMatrices(void)
{
	HIE_gs_lCurrentFrame++; /*macro when optimized ?*/
	if(HIE_gs_lCurrentFrame==HIE_C_lCounterNotValid) HIE_gs_lCurrentFrame++;
}
 
void HIE_fn_vInvalidateOneGlobalMatrix(HIE_tdxHandleToSuperObject _hSprObj)
{
 
	if (HIE_M_xGetSuperObjectMember(_hSprObj,lLastComputeFrame) == HIE_C_lCounterNotValid)
	{
/*		assert(0);*/
		return;
	}
 
	if(HIE_gs_lCurrentFrame!=HIE_C_lCounterNotValid+1)
	{
		HIE_M_vSetSuperObjectMember(_hSprObj,lLastComputeFrame, HIE_gs_lCurrentFrame-1);
	}
	else
	{
		HIE_M_vSetSuperObjectMember(_hSprObj,lLastComputeFrame, HIE_gs_lCurrentFrame-2);
	}
}
 
void HIE_fn_vSetSuperObjectStaticMatrix(HIE_tdxHandleToSuperObject _hSprObj, GEO_tdxHandleToMatrix _hMatrix)
{
	GEO_M_vCopyMatrix(HIE_M_xGetSuperObjectMember(_hSprObj,hGlobalMatrix), _hMatrix);
	HIE_M_vSetSuperObjectMember(_hSprObj,lLastComputeFrame, HIE_C_lCounterNotValid);
}
 
void HIE_fn_vInitGlobalMatrixFrameCounter(long lValue)
{
	if(lValue!=HIE_C_lCounterNotValid)
		HIE_gs_lCurrentFrame=lValue;
	else
		HIE_gs_lCurrentFrame=lValue+1;
}
 
 
void HIE_fn_vPushMatrix( HIE_tdxHandleToSuperObject _hSprObj )
{
	if(HIE_fn_bIsGlobalMatrixValid(_hSprObj))
	{
		HIE_fn_bStoreMatrix( HIE_M_xGetSuperObjectMember(_hSprObj,hGlobalMatrix) );
	}
	else
	{
		POS_fn_vMulMatrixMatrix(
				HIE_M_xGetSuperObjectMember(_hSprObj,hGlobalMatrix),
				HIE_g_a_hMatrixStack[HIE_g_lNbMatrixInStack-1],
				HIE_M_xGetSuperObjectMember(_hSprObj,hLocalMatrix) );
		HIE_fn_bStoreMatrix( HIE_M_xGetSuperObjectMember(_hSprObj,hGlobalMatrix) );
		HIE_fn_vValidateGlobalMatrix(_hSprObj);
	}
}
 
void HIE_fn_vPopMatrix (void)
{
	HIE_fn_bPopMatrix ();
}
 

#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC 04/06/99 */
void HIE_fn_vStoreOnCameraMatrixStack(HIE_tdxHandleToSuperObject _hSprObj)
{
	HIE_fn_bStoreOnCameraMatrixStack (HIE_M_xGetSuperObjectMember(_hSprObj,hGlobalMatrix));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC 04/06/99 */


void HIE_fn_vPushOnCameraMatrixStack(HIE_tdxHandleToSuperObject _hSprObj)
{
	HIE_fn_bPushOnCameraMatrixStack (HIE_M_xGetSuperObjectMember(_hSprObj,hLocalMatrix));
}
 
void HIE_fn_vPopOnCameraMatrixStack()
{
	HIE_fn_bPopOnCameraMatrixStack ();
}
 
/* compute the relative matrix of the SO, without changing the absolute one */
void HIE_fn_vComputeNewRelativeMatrix(HIE_tdxHandleToSuperObject _hSprObj)
{
    POS_tdstCompletePosition stLocalMatrix;
 
    POS_fn_vInvertMatrix(&stLocalMatrix, HIE_M_xGetSuperObjectMember(HIE_M_hGetSuperObjectFather(_hSprObj),hGlobalMatrix));
    POS_fn_vMulMatrixMatrix(HIE_M_xGetSuperObjectMember(_hSprObj, hLocalMatrix), &stLocalMatrix, HIE_M_xGetSuperObjectMember(_hSprObj, hGlobalMatrix));
}
 
void HIE_fn_vComputeNewRelativeScaleMatrix(HIE_tdxHandleToSuperObject _hSprObj)
{
/*	GEO_tdxHandleToMatrix hMatrix;
	POS_tdstCompletePosition LocalMatrix;
	hMatrix=&LocalMatrix;
 
	POS_fn_vSetIdentityMatrix(hMatrix);
 
	POS_fn_vInvertMatrix(hMatrix, HIE_M_xGetSuperObjectMember(HIE_M_hGetSuperObjectFather(_hSprObj),hGlobalMatrix));
	POS_fn_vMulMatrixMatrix(HIE_M_xGetSuperObjectMember(_hSprObj, hLocalMatrix), hMatrix, HIE_M_xGetSuperObjectMember(_hSprObj, hGlobalMatrix));
*/
	HIE_fn_vComputeNewRelativeMatrix (_hSprObj);
 
}
 
/* the SO will be the last child of its new father */
void HIE_fn_vChangeFather(HIE_tdxHandleToSuperObject _hSprObj, HIE_tdxHandleToSuperObject _hNewFather, ACP_tdxBool _bAtHead)
{
	HIE_M_vIsolate(_hSprObj);
  if ( _bAtHead )
  {
  	HIE_fn_vSuperObjectAddHead(_hNewFather, _hSprObj);
  }
  else
  {
  	HIE_fn_vSuperObjectAddTail(_hNewFather, _hSprObj);
  }
	HIE_fn_vComputeNewRelativeScaleMatrix(_hSprObj);
}
 
#ifndef _FIRE_DEADCODE_U64_
/* the SO will be the next brother of its new brother */
void HIE_fn_vChangeBrother(HIE_tdxHandleToSuperObject _hSprObj, HIE_tdxHandleToSuperObject _hNewPrevBrother)
{
	HIE_M_vIsolate(_hSprObj);
	HIE_M_vInsertBetween(_hSprObj, _hNewPrevBrother, HIE_M_hNextChild(_hNewPrevBrother));
	HIE_fn_vComputeNewRelativeScaleMatrix(_hSprObj);
}
#endif /* _FIRE_DEADCODE_U64_ */
 
 
/*Be careful : this is a recursive function !!!*/
/* If a global matrix is invalid, it is recomputed from the local matrix*/
/* you can use HIE_fn_vInvalidaeAllGlobalMatrices() before this function*/
/* to force all the global matrices to be recomputed*/
void HIE_fn_vRefreshHierarchy(HIE_tdxHandleToSuperObject _hSprObj)
{
	ACP_tdxIndex i;
	HIE_tdxHandleToSuperObject hChild;
 
	HIE_fn_vPushMatrix (_hSprObj);
 
	HIE_M_ForEachChildOf(_hSprObj, hChild, i)
		HIE_fn_vRefreshHierarchy(hChild);
 
	HIE_fn_vPopMatrix ();
}
 
void HIE_fn_vInvalidateHierarchy(HIE_tdxHandleToSuperObject _hSprObj)
{
	ACP_tdxIndex i;
	HIE_tdxHandleToSuperObject hChild;
 
	HIE_fn_vInvalidateOneGlobalMatrix(_hSprObj);
 
	HIE_M_ForEachChildOf(_hSprObj, hChild, i)
		HIE_fn_vInvalidateHierarchy(hChild);
}
 
#define HIE_M_hNextChild(_hBrother) LST2_M_DynamicGetNextElement(_hBrother)
#define HIE_M_hFirstChild(_hParent) LST2_M_DynamicGetFirstElement(_hParent)
#define HIE_M_hPrevChild(_hBrother) LST2_M_DynamicGetPrevElement(_hBrother)
#define HIE_M_hLastChild(_hParent) LST2_M_DynamicGetLastElement(_hParent)
#define HIE_M_hGetSuperObjectFather(_hSprObj) LST2_M_DynamicGetFather(_hSprObj)
 
/*for binarisation only : DO NOT use these functions (too low level)*/
#ifndef _FIRE_DEADCODE_U64_
HIE_tdxHandleToSuperObject HIE_fn_hGetSuperObjectPrevBrother(HIE_tdxHandleToSuperObject _hSprObj)
{
  return HIE_M_hPrevChild(_hSprObj);
}
HIE_tdxHandleToSuperObject HIE_fn_hGetSuperObjectLastChild(HIE_tdxHandleToSuperObject _hSprObj)
{
  return HIE_M_hLastChild(_hSprObj);
}
#endif /* _FIRE_DEADCODE_U64_ */
 
 
#ifndef _FIRE_DEADCODE_U64_
void HIE_fn_vSetSuperObjectLastChild(HIE_tdxHandleToSuperObject _hSprObj,HIE_tdxHandleToSuperObject _hChild)
{
  HIE_M_hLastChild(_hSprObj)=_hChild;
}
void HIE_fn_vSetSuperObjectNextBrother(HIE_tdxHandleToSuperObject _hSprObj,HIE_tdxHandleToSuperObject _hBrother)
{
  HIE_M_hNextChild(_hSprObj)=_hBrother;
}
void HIE_fn_vSetSuperObjectPrevBrother(HIE_tdxHandleToSuperObject _hSprObj,HIE_tdxHandleToSuperObject _hBrother)
{
  HIE_M_hPrevChild(_hSprObj)=_hBrother;
}
void HIE_fn_vSetSuperObjectFather(HIE_tdxHandleToSuperObject _hSprObj,HIE_tdxHandleToSuperObject _hFather)
{
  HIE_M_hGetSuperObjectFather(_hSprObj)=_hFather;
}
#endif /* _FIRE_DEADCODE_U64_ */
 
 
 
/* LOL*/
#ifndef _FIRE_DEADCODE_U64_
/* ANNECY MT 06/03/98 {*/
void HIE_fn_vSetMagnetModification(HIE_tdxHandleToSuperObject _hSprObj, ACP_tdxBool xModified)
{
	if( xModified )
		_hSprObj->ulFlags |= HIE_C_Flag_MagnetModification;
	else
		_hSprObj->ulFlags &= ~HIE_C_Flag_MagnetModification;
}
 
ACP_tdxBool HIE_fn_bGetMagnetModification(HIE_tdxHandleToSuperObject _hSprObj)
{
	return ((_hSprObj->ulFlags & HIE_C_Flag_MagnetModification) ? TRUE : FALSE);
}
/* END ANNECY MT }*/
#endif /* _FIRE_DEADCODE_U64_ */
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH3D_tdstVector *HIE_fn_xGetSemiLookAtVector (HIE_tdxHandleToSuperObject _hSprObj) {
	return ((MTH3D_tdstVector *)&(HIE_M_xGetSuperObjectMember(_hSprObj, stSemiLookAtVector))) ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
