Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS Common - Geometry - 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".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/* == Common ============================================================================================================================================================ */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Types                                                                                                                                                          */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgTYPE_STRUCT(V(TgDELTA),)
{
    V(TgVEC)                                    m_vUDT;
    V(TgVEC)                                    m_vDT;
    TYPE                                        m_fDT;
    TYPE                                        m_fDT_DT;
    TYPE                                        m_fInv_DT;
    PAD32_4(                                    1)
};

TgTYPE_STRUCT(V(TgRECT2D),)
{
    TYPE                                        m_fX0, m_fY0; /*« Upper left point. */
    TYPE                                        m_fX1, m_fY1; /*« Lower right point. */
};

TgTYPE_STRUCT(V(TgBOXAA),)
{
    V(TgVEC)                                    m_vMin, m_vMax;
};

TgTYPE_STRUCT(V(TgBOX),)
{
    union {
        V(TgVEC)                                    avData[4];
        M44(TgMAT)                                  xData;
        struct {
            V(TgVEC)                                    avAxis[3]; /*« The three ortho-normal axes used to define the box edges. */
            V(TgVEC)                                    vOrigin; /*« Origin | Centroid of the box. */
        }                                           m;
    }                                           m;
    V(TgVEC)                                    m_vExtent; /*« The box's length along each axis from origin to extremity. */
    PAD32_3(                                    1)
};

TgTYPE_STRUCT(V(TgCIRCLE),)
{
    union {
        V(TgVEC)                                    avData[4]; /*« Full basis set */
        M44(TgMAT)                                  xData;
        struct {
            V(TgVEC)                                    vU; /*« [x-axis] */
            V(TgVEC)                                    vNormal; /*« Normal of the plane. [y-axis] */
            V(TgVEC)                                    vV; /*« [z-axis] */
            V(TgVEC)                                    vOrigin; /*« Origin of the circle in the reference frame. */
        }                                           m;
    }                                           m;
    TYPE                                        m_fRadius; /*« Radius of the circle. */
    TYPE                                        m_fRadiusSq;/*« Radius Squared of the circle. */
    PAD32_3(                                    2)
    PAD32_4(                                    2)
};

TgTYPE_STRUCT(V(TgDISK),)
{
    union {
        V(TgVEC)                                    avData[4]; /*« Full basis set */
        M44(TgMAT)                                  xData;
        struct {
            V(TgVEC)                                    vU; /*« [x-axis] */
            V(TgVEC)                                    vNormal; /*« Normal of the plane. [y-axis] */
            V(TgVEC)                                    vV; /*« [z-axis] */
            V(TgVEC)                                    vOrigin; /*« Origin of the circle in the reference frame. */
        }                                           m;
    }                                           m;
    TYPE                                        m_fRadius; /*« Radius of the disk. */
    TYPE                                        m_fRadiusSq;/*« Radius Squared of the disk. */
    PAD32_3(                                    2)
    PAD32_4(                                    2)
};

TgTYPE_STRUCT(V(TgELLIPSE),)
{
    union {
        V(TgVEC)                                    avData[4]; /*« Full basis set */
        M44(TgMAT)                                  xData;
        struct {
            V(TgVEC)                                    vMajor_Axis; /*« [x-axis] */
            V(TgVEC)                                    vNormal; /*« Normal of the plane. [y-axis] */
            V(TgVEC)                                    vMinor_Axis; /*« [z-axis] */
            V(TgVEC)                                    vOrigin; /*« Origin *| Centre of the ellipse. */
        }                                           m;
    }                                           m;
    TYPE                                        m_fMajor; /*« Major radius. */
    TYPE                                        m_fMinor; /*« Minor radius. */
    PAD32_3(                                    2)
    PAD32_4(                                    2)
};

TgTYPE_STRUCT(V(TgLINE),)
{
    V(TgVEC)                                    m_vOrigin; /*« Origin of the line segment (start point). */
    V(TgVEC)                                    m_vDirN; /*« The line direction. */
};


TgTYPE_STRUCT(V(TgMESH_SIMPLE),)
{
    V(P_TgVEC)                                  m_pvVert_List;
    P_TgUINT16                                  m_puiIndx_List;
    TgUINT32                                    m_nuiVert;
    TgUINT32                                    m_nuiIndx;
    PAD32_4(                                    2)
};

TgTYPE_STRUCT(V(TgMESH_BA),)
{
    V(TgMESH_SIMPLE)                            m_sMS; /*« Vertex and Face Data */
    V(TgDELTA)                                  m_sDT; /*« Linear displacement vector, valid only for linear sweep. */
    V(TgVEC)                                    m_vCG[2]; /*« Centre of gravity at sweep interval. */
    V(TgBOXAA)                                  *m_psBA; /*« Bounding box per face */
    V(P_TgVEC)                                  m_pvVert_DT; /*« Vertex delta for a swept mesh */
    P_TgUINT32                                  m_puiFlags; /*« Collision flags per face */
    ETgSWEEP_TYPE                               m_enSweep; /*« Static, Linear or Rotational test indicator. */
    PAD32_4(                                    1)
    PAD64_4(                                    1)
};

TgTYPE_STRUCT(V(TgMESH_BVT),)
{
    V(TgMESH_SIMPLE)                            m_sMS; /*« Vertex and Face Data */
};

TgTYPE_STRUCT(V(TgPARALLELOGRAM),)
{
    V(TgVEC)                                    m_vOrigin; /*« Common point of two of the parallelogram's edges. */
    V(TgVEC)                                    m_avEdge[2]; /*« The two edge's sourced at the origin point. */
    V(TgVEC)                                    m_vNormal; /*« The normal for the plane defined by the two edges. */
    V(TgVEC)                                    m_avEdgeNormal[2]; /*« The normal of the plane defined by an edge and normal. */
};

