reman3/Rayman_X/cpa/public/COL/CollGOCo.h

384 lines
12 KiB
C

/*
MODULE : COL (Intersection & Collision Library)
AUTHOR : Frederic PHILIPPE
UBI R&D
FILE : CollGOCo.h (Geometric object collision)
*/
#ifndef COL_COLLGOCO_H
#define COL_COLLGOCO_H
#ifdef __cplusplus
extern "C" {
#endif
#include "cpa_expt.h"
/* For Global declaration in C files : */
#ifdef COL_GLOBALS
#define COL_EXTERN extern
#else /* !COL_GLOBALS */
#define COL_EXTERN
#endif /* !COL_GLOBALS */
/*
-----------------------------------------------------------------------------
INCLUDES FILES
-----------------------------------------------------------------------------
*/
#include "Futil.h"
#include "Box.h"
#include "Inters.h"
#include "IntersGO.h"
#include "OctreeGO.h"
#include "CollGOUt.h"
/*
-----------------------------------------------------------------------------
CONSTANT DECLARATION
-----------------------------------------------------------------------------
*/
/* cas de collision */
#define COL_C_ulDynamicNonWithStaticNon 0x00000000
#define COL_C_ulDynamicPtsWithStaticITr 0x00000001
#define COL_C_ulDynamicPtsWithStaticFMD 0x00000002
#define COL_C_ulDynamicPtsWithStaticSph 0x00000004
#define COL_C_ulDynamicPtsWithStaticBox 0x00000008
#define COL_C_ulDynamicPtsWithStaticElt 0x0000000F
#define COL_C_ulDynamicITrWithStaticPts 0x00000010
#define COL_C_ulDynamicFMDWithStaticPts 0x00000020
#define COL_C_ulDynamicSphWithStaticPts 0x00000040
#define COL_C_ulDynamicBoxWithStaticPts 0x00000080
#define COL_C_ulDynamicEltWithStaticPts 0x000000F0
#define COL_C_ulDynamicEdgWithStaticEdg 0x00000100
#define COL_C_ulDynamicEdgWithStaticSph 0x00000200
#define COL_C_ulDynamicEdgWithStaticBox 0x00000400
#define COL_C_ulDynamicEdgWithStaticElt 0x00000600
#define COL_C_ulDynamicSphWithStaticEdg 0x00000800
#define COL_C_ulDynamicBoxWithStaticEdg 0x00001000
#define COL_C_ulDynamicEltWithStaticEdg 0x00001800
#define COL_C_ulDynamicITrWithStaticSph 0x00002000
#define COL_C_ulDynamicITrWithStaticBox 0x00004000
#define COL_C_ulDynamicITrWithStaticElt 0x00006000
#define COL_C_ulDynamicFMDWithStaticSph 0x00008000
#define COL_C_ulDynamicFMDWithStaticBox 0x00010000
#define COL_C_ulDynamicFMDWithStaticElt 0x00018000
#define COL_C_ulDynamicSphWithStaticITr 0x00020000
#define COL_C_ulDynamicSphWithStaticFMD 0x00040000
#define COL_C_ulDynamicSphWithStaticSph 0x00080000
#define COL_C_ulDynamicSphWithStaticBox 0x00100000
#define COL_C_ulDynamicSphWithStaticElt 0x001E0000
#define COL_C_ulDynamicBoxWithStaticITr 0x00200000
#define COL_C_ulDynamicBoxWithStaticFMD 0x00400000
#define COL_C_ulDynamicBoxWithStaticSph 0x00800000
#define COL_C_ulDynamicBoxWithStaticBox 0x01000000
#define COL_C_ulDynamicBoxWithStaticElt 0x01E00000
#define COL_C_ulDynamicEltWithStaticElt 0x01FFE000
#define COL_C_ulDynamicAllWithStaticAll 0x01FFFFFF
/* ANNECY AV {*/
/*#define COL_C_xPointEntity 0*/
#define COL_C_xTriangleEntity 1
/*#define COL_C_xEdgeEntity 2*/
#define COL_C_xSphereEntity 3
#define COL_C_xAlignedBoxEntity 4
#define COL_C_xHighEdgeEntity 7 /* Edge that is above the collision point */
#define COL_C_xLowEdgeEntity 8 /* Edge that is below the collision point */
/* END ANNECY AV }*/
/*ANNECY jt {*/
#define COL_C_xNoEntity 99
/*ENDANNECY jt }*/
#define COL_C_xMaxStaticPoints 500
#define COL_C_xMaxStaticEdges 500
#define COL_C_xMaxStaticBoundingBoxes 50
/*#define COL_C_xMaxNumberOfCollisions 25 // 50 jt*/
#define COL_C_xMaxNumberOfCollisions 75
/*
-----------------------------------------------------------------------------
TYPES DEFINITION
-----------------------------------------------------------------------------
*/
/* WARNING
To Optimize MECA-Collisions Array computing,
this struct MUST BE exactly the same as
DNM_stMecObstacle in DNMObsta.h
Any change to this struct MUST be reported to DNM_stMecObstacle */
typedef struct COL_tdstCollisionCase_
{
/* 1 temps de collision */
MTH_tdxReal xCollisionTime;
/* 2 normale de collision */
MTH3D_tdstVector stCollisionNormal;
/* 3 point de collision */
MTH3D_tdstVector stCollisionPoint;
/* 4 materiau dynamique */
GMT_tdxHandleToGameMaterial hDynamicMaterial;
/* 5 materiau statique */
GMT_tdxHandleToGameMaterial hStaticMaterial;
/* 6 parametre 1 pour la meca HIE_tdxHandleToSuperObject mp_stSupObj */
void *p_vParameter1;
/* 7 parametre 2 pour la meca DNM_tdeObstacleType m_eType */
long sParameter2;
/* 8 geometrie dynamique */
ACP_tdxIndex xDynamicGeomEntity;
/* 9 geometrie statique */
ACP_tdxIndex xStaticGeomEntity;
/* 10 The translation to do to the actor*/
MTH3D_tdstVector stTranslation;
/* 11 the movement of the zone */
MTH3D_tdstVector stMovement;
/* 12 the final position of the center of the sphere */
MTH3D_tdstVector stEndPosition;
/* 13 The radius of the sphere (or the dimension of the box) */
MTH_tdxReal xSphereRadius;
/* 14 Pour correspondre a la structure de meca*/
/*DNM_tdstMecMatCharacteristics m_stProperties; *//* Material properties */
MTH_tdxReal m_xSlide1;
MTH_tdxReal m_xRebound1;
/* 15 Pour correspondre a la structure de meca*/
/* DNM_tdstMecMatCharacteristics m_stMyProperties;*/ /* Material properties of mine */
MTH_tdxReal m_xSlide2;
MTH_tdxReal m_xRebound2;
}
COL_tdstCollisionCase;
typedef struct COL_tdstGVForCollision_
{
/* parametres */
ACP_tdxBool bStaticGeomObjHasNoTransformationMatrix;
ACP_tdxBool bDynamicGeomObjHasZoomInsteadOfScale;
GEO_tdstGeometricObject *p_stDynamicGeomObj;
POS_tdstCompletePosition *p_stT0DynamicGeomObjMatrix;
POS_tdstCompletePosition *p_stT1DynamicGeomObjMatrix;
GEO_tdstGeometricObject *p_stStaticGeomObj;
POS_tdstCompletePosition *p_stStaticGeomObjMatrix;
unsigned long ulSelectedCollisionCases;
void *p_vParameter1;
short sParameter2;
/* variables internes */
/* matrices */
POS_tdstCompletePosition stInvMatrix;
POS_tdstCompletePosition stD2ST0TransformMatrix;
POS_tdstCompletePosition stD2ST1TransformMatrix;
POS_tdstCompletePosition stS2DT0TransformMatrix;
POS_tdstCompletePosition stS2DT1TransformMatrix;
MTH_tdxReal xStaticScale;
/* index generaux */
ACP_tdxIndex xDynamicPointIndex;
ACP_tdxIndex xStaticPointIndex;
ACP_tdxIndex xDynamicEdgeIndex;
ACP_tdxIndex xStaticEdgeIndex;
ACP_tdxIndex xDynamicElementIndex;
ACP_tdxIndex xStaticElementIndex;
/* pointeurs des elements */
MTH3D_tdstVector *p_stDynamicPoint;
MTH3D_tdstVector *p_stStaticPoint;
GEO_tdstDoubledIndex *p_stDynamicEdge;
GEO_tdstDoubledIndex *p_stStaticEdge;
GEO_tdstElementIndexedTriangles *p_stDynamicElementIndexedTriangles;
GEO_tdstElementIndexedTriangles *p_stStaticElementIndexedTriangles;
//XB99/04/27
#ifndef U64
GEO_tdstElementFaceMapDescriptors *p_stDynamicElementFaceMapDescriptors;
GEO_tdstElementFaceMapDescriptors *p_stStaticElementFaceMapDescriptors;
#endif U64
//End XB99/04/27
GEO_tdstElementSpheres *p_stDynamicElementSpheres;
GEO_tdstElementSpheres *p_stStaticElementSpheres;
GEO_tdstElementAlignedBoxes *p_stDynamicElementAlignedBoxes;
GEO_tdstElementAlignedBoxes *p_stStaticElementAlignedBoxes;
#ifdef USE_ALTIMAPS
GEO_tdstElementAltimap *p_stStaticElementAltimap;
#endif /*USE_ALTIMAPS*/
/* index des elements */
ACP_tdxIndex xDynamicIndexedTriangleIndex;
ACP_tdxIndex xStaticIndexedTriangleIndex;
ACP_tdxIndex xDynamicFaceMapTriangleIndex;
ACP_tdxIndex xStaticFaceMapTriangleIndex;
ACP_tdxIndex xDynamicIndexedSphereIndex;
ACP_tdxIndex xStaticIndexedSphereIndex;
ACP_tdxIndex xDynamicIndexedAlignedBoxIndex;
ACP_tdxIndex xStaticIndexedAlignedBoxIndex;
/* ANNECY MT 25/02/98 {*/
long lBitsFieldOfIndexedSpheresInCollision;
/* END ANNECY MT }*/
/* pointeurs des parties d element */
GEO_tdstIndexedSphere *p_stDynamicIndexedSphere;
GEO_tdstIndexedSphere *p_stStaticIndexedSphere;
GEO_tdstIndexedAlignedBox *p_stDynamicIndexedAlignedBox;
GEO_tdstIndexedAlignedBox *p_stStaticIndexedAlignedBox;
/* donnees de base */
MTH3D_tdstVector stDinST0Point;
MTH3D_tdstVector stDinST1Point;
MTH3D_tdstVector stDinST01Vector;
/* jt 220399 */
MTH3D_tdstVector stSwapDinST0Point;
MTH3D_tdstVector stSinDT0Point;
MTH3D_tdstVector stSinDT1Point;
MTH3D_tdstVector stSinDT01Vector;
ACP_tdxIndex xVertex1Index;
ACP_tdxIndex xVertex2Index;
MTH3D_tdstVector *p_stVertex1;
MTH3D_tdstVector *p_stVertex2;
MTH3D_tdstVector stEdgeVector;
MTH3D_tdstVector *p_stDynamicCenter;
MTH3D_tdstVector *p_stStaticCenter;
MTH_tdxReal xDynamicRadius;
/* jt 260399 */
MTH_tdxReal xSwapRadius;
ACP_tdxBool bUseEnlargeSphere;
MTH3D_tdstVector *p_stDynamicMinPoint;
MTH3D_tdstVector *p_stDynamicMaxPoint;
MTH3D_tdstVector *p_stStaticMinPoint;
MTH3D_tdstVector *p_stStaticMaxPoint;
MTH3D_tdstVector stDinST0MaxPoint;
MTH3D_tdstVector stDinST1MaxPoint;
MTH3D_tdstVector stDinST0MinPoint;
MTH3D_tdstVector stDinST1MinPoint;
COL_tda8st8VerticesBox a8_stDynamic8VBox;
COL_tda8st8VerticesBox a8_stStatic8VBox;
COL_tda8st8VerticesBox a8_stDinST08VBox;
COL_tda8st8VerticesBox a8_stDinST18VBox;
COL_tda8st8VerticesBox a8_stDinST01Vect;
COL_tda8st8VerticesBox a8_stSinDT08VBox;
COL_tda8st8VerticesBox a8_stSinDT18VBox;
COL_tda8st8VerticesBox a8_stSinDT01Vect;
GMT_tdxHandleToGameMaterial hDynamicMaterial;
GMT_tdxHandleToGameMaterial hStaticMaterial;
COL_tdpstOctree p_stOctree;
ACP_tdxIndex xNumberOfSelectedNodes;
COL_tdpstOctreeNode aDEF_pstSelectedNode[COL_C_xMaxSelectedNodes];
MTH_tdxReal aDEF_xSelectedT[COL_C_xMaxSelectedNodes];
ACP_tdxBool bSurfacicDynamicElement;
ACP_tdxBool bDynamicSphereAndPointOnly;
ACP_tdxIndex xNbStaticPoints;
ACP_tdxIndex aDEF_xListOfStaticPoints[COL_C_xMaxStaticPoints];
ACP_tdxIndex xNbStaticEdges;
ACP_tdxIndex aDEF_xListOfStaticPt1Edges[COL_C_xMaxStaticEdges];
ACP_tdxIndex aDEF_xListOfStaticPt2Edges[COL_C_xMaxStaticEdges];
GMT_tdxHandleToGameMaterial aDEF_hListOfStaticMaterialEdges[COL_C_xMaxStaticEdges];
}
COL_tdstGVForCollision;
/*
-----------------------------------------------------------------------------
GLOBAL VARIABLE DECLARATION
-----------------------------------------------------------------------------
*/
/* cas de collision */
extern COL_tdstCollisionCase COL_g_stCollisionCase [COL_C_xMaxNumberOfCollisions];
extern COL_tdstGVForCollision COL_g_stGVForCol;
extern long COL_g_lNbElementsInTable;
/*
-----------------------------------------------------------------------------
FUNCTIONS DECLARATION
-----------------------------------------------------------------------------
*/
/*extern CPA_EXPORT void COL_fn_vInitCollisionTable ( void );*/ /* anthony */
#define COL_fn_vInitCollisionTable() { COL_g_lNbElementsInTable = 0; }
extern CPA_EXPORT void COL_fn_vAddInStaticCollisionTable ( MTH_tdxReal _xT,
MTH3D_tdstVector * _p_stTranslation,
MTH3D_tdstVector * _p_stHit,
MTH3D_tdstVector * _p_stNormal,
GMT_tdxHandleToGameMaterial _hDynMat,
GMT_tdxHandleToGameMaterial _hStatMat,
ACP_tdxIndex _xDynamicGeomEntity,
ACP_tdxIndex _xStaticGeomEntity,
void * _p_vParameter1,
short _sParameter2,
MTH3D_tdstVector * _p_stMovement,
MTH_tdxReal _xSphereRadius,
MTH3D_tdstVector * _p_stEndPosition);
/*extern CPA_EXPORT ACP_tdxBool COL_fn_bGetResultCollision (COL_tdstCollisionCase * p_stCollisionCaseDst);*/
extern CPA_EXPORT ACP_tdxBool COL_fn_bGetMultipleResultCollision (COL_tdstCollisionCase * * _p_p_stCollisionCaseDst);
#ifdef __cplusplus
};
#endif
#endif /* COL_COLLGOCO_H */