Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Collision - Type.h_inc
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Collision ========================================================================================================================================================= */

TgTYPE_STRUCT(V(STg2_CO_Clip_List),)
{
    TgSINT32                                    m_niPoint;
    TgSINT32                                    m_niMax;
    TgSINT32                                    m_iPad[2];
    V(TgVEC)                                    m_avPoint[1]; /* Variable sized clip array */
};

/* ---- Separating Axis ------------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_STRUCT(V(STg2_CO_Axis_Project),)
{
    V(TgVEC)                                    m_avMinVert[4], m_avMaxVert[4]; /*« Index of points coincident at min/max */
    TgSINT32                                    m_iMinID, m_iMaxID; /*« Bitfield representing the triangle feature at min/max */
    TgUINT32                                    m_nuiMinDepth, m_nuiMaxDepth; /*« Count of vertices coincident at min/max */
};

TgTYPE_STRUCT(V(STg2_CO_Axis_Test),)
{
    TYPE                                        m_fLimitT; /*« Maximal limit on the time value. */
    TYPE                                        m_fMin0, m_fMax0; /*« The extremities of the primitive projected onto the axis. */
    TYPE                                        m_fMin1, m_fMax1; /*« The extremities of the primitive projected onto the axis. */
    TYPE                                        m_fSpeed; /*« The relative speed of primitive 1 to primitive 0 along the axis. */
    TYPE                                        m_fMinT, m_fMaxT; /*« First and last time of contact. */
};

TgTYPE_STRUCT(V(STg2_CO_Axis_Info),)
{
    V(TgVEC)                                    m_vNormal;
    TYPE                                        m_fMinT;
    ETgCO_AXIS_CONTACT_DIRECTION                m_enSide;
    PAD32_4(                                    2 )
    PAD64_4(                                    1 )
};

TgTYPE_STRUCT(V(STg2_CO_Axis_Result),)
{
    V(TgVEC)                                    m_vNormal;
    V(TgVEC)                                    m_vPoint;
    TYPE                                        m_fDepth;
    TgSINT32                                    m_iAxis;
    PAD32_4(                                    2 )
    PAD64_4(                                    1 )
};

/* ---- Result ---------------------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_STRUCT(V(STg2_CO_Context),)
{
    TgSINT32                                    m_iTriIdx;
};

TgTYPE_STRUCT(V(STg2_CO_Contact),)
{
    V(TgVEC)                                    m_vS0; /*« Contact position */
    V(TgVEC)                                    m_vN0; /*« Contact normal */
    TYPE                                        m_fT0; /*« Normalized time of contact (first for a range)f */
    TYPE                                        m_fDepth; /*« Penetration depth */
    PAD32_4(                                    2 )
};

TgTYPE_STRUCT(V(STg2_CO_Packet),)
{
    V(P_STg2_CO_Contact)                        m_psContact;
    TYPE                                        m_fSweepTol;
    TYPE                                        m_fSnapTol;
    TgSINT32                                    m_niContact;
    TgSINT32                                    m_niMaxContact;
    TgBOOL                                      m_bReport_Penetration;
    TgUINT32                                    m_uiPad0;
};

TgTYPE_STRUCT(V(STg2_CO_Result),)
{
    V(STg2_CO_Contact)                          m_sContact; /*« Result contact */
    V(TgPTRI)                                   m_sPT; /*« Minimal target triangle representation */
    V(STg2_CO_Context)                          m_sContext; /*« Context of the result */
    TgFLOAT32                                   m_fT1; /*« Normalized last time of contact */
    TgBOOL                                      m_bValid; /*« Allows for easy post-processing of collision results */
    TgBOOL                                      m_bTri; /*« Indicates if the contained triangle is valid */
};


/* ---- Request --------------------------------------------------------------------------------------------------------------------------------------------------------- */

TgTYPE_STRUCT_ALIGN(V(STg2_CO_Request),TgCOMPILE_CACHE_LINE_SIZE,)
{
    V(STg2_CO_Context)                          m_sContext; /*« Context of the current collision state. */

    ETgPRIMITIVE                                m_enPrimitive; /*« (ETgPRIMITIVE) Active primitive for the structure. */
    ETgCO_TEST                                  m_enTest; /*« (ETgSWEEP_TYPE) Test is intersection, penetration and/or sweep. */
    ETgCO_PURPOSE                               m_enPurpose; /*« Bitfield describing the purpose of the collision call. */
    TgUINT32                                    m_uiFilter_Objects; /*« Category of objects included in collision call. */
    TgUINT32                                    m_bfFlags; /*« General bitfield for collision flags. */

    TgSINT32                                    m_niConnection_Graph_Ignored; /*« Inclusively ignore all descendants. */
    TgSINT32                                    m_niConnection_Ignored; /*« Ignore only the object. */
    P_STg2_Connection                           m_apsConnection_Graph_Ignored[KTgCO_REQUEST__MAX_IGNORE];
    P_STg2_Connection                           m_apsConnection_Ignored[KTgCO_REQUEST__MAX_IGNORE];

    V(TgDELTA)                                  m_sDT;

    TgSINT32                                    m_aiNative_String[KTgCO_REQUEST__MAX_IGNORE];
    TgSINT32                                    m_niNative_String; /*« Ignore a specific literal (eg class name) */
    PAD64_4(                                    1 )

    TYPE                                        m_fToI; /*« The closest point of intersection during the sweep test [0..1] */
    TYPE                                        m_fDist;
    TYPE                                        m_fNudge;

                                                /* Result list filtered by selectors (greatest depth etc.) */
    V(STg2_CO_Result)                           m_asInternal_Result[KTgCO_REQUEST__INTERNAL_RESULTS];
    V(P_STg2_CO_Result)                         m_psResult;
    TgSINT32                                    m_niResult_End; /* Terminates the memory region */
    TgSINT32                                    m_niResult_Last; /* Terminates the array of valid results */

                                                /* Used on a per query basis to be merged into results (temporary data) */
    V(STg2_CO_Packet)                           m_sPacket;
    V(STg2_CO_Contact)                          m_asContact[8]; 

                                                /* Collect List */
    V(P_TgPTRI)                                 m_psCollect;
    TgSINT32                                    m_niCollect_End;
    TgSINT32                                    m_niCollect_Last;

    union
    {
        V(TgSEGMENT)                                m_sSG;
        V(TgSPHERE)                                 m_sSP;
    }                                           m_sPrimitive;

#if (TgCOMPILE_CACHE_LINE_SIZE >= 64) && defined(IS_64BIT_TYPE)
    TgUINT08                                    m_uiPad[TgCOMPILE_CACHE_LINE_SIZE - 32];
#endif
#if (TgCOMPILE_CACHE_LINE_SIZE > 64) && !defined(IS_64BIT_TYPE)
    TgUINT08                                    m_uiPad[TgCOMPILE_CACHE_LINE_SIZE - 64];
#endif
};