Home

Resume

Blog

Teikitu


// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »Project«   Teikitu Gaming System (TgS) (∂)
//  »File«      TgS Collision - F - Box-Line.i_inc
//  »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
//  »Version«   4.0
//  »Keywords«  Collision;Distance;Closest;Intersect;Penetrate;Sweep;Box;Line;
// ------------------------------------------------------------------------------------------------------------------------------ //
//  Copyright: © 2002-2010, 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: 
//    Redistributions of source code must retain this copyright notice, this list of conditions and the following disclaimers. 
//    Redistributions 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. 
//  Neither the names of the copyright owner nor the names of its contributors may 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 ================================================================================================================= //

#define VI(A) V(A##00)
#define LR_CAP_0 0
#define LR_CAP_1 0
#include "TgS Collision - F - Box-Linear.i_inc"
#undef LR_CAP_1
#undef LR_CAP_0
#undef VI

TgINLINE TYPE V(tgCO_F_DistSq_BX_LN)( V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    TYPE                                fBX0,fBX1,fBX2, fLN0;

    return (V(tgCO_FI_ParamSq_BX_LR00)(
        &fBX0,&fBX1,&fBX2, &fLN0, psBX0, &psLN0->m_vOrigin, &psLN0->m_vDirN ));
}


TgINLINE TYPE V(tgCO_F_Dist_BX_LN)( V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    const TYPE                          fDistSq = V(tgCO_F_DistSq_BX_LN)( psBX0, psLN0 );

    return (F(tgPM_FSEL)( fDistSq, F(tgPM_SQRT)( fDistSq ), -F(KTgMAX) ));
}


TgINLINE TYPE V(tgCO_F_ClosestSq_BX_LN)( V(PCU_TgVEC) pvBX0, V(PCU_TgVEC) pvLN0, V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    TYPE                                fBX0,fBX1,fBX2, fLN0;

    V(CPC_TgVEC)                        pvLN0_OG = &psLN0->m_vOrigin;
    V(CPC_TgVEC)                        pvLN0_DN = &psLN0->m_vDirN;

    const TYPE                          fDistSq = V(tgCO_FI_ParamSq_BX_LR00)( &fBX0,&fBX1,&fBX2, &fLN0, psBX0, pvLN0_OG,pvLN0_DN );

    V(C_TgVEC)                          vK0 = V(F_MUL_SV)( fLN0, pvLN0_DN );

    *pvBX0 = V(tgGM_Calc_Point_BX)( psBX0, fBX0,fBX1,fBX2 );
    *pvLN0 = V(F_ADD_VV)( pvLN0_OG, &vK0 );

    return (F(tgPM_FSEL)( fDistSq, fDistSq, -F(KTgMAX) ));
}


TgINLINE TYPE V(tgCO_F_Closest_BX_LN)( V(PCU_TgVEC) pvBX0, V(PCU_TgVEC) pvLN0, V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    const TYPE                          fDistSq = V(tgCO_F_ClosestSq_BX_LN)( pvBX0, pvLN0, psBX0, psLN0 );

    return (F(tgPM_FSEL)( fDistSq, F(tgPM_SQRT)( fDistSq ), -F(KTgMAX) ));
}


TgINLINE TYPE V(tgCO_F_ParamSq_BX_LN)(
    PCU_TYPE pfBX0, PCU_TYPE pfBX1, PCU_TYPE pfBX2, PCU_TYPE pfLN0, V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    return (V(tgCO_FI_ParamSq_BX_LR00)(
        pfBX0,pfBX1,pfBX2, pfLN0, psBX0, &psLN0->m_vOrigin, &psLN0->m_vDirN ));
}


TgINLINE TYPE V(tgCO_F_Param_BX_LN)(
    PCU_TYPE pfBX0, PCU_TYPE pfBX1, PCU_TYPE pfBX2, PCU_TYPE pfLN0, V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    const TYPE                          fDistSq = V(tgCO_F_ParamSq_BX_LN)( pfBX0,pfBX1,pfBX2, pfLN0, psBX0, psLN0 );

    return (F(tgPM_FSEL)( fDistSq, F(tgPM_SQRT)( fDistSq ), -F(KTgMAX) ));
}


TgINLINE TgRESULT V(tgCO_F_Clip_Param_BX_LN)( PCU_TYPE pfLN0, PCU_TYPE pfLN1, V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    return (V(tgCO_FI_Clip_Param_BX_LR00)( pfLN0,pfLN1, psBX0, &psLN0->m_vOrigin, &psLN0->m_vDirN ));
}


TgINLINE TgRESULT V(tgCO_F_Clip_Param_BXF_LN)(
    PCU_TYPE pfLN0, PCU_TYPE pfLN1, V(CPCU_TgBOX) psBX0, C_TgSINT32 i0, V(CPCU_TgLINE) psLN0 )
{
    return (V(tgCO_FI_Clip_Param_BXF_LR00)( pfLN0, pfLN1, psBX0, i0, &psLN0->m_vOrigin, &psLN0->m_vDirN ));
}


TgINLINE TgRESULT V(tgCO_F_Clip_BX_LN)( V(PCU_STg2_CO_Clip_List) psCL, V(CPCU_TgBOX) psBX0, V(CPCU_TgLINE) psLN0 )
{
    return (V(tgCO_F_Clip_BX_LR00)( psCL, psBX0, &psLN0->m_vOrigin, &psLN0->m_vDirN ));
}


TgINLINE TgRESULT V(tgCO_F_Clip_BXF_LN)( V(PCU_STg2_CO_Clip_List) psCL,V(CPCU_TgBOX) psBX0,C_TgSINT32 i0,V(CPCU_TgLINE) psLN0 )
{
    V(TgRECTANGLE)                      tgFace;

    return (V(tgCO_F_Clip_RT_LN)( psCL, V(tgCO_F_BXF_Init_Face)( &tgFace, psBX0, i0 ), psLN0 ));
}