00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00036 #pragma once
00037 #include <foundation/PxPreprocessor.h>
00038 #include <foundation/PxProfiler.h>
00039 #include <foundation/PxAssert.h>
00040 #ifndef NV_CLOTH_IMPORT
00041 #define NV_CLOTH_IMPORT PX_DLL_IMPORT
00042 #endif
00043
00044 #define NV_CLOTH_DLL_ID 0x2
00045
00046 #define NV_CLOTH_LINKAGE PX_C_EXPORT NV_CLOTH_IMPORT
00047 #define NV_CLOTH_CALL_CONV PX_CALL_CONV
00048 #define NV_CLOTH_API(ret_type) NV_CLOTH_LINKAGE ret_type NV_CLOTH_CALL_CONV
00049
00050 namespace physx
00051 {
00052 class PxAllocatorCallback;
00053 class PxErrorCallback;
00054 class PxProfilerCallback;
00055 class PxAssertHandler;
00056 }
00057
00059 namespace nv
00060 {
00062 namespace cloth
00063 {
00072 NV_CLOTH_API(void)
00073 InitializeNvCloth(physx::PxAllocatorCallback* allocatorCallback, physx::PxErrorCallback* errorCallback,
00074 physx::PxAssertHandler* assertHandler, physx::PxProfilerCallback* profilerCallback,
00075 int autoDllIDCheck = NV_CLOTH_DLL_ID);
00076 }
00077 }
00078
00079
00080 NV_CLOTH_API(physx::PxAllocatorCallback*) GetNvClothAllocator();
00081
00082 namespace nv
00083 {
00084 namespace cloth
00085 {
00086
00087 void LogErrorFn (const char* fileName, int lineNumber, const char* msg, ...);
00088 void LogInvalidParameterFn (const char* fileName, int lineNumber, const char* msg, ...);
00089 void LogWarningFn(const char* fileName, int lineNumber, const char* msg, ...);
00090 void LogInfoFn (const char* fileName, int lineNumber, const char* msg, ...);
00092 #define NV_CLOTH_LOG_ERROR(...) nv::cloth::LogErrorFn(__FILE__,__LINE__,__VA_ARGS__)
00093 #define NV_CLOTH_LOG_INVALID_PARAMETER(...) nv::cloth::LogInvalidParameterFn(__FILE__,__LINE__,__VA_ARGS__)
00094 #define NV_CLOTH_LOG_WARNING(...) nv::cloth::LogWarningFn(__FILE__,__LINE__,__VA_ARGS__)
00095 #define NV_CLOTH_LOG_INFO(...) nv::cloth::LogInfoFn(__FILE__,__LINE__,__VA_ARGS__)
00096
00097
00098 NV_CLOTH_API(physx::PxAssertHandler*) GetNvClothAssertHandler();
00099 #if !PX_ENABLE_ASSERTS
00100 #if PX_VC
00101 #define NV_CLOTH_ASSERT(exp) __noop
00102 #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp) __noop
00103 #else
00104 #define NV_CLOTH_ASSERT(exp) ((void)0)
00105 #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp) ((void)0)
00106 #endif
00107 #else
00108 #if PX_VC
00109 #define PX_CODE_ANALYSIS_ASSUME(exp) \
00110 __analysis_assume(!!(exp)) // This macro will be used to get rid of analysis warning messages if a PX_ASSERT is used
00111
00112 #else
00113 #define PX_CODE_ANALYSIS_ASSUME(exp)
00114 #endif
00115 #define NV_CLOTH_ASSERT(exp) \
00116 { \
00117 static bool _ignore = false; \
00118 ((void)((!!(exp)) || (!_ignore && ((*nv::cloth::GetNvClothAssertHandler())(#exp, __FILE__, __LINE__, _ignore), false)))); \
00119 PX_CODE_ANALYSIS_ASSUME(exp); \
00120 }
00121 #define NV_CLOTH_ASSERT_WITH_MESSAGE(message, exp) \
00122 { \
00123 static bool _ignore = false; \
00124 ((void)((!!(exp)) || (!_ignore && (physx::PxGetAssertHandler()(message, __FILE__, __LINE__, _ignore), false)))); \
00125 PX_CODE_ANALYSIS_ASSUME(exp); \
00126 }
00127 #endif
00128
00129
00130 physx::PxProfilerCallback* GetNvClothProfiler();
00131 #if PX_DEBUG || PX_CHECKED || PX_PROFILE || 1
00132 class NvClothProfileScoped
00133 {
00134 public:
00135 PX_FORCE_INLINE NvClothProfileScoped(const char* eventName, bool detached, uint64_t contextId,
00136 const char* fileName, int lineno, physx::PxProfilerCallback* callback)
00137 : mCallback(callback)
00138 {
00139 PX_UNUSED(fileName);
00140 PX_UNUSED(lineno);
00141 mProfilerData = NULL;
00142 if (mCallback)
00143 {
00144 mEventName = eventName;
00145 mDetached = detached;
00146 mContextId = contextId;
00147 mProfilerData = mCallback->zoneStart(mEventName, mDetached, mContextId);
00148 }
00149 }
00150 ~NvClothProfileScoped(void)
00151 {
00152 if (mCallback)
00153 {
00154 mCallback->zoneEnd(mProfilerData, mEventName, mDetached, mContextId);
00155 }
00156 }
00157 physx::PxProfilerCallback* mCallback;
00158 const char* mEventName;
00159 bool mDetached;
00160 uint64_t mContextId;
00161 void* mProfilerData;
00162 };
00163
00164 #define NV_CLOTH_PROFILE_ZONE(x, y) \
00165 nv::cloth::NvClothProfileScoped PX_CONCAT(_scoped, __LINE__)(x, false, y, __FILE__, __LINE__, nv::cloth::GetNvClothProfiler())
00166 #define NV_CLOTH_PROFILE_START_CROSSTHREAD(x, y) \
00167 (GetNvClothProfiler()!=nullptr? \
00168 GetNvClothProfiler()->zoneStart(x, true, y):nullptr)
00169 #define NV_CLOTH_PROFILE_STOP_CROSSTHREAD(profilerData, x, y) \
00170 if (GetNvClothProfiler()) \
00171 GetNvClothProfiler()->zoneEnd(profilerData, x, true, y)
00172 #else
00173
00174 #define NV_CLOTH_PROFILE_ZONE(x, y)
00175 #define NV_CLOTH_PROFILE_START_CROSSTHREAD(x, y) nullptr
00176 #define NV_CLOTH_PROFILE_STOP_CROSSTHREAD(profilerData, x, y)
00177
00178 #endif
00179
00180 }
00181 }