EgtGeomKernel :

- aggiunte funzioni per verifica collisione tra Box, Cilindro e Sfera con Superfici triMesh chiuse
- aggiunta costruzione di Polygon3d da triangolo.
This commit is contained in:
Dario Sassi
2020-01-10 09:32:59 +00:00
parent 00c725651f
commit fba63ea82e
10 changed files with 321 additions and 62 deletions
+13 -5
View File
@@ -90,10 +90,18 @@ CDeBoxPlane( const BBox3d& Box, const Plane3d& Plane)
//----------------------------------------------------------------------------
bool
CDeBoxTria( const BBox3d& b3Box, const Triangle3d& trTria)
CDeBoxTria( const Frame3d& frBox, const Vector3d& vtDiag, double dSafeDist, const Triangle3d& trTria)
{
// vedi Ericson, Real-Time Collision Detection, pag. 172 + Akenine-Moller
// Porto il triangolo nel riferimento del box
Triangle3d trTriaL = trTria ;
trTriaL.ToLoc( frBox) ;
// Calcolo il box come tale
BBox3d b3Box( ORIG, ORIG + vtDiag) ;
b3Box.Expand( dSafeDist) ;
// Compute box center and extents
Point3d ptCen ;
Vector3d vtExt ;
@@ -101,9 +109,9 @@ CDeBoxTria( const BBox3d& b3Box, const Triangle3d& trTria)
return false ;
// Translate triangle as conceptually moving AABB to origin
Point3d ptV0 = trTria.GetP( 0) - ( ptCen - ORIG) ;
Point3d ptV1 = trTria.GetP( 1) - ( ptCen - ORIG) ;
Point3d ptV2 = trTria.GetP( 2) - ( ptCen - ORIG) ;
Point3d ptV0 = trTriaL.GetP( 0) - ( ptCen - ORIG) ;
Point3d ptV1 = trTriaL.GetP( 1) - ( ptCen - ORIG) ;
Point3d ptV2 = trTriaL.GetP( 2) - ( ptCen - ORIG) ;
// Compute edge vectors for triangle
Vector3d vtE0 = ptV1 - ptV0 ;
@@ -148,6 +156,6 @@ CDeBoxTria( const BBox3d& b3Box, const Triangle3d& trTria)
// Test separating axis corresponding to triangle face normal (category 2)
Plane3d Plane ;
Plane.Set( trTria.GetP( 0), trTria.GetN()) ;
Plane.Set( trTriaL.GetP( 0), trTriaL.GetN()) ;
return CDeBoxPlane( b3Box, Plane) ;
}