reman3/Rayman_X/cpa/public/GAM/Futil.h

431 lines
17 KiB
C

#ifndef _FUTIL_H_
#define _FUTIL_H_
/******************************************/
#if _MSC_VER >= 1000
#pragma once
#endif /* _MSC_VER >= 1000 */
/******************************************/
#include "GAM/Header.h"
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xSqr()
// Return the square of a value
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xSqr( A) ( ( A ) * ( A ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xMaxValue()
// Return the max value of two values
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xMaxValue( A, B) ( ( ( A ) > ( B ) ) ? ( A ) : ( B ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xMinValue()
// Return the min value of two values
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xMinValue( A, B) ( ( ( A ) < ( B ) ) ? ( A ) : ( B ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xMaxValue3()
// Return the max value of three values
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xMaxValue3( A, B, C) (\
( ( (A) > (B) ) && ( (A) > (C) ) )\
? (A) :\
( ( (B) > (C) ) ? (B) : (C) )\
)
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xMinValue3()
// Return the min value of three values
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xMinValue3( A, B, C) (\
( ( (A) < (B) ) && ( (A) < (C) ) )\
? (A) :\
( ( (B) < (C) ) ? (B) : (C) )\
)
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xLinearInterp()
// Return the linear interpolation
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xLinearInterp( A, B, C) ( ( B ) + MTH_M_xMul ( ( A ), ( ( C ) - ( B ) ) ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_bInRangeE()
// Return the interval inclusion
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_bInRangeE( A, B, C) ( ((A) <= (B)) && ((B) <= (C)) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_bInRangeE2()
// Return the interval inclusion for 2 two values
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_bInRangeE2( A, B, C, D, E, F) ( ((A) <= (B)) && ((B) <= (C)) &&\
((D) <= (E)) && ((E) <= (F)) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_ubf3VectSign()
// Return the sign of the vector three components
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_ulVectSign( A, B, C) ( ((A)<0)?4:0 | ((B)<0)?2:0 | ((C)<0)?1:0 )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vCopyVertex()
// Copy vertex to another
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vCopyVertex( A, B)\
(A)->xX = (B)->xX;\
(A)->xY = (B)->xY;\
(A)->xZ = (B)->xZ
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vCopy2Vertex()
// Copy two vertice to another
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vCopy2Vertex( A, B, C)\
(A)->xX = (B)->xX = (C)->xX;\
(A)->xY = (B)->xY = (C)->xY;\
(A)->xZ = (B)->xZ = (C)->xZ
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vAddScale3Vertex()
// Add a vertex with a scalar
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vAddScale3Vertex( A, B, C)\
(A)->xX = MTH_M_xAdd ( (B)->xX, (C) );\
(A)->xY = MTH_M_xAdd ( (B)->xY, (C) );\
(A)->xZ = MTH_M_xAdd ( (B)->xZ, (C) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vSub3Vertex()
// Subtract two vertices
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vSub3Vertex( A, B, C)\
(A)->xX = (B)->xX - (C)->xX;\
(A)->xY = (B)->xY - (C)->xY;\
(A)->xZ = (B)->xZ - (C)->xZ
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vSubScale3Vertex()
// Subtract a vertex by a scalar
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vSubScale3Vertex( A, B, C)\
(A)->xX = MTH_M_xSub ( (B)->xX, (C) );\
(A)->xY = MTH_M_xSub ( (B)->xY, (C) );\
(A)->xZ = MTH_M_xSub ( (B)->xZ, (C) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vMul3Vertex()
// Multiply two vertices
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vMul3Vertex( A, B, C)\
(A)->xX = MTH_M_xMul ( (B)->xX, (C)->xX );\
(A)->xY = MTH_M_xMul ( (B)->xY, (C)->xY );\
(A)->xZ = MTH_M_xMul ( (B)->xZ, (C)->xZ )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vNegVertex()
// Negative a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vNegVertex( A, B)\
(A)->xX = MTH_M_xNeg ( (B)->xX );\
(A)->xY = MTH_M_xNeg ( (B)->xY );\
(A)->xZ = MTH_M_xNeg ( (B)->xZ )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vDivScaleVertex()
// Divide a vertex by a scalar
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vDivScaleVertex( A, B)\
(A)->xX = MTH_M_xDiv ( (A)->xX, (B) );\
(A)->xY = MTH_M_xDiv ( (A)->xY, (B) );\
(A)->xZ = MTH_M_xDiv ( (A)->xZ, (B) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vMulAddVertex()
// Multiply by a scalar and addition a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vMulAddVertex( A, B, C, D)\
(A)->xX = MTH_M_xMul ( (B), (C)->xX ) + (D)->xX;\
(A)->xY = MTH_M_xMul ( (B), (C)->xY ) + (D)->xY;\
(A)->xZ = MTH_M_xMul ( (B), (C)->xZ ) + (D)->xZ
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vMidVertex()
// Divide a vertex by a scalar
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vMidVertex( A, B, C)\
(A)->xX = MTH_M_xMul ( (B)->xX + (C)->xX, MTH_M_xFloatToReal ( 0.5 ) );\
(A)->xY = MTH_M_xMul ( (B)->xY + (C)->xY, MTH_M_xFloatToReal ( 0.5 ) );\
(A)->xZ = MTH_M_xMul ( (B)->xZ + (C)->xZ, MTH_M_xFloatToReal ( 0.5 ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vMaxVertex()
// Max coordinates of a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vMaxVertex( A, B, C)\
(A)->xX = FUT_M_xMaxValue ( (B)->xX, (C)->xX );\
(A)->xY = FUT_M_xMaxValue ( (B)->xY, (C)->xY );\
(A)->xZ = FUT_M_xMaxValue ( (B)->xZ, (C)->xZ )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vMinVertex()
// Min coordinates of a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vMinVertex( A, B, C)\
(A)->xX = FUT_M_xMinValue ( (B)->xX, (C)->xX );\
(A)->xY = FUT_M_xMinValue ( (B)->xY, (C)->xY );\
(A)->xZ = FUT_M_xMinValue ( (B)->xZ, (C)->xZ )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vCrossProduct()
// Croos product of two vectors
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vCrossProduct( A, B, C)\
(A)->xX = MTH_M_xMul ( (B)->xY, (C)->xZ ) - MTH_M_xMul ( (B)->xZ, (C)->xY );\
(A)->xY = MTH_M_xMul ( (B)->xZ, (C)->xX ) - MTH_M_xMul ( (B)->xX, (C)->xZ );\
(A)->xZ = MTH_M_xMul ( (B)->xX, (C)->xY ) - MTH_M_xMul ( (B)->xY, (C)->xX )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_vLinearIntVertex()
// Linear interpolation of two vertices
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_vLinearIntVertex( A, B, C, D)\
(A)->xX = FUT_M_xLinearInterp ( (B), (C)->xX, (D)->xX );\
(A)->xY = FUT_M_xLinearInterp ( (B), (C)->xY, (D)->xY );\
(A)->xZ = FUT_M_xLinearInterp ( (B), (C)->xZ, (D)->xZ )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xDetXYVertex()
// Deter XY of a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xDetXYVertex( A, B) ( MTH_M_xMul ( (A)->xX, (B)->xY ) -\
MTH_M_xMul ( (A)->xY, (B)->xX ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xDetYZVertex()
// Deter YZ of a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xDetYZVertex( A, B) ( MTH_M_xMul ( (A)->xY, (B)->xZ ) -\
MTH_M_xMul ( (A)->xZ, (B)->xY ) )
/*
////////////////////////////////////////////////////////////////////////////////
// Description : FUT_M_xDetZXVertex()
// Deter ZX of a vertex
////////////////////////////////////////////////////////////////////////////////
// Input :
// Output :
////////////////////////////////////////////////////////////////////////////////
// Creation date : 22 aug 1996 Author : FPI
////////////////////////////////////////////////////////////////////////////////
*/
#define FUT_M_xDetZXVertex( A, B) ( MTH_M_xMul ( (A)->xZ, (B)->xX ) -\
MTH_M_xMul ( (A)->xX, (B)->xZ ) )
#endif