NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxMetaData.h Source File

NVIDIA PhysX SDK 3.4 API

PxMetaData.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-2017 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 
00030 
00031 #ifndef PX_PHYSICS_METADATA_H
00032 #define PX_PHYSICS_METADATA_H
00033 
00037 #include "foundation/Px.h"
00038 #include "foundation/PxIO.h"
00039 #include "PxMetaDataFlags.h"
00040 
00041 
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046 
00052     struct PxMetaDataEntry
00053     {
00054         const char*     type;           
00055         const char*     name;           
00056         PxU32           offset;         
00057         PxU32           size;           
00058         PxU32           count;          
00059         PxU32           offsetSize;     
00060         PxU32           flags;          
00061         PxU32           alignment;      
00062     };
00063 
00064     #define PX_STORE_METADATA(stream, metaData) stream.write(&metaData, sizeof(PxMetaDataEntry))
00065 
00066     #define PX_SIZE_OF(Class, Member)   sizeof((reinterpret_cast<Class*>(0))->Member)
00067 
00071     #define PX_DEF_BIN_METADATA_ITEM(stream, Class, type, name, flags) \
00072     { \
00073         PxMetaDataEntry tmp = { #type, #name, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
00074                                 1, 0, flags, 0}; \
00075         PX_STORE_METADATA(stream, tmp); \
00076     }
00077 
00082     #define PX_DEF_BIN_METADATA_ITEMS(stream, Class, type, name, flags, count) \
00083     { \
00084         PxMetaDataEntry tmp = { #type, #name, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
00085                             count, 0, flags, 0}; \
00086         PX_STORE_METADATA(stream, tmp); \
00087     }
00088 
00094     #define PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Class, type, name, flags) \
00095     { \
00096         PxMetaDataEntry tmp = { #type, #name, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
00097                             sizeof((reinterpret_cast<Class*>(0))->name)/sizeof(type), 0, flags, 0}; \
00098                             PX_STORE_METADATA(stream, tmp); \
00099     }
00100 
00104     #define PX_DEF_BIN_METADATA_CLASS(stream, Class) \
00105     { \
00106         PxMetaDataEntry tmp = { #Class, 0, 0, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS, 0 }; \
00107         PX_STORE_METADATA(stream, tmp); \
00108     }
00109 
00113     #define PX_DEF_BIN_METADATA_VCLASS(stream, Class) \
00114     { \
00115         PxMetaDataEntry tmp = { #Class, 0, 0, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS|PxMetaDataFlag::eVIRTUAL, 0}; \
00116         PX_STORE_METADATA(stream, tmp); \
00117     }
00118 
00122     #define PX_DEF_BIN_METADATA_TYPEDEF(stream, newType, oldType) \
00123     { \
00124         PxMetaDataEntry tmp = { #newType, #oldType, 0, 0, 0, 0, PxMetaDataFlag::eTYPEDEF, 0 }; \
00125         PX_STORE_METADATA(stream, tmp); \
00126     }
00127 
00131     #define PX_DEF_BIN_METADATA_BASE_CLASS(stream, Class, BaseClass) \
00132     { \
00133         Class* myClass = reinterpret_cast<Class*>(42);                                                          \
00134         BaseClass* s = static_cast<BaseClass*>(myClass);                                                        \
00135         const PxU32 offset = PxU32(size_t(s) - size_t(myClass));                                                \
00136         PxMetaDataEntry tmp = { #Class, #BaseClass, offset, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS, 0 };   \
00137         PX_STORE_METADATA(stream, tmp);                                                                         \
00138     }
00139 
00143     #define PX_DEF_BIN_METADATA_UNION(stream, Class, name) \
00144     { \
00145         PxMetaDataEntry tmp = { #Class, 0, PxU32(PX_OFFSET_OF_RT(Class, name)), PX_SIZE_OF(Class, name), \
00146                             1, 0, PxMetaDataFlag::eUNION, 0 }; \
00147         PX_STORE_METADATA(stream, tmp); \
00148     }
00149 
00153     #define PX_DEF_BIN_METADATA_UNION_TYPE(stream, Class, type, enumValue)  \
00154     { \
00155         PxMetaDataEntry tmp = { #Class, #type, enumValue, 0, 0, 0, PxMetaDataFlag::eUNION, 0 }; \
00156         PX_STORE_METADATA(stream, tmp); \
00157     }
00158 
00162     #define PX_DEF_BIN_METADATA_EXTRA_ITEM(stream, Class, type, control, align) \
00163     { \
00164         PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, control)), sizeof(type), 0, PxU32(PX_SIZE_OF(Class, control)), \
00165                             PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEM, align }; \
00166         PX_STORE_METADATA(stream, tmp); \
00167     }
00168 
00172     #define PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, Class, type, control, count, flags, align)  \
00173     { \
00174         PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, control)), PxU32(PX_SIZE_OF(Class, control)), \
00175                             PxU32(PX_OFFSET_OF_RT(Class, count)), PxU32(PX_SIZE_OF(Class, count)), \
00176                             PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEMS|flags, align }; \
00177         PX_STORE_METADATA(stream, tmp); \
00178     }
00179     
00185     #define PX_DEF_BIN_METADATA_EXTRA_ITEMS_MASKED_CONTROL(stream, Class, type, control, controlMask ,count, flags, align) \
00186     { \
00187         PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, control)), PxU32(PX_SIZE_OF(Class, control)), \
00188                             PxU32(PX_OFFSET_OF_RT(Class, count)), PxU32(PX_SIZE_OF(Class, count)), \
00189                             PxMetaDataFlag::eCONTROL_MASK|PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEMS|flags|(controlMask & PxMetaDataFlag::eCONTROL_MASK_RANGE) << 16, \
00190                             align}; \
00191         PX_STORE_METADATA(stream, tmp); \
00192     }
00193 
00198     #define PX_DEF_BIN_METADATA_EXTRA_ARRAY(stream, Class, type, dyn_count, align, flags) \
00199     { \
00200         PxMetaDataEntry tmp = { #type, 0, PxU32(PX_OFFSET_OF_RT(Class, dyn_count)), PX_SIZE_OF(Class, dyn_count), align, 0, \
00201                             PxMetaDataFlag::eEXTRA_DATA|flags, align }; \
00202         PX_STORE_METADATA(stream, tmp); \
00203     }
00204 
00208     #define PX_DEF_BIN_METADATA_EXTRA_NAME(stream, Class, control, align) \
00209     { \
00210         PxMetaDataEntry tmp = { "char", "string", 0, 0, 0, 0, PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_NAME, align }; \
00211         PX_STORE_METADATA(stream, tmp); \
00212     }
00213     
00217     #define PX_DEF_BIN_METADATA_EXTRA_ALIGN(stream, Class, align)   \
00218     { \
00219         PxMetaDataEntry tmp = { "PxU8", "Alignment", 0, 0, 0, 0, PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eALIGNMENT, align}; \
00220         PX_STORE_METADATA(stream, tmp); \
00221     }
00222 
00223 #if !PX_DOXYGEN
00224 } // namespace physx
00225 #endif
00226 
00228 #endif


Copyright © 2008-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com