/*
  MODULE : COL (Intersection & Collision Library)
  AUTHOR : Frederic PHILIPPE
           UBI R&D
  FILE : CollGOUt.h (Geometric object collision)
*/
 
#ifndef COL_COLLGOUT_H
#define COL_COLLGOUT_H
 
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
 
#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"
 
/*
-----------------------------------------------------------------------------
FUNCTIONS DECLARATION
-----------------------------------------------------------------------------
*/
 
#define COL_M_vIntSegTriBoundReject( p_stVertexA, p_stVectAB, p_stVertex1, p_stVertex2, p_stVertex3, xCoord, xMin, xMax )\
{\
  xMin = p_stVertexA->xCoord;\
  if (*((long *)&(p_stVectAB->xCoord)) < 0L)\
  {\
    xMin += p_stVectAB->xCoord;\
  }\
\
  FUT_M_vMaxValue3 ( xMax, p_stVertex1->xCoord, p_stVertex2->xCoord, p_stVertex3->xCoord );\
\
  if ( MTH_M_bLess ( xMax, xMin ) )\
  {\
    return ;\
  }\
\
  xMax = p_stVertexA->xCoord;\
  if (*((long *)&(p_stVectAB->xCoord)) > 0L)\
  {\
    xMax += p_stVectAB->xCoord;\
  }\
\
  FUT_M_vMinValue3 ( xMin, p_stVertex1->xCoord, p_stVertex2->xCoord, p_stVertex3->xCoord );\
\
  if ( MTH_M_bLess ( xMax, xMin ) )\
  {\
    return ;\
  }\
}
 
#define COL_M_vIntSegSphBoundReject( p_stVertex1, p_stVect12, p_stSphereCenter, xRadius, xCoord, xMin, xMax )\
{\
  xMin = p_stVertex1->xCoord;\
  if (*((long *)&(p_stVect12->xCoord)) < 0L)\
  {\
    xMin += p_stVect12->xCoord;\
  }\
\
  xMax = MTH_M_xAdd ( p_stSphereCenter->xCoord, xRadius );\
\
  if ( MTH_M_bLess ( xMax, xMin ) )\
  {\
    return ;\
  }\
\
  xMax = p_stVertex1->xCoord;\
  if (*((long *)&(p_stVect12->xCoord)) > 0L)\
  {\
    xMax += p_stVect12->xCoord;\
  }\
\
  xMin = MTH_M_xSub ( p_stSphereCenter->xCoord, xRadius );\
\
  if ( MTH_M_bLess ( xMax, xMin ) )\
  {\
    return ;\
  }\
}
 
#define COL_M_vIntSegCylBoundRejection( p_stVertex1, p_stVect12, p_stVertexA, p_stVectAB, xCoord, xRadius, xMin, xMax )\
{\
  xMin = p_stVertex1->xCoord;\
  if (*((long *)&(p_stVect12->xCoord)) < 0L)\
  {\
    xMin += p_stVect12->xCoord;\
  }\
\
  xMax = p_stVertexA->xCoord;\
  if (*((long *)&(p_stVectAB->xCoord)) > 0L)\
  {\
    xMax += p_stVectAB->xCoord;\
  }\
\
  if ( MTH_M_bLess ( MTH_M_xAdd ( xMax, xRadius ), xMin ) )\
  {\
    return ;\
  }\
\
  xMax = p_stVertex1->xCoord;\
  if (*((long *)&(p_stVect12->xCoord)) > 0L)\
  {\
    xMax += p_stVect12->xCoord;\
  }\
\
  xMin = p_stVertexA->xCoord;\
  if (*((long *)&(p_stVectAB->xCoord)) < 0L)\
  {\
    xMin += p_stVectAB->xCoord;\
  }\
\
  if ( MTH_M_bLess ( xMax, MTH_M_xSub ( xMin, xRadius ) ) )\
  {\
    return ;\
  }\
}
 
extern CPA_EXPORT ACP_tdxBool COL_fn_bGetSurfaceInGeometricObject ( ACP_tdxHandleOfObject _hGeometricObject );
 
extern CPA_EXPORT ACP_tdxBool COL_fn_bGetSphereAndPointOnlyInGeometricObject ( ACP_tdxHandleOfObject _hGeometricObject );
 
#ifdef __cplusplus
};
#endif /* __cplusplus */
 
#endif /* COL_COLLGOUT_H */
