//---------------------------------------------------------------------------- // EgalTech 2020-2020 //---------------------------------------------------------------------------- // File : LUA_CDeObjSolid.cpp Data : 09.01.20 Versione : 2.2a2 // Contenuto : Funzioni di verifica collisioni tra oggetti e solidi. // Oggetti = Box, Sfere, Cilindri // Solidi = SurfTriMesh, VolZMap // // Modifiche : 09.01.20 DS Creazione modulo. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "LUA.h" #include "/EgtDev/Include/EXeExecutor.h" #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EGkLuaAux.h" #include "/EgtDev/Include/EgnStringUtils.h" using namespace std ; //------------------------------------------------------------------------------- static int LuaCDeBoxSolid( lua_State* L) { // 4 o 5 parametri : frBox, vtDiag, nSolidId, dSafeDist [, nRefType] Frame3d frBox ; LuaCheckParam( L, 1, frBox) Vector3d vtDiag ; LuaCheckParam( L, 2, vtDiag) int nSolidId ; LuaCheckParam( L, 3, nSolidId) double dSafeDist ; LuaCheckParam( L, 4, dSafeDist) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // eseguo verifica di collisione int nRes = ExeCDeBoxSolid( frBox, vtDiag, nSolidId, dSafeDist, nRefType) ; // restituisco il risultato if ( nRes >= 0) LuaSetParam( L, ( nRes != 0)) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- static int LuaCDeCylSolid( lua_State* L) { // 5 o 6 parametri : frCyl, dH, dR, nSolidId, dSafeDist [, nRefType] Frame3d frCyl ; LuaCheckParam( L, 1, frCyl) double dH ; LuaCheckParam( L, 2, dH) double dR ; LuaCheckParam( L, 3, dR) int nSolidId ; LuaCheckParam( L, 4, nSolidId) double dSafeDist ; LuaCheckParam( L, 5, dSafeDist) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 6, nRefType) ; LuaClearStack( L) ; // eseguo verifica di collisione int nRes = ExeCDeCylSolid( frCyl, dH, dR, nSolidId, dSafeDist, nRefType) ; // restituisco il risultato if ( nRes >= 0) LuaSetParam( L, ( nRes != 0)) ; else LuaSetParam( L) ; return 1 ; } //---------------------------------------------------------------------------- static int LuaCDeSpheSolid( lua_State* L) { // 4 o 5 parametri : ptCen, dRad, nSolidId, dSafeDist [, nRefType] Point3d ptCen ; LuaCheckParam( L, 1, ptCen) double dR ; LuaCheckParam( L, 2, dR) int nSolidId ; LuaCheckParam( L, 3, nSolidId) double dSafeDist ; LuaCheckParam( L, 4, dSafeDist) int nRefType = RTY_DEFAULT ; LuaGetParam( L, 5, nRefType) ; LuaClearStack( L) ; // eseguo verifica di collisione int nRes = ExeCDeSpheSolid( ptCen, dR, nSolidId, dSafeDist, nRefType) ; // restituisco il risultato if ( nRes >= 0) LuaSetParam( L, ( nRes != 0)) ; else LuaSetParam( L) ; return 1 ; } //------------------------------------------------------------------------------- bool LuaInstallCDeObjSolid( LuaMgr& luaMgr) { bool bOk = ( &luaMgr != nullptr) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCDeBoxSolid", LuaCDeBoxSolid) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCDeCylSolid", LuaCDeCylSolid) ; bOk = bOk && luaMgr.RegisterFunction( "EgtCDeSpheSolid", LuaCDeSpheSolid) ; return bOk ; }