Home

Resume

Blog

Teikitu


// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= //
//  »Project«   Teikitu Gaming System (TgS) (∂)
//  »File«      TgS Collision - F - Parallelogram-Segment.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;Parallelogram;
// ------------------------------------------------------------------------------------------------------------------------------ //
//  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##11)
#define LR_CAP_0 1
#define LR_CAP_1 1
    #include "TgS Collision - F - Parallelogram-Linear.i_inc"
#undef LR_CAP_1
#undef LR_CAP_0
#undef VI

TgINLINE TYPE V(tgCO_F_DistSq_PE_SG)( V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    TYPE                                fT0,fT1, fT2;

    return (V(tgCO_F_ParamSq_PE_SG)( &fT0,&fT1, &fT2, psPE0, psSG0 ));
}


TgINLINE TYPE V(tgCO_F_Dist_PE_SG)( V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    const TYPE                          fDistSq = V(tgCO_F_DistSq_PE_SG)( psPE0, psSG0 );

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


TgINLINE TYPE V(tgCO_F_ClosestSq_PE_SG)(
    V(PCU_TgVEC) pvPE0, V(PCU_TgVEC) pvSG0, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    TYPE                                fT0,fT1, fT2;

    const TYPE                          fDistSq = V(tgCO_F_ParamSq_PE_SG)( &fT0,&fT1, &fT2, psPE0, psSG0 );
    V(C_TgVEC)                          vK0 = V(F_MUL_SV)( fT0, psPE0->m_avEdge + 0 );
    V(C_TgVEC)                          vK1 = V(F_MUL_SV)( fT1, psPE0->m_avEdge + 1 );
    V(C_TgVEC)                          vK2 = V(F_ADD_VV)( &vK0, &vK1 );
    V(C_TgVEC)                          vK3 = V(F_MUL_SV)( fT2, &psSG0->m_vDirN );

    *pvPE0 = V(F_ADD_VV)( &psPE0->m_vOrigin, &vK2 );
    *pvSG0 = V(F_ADD_VV)( &psSG0->m_vOrigin, &vK3 );

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


TgINLINE TYPE V(tgCO_F_Closest_PE_SG)(
    V(PCU_TgVEC) pvPE0, V(PCU_TgVEC) pvSG0, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    const TYPE                          fDistSq = V(tgCO_F_ClosestSq_PE_SG)( pvPE0,pvSG0, psPE0,psSG0 );

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


TgINLINE TYPE V(tgCO_F_ParamSq_PE_SG)(
    PCU_TYPE pfPE0, PCU_TYPE pfPE1, PCU_TYPE pfSG0, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    return (V(tgCO_F_ParamSq_PE_LR11)( pfPE0,pfPE1, pfSG0, psPE0, &psSG0->m_vOrigin, &psSG0->m_vDirN ));
}


TgINLINE TYPE V(tgCO_F_Param_PE_SG)(
    PCU_TYPE pfPE0, PCU_TYPE pfPE1, PCU_TYPE pfSG0, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    const TYPE                          fDistSq = V(tgCO_F_ParamSq_PE_SG)( pfPE0,pfPE1, pfSG0, psPE0,psSG0 );

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


TgINLINE TgBOOL V(tgCO_F_Test_PE_SG)( V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    return (V(tgCO_FI_Test_PE_LR11)( psPE0, &psSG0->m_vOrigin, &psSG0->m_vDirN ));
}


TgINLINE TgRESULT V(tgCO_F_Clip_Param_PE_SG)( PCU_TYPE pfSG0, PCU_TYPE pfSG1, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    return (V(tgCO_FI_Clip_Param_PE_LR11)( pfSG0,pfSG1, psPE0, &psSG0->m_vOrigin, &psSG0->m_vDirN ));
}


TgINLINE TgRESULT V(tgCO_F_Clip_PE_SG)( V(PCU_STg2_CO_Clip_List) psCL, V(CPCU_TgPARALLELOGRAM) psPE0, V(CPCU_TgSEGMENT) psSG0 )
{
    return (V(tgCO_FI_Clip_PE_LR11)( psCL, psPE0, &psSG0->m_vOrigin, &psSG0->m_vDirN ));
}