PxMetaData.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 #ifndef PX_PHYSICS_METADATA_H
15 #define PX_PHYSICS_METADATA_H
16 
20 #include "foundation/Px.h"
21 #include "PxMetaDataFlags.h"
22 #include "foundation/PxIO.h"
23 
24 #ifndef PX_DOXYGEN
25 namespace physx
26 {
27 #endif
28 
35  {
36  const char* type;
37  const char* name;
44  };
45 
46  #define PX_STORE_METADATA(stream, metaData) stream.write(&metaData, sizeof(PxMetaDataEntry))
47 
51  #define PX_DEF_BIN_METADATA_ITEM(stream, Class, type, name, flags) \
52  { \
53  PxMetaDataEntry tmp = { #type, #name, (PxU32)PX_OFFSET_OF(Class, name), PX_SIZE_OF(Class, name), \
54  1, 0, flags, 0}; \
55  PX_STORE_METADATA(stream, tmp); \
56  }
57 
62  #define PX_DEF_BIN_METADATA_ITEMS(stream, Class, type, name, flags, count) \
63  { \
64  PxMetaDataEntry tmp = { #type, #name, (PxU32)PX_OFFSET_OF(Class, name), PX_SIZE_OF(Class, name), \
65  count, 0, flags, 0}; \
66  PX_STORE_METADATA(stream, tmp); \
67  }
68 
74  #define PX_DEF_BIN_METADATA_ITEMS_AUTO(stream, Class, type, name, flags) \
75  { \
76  PxMetaDataEntry tmp = { #type, #name, (PxU32)PX_OFFSET_OF(Class, name), PX_SIZE_OF(Class, name), \
77  sizeof(((Class*)0)->name)/sizeof(type), 0, flags, 0}; \
78  PX_STORE_METADATA(stream, tmp); \
79  }
80 
84  #define PX_DEF_BIN_METADATA_CLASS(stream, Class) \
85  { \
86  PxMetaDataEntry tmp = { #Class, 0, 0, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS, 0 }; \
87  PX_STORE_METADATA(stream, tmp); \
88  }
89 
93  #define PX_DEF_BIN_METADATA_VCLASS(stream, Class) \
94  { \
95  PxMetaDataEntry tmp = { #Class, 0, 0, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS|PxMetaDataFlag::eVIRTUAL, 0}; \
96  PX_STORE_METADATA(stream, tmp); \
97  }
98 
102  #define PX_DEF_BIN_METADATA_TYPEDEF(stream, newType, oldType) \
103  { \
104  PxMetaDataEntry tmp = { #newType, #oldType, 0, 0, 0, 0, PxMetaDataFlag::eTYPEDEF, 0 }; \
105  PX_STORE_METADATA(stream, tmp); \
106  }
107 
111  #define PX_DEF_BIN_METADATA_BASE_CLASS(stream, Class, BaseClass) \
112  { \
113  Class* myClass = reinterpret_cast<Class*>(42); \
114  BaseClass* s = static_cast<BaseClass*>(myClass); \
115  const PxU32 offset = PxU32(size_t(s) - size_t(myClass)); \
116  PxMetaDataEntry tmp = { #Class, #BaseClass, offset, sizeof(Class), 0, 0, PxMetaDataFlag::eCLASS, 0 }; \
117  PX_STORE_METADATA(stream, tmp); \
118  }
119 
123  #define PX_DEF_BIN_METADATA_UNION(stream, Class, name) \
124  { \
125  PxMetaDataEntry tmp = { #Class, 0, (PxU32)PX_OFFSET_OF(Class, name), PX_SIZE_OF(Class, name), \
126  1, 0, PxMetaDataFlag::eUNION, 0 }; \
127  PX_STORE_METADATA(stream, tmp); \
128  }
129 
133  #define PX_DEF_BIN_METADATA_UNION_TYPE(stream, Class, type, enumValue) \
134  { \
135  PxMetaDataEntry tmp = { #Class, #type, enumValue, 0, 0, 0, PxMetaDataFlag::eUNION, 0 }; \
136  PX_STORE_METADATA(stream, tmp); \
137  }
138 
142  #define PX_DEF_BIN_METADATA_EXTRA_ITEM(stream, Class, type, control, align) \
143  { \
144  PxMetaDataEntry tmp = { #type, 0, (PxU32)PX_OFFSET_OF(Class, control), sizeof(type), 0, (PxU32)PX_SIZE_OF(Class, control), \
145  PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEM, align }; \
146  PX_STORE_METADATA(stream, tmp); \
147  }
148 
152  #define PX_DEF_BIN_METADATA_EXTRA_ITEMS(stream, Class, type, control, count, flags, align) \
153  { \
154  PxMetaDataEntry tmp = { #type, 0, (PxU32)PX_OFFSET_OF(Class, control), (PxU32)PX_SIZE_OF(Class, control), \
155  (PxU32)PX_OFFSET_OF(Class, count), (PxU32)PX_SIZE_OF(Class, count), \
156  PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEMS|flags, align }; \
157  PX_STORE_METADATA(stream, tmp); \
158  }
159 
165  #define PX_DEF_BIN_METADATA_EXTRA_ITEMS_MASKED_CONTROL(stream, Class, type, control, controlMask ,count, flags, align) \
166  { \
167  PxMetaDataEntry tmp = { #type, 0, (PxU32)PX_OFFSET_OF(Class, control), (PxU32)PX_SIZE_OF(Class, control), \
168  (PxU32)PX_OFFSET_OF(Class, count), (PxU32)PX_SIZE_OF(Class, count), \
169  PxMetaDataFlag::eCONTROL_MASK|PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_ITEMS|flags|(controlMask & PxMetaDataFlag::eCONTROL_MASK_RANGE) << 16, \
170  align}; \
171  PX_STORE_METADATA(stream, tmp); \
172  }
173 
178  #define PX_DEF_BIN_METADATA_EXTRA_ARRAY(stream, Class, type, dyn_count, align, flags) \
179  { \
180  PxMetaDataEntry tmp = { #type, 0, (PxU32)PX_OFFSET_OF(Class, dyn_count), PX_SIZE_OF(Class, dyn_count), align, 0, \
181  PxMetaDataFlag::eEXTRA_DATA|flags, align }; \
182  PX_STORE_METADATA(stream, tmp); \
183  }
184 
188  #define PX_DEF_BIN_METADATA_EXTRA_NAME(stream, Class, control, align) \
189  { \
190  PxMetaDataEntry tmp = { "char", "string", 0, 0, 0, 0, PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eEXTRA_NAME, align }; \
191  PX_STORE_METADATA(stream, tmp); \
192  }
193 
197  #define PX_DEF_BIN_METADATA_EXTRA_ALIGN(stream, Class, align) \
198  { \
199  PxMetaDataEntry tmp = { "PxU8", "Alignment", 0, 0, 0, 0, PxMetaDataFlag::eEXTRA_DATA|PxMetaDataFlag::eALIGNMENT, align}; \
200  PX_STORE_METADATA(stream, tmp); \
201  }
202 
203 #ifndef PX_DOXYGEN
204 } // namespace physx
205 #endif
206 
208 #endif


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