/* (c) Ubi R&D 1997*/ /* See Alain Robin for any comment or question*/ /****************************************************************************/ /* INCLUDES */ /****************************************************************************/ #include "acp_base.h" #include "MTH.h" #include "GEO.h" #include "GLI.h" #include "ErmGmt.h" #include "GmtStruc.h" /* structure definition*/ #include "GmtFunct.h" /* access function definition*/ #include "GmtProto.h" /* complex function definition*/ /****************************************************************************/ /* BASIC FUNCTIONS FOR COLLIDE MATERIAL */ /****************************************************************************/ /*---------------------------------------------------------------------------- // Description : GMT_fn_hCreateCollideMaterial // To create an empty collide material handle ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : // Output : Handle to the created collide material ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ GMT_tdxHandleToCollideMaterial GMT_fn_hCreateCollideMaterial(void) { GMT_tdxHandleToCollideMaterial hNewCollideMaterial; MMG_fn_vAddMemoryInfo( MMG_C_lTypeGMT , MMG_C_lSubTypeForA3D , 0 ); GEO_M_CPAMalloc(hNewCollideMaterial,GMT_tdxHandleToCollideMaterial,sizeof(struct GMT_tdstCollideMaterial_),E_uwGEONotEnoughtMemory); if(hNewCollideMaterial!=NULL) { /* initialization */ hNewCollideMaterial->wTypeOfZone=-1; hNewCollideMaterial->xIdentifier=0; /* All bits set to 0*/ return hNewCollideMaterial; } return NULL; } /*---------------------------------------------------------------------------- // Description : GMT_fn_vDestroyCollideMaterial // Delete a created collide material handle ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _p_hOld : collide material handle to delete // Output : ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void GMT_fn_vDestroyCollideMaterial(GMT_tdxHandleToCollideMaterial* _p_hOld) { GEO_M_CPAFree(*_p_hOld); *_p_hOld=GMT_C_InvalidCollideMaterial; } /*---------------------------------------------------------------------------- // Description : GMT_fn_vCopyGameMaterial // Used to copy an existing game material ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hSrc : source game material // Output : _hDst : copied game material ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ void GMT_fn_vCopyCollideMaterial(GMT_tdxHandleToCollideMaterial _hDst, GMT_tdxHandleToCollideMaterial _hSrc) { GMT_M_vSetTypeOfCollideMaterial(_hDst,GMT_M_wGetTypeOfCollideMaterial(_hSrc)); GMT_M_vSetCollideMaterialIdentifier(_hDst,GMT_M_wGetCollideMaterialIdentifier(_hSrc)); } /****************************************************************************/ /* ACCESSORS FOR COLLIDE MATERIAL */ /****************************************************************************/ /*---------------------------------------------------------------------------- // Description : GMT_fn_wGetTypeOfCollideMaterial // Used to get the type of the collide material ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the collide material // Output : GMT_C_wZDM or GMT_C_wZDR or GMT_C_wZDE ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ short GMT_fn_wGetTypeOfCollideMaterial(GMT_tdxHandleToCollideMaterial _hCollideMat) { return GMT_M_wGetTypeOfCollideMaterial(_hCollideMat); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*---------------------------------------------------------------------------- // Description : GMT_fn_vSetTypeOfCollideMaterial // Used to set the type of the collide material ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the game material // GMT_C_wZDM or GMT_C_wZDR or GMT_C_wZDE // Output : ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ void GMT_fn_vSetTypeOfCollideMaterial(GMT_tdxHandleToCollideMaterial _hCollideMat, short _wType) { GMT_M_vSetTypeOfCollideMaterial(_hCollideMat,_wType); } /*---------------------------------------------------------------------------- // Description : GMT_fn_hGetCollideMaterialIdentifier // Used to get the identifier of the collide material ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the collide material // Output : the identifier ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ GMT_tdxMask GMT_fn_hGetCollideMaterialIdentifier(GMT_tdxHandleToCollideMaterial _hCollideMat) { return GMT_M_wGetCollideMaterialIdentifier(_hCollideMat); } /*---------------------------------------------------------------------------- // Description : GMT_fn_hSetCollideMaterialIdentifier // Used to set the collide identifier part of the collide material ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the collide material // the identifier // Output : ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ void GMT_fn_hSetCollideMaterialIdentifier(GMT_tdxHandleToCollideMaterial _hCollideMat,GMT_tdxMask _xIdentifier) { GMT_M_vSetCollideMaterialIdentifier(_hCollideMat,_xIdentifier); } /****************************************************************************/ /* MORE COMPLEX FUNCTIONS */ /****************************************************************************/ /*---------------------------------------------------------------------------- // Description : GMT_fn_vSetCollideMaterialTypeOfIdentifier // Set to 1 the corresponding bit of the identifier ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the collide material // _uwType : Number of the type (0 to 15) // Output : ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ void GMT_fn_vSetCollideMaterialTypeOfIdentifier(GMT_tdxHandleToCollideMaterial _hCollideMat, unsigned short _uwType) { unsigned short uwMask; unsigned short uwIdentifier; uwMask=0x0001; uwMask=uwMask<<_uwType; uwIdentifier = (unsigned short)GMT_fn_hGetCollideMaterialIdentifier(_hCollideMat); GMT_M_vSetCollideMaterialIdentifier(_hCollideMat,(uwIdentifier|uwMask)); } /*---------------------------------------------------------------------------- // Description : GMT_fn_vResetCollideMaterialType // Set to 0 the corresponding bit of the identifier ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the collide material // _uwType : Number of the type (0 to 15) // Output : ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ void GMT_fn_vResetCollideMaterialTypeOfIdentifier(GMT_tdxHandleToCollideMaterial _hCollideMat, unsigned short _uwType) { unsigned short uwMask; unsigned short uwIdentifier; uwMask=0x0001; uwMask=uwMask<<_uwType; uwMask=~uwMask; uwIdentifier = (unsigned short)GMT_fn_hGetCollideMaterialIdentifier(_hCollideMat); GMT_M_vSetCollideMaterialIdentifier(_hCollideMat,(uwIdentifier&uwMask)); } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*---------------------------------------------------------------------------- // Description : GMT_fn_xTestCollideMaterialType // Test the corresponding bit of the identifier ----------------------------------------------------------------------------// // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _hCollideMat : Handle to the collide material // _uwType : Number of the type (0 to 15) // Output : TRUE if the bit is set to 1 FALSE else ----------------------------------------------------------------------------// // Modification : // Mdofication date : Modification author : ----------------------------------------------------------------------------*/ ACP_tdxBool GMT_fn_xTestCollideMaterialTypeOfIdentifier(GMT_tdxHandleToCollideMaterial _hCollideMat, unsigned short _uwType) { unsigned short uwMask; unsigned short uwIdentifier; uwMask=0x0001; uwMask=uwMask<<_uwType; uwIdentifier = (unsigned short)GMT_fn_hGetCollideMaterialIdentifier(_hCollideMat); uwMask=uwMask&uwIdentifier; if(uwMask==0) return FALSE; else return TRUE; } /*---------------------------------------------------------------------------- // Description : GMT_fn_xMultipleTestCollideIdentifier // Test the collide type for the identifier (test several bits in one operation) ------------------------------------------------------------------------------ // Method : Logical operation ------------------------------------------------------------------------------ // Input : _hCollideMat : Handle to the collide material // _xType : Mask containing the bits to test // Output : TRUE if all the bits set in _xType are present into the collide material // identifier, FALSE else ------------------------------------------------------------------------------ // Creation date : May 97 Author : Alain Robin ------------------------------------------------------------------------------ // Modification : // Modification date : Modification author : ----------------------------------------------------------------------------*/ ACP_tdxBool GMT_fn_xMultipleTestCollideIdentifier(GMT_tdxHandleToCollideMaterial _hCollideMat, GMT_tdxMask _xType) { GMT_tdxMask xIdentifier; xIdentifier = GMT_fn_hGetCollideMaterialIdentifier(_hCollideMat); xIdentifier = xIdentifier&_xType; if(xIdentifier==_xType) return TRUE; else return FALSE; } /*---------------------------------------------------------------------------- // Description : GMT_fn_xCombineMask // Combine 2 GMT_tdxMask and return the result ------------------------------------------------------------------------------ // Method : Logical operation ------------------------------------------------------------------------------ // Input : _xMaskA, _xMaskB : The 2 masks to combine // Output : the combinaison ------------------------------------------------------------------------------ // Creation date : May 97 Author : Alain Robin ------------------------------------------------------------------------------ // Modification : // Modification date : Modification author : ----------------------------------------------------------------------------*/ #ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */ GMT_tdxMask GMT_fn_xCombineMask(GMT_tdxMask _xMaskA,GMT_tdxMask _xMaskB) { return (_xMaskA|_xMaskB); } /*---------------------------------------------------------------------------- // Description : GMT_fn_vSetEntireMask // Set all the bits of a mask to 1 ------------------------------------------------------------------------------ // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _p_xMask : pointer to the mask // Output : ------------------------------------------------------------------------------ // Modification : // Modification date : Modification author : ----------------------------------------------------------------------------*/ void GMT_fn_vSetEntireMask(GMT_tdxMask* _p_xMask) { *_p_xMask=0xffff; } #endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */ /*---------------------------------------------------------------------------- // Description : GMT_fn_vResetEntireMask // Set all the bits of a mask to 0 ------------------------------------------------------------------------------ // Method : Nothing to say ----------------------------------------------------------------------------// // Input : _xMask : The mask // Output : ------------------------------------------------------------------------------ // Modification : // Modification date : Modification author : ----------------------------------------------------------------------------*/ void GMT_fn_vResetEntireMask(GMT_tdxMask* _p_xMask) { *_p_xMask=0x0000; }