EgtExecutor 2.5f2 :

- aggiunte funzioni Exe e Lua CDeSolidSolid.
This commit is contained in:
DarioS
2023-06-19 08:10:17 +02:00
parent 7d3bec9f44
commit 1620054970
3 changed files with 98 additions and 5 deletions
+75 -5
View File
@@ -25,7 +25,9 @@
#include "/EgtDev/Include/EGkCDeCylClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeConeFrustumClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeSpheClosedSurfTm.h"
#include "/EgtDev/Include/EGkCDeClosedSurfTmClosedSurfTm.h"
#include "/EgtDev/Include/EGkVolZmap.h"
#include "/EgtDev/Include/EGkSurfLocal.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
using namespace std ;
@@ -67,7 +69,7 @@ MyCDeBoxVolZmap( const Frame3d& frBox, const Vector3d& vtDiag, int nZmapId, doub
// porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento)
Frame3d frBoxL = GetFrameLocal( pGeomDB, frBox, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidBox( frBoxL, vtDiag, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -138,7 +140,7 @@ MyCDeRectPrismoidVolZmap( const Frame3d& frPrismoid, double dBaseLenX, double dB
// porto in locale il riferimento (il vettore è già in locale a questo stesso riferimento)
Frame3d frPrismoidL = GetFrameLocal( pGeomDB, frPrismoid, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidRectPrismoid( frPrismoidL, dBaseLenX, dBaseLenY, dTopLenX, dTopLenY, dHeight, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -211,7 +213,7 @@ MyCDeCylVolZmap( const Frame3d& frCyl, double dR, double dH, int nZmapId, double
// porto in locale il riferimento
Frame3d frCylL = GetFrameLocal( pGeomDB, frCyl, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidCylinder( frCylL, dR, dH, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -279,7 +281,7 @@ MyCDeConeVolZmap( const Frame3d& frCone, double dR1, double dR2, double dH, int
// porto in locale il riferimento
Frame3d frConeL = GetFrameLocal( pGeomDB, frCone, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidConeFrustum( frConeL, dR1, dR2, dH, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -348,7 +350,7 @@ MyCDeSpheVolZmap( const Point3d& ptCen, double dRad, int nZmapId, double dSafeDi
// porto in locale il centro della sfera
Point3d ptCenL = GetPointLocal( pGeomDB, ptCen, nRefType, frLoc) ;
// verifico la collisione
return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist) ? 0 : 1) ;
return ( pVZM->AvoidSphere( ptCenL, dRad, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
@@ -374,3 +376,71 @@ ExeCDeSpheSolid( const Point3d& ptCen, double dR, int nSolidId, double dSafeDist
// restituisco risultato
return nRes ;
}
//----------------------------------------------------------------------------
static int
MyCDeClosedSurfTmClosedSurfTm( int nSurfTm1Id, int nSurfTm2Id, double dSafeDist)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, -1)
// recupero il riferimento della seconda superficie
Frame3d frSurf2 ;
if ( ! pGeomDB->GetGlobFrame( nSurfTm2Id, frSurf2))
return -1 ;
// recupero la prima superficie in locale alla seconda
SurfLocal Surf1Loc( pGeomDB, nSurfTm1Id, frSurf2) ;
const ISurfTriMesh* pStm1 = GetSurfTriMesh( Surf1Loc) ;
if ( pStm1 == nullptr)
return -1 ;
// recupero la seconda superficie TriMesh
const ISurfTriMesh* pStm2 = GetSurfTriMesh( pGeomDB->GetGeoObj( nSurfTm2Id)) ;
if ( pStm2 == nullptr)
return -1 ;
// verifico la collisione
return ( CDeClosedSurfTmClosedSurfTm( *pStm1, *pStm2, dSafeDist) ? 1 : 0) ;
}
//----------------------------------------------------------------------------
static int
MyCDeClosedSurfTmVolZmap( int nSurfTmId, int nZmapId, double dSafeDist)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
VERIFY_GEOMDB( pGeomDB, -1)
// recupero il riferimento dello Zmap
Frame3d frZmap ;
if ( ! pGeomDB->GetGlobFrame( nZmapId, frZmap))
return -1 ;
// recupero la superficie in locale allo Zmap
SurfLocal SurfLoc( pGeomDB, nSurfTmId, frZmap) ;
const ISurfTriMesh* pStm = GetSurfTriMesh( SurfLoc) ;
if ( pStm == nullptr)
return -1 ;
// recupero lo Zmap
const IVolZmap* pVZM = GetVolZmap( pGeomDB->GetGeoObj( nZmapId)) ;
if ( pVZM == nullptr)
return -1 ;
// verifico la collisione
return ( pVZM->AvoidSurfTm( *pStm, dSafeDist, false) ? 0 : 1) ;
}
//----------------------------------------------------------------------------
int
ExeCDeSolidSolid( int nSolid1Id, int nSolid2Id, double dSafeDist)
{
IGeomDB* pGeomDB = GetCurrGeomDB() ;
int nRes = -1 ;
if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == SRF_TRIMESH)
nRes = MyCDeClosedSurfTmClosedSurfTm( nSolid1Id, nSolid2Id, dSafeDist) ;
else if ( pGeomDB != nullptr && pGeomDB->GetGeoType( nSolid1Id) == SRF_TRIMESH && pGeomDB->GetGeoType( nSolid2Id) == VOL_ZMAP)
nRes = MyCDeClosedSurfTmVolZmap( nSolid1Id, nSolid2Id, dSafeDist) ;
// se richiesto, salvo il comando Lua equivalente
if ( IsCmdLog()) {
string sLua = "EgtCDeSolidSolid({" + IdToString( nSolid1Id) + "," +
IdToString( nSolid2Id) + "," +
ToString( dSafeDist) + ")" +
" -- Res=" + ToString( nRes) ;
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
}
// restituisco risultato
return nRes ;
}
BIN
View File
Binary file not shown.
+23
View File
@@ -165,6 +165,28 @@ LuaCDeSpheSolid( lua_State* L)
return 1 ;
}
//----------------------------------------------------------------------------
static int
LuaCDeSolidSolid( lua_State* L)
{
// 3 parametri : nSolid1Id, nSolid2Id, dSafeDist
int nSolid1Id ;
LuaCheckParam( L, 1, nSolid1Id)
int nSolid2Id ;
LuaCheckParam( L, 2, nSolid2Id)
double dSafeDist ;
LuaCheckParam( L, 3, dSafeDist)
LuaClearStack( L) ;
// eseguo verifica di collisione
int nRes = ExeCDeSolidSolid( nSolid1Id, nSolid2Id, dSafeDist) ;
// restituisco il risultato
if ( nRes >= 0)
LuaSetParam( L, ( nRes != 0)) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallCDeObjSolid( LuaMgr& luaMgr)
@@ -175,5 +197,6 @@ LuaInstallCDeObjSolid( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeCylSolid", LuaCDeCylSolid) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeConeSolid", LuaCDeConeSolid) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSpheSolid", LuaCDeSpheSolid) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSolidSolid", LuaCDeSolidSolid) ;
return bOk ;
}