[an error occurred while processing this directive]
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // // Project: Talina Gaming System (TgS) (∂) // File: TgS Collision - Triangle-Point.inl // Author: Andrew Aye (EMail: andrew.aye@gmail.com, Web: http://www.andrewaye.com) // Version: 3.11 // // ------------------------------------------------------------------------------------------------------------------------------ // // // Copyright: © 2002-2008, 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". // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // #if !defined(_TGS_COLLISION_TRIANGLE_POINT_INL_) #define _TGS_COLLISION_TRIANGLE_POINT_INL_ #pragma once // ============================================================================================================================== // // F_Dist[Sq], F_Closest[Sq] - Return the minimal distance [squared] between the primitives or negative type max if intersecting. // tgET0 Triangle (Input) // tvS0 Point (Input) // tvET0 The point of closest proximity on the triangle. (Output) // tyET0 Parametric parameter #1 to generate point of contact based on the triangle. (Output) // tyET1 Parametric parameter #2 to generate point of contact based on the triangle. (Output) // ============================================================================================================================== // namespace TGS { // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////// namespace COL { // START COL /////////////////////////////////////////////////////////////////////////////////////////////////////// // ============================================================================================================================== // template <typename TYPE, int DIM> TgFORCEINLINE TYPE F_DistSq( CR_(ETRI,DIM) tgET0, M_(VECTOR,DIM) tvS1 ) { TYPE tyT0,tyT1; return (F_ClosestSq( &tyT0,&tyT1, tgET0, tvS1 )); }; template <typename TYPE, int DIM> TgFORCEINLINE TYPE F_Dist( CR_(ETRI,DIM) tgET0, M_(VECTOR,DIM) tvS1 ) { TYPE tyT0,tyT1; const TYPE tyDistSq = F_ClosestSq( &tyT0,&tyT1, tgET0, tvS1 ); return (P::FSEL( tyDistSq, P::SQRT( tyDistSq ), -LIMITS<TYPE>::MAX )); }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // template <typename TYPE, int DIM> TgFORCEINLINE TYPE F_ClosestSq( PC_(VECTOR,DIM) ptvET0, CR_(ETRI,DIM) tgET0, M_(VECTOR,DIM) tvS1 ) { TYPE tyET0,tyET1; const TYPE tyDistSq = F_ClosestSq( &tyET0,&tyET1, tgET0, tvS1 ); C_(VECTOR,DIM) tvK0 = MATH::F_MUL( tyET0, tgET0.Query_Edge0() ); C_(VECTOR,DIM) tvK1 = MATH::F_MUL( tyET1, tgET0.Query_Edge2() ); C_(VECTOR,DIM) tvK2 = MATH::F_ADD( tgET0.Query_Origin(), tvK0 ); *ptvET0 = MATH::F_SUB( tvK2, tvK1 ); return (P::FSEL( tyDistSq, tyDistSq, -LIMITS<TYPE>::MAX )); }; template <typename TYPE, int DIM> TgFORCEINLINE TYPE F_Closest( PC_(VECTOR,DIM) ptvET0, CR_(ETRI,DIM) tgET0, M_(VECTOR,DIM) tvS1 ) { TYPE tyET0,tyET1; const TYPE tyDistSq = F_ClosestSq( &tyET0,&tyET1, tgET0, tvS1 ); C_(VECTOR,DIM) tvK0 = MATH::F_MUL( tyET0, tgET0.Query_Edge0() ); C_(VECTOR,DIM) tvK1 = MATH::F_MUL( tyET1, tgET0.Query_Edge2() ); C_(VECTOR,DIM) tvK2 = MATH::F_ADD( tgET0.Query_Origin(), tvK0 ); *ptvET0 = MATH::F_SUB( tvK2, tvK1 ); return (P::FSEL( tyDistSq, P::SQRT( tyDistSq ), -LIMITS<TYPE>::MAX )); }; template <typename TYPE, int DIM> TgFORCEINLINE TYPE F_Closest( TYPE *ptyET0, TYPE *ptyET1, CR_(ETRI,DIM) tgET0, M_(VECTOR,DIM) tvS1 ) { const TYPE tyDistSq = F_ClosestSq( ptyET0,ptyET1, tgET0, tvS1 ); return (P::FSEL( tyDistSq, P::SQRT( tyDistSq ), -LIMITS<TYPE>::MAX )); }; // ============================================================================================================================== // }; // END COL ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }; // END TGS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #endif // END ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////[an error occurred while processing this directive]