PxJointRepXExtensions.h
Go to the documentation of this file.00001 // This code contains NVIDIA Confidential Information and is disclosed to you 00002 // under a form of NVIDIA software license agreement provided separately to you. 00003 // 00004 // Notice 00005 // NVIDIA Corporation and its licensors retain all intellectual property and 00006 // proprietary rights in and to this software and related documentation and 00007 // any modifications thereto. Any use, reproduction, disclosure, or 00008 // distribution of this software and related documentation without an express 00009 // license agreement from NVIDIA Corporation is strictly prohibited. 00010 // 00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES 00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, 00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. 00015 // 00016 // Information and code furnished is believed to be accurate and reliable. 00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such 00018 // information or for any infringement of patents or other rights of third parties that may 00019 // result from its use. No license is granted by implication or otherwise under any patent 00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice. 00021 // This code supersedes and replaces all information previously supplied. 00022 // NVIDIA Corporation products are not authorized for use as critical 00023 // components in life support devices or systems without express written approval of 00024 // NVIDIA Corporation. 00025 // 00026 // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved. 00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. 00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. 00029 #ifndef PX_JOINT_REPX_EXTENSIONS_H 00030 #define PX_JOINT_REPX_EXTENSIONS_H 00031 00035 #include "RepX/RepX.h" 00036 #include "foundation/PxSimpleTypes.h" 00037 #include "extensions/PxD6Joint.h" 00038 #include "extensions/PxDistanceJoint.h" 00039 #include "extensions/PxFixedJoint.h" 00040 #include "extensions/PxPrismaticJoint.h" 00041 #include "extensions/PxRevoluteJoint.h" 00042 #include "extensions/PxSphericalJoint.h" 00043 #include "foundation/PxAssert.h" 00044 #include "foundation/PxString.h" 00045 #include "PxConstraintExt.h" 00046 #include "PxConstraint.h" 00047 00048 namespace physx { namespace repx { 00049 00050 class RepXCollection; 00051 00052 00053 //Id auto-generating function. 00054 PX_INLINE const void* getId( const PxJoint* inJoint ) { return inJoint; } 00055 00056 //Mapping from datatype to repx extension name 00057 PX_INLINE const char* getExtensionNameForType( const PxD6Joint* ) { return "PxD6Joint"; } 00058 PX_INLINE const char* getExtensionNameForType( const PxDistanceJoint* ) { return "PxDistanceJoint"; } 00059 PX_INLINE const char* getExtensionNameForType( const PxFixedJoint* ) { return "PxFixedJoint"; } 00060 PX_INLINE const char* getExtensionNameForType( const PxPrismaticJoint* ){ return "PxPrismaticJoint"; } 00061 PX_INLINE const char* getExtensionNameForType( const PxRevoluteJoint* ) { return "PxRevoluteJoint"; } 00062 PX_INLINE const char* getExtensionNameForType( const PxSphericalJoint* ){ return "PxSphericalJoint"; } 00063 PX_INLINE const char* getExtensionNameForType( const PxJoint* inJoint ) 00064 { 00065 if ( inJoint ) 00066 { 00067 switch( inJoint->getType() ) 00068 { 00069 case PxJointType::eD6: return getExtensionNameForType( static_cast<const PxD6Joint*>( inJoint ) ); 00070 case PxJointType::eDISTANCE: return getExtensionNameForType( static_cast<const PxDistanceJoint*>( inJoint ) ); 00071 case PxJointType::eFIXED: return getExtensionNameForType( static_cast<const PxFixedJoint*>( inJoint ) ); 00072 case PxJointType::ePRISMATIC: return getExtensionNameForType( static_cast<const PxPrismaticJoint*>( inJoint ) ); 00073 case PxJointType::eREVOLUTE: return getExtensionNameForType( static_cast<const PxRevoluteJoint*>( inJoint ) ); 00074 case PxJointType::eSPHERICAL: return getExtensionNameForType( static_cast<const PxSphericalJoint*>( inJoint ) ); 00075 default: 00076 break; 00077 } 00078 } 00079 return "__unknown joint type__"; 00080 } 00081 00082 //Mapping from abstract pointer to specific point so that 00083 //when converted to/from a void* we know exactly what we 00084 //are getting. 00085 PX_INLINE const void* getBasePtr( const PxJoint* inJoint ) 00086 { 00087 if ( inJoint ) 00088 { 00089 switch( inJoint->getType() ) 00090 { 00091 case PxJointType::eD6: return static_cast<const PxD6Joint*>( inJoint ); 00092 case PxJointType::eDISTANCE: return static_cast<const PxDistanceJoint*>( inJoint ); 00093 case PxJointType::eFIXED: return static_cast<const PxFixedJoint*>( inJoint ); 00094 case PxJointType::ePRISMATIC: return static_cast<const PxPrismaticJoint*>( inJoint ); 00095 case PxJointType::eREVOLUTE: return static_cast<const PxRevoluteJoint*>( inJoint ); 00096 case PxJointType::eSPHERICAL: return static_cast<const PxSphericalJoint*>( inJoint ); 00097 default: 00098 break; 00099 } 00100 } 00101 return NULL; 00102 } 00103 00104 //Operator on the actual data underlying the generic type. 00105 template<typename TResultType, typename TOperator> 00106 PX_INLINE TResultType visitJointRepXObject( const TRepXId inId, void* inLiveObject, const char* inRepXExtensionName, TOperator inOperator ) 00107 { 00108 if ( PxStricmp( inRepXExtensionName, getExtensionNameForType( (PxD6Joint*)NULL ) ) == 0 ) 00109 return inOperator( inId, reinterpret_cast<PxD6Joint*>( inLiveObject ) ); 00110 else if ( PxStricmp( inRepXExtensionName, getExtensionNameForType( (PxDistanceJoint*)NULL ) ) == 0 ) 00111 return inOperator( inId, reinterpret_cast<PxDistanceJoint*>( inLiveObject ) ); 00112 else if ( PxStricmp( inRepXExtensionName, getExtensionNameForType( (PxFixedJoint*)NULL ) ) == 0 ) 00113 return inOperator( inId, reinterpret_cast<PxFixedJoint*>( inLiveObject ) ); 00114 else if ( PxStricmp( inRepXExtensionName, getExtensionNameForType( (PxPrismaticJoint*)NULL ) ) == 0 ) 00115 return inOperator( inId, reinterpret_cast<PxPrismaticJoint*>( inLiveObject ) ); 00116 else if ( PxStricmp( inRepXExtensionName, getExtensionNameForType( (PxRevoluteJoint*)NULL ) ) == 0 ) 00117 return inOperator( inId, reinterpret_cast<PxRevoluteJoint*>( inLiveObject ) ); 00118 else if ( PxStricmp( inRepXExtensionName, getExtensionNameForType( (PxSphericalJoint*)NULL ) ) == 0 ) 00119 return inOperator( inId, reinterpret_cast<PxSphericalJoint*>( inLiveObject ) ); 00120 else 00121 return inOperator( inId, inLiveObject, inRepXExtensionName ); 00122 } 00123 00124 00125 PX_INLINE RepXAddToCollectionResult addToRepXCollection( RepXCollection& inCollection, RepXIdToRepXObjectMap& inIdMap, const PxConstraint& inType ) 00126 { 00127 PxU32 constraintType = 0; 00128 void* joint = const_cast<PxConstraint*>( &inType )->getExternalReference( constraintType ); 00129 if ( constraintType == PxConstraintExtIDs::eJOINT ) 00130 { 00131 PxJoint* theJoint = reinterpret_cast<PxJoint*>( joint ); 00132 return inCollection.addRepXObjectToCollection( RepXObject( getExtensionNameForType( theJoint ), joint, static_cast<TRepXId>(reinterpret_cast<size_t>(joint)) ), inIdMap ); 00133 } 00134 else //RepX doesn't support non-joint constraints. 00135 { 00136 return RepXAddToCollectionResult::InvalidParameters; 00137 } 00138 } 00139 00140 PxU32 getNumJointExtensions(); 00141 //The repx collection is responsible for freeing these extensions. 00142 PxU32 createJointExtensions( RepXExtension** outExtensions, PxU32 outBufferSize, PxAllocatorCallback& inCallback ); 00143 00144 }} 00145 00147 #endif
Copyright © 2008-2012 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com