@ -39,44 +39,20 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead , WA 99021
Mead , WA 99021
* = = LICENSE = = */
* = = LICENSE = = */
# include "plPXConvert.h"
bool plPXConvert : : Validate ( )
{
NxVec3 nxVec ;
hsVector3 plVec ;
int nxVecXOffset = ( ( char * ) & nxVec . x ) - ( ( char * ) & nxVec ) ;
int nxVecYOffset = ( ( char * ) & nxVec . y ) - ( ( char * ) & nxVec ) ;
int nxVecZOffset = ( ( char * ) & nxVec . z ) - ( ( char * ) & nxVec ) ;
int plVecXOffset = ( ( char * ) & plVec . fX ) - ( ( char * ) & plVec ) ;
# include "plPXConvert.h"
int plVecYOffset = ( ( char * ) & plVec . fY ) - ( ( char * ) & plVec ) ;
int plVecZOffset = ( ( char * ) & plVec . fZ ) - ( ( char * ) & plVec ) ;
NxQuat nxQuat ;
hsQuat plQuat ;
int nxQuatXOffset = ( ( char * ) & nxQuat . x ) - ( ( char * ) & nxQuat ) ;
int nxQuatYOffset = ( ( char * ) & nxQuat . y ) - ( ( char * ) & nxQuat ) ;
int nxQuatZOffset = ( ( char * ) & nxQuat . z ) - ( ( char * ) & nxQuat ) ;
int nxQuatWOffset = ( ( char * ) & nxQuat . w ) - ( ( char * ) & nxQuat ) ;
int plQuatXOffset = ( ( char * ) & plQuat . fX ) - ( ( char * ) & plQuat ) ;
# define CHECK_OFFSET(NxCls, NxMem, hsCls, hsMem) \
int plQuatYOffset = ( ( char * ) & plQuat . fY ) - ( ( char * ) & plQuat ) ;
static_assert ( offsetof ( NxCls , NxMem ) = = offsetof ( hsCls , hsMem ) , \
int plQuatZOffset = ( ( char * ) & plQuat . fZ ) - ( ( char * ) & plQuat ) ;
" PhysX Conversion Failure: " # NxCls " and " # hsCls " offsets do not match for " # NxMem " ! " ) ;
int plQuatWOffset = ( ( char * ) & plQuat . fW ) - ( ( char * ) & plQuat ) ;
bool offsetsOK =
CHECK_OFFSET ( NxVec3 , x , hsScalarTriple , fX ) ;
nxVecXOffset = = plVecXOffset & &
CHECK_OFFSET ( NxVec3 , y , hsScalarTriple , fY ) ;
nxVecYOffset = = plVecYOffset & &
CHECK_OFFSET ( NxVec3 , z , hsScalarTriple , fZ ) ;
nxVecZOffset = = plVecZOffset & &
nxQuatXOffset = = plQuatXOffset & &
nxQuatYOffset = = plQuatYOffset & &
nxQuatZOffset = = plQuatZOffset & &
nxQuatWOffset = = plQuatWOffset ;
hsAssert ( offsetsOK , " PhysX or Plasma offsets have changed, need to rewrite conversion code " ) ;
CHECK_OFFSET ( NxQuat , x , hsQuat , fX ) ;
CHECK_OFFSET ( NxQuat , y , hsQuat , fY ) ;
CHECK_OFFSET ( NxQuat , z , hsQuat , fZ ) ;
CHECK_OFFSET ( NxQuat , w , hsQuat , fW ) ;
# undef CHECK_OFFSET
return offsetsOK ;
}