reman3/Rayman_X/cpa/tempgrp/AI/AIGame/AITools.c

669 lines
20 KiB
C
Raw Blame History

/*---------------------------------------------------------------------------*/
/* AITools.C : Some useful functions*/
/* author : Olivier Couvreur.*/
/* date : 05/05/1996*/
/*---------------------------------------------------------------------------*/
#include "AIUseCPA.h"
#include "specif/AIOption.h"
#include "AIMacros.h"
#include "AI_Erm.h"
#include "AI_Mmg.h"
#include "AI_Struc.h"
#include "WPWayPt.h"
#include "specif/AITools.h"
#include "StrIntel.h"
#include "safe.h"
/* in order to test NULL perso,waypoint,action,GMT, text, etc. */
#if defined(__DEBUG_AI__)
static unsigned char gs_ucDontCheckNULLFlag = 0;
void fn_vSetDontCheckNULLFlag(signed char _cValue)
{
gs_ucDontCheckNULLFlag += _cValue;
}
#endif /* __DEBUG_AI__*/
#ifdef ACTIVE_EDITOR
extern unsigned char g_ucIsEdInGhostMode;
void fn_vCheckModuleAccess(HIE_tdxHandleToSuperObject hPerso, ACP_tdxBool _bNextArgIsAChannel, void *_p_vChannelOrModuleHandle)
{
HIE_tdxHandleToSuperObject hModule;
unsigned char ucChannel;
if ( _bNextArgIsAChannel )
{
ucChannel = *(unsigned char *)_p_vChannelOrModuleHandle;
hModule = fn_hGetSuperObjectInChannel(fn_h3dDataGetChannelSOList(M_GetMSHandle(hPerso, 3dData)),(short) ucChannel);
}
else
{
ucChannel = C_ucUnknownChannel;
hModule = *(HIE_tdxHandleToSuperObject *)_p_vChannelOrModuleHandle;
}
/* if B mode, no check is done */
if (g_ucIsEdInGhostMode)
{
if (hModule)
hModule->llastComputeFrameForModule = HIE_gs_lCurrentFrame;
return;
}
/* if hModule is NULL, then there is an error : access to a valid channel number, but nothing in the channel !*/
if (hModule == NULL)
{
/* error !*/
char cText[512];
if (M_GetMSHandle(hPerso,Brain) && M_pstGetMindOfBrain(M_GetMSHandle(hPerso,Brain)))
{
sprintf(cText,"You try to access a module that does not exist at this moment !!!\n"
"this module belongs to : %s\nThe number of the channel you try to access is : %i\n",(M_pstGetMindOfBrain(M_GetMSHandle(hPerso,Brain)))->szPersoName,ucChannel);
}
else
{
sprintf(cText,"You try to access a module that does not exist at this moment !!!\n"
"this module belongs to <actor with no brain (current state is %s)>\nThe number of the channel you try to access is : %i\n",ucChannel, fn_p_szGetStateName(fn_h3dDataGetCurrentState(M_GetMSHandle(hPerso,3dData))));
}
SAF_M_AssertWithMsg(FALSE,cText);
}
else if (hModule->llastComputeFrameForModule < HIE_gs_lCurrentFrame-1)
{
/* error !*/
char cText[512];
if (M_GetMSHandle(hPerso,Brain) && M_pstGetMindOfBrain(M_GetMSHandle(hPerso,Brain)))
{
sprintf(cText,"You try to get a module position that is not up to date !!!\n"
"this module belongs to : %s\n",(M_pstGetMindOfBrain(M_GetMSHandle(hPerso,Brain)))->szPersoName);
}
else
{
sprintf(cText,"You try to get a module position that is not up to date !!!\n"
"this module belongs to <actor with no brain (current state is %s)>\n", fn_p_szGetStateName(fn_h3dDataGetCurrentState(M_GetMSHandle(hPerso,3dData))));
}
if (fn_ulStandardGameGetCustomBitsSO(hPerso) & GAM_C_CustBitNeedModuleMatrices)
{
strcat(cText,"This Perso already has the custombit 2 set, but it seems that the anim player has not\n"
"been played this time..., so check anim player related flags\n");
}
else
{
strcat(cText,"This perso does not have the custom bit 2 set, correct this and try again\n");
}
sprintf (cText + strlen(cText),"There is a difference of %i frames\n",HIE_gs_lCurrentFrame-hModule->llastComputeFrameForModule);
SAF_M_AssertWithMsg(FALSE,cText);
}
}
#endif
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
#if defined(__DEBUG_AI__)
unsigned char fn_ucGetDontCheckNULLFlag()
{
return gs_ucDontCheckNULLFlag;
}
#endif /* __DEBUG_AI__ */
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* CGHT*/
#if 0
/* MODIF YLG*/
ACP_tdxBool fn_bIsEndReached(MTH_tdxReal xStart,MTH_tdxReal xEnd,MTH_tdxReal xSpeed)
{
if(MTH_M_bGreaterZero(xSpeed))
{
return(MTH_M_bGreaterEqual(xStart,xEnd));
}
else if(MTH_M_bLessZero(xSpeed))
{
return(MTH_M_bLessEqual(xStart,xEnd));
}
return(TRUE);
}
#endif
char *fn_szGetStringFromTextOrStringParam(tdstGetSetParam *p_stValue)
{
char *pszString = NULL;
if ( M_GetSetParam_Type(p_stValue) == E_vt_String )
{
pszString = M_GetSetParam_szString(p_stValue);
}
else if ( M_GetSetParam_Type(p_stValue) == E_vt_Text )
{
pszString = FON_fn_szGetTextPointerForHandle(M_GetSetParam_hText(p_stValue));
}
return pszString;
}
void fn_vGetCenterOfBoundingVolume(HIE_tdxHandleToSuperObject hPerso,struct MTH3D_tdstVector_ *p_stVertex)
{
GEO_tdxHandleToBoundingSphere hBoundingSphere;
hBoundingSphere = (GEO_tdxHandleToBoundingSphere)HIE_fn_hGetSuperObjectBoundingVolume(hPerso);
/* si il y a un bounding volume*/
if (hBoundingSphere!=NULL)
{
/* on renvoie le centre de la sph<70>re*/
MTH3D_M_vMulMatrixVector(p_stVertex, &(hPerso->hGlobalMatrix->stRotationMatrix), &(hBoundingSphere->stCenterPoint));
MTH3D_M_vAddVector (p_stVertex,p_stVertex,&(hPerso->hGlobalMatrix->stTranslationVector));
}
else
{
/* on renvoie l'origine du rep<65>re*/
MTH3D_M_vCopyVector(p_stVertex, &(hPerso->hGlobalMatrix->stTranslationVector));
}
}
MTH_tdxReal fn_xDistanceBetweenPersoAndWP(HIE_tdxHandleToSuperObject p_SuperObjPerso, WP_tdhWayPoint hWP)
{
MTH3D_tdstVector stVertex1, stVertex2;
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso), &stVertex1);
WP_fnv_WayPoint_ComputeLocation(hWP, &stVertex2);
MTH3D_M_vSubVector(&stVertex1, &stVertex1, &stVertex2);
return (MTH3D_M_xNormVector(&stVertex1));
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xDistanceBetweenPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso1, HIE_tdxHandleToSuperObject p_SuperObjPerso2)
{
MTH3D_tdstVector stVertex1, stVertex2;
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso1), &stVertex1);
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso2), &stVertex2);
MTH3D_M_vSubVector(&stVertex1, &stVertex1, &stVertex2);
return (MTH3D_M_xNormVector(&stVertex1));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
MTH_tdxReal fn_xInternalDistance(MTH3D_tdstVector *p_stVector,unsigned char ucFlags)
{
MTH_tdxReal xX,xY,xZ;
xX=MTH3D_M_xGetXofVector(p_stVector);
xY=MTH3D_M_xGetYofVector(p_stVector);
xZ=MTH3D_M_xGetZofVector(p_stVector);
switch (ucFlags)
{
/* signed distance */
case C_DISTANCE_X:
return(xX);
case C_DISTANCE_Y:
return(xY);
case C_DISTANCE_Z:
return(xZ);
/* unsigned distance */
case C_DISTANCE_XY:
return(MTH_M_xSqrt(MTH_M_xAdd(MTH_M_xSqr(xX),MTH_M_xSqr(xY))));
case C_DISTANCE_XZ:
return(MTH_M_xSqrt(MTH_M_xAdd(MTH_M_xSqr(xX),MTH_M_xSqr(xZ))));
case C_DISTANCE_YZ:
return(MTH_M_xSqrt(MTH_M_xAdd(MTH_M_xSqr(xY),MTH_M_xSqr(xZ))));
default:
return 0;
break;
case C_DISTANCE_XYZ:
return(MTH3D_M_xNormVector(p_stVector));
}
}
/* distance expressed in local of perso2 */
MTH_tdxReal fn_xExtendedDistanceBetweenPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso1, HIE_tdxHandleToSuperObject p_SuperObjPerso2, unsigned char ucFlags)
{
MTH3D_tdstVector stVertex1, stVertex2;
/*XB980430*/
/* MTH_tdxReal xNorm2=MTH_C_ZERO;*/
/*End XB*/
POS_tdstCompletePosition stMatrix;
/* bounding volume center or origin*/
if (ucFlags & DISTANCE_TO_CENTER_OF_BOUNDING_VOLUME)
{
fn_vGetCenterOfBoundingVolume(p_SuperObjPerso1,&stVertex1);
fn_vGetCenterOfBoundingVolume(p_SuperObjPerso2,&stVertex2);
}
else
{
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso1), &stVertex1);
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso2), &stVertex2);
}
MTH3D_M_vSubVector(&stVertex1, &stVertex1, &stVertex2);
ucFlags &= C_DISTANCE_MASK;
if (ucFlags!=C_DISTANCE_MASK)
{
/* return to local coordinates*/
POS_fn_vInvertIsoMatrix(&stMatrix,HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso2));
POS_fn_vMulMatrixVector(&stVertex1,&stMatrix,&stVertex1);
}
return(fn_xInternalDistance(&stVertex1,ucFlags));
}
/* local in perso2 */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xExtendedDistanceBetweenVertexAndPerso(MTH3D_tdstVector *p_stVertex1,HIE_tdxHandleToSuperObject p_SuperObjPerso2 , unsigned char ucFlags)
{
MTH3D_tdstVector stVertex2;
/*XB980430*/
/* MTH_tdxReal xNorm2=MTH_C_ZERO;*/
/*End XB*/
POS_tdstCompletePosition stMatrix;
/* bounding volume center or origin*/
if (ucFlags & DISTANCE_TO_CENTER_OF_BOUNDING_VOLUME)
{
fn_vGetCenterOfBoundingVolume(p_SuperObjPerso2,&stVertex2);
}
else
{
POS_fn_vGetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso2), &stVertex2);
}
MTH3D_M_vSubVector(p_stVertex1,p_stVertex1,&stVertex2);
ucFlags &= C_DISTANCE_MASK;
if (ucFlags!=C_DISTANCE_MASK)
{
/* return to local coordinates*/
POS_fn_vInvertIsoMatrix(&stMatrix,HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso2));
POS_fn_vMulMatrixVector(p_stVertex1,&stMatrix,p_stVertex1);
}
return(fn_xInternalDistance(p_stVertex1,ucFlags));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
MTH_tdxReal fn_xComputeDirectionAngle(MTH3D_tdstVector *p_stVector)
{
MTH_tdxReal xRealX,xRealY,xAngle;
xRealX=MTH3D_M_xGetXofVector(p_stVector);
xRealY=MTH3D_M_xGetYofVector(p_stVector);
/* Arctan(y/x)*/
if (xRealX) xAngle=MTH_M_xATan(MTH_M_xDiv(xRealY , xRealX));
else if(MTH_M_bLess(xRealY ,MTH_C_ZERO)) xAngle=MTH_M_xNeg(MTH_C_PiBy2);
else xAngle=MTH_C_PiBy2;
/* correction !?!*/
if(MTH_M_bLess(xRealX ,MTH_C_ZERO)) xAngle=MTH_M_xAdd(xAngle,MTH_C_Pi);
if(MTH_M_bLess(xAngle,MTH_C_ZERO)) xAngle=MTH_M_xAdd(xAngle,MTH_C_2Pi);
/* correction if xAngle=0 (you go on the x axis), the angle of the perso is PI/2.*/
xAngle = MTH_M_xAdd(xAngle,MTH_C_PiBy2);
if(MTH_M_bGreater(xAngle,MTH_C_2Pi)) xAngle=MTH_M_xSub(xAngle,MTH_C_2Pi);
return(xAngle);
}
/* angle must be [in 0, 2pi[ : use xAngle=fn_xRealModuloAround(MTH_C_ZERO,MTH_C_2Pi,xAngle);*/
MTH_tdxReal fn_xComputeBestEcartDirectionAngle(MTH_tdxReal xAngleFollowed,MTH_tdxReal xAngleToFollow)
{
/* to be sure Abs(xDeltaAngle) is <=180 deg : so that it is the shortest angle */
MTH_tdxReal xDeltaAngle=MTH_M_xSub(xAngleToFollow,xAngleFollowed);
if (MTH_M_bGreater(xDeltaAngle,MTH_C_ZERO))
{
if (MTH_M_bGreater(xDeltaAngle,MTH_C_Pi))
{
xDeltaAngle=MTH_M_xSub(xDeltaAngle,MTH_C_2Pi);
}
}
else
{
if (MTH_M_bLess(xDeltaAngle,MTH_M_xNeg(MTH_C_Pi)))
{
xDeltaAngle=MTH_M_xAdd(xDeltaAngle,MTH_C_2Pi);
}
}
return(xDeltaAngle);
}
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
tdstMACDPID *fn_p_stGetMACDPIDPointer(HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
tdstMACDPID *p_stMACDPID=NULL;
MS_tdxHandleToDynam h_Dynam;
DNM_tdstDynamics *p_stDynamics;
if((h_Dynam = M_GetMSHandle(p_SuperObjPerso,Dynam)) != NULL )
{
if((p_stDynamics = fn_p_stDynamGetDynamics(h_Dynam)) != NULL)
{
p_stMACDPID = DNM_M_p_stDynamicsGetExternalDatas(p_stDynamics);
}
}
if (p_stMACDPID==NULL)
{
M_AIFatalError(E_uwAIFatalNoDynamics);
}
return (p_stMACDPID);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
DNM_tdstReport *fn_pstGetDNMReport(HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
MS_tdxHandleToDynam h_Dynam;
DNM_tdstDynamics *p_stDynamics;
if((h_Dynam = M_GetMSHandle(p_SuperObjPerso,Dynam)) == NULL )
return NULL;
if((p_stDynamics = fn_p_stDynamGetDynamics(h_Dynam)) == NULL)
return NULL;
return DNM_M_p_stDynamicsGetReport(p_stDynamics);
}
/* round xValue so that it belongs to [xFrom,xFrom+xModulus[*/
MTH_tdxReal fn_xRealModuloAround(MTH_tdxReal xFrom,MTH_tdxReal xModulus,MTH_tdxReal xValue)
{
/* xValue -= xFrom;*/
xValue=MTH_M_xSub(xValue,xFrom);
/* while (xValue<0) xValue += xModulus;*/
while (MTH_M_bLess(xValue,MTH_C_ZERO))
{
xValue=MTH_M_xAdd(xValue,xModulus);
}
/* while (xValue>=xModulus) xValue -= xModulus;*/
while (MTH_M_bGreaterEqual(xValue,xModulus))
{
xValue=MTH_M_xSub(xValue,xModulus);
}
/* xValue += xFrom;*/
xValue=MTH_M_xAdd(xValue,xFrom);
/* that's all folks*/
return(xValue);
};
/* same but but for a vector (X,Y,Z)*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vVectorModuloAround(MTH_tdxReal xFrom,MTH_tdxReal xModulus,struct MTH3D_tdstVector_ *p_stRotationVector)
{
MTH3D_M_vSetXofVector(p_stRotationVector,fn_xRealModuloAround(xFrom,xModulus,MTH3D_M_xGetXofVector(p_stRotationVector)));
MTH3D_M_vSetYofVector(p_stRotationVector,fn_xRealModuloAround(xFrom,xModulus,MTH3D_M_xGetYofVector(p_stRotationVector)));
MTH3D_M_vSetZofVector(p_stRotationVector,fn_xRealModuloAround(xFrom,xModulus,MTH3D_M_xGetZofVector(p_stRotationVector)));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
;
/* make angular speed vector positive*/
/*
void fn_vMakeAngularSpeedVectorPositive(struct MTH3D_tdstVector_ *p_stRotationVector,struct MTH3D_tdstVector_ *p_stAngleVector,struct MTH3D_tdstVector_ *p_stAimAngleVector)
{
MTH_tdxReal xTemp;
// we must quarantee that RotationVector is >0, and that
// sgn(AimAngleVector-Anglevector)=sgn(RotationVector)
// if (RotationVector<0)
// {
// RotationVector=-RotationVector;
// if (Anglevector<AimAngleVector) AngleVector+=2Pi;
// }
// else
// {
// if (Anglevector>AimAngleVector) AngleVector-=2Pi;
// }
///
// X
if (MTH_M_bLess(xTemp=MTH3D_M_xGetXofVector(p_stRotationVector),MTH_C_ZERO))
{
MTH3D_M_vSetXofVector(p_stRotationVector,MTH_M_xNeg(xTemp));
xTemp=MTH3D_M_xGetXofVector(p_stAngleVector);
while (MTH_M_bLess(xTemp,MTH3D_M_xGetXofVector(p_stAimAngleVector)))
{
xTemp=MTH_M_xAdd(xTemp,MTH_C_2Pi);
}
MTH3D_M_vSetXofVector(p_stAngleVector,xTemp);
}
else
{
xTemp=MTH3D_M_xGetXofVector(p_stAngleVector);
while (MTH_M_bGreater(xTemp,MTH3D_M_xGetXofVector(p_stAimAngleVector)))
{
xTemp=MTH_M_xSub(xTemp,MTH_C_2Pi);
}
MTH3D_M_vSetXofVector(p_stAngleVector,xTemp);
}
// Y
if (MTH_M_bLess(xTemp=MTH3D_M_xGetYofVector(p_stRotationVector),MTH_C_ZERO))
{
MTH3D_M_vSetYofVector(p_stRotationVector,MTH_M_xNeg(xTemp));
xTemp=MTH3D_M_xGetYofVector(p_stAngleVector);
while (MTH_M_bLess(xTemp,MTH3D_M_xGetYofVector(p_stAimAngleVector)))
{
xTemp=MTH_M_xAdd(xTemp,MTH_C_2Pi);
}
MTH3D_M_vSetYofVector(p_stAngleVector,xTemp);
}
else
{
xTemp=MTH3D_M_xGetYofVector(p_stAngleVector);
while (MTH_M_bGreater(xTemp,MTH3D_M_xGetYofVector(p_stAimAngleVector)))
{
xTemp=MTH_M_xSub(xTemp,MTH_C_2Pi);
}
MTH3D_M_vSetYofVector(p_stAngleVector,xTemp);
}
// Z
if (MTH_M_bLess(xTemp=MTH3D_M_xGetZofVector(p_stRotationVector),MTH_C_ZERO))
{
MTH3D_M_vSetZofVector(p_stRotationVector,MTH_M_xNeg(xTemp));
xTemp=MTH3D_M_xGetZofVector(p_stAngleVector);
while (MTH_M_bLess(xTemp,MTH3D_M_xGetZofVector(p_stAimAngleVector)))
{
xTemp=MTH_M_xAdd(xTemp,MTH_C_2Pi);
}
MTH3D_M_vSetZofVector(p_stAngleVector,xTemp);
}
else
{
xTemp=MTH3D_M_xGetZofVector(p_stAngleVector);
if (MTH_M_bGreater(xTemp,MTH3D_M_xGetZofVector(p_stAimAngleVector)))
{
xTemp=MTH_M_xSub(xTemp,MTH_C_2Pi);
}
MTH3D_M_vSetZofVector(p_stAngleVector,xTemp);
}
}
*/
unsigned char fn_ucIsThereFloatIfYesConvertItToInteger(tdstGetSetParam *p_stParam)
{
unsigned char ucIsThereFloat=(unsigned char) M_IsFloatType(p_stParam);
if (ucIsThereFloat)
{
long lValue;
if((M_GetSetParam_xValue(p_stParam)<MTH_C_MAX_LONG)&&
(M_GetSetParam_xValue(p_stParam)>(-MTH_C_MAX_LONG)))/*AR980325 Antibug U64*/
lValue=MTH_M_xRealToLong(M_GetSetParam_xValue(p_stParam));
else if (M_GetSetParam_xValue(p_stParam)>0)
lValue=MTH_C_MAX_LONG;
else
lValue=-MTH_C_MAX_LONG;
M_Full_GetSetParam_Integer(p_stParam,lValue);
}
return(ucIsThereFloat);
}
unsigned char fn_ucAreThereFloatIfYesConvertThem(tdstGetSetParam *p_stParam1,tdstGetSetParam *p_stParam2)
{
unsigned char ucIsThereFloat=(unsigned char) M_IsFloatType(p_stParam1);
if (ucIsThereFloat)
{
if (!M_IsFloatType(p_stParam2))
{
M_GetSetParam_xValue(p_stParam2)=MTH_M_xLongToReal(M_GetSetParam_lValue(p_stParam2)) ;
}
}
else
{
ucIsThereFloat=(unsigned char) M_IsFloatType(p_stParam2);
if (ucIsThereFloat)
{
M_GetSetParam_xValue(p_stParam1)=MTH_M_xLongToReal(M_GetSetParam_lValue(p_stParam1));
}
}
return(ucIsThereFloat);
}
#if defined(__DEBUG_AI__)
char *fn_szGetPersoName(HIE_tdxHandleToSuperObject hPerso)
{
return AI_M_szGetPersoName(AI_M_stGetMindOfSuperObj(hPerso));
}
#endif
/*************************************************************************************
* Set the position of p_SuperObjPerso to p_stVertex. Make the mecanic collision test.
**************************************************************************************/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
ACP_tdxBool fn_bSetPositionWithCollideTest(HIE_tdxHandleToSuperObject p_SuperObjPerso, MTH3D_tdstVector *p_stVertex)
{
/* MS_tdxHandleToDynam h_Dynam;
DNM_tdstDynamics *p_stDynamics;
if((h_Dynam = M_GetMSHandle(p_SuperObjPerso,Dynam)) == NULL )
return FALSE;
if((p_stDynamics = fn_p_stDynamGetDynamics(h_Dynam)) == NULL)
return FALSE;*/
/* Break the son-father link.*/
fn_vReputCharacterSuperObjectAtTheWorld(p_SuperObjPerso);
/* Set the new position*/
POS_fn_vSetTranslationVector(HIE_fn_hGetSuperObjectGlobalMatrix(p_SuperObjPerso),p_stVertex);
POS_fn_vSetTranslationVector(HIE_fn_hGetSuperObjectMatrix(p_SuperObjPerso),p_stVertex);
/* DNM_fn_vDynamicsSetFromHiePositionByTakingIntoAccountTheObstaclesOfTheWayCoveredByTheObject(p_stDynamics, p_SuperObjPerso);*/
/* LRM_fn_xBoolInitListOfRequests(fn_pDynamGetListOfRequests(h_Dynam));*/
return TRUE;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*ANNECY BBB { parti dans GAM\actions\Dynam.c*/
/********************************************************************************************
* Set the position of p_SuperObjPerso to p_stVertex. Do not make the mecanic collision test.
*********************************************************************************************/
/*ACP_tdxBool fn_bSetPositionWithoutCollideTest(HIE_tdxHandleToSuperObject p_SuperObjPerso, MTH3D_tdstVector *p_stVertex)*/
/*ANNECY BBB } parti dans GAM\actions\Dynam.c*/
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned char fn_bGethDynamAndMACDPIDPointers(HIE_tdxHandleToSuperObject p_SuperObjPerso, MS_tdxHandleToDynam *p_h_Dynam, tdstMACDPID **p_p_stMACDPID)
{
DNM_tdstDynamics *p_stDynamics;
if((*p_h_Dynam = M_GetMSHandle(p_SuperObjPerso,Dynam)) != NULL )
{
if((p_stDynamics = fn_p_stDynamGetDynamics(*p_h_Dynam)) != NULL)
{
*p_p_stMACDPID = DNM_M_p_stDynamicsGetExternalDatas(p_stDynamics);
return(TRUE);
}
}
return(FALSE);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
unsigned char fn_ucInternalTurn(HIE_tdxHandleToSuperObject p_SuperObjPerso,MTH_tdxReal xAngle)
{
struct DNM_stDynamics* pstDynamic;
MS_tdxHandleToDynam h_Dynam;
/* Get Dynamics structure*/
h_Dynam = M_GetMSHandle(p_SuperObjPerso,Dynam);
if (h_Dynam)
{
pstDynamic = fn_p_stDynamGetDynamics(h_Dynam);
if (pstDynamic)
{
MEC_vTurnAroundZAxis ( pstDynamic, xAngle );
return TRUE;
}
}
return FALSE;
}
void fn_vConvertParamToColor(struct tdstGetSetParam_ *p_stParam,struct GEO_tdstColor_ *p_stColor)
{
/* don't use MTH because this is real float*/
float lValue;
float fValue=0.0f;
float fFactor=0.01f;
lValue=M_GetSetParam_RedValue(p_stParam);
if (lValue<0) fValue=0.0f; else if (lValue>100) fValue=1.0f; else fValue=lValue*fFactor;
p_stColor->xR=fValue;
lValue=M_GetSetParam_GreenValue(p_stParam);
if (lValue<0) fValue=0.0f; else if (lValue>100) fValue=1.0f; else fValue=lValue*fFactor;
p_stColor->xG=fValue;
lValue=M_GetSetParam_BlueValue(p_stParam);
if (lValue<0) fValue=0.0f; else if (lValue>100) fValue=1.0f; else fValue=lValue*fFactor;
p_stColor->xB=fValue;
lValue=M_GetSetParam_AlphaValue(p_stParam);
if (lValue<0) fValue=0.0f; else if (lValue>100) fValue=1.0f; else fValue=lValue*fFactor;
p_stColor->xA=fValue;
}
void fn_vConvertColorToParam(struct GEO_tdstColor_ *p_stColor,struct tdstGetSetParam_ *p_stParam)
{
M_GetSetParam_RedValue(p_stParam) =(unsigned char) (100*p_stColor->xR);
M_GetSetParam_GreenValue(p_stParam) =(unsigned char) (100*p_stColor->xG);
M_GetSetParam_BlueValue(p_stParam) =(unsigned char) (100*p_stColor->xB);
M_GetSetParam_AlphaValue(p_stParam) =(unsigned char) (100*p_stColor->xA);
M_GetSetParam_Type(p_stParam)=E_vt_Color;
}