TgTYPE_STRUCT(V(TgPARTICLE),)
{
    V(TgVEC)                                    m_vPos; /*« Initial position. */
    V(TgVEC)                                    m_vVel; /*« Initial velocity. */
    V(TgVEC)                                    m_vAccel; /*« Initial acceleration. */
};

TgTYPE_STRUCT(V(TgPLANE),)
{
    V4(TgVEC)                                   m_vPlnEqN; /*« Store the plane constant in the last element of the vector. */
    V(TgVEC)                                    m_vNormal; /*« Plane unit-normal. */
    TYPE                                        m_fD; /*« Plane constant. */
    PAD32_4(                                    3)
};

TgTYPE_STRUCT(V(TgRAY),)
{
    V(TgVEC)                                    m_vOrigin; /*« Origin of the line segment (start point). */
    V(TgVEC)                                    m_vDirN; /*« The line direction. */
};

TgTYPE_STRUCT( V(TgRECTANGLE), )
{
    V(TgVEC)                                    m_vOrigin; /*« Common point of two of the rectangle's edges. */
    V(TgVEC)                                    m_avEdge[2]; /*« The two edge's sourced at the origin point. */
    V(TgVEC)                                    m_vNormal; /*« The normal for the plane defined by the two edges. */
};

TgTYPE_STRUCT(V(TgSEGMENT),)
{
    V(TgVEC)                                    m_vOrigin; /*« Origin of the line segment (start point). */
    V(TgVEC)                                    m_vDirN; /*« The line direction. */
};

TgTYPE_STRUCT(V(TgSPHERE),)
{
    V(TgVEC)                                    m_vOrigin; /*« Origin of the sphere. */
    TYPE                                        m_fRadius; /*« Radius of the sphere. */
    TYPE                                        m_fRadiusSq; /*« Radius squared of the sphere. */
    PAD32_4(                                    2)
};

TgTYPE_STRUCT(V(TgTORUS),)
{
    V(TgVEC)                                    m_vOrigin; /*« Origin of the torus. */
    V(TgVEC)                                    m_vNormal; /*«  */
    TYPE                                        m_fRI; /*« Radius of the tube. */
    TYPE                                        m_fRO; /*« Radius of the torus path. */
    PAD32_4(                                    2)
};

TgTYPE_STRUCT(V(TgPTRI),)
{
    V(TgVEC)                                    m_avPoint[3]; /*« Three vertices defining the triangle */
    V(TgVEC)                                    m_vNormal; /*« Triangle normal, not necessarily valid. */
};

TgTYPE_STRUCT(V(TgETRI),)
{
    V(TgPTRI)                                   m_sPT;
    V(TgVEC)                                    m_avEdge[3]; /*« [0-1], [1-2], [2-0] segments between vertices */
};

TgTYPE_STRUCT(V(TgCTRI),)
{
    V(TgETRI)                                   m_sET;
    TgUINT32                                    m_bfFlags; /*« Bitfield container for a collection of booleans. */
    PAD32_4(                                    3)
    PAD64_3(                                    1)
    PAD64_4(                                    1)
};

TgTYPE_STRUCT(V(TgSTRI),)
{
    V(TgCTRI)                                   m_sCT;
    PAD32_3(                                    2)
    V(TgPLANE)                                  m_avPlane[3];
};

TgTYPE_STRUCT(V(TgTUBE),)
{
    /* Ortho-normal definition of the reference frame of the tube. */
    union {
        V(TgVEC)                                    avData[4]; /*« Full basis set */
        M44(TgMAT)                                  xData;
        struct {
            V(TgVEC)                                    vU_Basis0; /*« Another vector to make an ortho-normal basis set */
            V(TgVEC)                                    vU_HAX; /*« Primary unit half-axis */
            V(TgVEC)                                    vU_Basis1; /*« Another vector to make an ortho-normal basis set */
            V(TgVEC)                                    vOrigin; /*« Mid point of the tube primary axis */
        }                                           m;
    }                                           m;

    /* Tube definition - centre point and the vector such that its sum and difference with the origin are the two end points. */

    V(TgVEC)                                    m_vHAX; /*« Primary half-axis of the tube */

    /* The line segment that forms the primary axis of the tube, enclosing both end points inclusively. */

    V(TgSEGMENT)                                m_sAX; /*« Segment from end-to-end of the tube */

    /* Scalar properties of the tube. */

    TYPE                                        m_fExtent; /*« Half-height of the tube */
    TYPE                                        m_fRadius; /*« Radius of the tube */
    TYPE                                        m_fRadiusSq; /*« Radius Squared */
    PAD32_4(                                    1)
};


/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Public Functions                                                                                                                                                      */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

TgINLINE TgVOID                             V(tgGM_DT_Reset)( V(PCU_TgDELTA) );
TgINLINE TgBOOL                             V(tgGM_DT_Is_Valid)( V(CPCU_TgDELTA) );
TgINLINE TgVOID                             V(tgGM_DT_TX)( V(PCU_TgDELTA), M34(CPCU_TgMAT) );
TgINLINE TgVOID                             V(tgGM_DT_Copy_TX)( V(PCU_TgDELTA), V(CPCU_TgDELTA), M34(CPCU_TgMAT) );
TgINLINE TgVOID                             V(tgGM_DT_Set)( V(PCU_TgDELTA), V(CPCU_TgVEC) );