reman3/Rayman_X/cpa/tempgrp/COL/Box.c

590 lines
26 KiB
C
Raw Blame History

/*
0 1 2 3 4 5 6 7
01234567890123456789012345678901234567890123456789012345678901234567890123456789
--------------------------------------------------------------------------------
-- Description : Box utils
--------------------------------------------------------------------------------
-- Creation date : 22 aug 1996 Author : FPI
--------------------------------------------------------------------------------
*/
#include "acp_base.h"
#include "MTH.h"
#include "GEO.h"
#include "GLI.h"
#include "MEC.h"
#include "GMT.h"
#include "COL/Box.h"
/*
--------------------------------------------------------------------------------
-- Description : Macros
--------------------------------------------------------------------------------
*/
#define COL_M_vUpdateMin( xMin , xValue ) if( MTH_M_bLess( (xValue) , (xMin) ) ) (xMin) = (xValue);
#define COL_M_vUpdateMax( xMax , xValue ) if( MTH_M_bGreater( (xValue) , (xMax) ) ) (xMax) = (xValue);
#define COL_M_vUpdateWithMin( xMin , xValue1 , xValue2 )\
{\
if( MTH_M_bLess( (xValue1) , (xValue2) ) )\
{\
COL_M_vUpdateMin( (xMin) , (xValue1) );\
}\
else\
{\
COL_M_vUpdateMin( (xMin) , (xValue2) );\
}\
}
#define COL_M_vUpdateWithMax( xMax , xValue1 , xValue2 )\
{\
if( MTH_M_bGreater( (xValue1) , (xValue2) ) )\
{\
COL_M_vUpdateMax( (xMax) , (xValue1) );\
}\
else\
{\
COL_M_vUpdateMax( (xMax) , (xValue2) );\
}\
}
/*
--------------------------------------------------------------------------------
-- Description : Global variables
--------------------------------------------------------------------------------
*/
/* normales aux faces d une boite */
MTH3D_tdstVector COL_g_a6_stBoxSidesNormal[COL_C_xNbSidesPerBox] =
{
{ MTH_C_MinusONE, MTH_C_ZERO, MTH_C_ZERO },
{ MTH_C_ONE, MTH_C_ZERO, MTH_C_ZERO },
{ MTH_C_ZERO, MTH_C_MinusONE, MTH_C_ZERO },
{ MTH_C_ZERO, MTH_C_ONE, MTH_C_ZERO },
{ MTH_C_ZERO, MTH_C_ZERO, MTH_C_MinusONE },
{ MTH_C_ZERO, MTH_C_ZERO, MTH_C_ONE }
};
/* tableau d aretes d une boite */
GEO_tdstDoubledIndex COL_g_a12_stBoxEdges[COL_C_xNbEdgesPerBox] =
{
{ { COL_C_xXMinYMinZMin, COL_C_xXMaxYMinZMin } }, /* 00 = 0 - 4 */
{ { COL_C_xXMinYMinZMax, COL_C_xXMaxYMinZMax } }, /* 01 = 1 - 5 */
{ { COL_C_xXMinYMaxZMin, COL_C_xXMaxYMaxZMin } }, /* 02 = 2 - 6 */
{ { COL_C_xXMinYMaxZMax, COL_C_xXMaxYMaxZMax } }, /* 03 = 3 - 7 */
{ { COL_C_xXMinYMinZMin, COL_C_xXMinYMaxZMin } }, /* 04 = 0 - 2 */
{ { COL_C_xXMinYMinZMax, COL_C_xXMinYMaxZMax } }, /* 05 = 1 - 3 */
{ { COL_C_xXMaxYMinZMin, COL_C_xXMaxYMaxZMin } }, /* 06 = 4 - 6 */
{ { COL_C_xXMaxYMinZMax, COL_C_xXMaxYMaxZMax } }, /* 07 = 5 - 7 */
{ { COL_C_xXMinYMinZMin, COL_C_xXMinYMinZMax } }, /* 08 = 0 - 1 */
{ { COL_C_xXMinYMaxZMin, COL_C_xXMinYMaxZMax } }, /* 09 = 2 - 3 */
{ { COL_C_xXMaxYMinZMin, COL_C_xXMaxYMinZMax } }, /* 10 = 4 - 5 */
{ { COL_C_xXMaxYMaxZMin, COL_C_xXMaxYMaxZMax } } /* 11 = 6 - 7 */
};
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned long COL_g_a6_ulBoxSideMask[COL_C_xNbSidesPerBox] =
{
COL_C_ulXMinMask,
COL_C_ulXMaxMask,
COL_C_ulYMinMask,
COL_C_ulYMaxMask,
COL_C_ulZMinMask,
COL_C_ulZMaxMask
};
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
unsigned long COL_g_a6_ulBoxSideInvMask[COL_C_xNbSidesPerBox] =
{
COL_C_ulXMinInvMask,
COL_C_ulXMaxInvMask,
COL_C_ulYMinInvMask,
COL_C_ulYMaxInvMask,
COL_C_ulZMinInvMask,
COL_C_ulZMaxInvMask
};
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*
--------------------------------------------------------------------------------
-- Description : Convert a min-max box to a 8 vertices box
--------------------------------------------------------------------------------
-- Creation date : 22 aug 1996 Author : FPI
--------------------------------------------------------------------------------
*/
/* a revoir les get vector */
void COL_fn_vMinMaxBox2VerticesBox ( COL_tda8st8VerticesBox a8_stBoxDest,
MTH3D_tdstVector *p_stMinPoint,
MTH3D_tdstVector *p_stMaxPoint )
{
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMinYMinZMin]), p_stMinPoint->xX, p_stMinPoint->xY, p_stMinPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMinYMinZMax]), p_stMinPoint->xX, p_stMinPoint->xY, p_stMaxPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMinYMaxZMin]), p_stMinPoint->xX, p_stMaxPoint->xY, p_stMinPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMinYMaxZMax]), p_stMinPoint->xX, p_stMaxPoint->xY, p_stMaxPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMaxYMinZMin]), p_stMaxPoint->xX, p_stMinPoint->xY, p_stMinPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMaxYMinZMax]), p_stMaxPoint->xX, p_stMinPoint->xY, p_stMaxPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMaxYMaxZMin]), p_stMaxPoint->xX, p_stMaxPoint->xY, p_stMinPoint->xZ );
MTH3D_M_vSetVectorElements ( &(a8_stBoxDest[COL_C_xXMaxYMaxZMax]), p_stMaxPoint->xX, p_stMaxPoint->xY, p_stMaxPoint->xZ );
}
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of a list of vertices
--------------------------------------------------------------------------------
-- Creation date : 22 aug 1996 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante d un nuage de points */
void COL_fn_vComputeBoundingBoxOfVertices ( MTH3D_tdstVector *p_stMinPoint,
MTH3D_tdstVector *p_stMaxPoint,
ACP_tdxIndex xNbVertices,
MTH3D_tdstVector *d_stListOfVertices )
{
long lVertexIndex;
MTH3D_tdstVector *p_stVert;
MTH3D_M_vCopyVector ( p_stMinPoint, d_stListOfVertices );
MTH3D_M_vCopyVector ( p_stMaxPoint, d_stListOfVertices );
for ( lVertexIndex = 0 ; lVertexIndex < xNbVertices ; lVertexIndex ++ )
{
p_stVert = &(d_stListOfVertices[lVertexIndex]);
if ( MTH_M_bLess ( MTH3D_M_xGetXofVector ( p_stVert ),
MTH3D_M_xGetXofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetXofVector ( p_stMinPoint, MTH3D_M_xGetXofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetXofVector ( p_stVert ),
MTH3D_M_xGetXofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetXofVector ( p_stMaxPoint, MTH3D_M_xGetXofVector ( p_stVert ) );
if ( MTH_M_bLess ( MTH3D_M_xGetYofVector ( p_stVert ),
MTH3D_M_xGetYofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetYofVector ( p_stMinPoint, MTH3D_M_xGetYofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetYofVector ( &(d_stListOfVertices[lVertexIndex]) ),
MTH3D_M_xGetYofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetYofVector ( p_stMaxPoint, MTH3D_M_xGetYofVector ( p_stVert ) );
if ( MTH_M_bLess ( MTH3D_M_xGetZofVector ( p_stVert ),
MTH3D_M_xGetZofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetZofVector ( p_stMinPoint, MTH3D_M_xGetZofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetZofVector ( p_stVert ),
MTH3D_M_xGetZofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetZofVector ( p_stMaxPoint, MTH3D_M_xGetZofVector ( p_stVert ) );
}
}
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of two vertices boxes
--------------------------------------------------------------------------------
-- Creation date : 17 apr 1997 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante de deux boites de points */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vComputeBoundingBoxOfVerticesBoxes ( MTH3D_tdstVector *p_stMinPoint,
MTH3D_tdstVector *p_stMaxPoint,
COL_tda8st8VerticesBox a8_stBox1,
COL_tda8st8VerticesBox a8_stBox2 )
{
long lVertexIndex;
MTH3D_tdstVector *p_stVert;
MTH3D_M_vCopyVector ( p_stMinPoint, a8_stBox1 );
MTH3D_M_vCopyVector ( p_stMaxPoint, a8_stBox1 );
for ( lVertexIndex = 0 ; lVertexIndex < COL_C_xNbVerticesPerBox ; lVertexIndex ++ )
{
p_stVert = &(a8_stBox1[lVertexIndex]);
if ( MTH_M_bLess ( MTH3D_M_xGetXofVector ( p_stVert ),
MTH3D_M_xGetXofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetXofVector ( p_stMinPoint, MTH3D_M_xGetXofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetXofVector ( p_stVert ),
MTH3D_M_xGetXofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetXofVector ( p_stMaxPoint, MTH3D_M_xGetXofVector ( p_stVert ) );
if ( MTH_M_bLess ( MTH3D_M_xGetYofVector ( p_stVert ),
MTH3D_M_xGetYofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetYofVector ( p_stMinPoint, MTH3D_M_xGetYofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetYofVector ( p_stVert ),
MTH3D_M_xGetYofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetYofVector ( p_stMaxPoint, MTH3D_M_xGetYofVector ( p_stVert ) );
if ( MTH_M_bLess ( MTH3D_M_xGetZofVector ( p_stVert ),
MTH3D_M_xGetZofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetZofVector ( p_stMinPoint, MTH3D_M_xGetZofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetZofVector ( p_stVert ),
MTH3D_M_xGetZofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetZofVector ( p_stMaxPoint, MTH3D_M_xGetZofVector ( p_stVert ) );
p_stVert = &(a8_stBox2[lVertexIndex]);
if ( MTH_M_bLess ( MTH3D_M_xGetXofVector ( p_stVert ),
MTH3D_M_xGetXofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetXofVector ( p_stMinPoint, MTH3D_M_xGetXofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetXofVector ( p_stVert ),
MTH3D_M_xGetXofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetXofVector ( p_stMaxPoint, MTH3D_M_xGetXofVector ( p_stVert ) );
if ( MTH_M_bLess ( MTH3D_M_xGetYofVector ( p_stVert ),
MTH3D_M_xGetYofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetYofVector ( p_stMinPoint, MTH3D_M_xGetYofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetYofVector ( p_stVert ),
MTH3D_M_xGetYofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetYofVector ( p_stMaxPoint, MTH3D_M_xGetYofVector ( p_stVert ) );
if ( MTH_M_bLess ( MTH3D_M_xGetZofVector ( p_stVert ),
MTH3D_M_xGetZofVector ( p_stMinPoint ) ) )
MTH3D_M_vSetZofVector ( p_stMinPoint, MTH3D_M_xGetZofVector ( p_stVert ) );
if ( MTH_M_bGreater ( MTH3D_M_xGetZofVector ( p_stVert ),
MTH3D_M_xGetZofVector ( p_stMaxPoint ) ) )
MTH3D_M_vSetZofVector ( p_stMaxPoint, MTH3D_M_xGetZofVector ( p_stVert ) );
}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of two boxes
--------------------------------------------------------------------------------
-- Creation date : 22 aug 1996 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante de deux boites */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vComputeBoundingBoxOfBoxes ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stMinPoint1,
MTH3D_tdstVector *p_stMaxPoint1,
MTH3D_tdstVector *p_stMinPoint2,
MTH3D_tdstVector *p_stMaxPoint2 )
{
MTH3D_M_vMinVector ( p_stMinBounding, p_stMinPoint1, p_stMinPoint2 );
MTH3D_M_vMaxVector ( p_stMaxBounding, p_stMaxPoint1, p_stMaxPoint2 );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding sphere of a box
--------------------------------------------------------------------------------
-- Creation date : 25 feb 1997 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la sphere englobante d une boite */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vComputeBoundingSphereOfBox ( MTH3D_tdstVector *p_stSphereCenter,
MTH_tdxReal *p_xSphereRadius,
MTH3D_tdstVector *p_stMinPoint,
MTH3D_tdstVector *p_stMaxPoint )
{
MTH3D_M_vMiddleVector ( p_stSphereCenter, p_stMinPoint, p_stMaxPoint );
*p_xSphereRadius = MTH_M_xMul ( MTH_C_Inv2, MTH3D_M_xVectorGap ( p_stMinPoint, p_stMaxPoint ) );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of a sphere
--------------------------------------------------------------------------------
-- Creation date : 25 feb 1997 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante d une sphere */
void COL_fn_vComputeBoundingBoxOfSphere ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stSphereCenter,
MTH_tdxReal xSphereRadius )
{
MTH3D_M_vSubScalarVector ( p_stMinBounding, xSphereRadius, p_stSphereCenter );
MTH3D_M_vAddScalarVector ( p_stMaxBounding, xSphereRadius, p_stSphereCenter );
}
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of two spheres
--------------------------------------------------------------------------------
-- Creation date : 27 dec 1996 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante de deux spheres */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vComputeBoundingBoxOfSpheres ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stSphereCenter1,
MTH_tdxReal xSphereRadius1,
MTH3D_tdstVector *p_stSphereCenter2,
MTH_tdxReal xSphereRadius2 )
{
p_stMinBounding->xX = MTH_M_xMin ( MTH_M_xSub ( p_stSphereCenter1->xX, xSphereRadius1 ), MTH_M_xSub ( p_stSphereCenter2->xX, xSphereRadius2 ) );
p_stMinBounding->xY = MTH_M_xMin ( MTH_M_xSub ( p_stSphereCenter1->xY, xSphereRadius1 ), MTH_M_xSub ( p_stSphereCenter2->xY, xSphereRadius2 ) );
p_stMinBounding->xZ = MTH_M_xMin ( MTH_M_xSub ( p_stSphereCenter1->xZ, xSphereRadius1 ), MTH_M_xSub ( p_stSphereCenter2->xZ, xSphereRadius2 ) );
p_stMaxBounding->xX = MTH_M_xMax ( MTH_M_xAdd ( p_stSphereCenter1->xX, xSphereRadius1 ), MTH_M_xAdd ( p_stSphereCenter2->xX, xSphereRadius2 ) );
p_stMaxBounding->xY = MTH_M_xMax ( MTH_M_xAdd ( p_stSphereCenter1->xY, xSphereRadius1 ), MTH_M_xAdd ( p_stSphereCenter2->xY, xSphereRadius2 ) );
p_stMaxBounding->xZ = MTH_M_xMax ( MTH_M_xAdd ( p_stSphereCenter1->xZ, xSphereRadius1 ), MTH_M_xAdd ( p_stSphereCenter2->xZ, xSphereRadius2 ) );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of a sphere and a box
--------------------------------------------------------------------------------
-- Creation date : 12 feb 1997 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante d une sphere et d une boite */
void COL_fn_vComputeBoundingBoxOfSphereAndBox ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stSphereCenter,
MTH_tdxReal xSphereRadius,
MTH3D_tdstVector *p_stMinPoint,
MTH3D_tdstVector *p_stMaxPoint )
{
p_stMinBounding->xX = MTH_M_xMin ( MTH_M_xSub ( p_stSphereCenter->xX, xSphereRadius ), p_stMinPoint->xX );
p_stMinBounding->xY = MTH_M_xMin ( MTH_M_xSub ( p_stSphereCenter->xY, xSphereRadius ), p_stMinPoint->xY );
p_stMinBounding->xZ = MTH_M_xMin ( MTH_M_xSub ( p_stSphereCenter->xZ, xSphereRadius ), p_stMinPoint->xZ );
p_stMaxBounding->xX = MTH_M_xMax ( MTH_M_xAdd ( p_stSphereCenter->xX, xSphereRadius ), p_stMaxPoint->xX );
p_stMaxBounding->xY = MTH_M_xMax ( MTH_M_xAdd ( p_stSphereCenter->xY, xSphereRadius ), p_stMaxPoint->xY );
p_stMaxBounding->xZ = MTH_M_xMax ( MTH_M_xAdd ( p_stSphereCenter->xZ, xSphereRadius ), p_stMaxPoint->xZ );
}
/*
--------------------------------------------------------------------------------
-- Description : Compute the bounding box of a geometric object
--------------------------------------------------------------------------------
-- Creation date : 12 feb 1997 Author : FPI
--------------------------------------------------------------------------------
*/
/* calcul de la boite englobante d un objet geometrique */
void COL_fn_vComputeBoundingBoxOfGeometricObject ( MTH3D_tdstVector *p_stMinPoint,
MTH3D_tdstVector *p_stMaxPoint,
GEO_tdstGeometricObject *p_stGeomObj )
{
ACP_tdxIndex xElementIndex;
ACP_tdxIndex xDataElementIndex;
GEO_tdstElementSpheres *p_stElementSpheres;
GEO_tdstIndexedSphere *p_stIndexedSphere;
MTH3D_tdstVector *p_stCenter;
COL_fn_vComputeBoundingBoxOfVertices ( p_stMinPoint, p_stMaxPoint, p_stGeomObj->xNbPoints, p_stGeomObj->d_stListOfPoints );
/* on n oublie pas d augmenter avec les spheres */
for ( xElementIndex = 0 ; xElementIndex < p_stGeomObj->xNbElements ; xElementIndex++ )
{
if ( p_stGeomObj->d_xListOfElementsTypes[xElementIndex] == GEO_C_xElementSpheres )
{
p_stElementSpheres = (GEO_tdstElementSpheres *)(p_stGeomObj->d_stListOfElements[xElementIndex]);
/* pour les spheres */
for ( xDataElementIndex = 0 ; xDataElementIndex < p_stElementSpheres->xNbSpheres ; xDataElementIndex++ )
{
/* sphere */
p_stIndexedSphere = p_stElementSpheres->d_stListOfSpheres + xDataElementIndex;
/* centre de la sphere */
p_stCenter = p_stGeomObj->d_stListOfPoints + p_stIndexedSphere->xCenterPoint;
/* recalcule la boite englobante */
COL_fn_vComputeBoundingBoxOfSphereAndBox ( p_stMinPoint, p_stMaxPoint,
p_stCenter, p_stIndexedSphere->xRadius, p_stMinPoint, p_stMaxPoint );
}
}
}
}
/* calcul de la boite englobante de deux spheres de m<>me rayon */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vComputeBoundingBoxOfSpheresWithSameRadius ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stSphereCenter1,
MTH3D_tdstVector *p_stSphereCenter2,
MTH_tdxReal xSphereRadius )
{
/* X axis*/
if( MTH_M_bLess( p_stSphereCenter1->xX , p_stSphereCenter2->xX ) )
{
p_stMinBounding->xX = MTH_M_xSub ( p_stSphereCenter1->xX, xSphereRadius );
p_stMaxBounding->xX = MTH_M_xAdd ( p_stSphereCenter2->xX, xSphereRadius );
}
else
{
p_stMinBounding->xX = MTH_M_xSub ( p_stSphereCenter2->xX, xSphereRadius );
p_stMaxBounding->xX = MTH_M_xAdd ( p_stSphereCenter1->xX, xSphereRadius );
}
/* Y axis*/
if( MTH_M_bLess( p_stSphereCenter1->xY , p_stSphereCenter2->xY ) )
{
p_stMinBounding->xY = MTH_M_xSub ( p_stSphereCenter1->xY, xSphereRadius );
p_stMaxBounding->xY = MTH_M_xAdd ( p_stSphereCenter2->xY, xSphereRadius );
}
else
{
p_stMinBounding->xY = MTH_M_xSub ( p_stSphereCenter2->xY, xSphereRadius );
p_stMaxBounding->xY = MTH_M_xAdd ( p_stSphereCenter1->xY, xSphereRadius );
}
/* Z axis*/
if( MTH_M_bLess( p_stSphereCenter1->xZ , p_stSphereCenter2->xZ ) )
{
p_stMinBounding->xZ = MTH_M_xSub ( p_stSphereCenter1->xZ, xSphereRadius );
p_stMaxBounding->xZ = MTH_M_xAdd ( p_stSphereCenter2->xZ, xSphereRadius );
}
else
{
p_stMinBounding->xZ = MTH_M_xSub ( p_stSphereCenter2->xZ, xSphereRadius );
p_stMaxBounding->xZ = MTH_M_xAdd ( p_stSphereCenter1->xZ, xSphereRadius );
}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* mise <20> jour de la boite englobante de deux spheres de m<>me rayon */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vUpdateBoundingBoxOfSpheresWithSameRadius ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stSphereCenter1,
MTH3D_tdstVector *p_stSphereCenter2,
MTH_tdxReal xSphereRadius )
{
MTH_tdxReal xValue;
/* X axis*/
if( MTH_M_bLess( p_stSphereCenter1->xX , p_stSphereCenter2->xX ) )
{
xValue = MTH_M_xSub ( p_stSphereCenter1->xX, xSphereRadius );
COL_M_vUpdateMin( p_stMinBounding->xX , xValue );
xValue = MTH_M_xAdd ( p_stSphereCenter2->xX, xSphereRadius );
COL_M_vUpdateMax( p_stMaxBounding->xX , xValue );
}
else
{
xValue = MTH_M_xSub ( p_stSphereCenter2->xX, xSphereRadius );
COL_M_vUpdateMin( p_stMinBounding->xX , xValue );
xValue = MTH_M_xAdd ( p_stSphereCenter1->xX, xSphereRadius );
COL_M_vUpdateMax( p_stMaxBounding->xX , xValue );
}
/* Y axis*/
if( MTH_M_bLess( p_stSphereCenter1->xY , p_stSphereCenter2->xY ) )
{
xValue = MTH_M_xSub ( p_stSphereCenter1->xY, xSphereRadius );
COL_M_vUpdateMin( p_stMinBounding->xY , xValue );
xValue = MTH_M_xAdd ( p_stSphereCenter2->xY, xSphereRadius );
COL_M_vUpdateMax( p_stMaxBounding->xY , xValue );
}
else
{
xValue = MTH_M_xSub ( p_stSphereCenter2->xY, xSphereRadius );
COL_M_vUpdateMin( p_stMinBounding->xY , xValue );
xValue = MTH_M_xAdd ( p_stSphereCenter1->xY, xSphereRadius );
COL_M_vUpdateMax( p_stMaxBounding->xY , xValue );
}
/* Z axis*/
if( MTH_M_bLess( p_stSphereCenter1->xZ , p_stSphereCenter2->xZ ) )
{
xValue = MTH_M_xSub ( p_stSphereCenter1->xZ, xSphereRadius );
COL_M_vUpdateMin( p_stMinBounding->xZ , xValue );
xValue = MTH_M_xAdd ( p_stSphereCenter2->xZ, xSphereRadius );
COL_M_vUpdateMax( p_stMaxBounding->xZ , xValue );
}
else
{
xValue = MTH_M_xSub ( p_stSphereCenter2->xZ, xSphereRadius );
COL_M_vUpdateMin( p_stMinBounding->xZ , xValue );
xValue = MTH_M_xAdd ( p_stSphereCenter1->xZ, xSphereRadius );
COL_M_vUpdateMax( p_stMaxBounding->xZ , xValue );
}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* mise <20> jour de la boite englobante de deux spheres */
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void COL_fn_vUpdateBoundingBoxOfSpheres ( MTH3D_tdstVector *p_stMinBounding,
MTH3D_tdstVector *p_stMaxBounding,
MTH3D_tdstVector *p_stSphereCenter1,
MTH_tdxReal xSphereRadius1,
MTH3D_tdstVector *p_stSphereCenter2,
MTH_tdxReal xSphereRadius2 )
{
MTH_tdxReal xMin1 , xMax1 , xMin2 , xMax2 ;
/* X axis*/
xMin1 = MTH_M_xSub ( p_stSphereCenter1->xX, xSphereRadius1 );
xMax1 = MTH_M_xAdd ( p_stSphereCenter1->xX, xSphereRadius1 );
xMin2 = MTH_M_xSub ( p_stSphereCenter2->xX, xSphereRadius2 );
xMax2 = MTH_M_xAdd ( p_stSphereCenter2->xX, xSphereRadius2 );
COL_M_vUpdateWithMin( p_stMinBounding->xX , xMin1 , xMin2 );
COL_M_vUpdateWithMax( p_stMaxBounding->xX , xMax1 , xMax2 );
/* Y axis*/
xMin1 = MTH_M_xSub ( p_stSphereCenter1->xY, xSphereRadius1 );
xMax1 = MTH_M_xAdd ( p_stSphereCenter1->xY, xSphereRadius1 );
xMin2 = MTH_M_xSub ( p_stSphereCenter2->xY, xSphereRadius2 );
xMax2 = MTH_M_xAdd ( p_stSphereCenter2->xY, xSphereRadius2 );
COL_M_vUpdateWithMin( p_stMinBounding->xY , xMin1 , xMin2 );
COL_M_vUpdateWithMax( p_stMaxBounding->xY , xMax1 , xMax2 );
/* Z axis*/
xMin1 = MTH_M_xSub ( p_stSphereCenter1->xZ, xSphereRadius1 );
xMax1 = MTH_M_xAdd ( p_stSphereCenter1->xZ, xSphereRadius1 );
xMin2 = MTH_M_xSub ( p_stSphereCenter2->xZ, xSphereRadius2 );
xMax2 = MTH_M_xAdd ( p_stSphereCenter2->xZ, xSphereRadius2 );
COL_M_vUpdateWithMin( p_stMinBounding->xZ , xMin1 , xMin2 );
COL_M_vUpdateWithMax( p_stMaxBounding->xZ , xMax1 , xMax2 );
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
/* determine si deux boites englobantes sont en collision */
ACP_tdxBool COL_fn_bDetectCollisionBetweenTwoParallelBoxes(MTH3D_tdstVector * _p_stFirstBoxMaxPoint,
MTH3D_tdstVector * _p_stFirstBoxMinPoint,
MTH3D_tdstVector * _p_stSecondBoxMaxPoint,
MTH3D_tdstVector * _p_stSecondBoxMinPoint)
{
if ( MTH_M_bGreater (_p_stSecondBoxMaxPoint->xX, _p_stFirstBoxMinPoint->xX) &&
MTH_M_bLess (_p_stSecondBoxMinPoint->xX, _p_stFirstBoxMaxPoint->xX) &&
MTH_M_bGreater (_p_stSecondBoxMaxPoint->xY, _p_stFirstBoxMinPoint->xY) &&
MTH_M_bLess (_p_stSecondBoxMinPoint->xY, _p_stFirstBoxMaxPoint->xY) &&
MTH_M_bGreater (_p_stSecondBoxMaxPoint->xZ, _p_stFirstBoxMinPoint->xZ) &&
MTH_M_bLess (_p_stSecondBoxMinPoint->xZ, _p_stFirstBoxMaxPoint->xZ))
return TRUE;
else
return FALSE;
}