//---------------------------------------------------------------------------- // EgalTech 2016-2016 //---------------------------------------------------------------------------- // File : CDBoxPolyhedron.cpp Data : 05.10.16 Versione : 1.6v1 // Contenuto : Implementazione della verifica di collisione tra // BoundingBox e Polyhedron. // // // Modifiche : 05.10.16 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "/EgtDev/Include/EGkCDeBoxTria.h" #include "/EgtDev/Include/EGkCDeBoxPolyhedron.h" using namespace std ; //---------------------------------------------------------------------------- bool CDeBoxPolyhedron( const BBox3d& b3Box, const ISurfTriMesh& Stm) { // verifico che la trimesh sia effettivamente un poliedro if ( ! Stm.IsClosed()) return false ; // recupero BBox del poliedro BBox3d b3Poly ; if ( ! Stm.GetLocalBBox( b3Poly)) return false ; // confronto i due Box if ( ! b3Box.Overlaps( b3Poly)) return false ; // confronto il Box con tutti i triangoli Triangle3d Tria ; int nId = Stm.GetFirstTriangle( Tria) ; while ( nId != SVT_NULL) { if ( CDeBoxTria( b3Box, Tria)) return true ; nId = Stm.GetNextTriangle( nId, Tria) ; } return false ; }