[an error occurred while processing this directive]
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // // // Project: Talina Gaming System (TgS) (∂) // File: TgS Collision - Box AA-Point.cpp // 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". // // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // namespace TGS { // START TGS /////////////////////////////////////////////////////////////////////////////////////////////////////// namespace COL { // START COL /////////////////////////////////////////////////////////////////////////////////////////////////////// // ============================================================================================================================== // // ---- F_ClosestSq ------------------------------------------------------------------------------------------------------------- // // Input: tgBA0: Box, Axis-Aligned primitive // Input: tvS0: Point // Output: tvBA0: Point of closest proximity on the box, axis-aligned // Return: Minimal distance between the two primitives or negative type max if they intersect or are invalid. // ------------------------------------------------------------------------------------------------------------------------------ // template <typename TYPE, int DIM> TYPE F_ClosestSq( PC_(VECTOR,DIM) ptvBA0, CR_(BOXAA,DIM) tgBA0, M_(VECTOR,DIM) tvS0 ) { TgASSERT(tgBA0.Is_Valid() && MATH::F_Is_Point_Valid( tvS0 )) TYPE tyT0,tyT1, tyX,tyY,tyZ; TYPE tyDistSq = TYPE(0.0); tyT0 = tgBA0.Query_MinX() - tvS0.X(); tyT1 = tvS0.X() - tgBA0.Query_MaxX(); tyX = P::FSEL( tyT0, tgBA0.Query_MinX(), P::FSEL( tyT1, tgBA0.Query_MaxX(), tvS0.X() ) ); tyDistSq += P::FSEL( tyT0, tyT0*tyT0, P::FSEL( tyT1, tyT1*tyT1, TYPE() ) ); tyT0 = tgBA0.Query_MinY() - tvS0.Y(); tyT1 = tvS0.Y() - tgBA0.Query_MaxY(); tyY = P::FSEL( tyT0, tgBA0.Query_MinY(), P::FSEL( tyT1, tgBA0.Query_MaxY(), tvS0.Y() ) ); tyDistSq += P::FSEL( tyT0, tyT0*tyT0, P::FSEL( tyT1, tyT1*tyT1, TYPE() ) ); tyT0 = tgBA0.Query_MinZ() - tvS0.Z(); tyT1 = tvS0.Z() - tgBA0.Query_MaxZ(); tyZ = P::FSEL( tyT0, tgBA0.Query_MinZ(), P::FSEL( tyT1, tgBA0.Query_MaxZ(), tvS0.Z() ) ); tyDistSq += P::FSEL( tyT0, tyT0*tyT0, P::FSEL( tyT1, tyT1*tyT1, TYPE() ) ); *ptvBA0 = MATH::F_SETP<TYPE,DIM>( tyX,tyY,tyZ ); return (P::FSEL( tyDistSq, tyDistSq, -LIMITS<TYPE>::MAX )); } template TgFLOAT32 F_ClosestSq( PC_TgF4VECTOR, CR_TgF4BOXAA, M_TgF4VECTOR ); // ============================================================================================================================== // }; // END COL ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }; // END TGS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////[an error occurred while processing this directive]