file_path
stringlengths 21
202
| content
stringlengths 13
1.02M
| size
int64 13
1.02M
| lang
stringclasses 9
values | avg_line_length
float64 5.43
98.5
| max_line_length
int64 12
993
| alphanum_fraction
float64 0.27
0.91
|
---|---|---|---|---|---|---|
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/NpOmniPvd.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef NP_OMNI_PVD_H
#define NP_OMNI_PVD_H
#include "omnipvd/PxOmniPvd.h"
#include "foundation/PxMutex.h"
class OmniPvdReader;
class OmniPvdWriter;
class OmniPvdLoader;
class OmniPvdFileWriteStream;
class OmniPvdPxSampler;
namespace physx
{
class NpOmniPvd : public PxOmniPvd
{
public:
NpOmniPvd();
~NpOmniPvd();
static void destroyInstance();
static void incRefCount();
static void decRefCount();
void release();
bool initOmniPvd();
OmniPvdWriter* getWriter();
OmniPvdWriter* blockingWriterLoad();
OmniPvdWriter* acquireExclusiveWriterAccess();
void releaseExclusiveWriterAccess();
OmniPvdFileWriteStream* getFileWriteStream();
bool startSampling();
OmniPvdLoader* mLoader;
OmniPvdFileWriteStream* mFileWriteStream;
OmniPvdWriter* mWriter;
OmniPvdPxSampler* mPhysXSampler;
static PxU32 mRefCount;
static NpOmniPvd* mInstance;
PxMutex mMutex;
PxMutex mWriterLoadMutex;
};
}
#endif
| 2,617 | C | 32.13924 | 74 | 0.771494 |
NVIDIA-Omniverse/PhysX/physx/source/physx/src/device/nvPhysXtoDrv.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef __NVPHYSXTODRV_H__
#define __NVPHYSXTODRV_H__
// The puprose of this interface is to provide graphics drivers with information
// about PhysX state to draw PhysX visual indicator
// We share information between modules using a memory section object. PhysX creates
// such object, graphics drivers try to open it. The name of the object has
// fixed part (NvPhysXToDrv_SectionName) followed by the process id. This allows
// each process to have its own communication channel.
namespace physx
{
#define NvPhysXToDrv_SectionName "PH71828182845_"
// Vista apps cannot create stuff in Global\\ namespace when NOT elevated, so use local scope
#define NvPhysXToDrv_Build_SectionName(PID, buf) sprintf(buf, NvPhysXToDrv_SectionName "%x", static_cast<unsigned int>(PID))
#define NvPhysXToDrv_Build_SectionNameXP(PID, buf) sprintf(buf, "Global\\" NvPhysXToDrv_SectionName "%x", static_cast<unsigned int>(PID))
typedef struct NvPhysXToDrv_Header_
{
int signature; // header interface signature
int version; // version of the interface
int size; // size of the structure
int reserved; // reserved, must be zero
} NvPhysXToDrv_Header;
// this structure describes layout of data in the shared memory section
typedef struct NvPhysXToDrv_Data_V1_
{
NvPhysXToDrv_Header header; // keep this member first in all versions of the interface.
int bCpuPhysicsPresent; // nonzero if cpu physics is initialized
int bGpuPhysicsPresent; // nonzero if gpu physics is initialized
} NvPhysXToDrv_Data_V1;
// some random magic number as our interface signature
#define NvPhysXToDrv_Header_Signature 0xA7AB
// use the macro to setup the header to the latest version of the interface
// update the macro when a new verson of the interface is added
#define NvPhysXToDrv_Header_Init(header) \
{ \
header.signature = NvPhysXToDrv_Header_Signature; \
header.version = 1; \
header.size = sizeof(NvPhysXToDrv_Data_V1); \
header.reserved = 0; \
}
// validate the header against all known interface versions
// add validation checks when new interfaces are added
#define NvPhysXToDrv_Header_Validate(header, curVersion) \
( \
(header.signature == NvPhysXToDrv_Header_Signature) && \
(header.version == curVersion) && \
(curVersion == 1) && \
(header.size == sizeof(NvPhysXToDrv_Data_V1)) \
)
}
#endif // __NVPHYSXTODRV_H__
| 4,354 | C | 45.827956 | 138 | 0.703721 |
NVIDIA-Omniverse/PhysX/physx/source/physx/src/device/windows/PhysXIndicatorWindows.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PhysXIndicator.h"
#include "nvPhysXtoDrv.h"
#include "foundation/windows/PxWindowsInclude.h"
#include <stdio.h>
#if _MSC_VER >= 1800
#include <VersionHelpers.h>
#endif
// Scope-based to indicate to NV driver that CPU PhysX is happening
physx::PhysXIndicator::PhysXIndicator(bool isGpu)
: mPhysXDataPtr(0), mFileHandle(0), mIsGpu(isGpu)
{
// Get the windows version (we can only create Global\\ namespace objects in XP)
/**
Operating system Version number
---------------- --------------
Windows 7 6.1
Windows Server 2008 R2 6.1
Windows Server 2008 6.0
Windows Vista 6.0
Windows Server 2003 R2 5.2
Windows Server 2003 5.2
Windows XP 5.1
Windows 2000 5.0
**/
char configName[128];
#if _MSC_VER >= 1800
if (!IsWindowsVistaOrGreater())
#else
OSVERSIONINFOEX windowsVersionInfo;
windowsVersionInfo.dwOSVersionInfoSize = sizeof (windowsVersionInfo);
GetVersionEx((LPOSVERSIONINFO)&windowsVersionInfo);
if (windowsVersionInfo.dwMajorVersion < 6)
#endif
NvPhysXToDrv_Build_SectionNameXP(GetCurrentProcessId(), configName);
else
NvPhysXToDrv_Build_SectionName(GetCurrentProcessId(), configName);
mFileHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL,
PAGE_READWRITE, 0, sizeof(NvPhysXToDrv_Data_V1), configName);
if (!mFileHandle || mFileHandle == INVALID_HANDLE_VALUE)
return;
bool alreadyExists = ERROR_ALREADY_EXISTS == GetLastError();
mPhysXDataPtr = (physx::NvPhysXToDrv_Data_V1*)MapViewOfFile(mFileHandle,
FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(NvPhysXToDrv_Data_V1));
if(!mPhysXDataPtr)
return;
if (!alreadyExists)
{
mPhysXDataPtr->bCpuPhysicsPresent = 0;
mPhysXDataPtr->bGpuPhysicsPresent = 0;
}
updateCounter(1);
// init header last to prevent race conditions
// this must be done because the driver may have already created the shared memory block,
// thus alreadyExists may be true, even if PhysX hasn't been initialized
NvPhysXToDrv_Header_Init(mPhysXDataPtr->header);
}
physx::PhysXIndicator::~PhysXIndicator()
{
if(mPhysXDataPtr)
{
updateCounter(-1);
UnmapViewOfFile(mPhysXDataPtr);
}
if(mFileHandle && mFileHandle != INVALID_HANDLE_VALUE)
CloseHandle(mFileHandle);
}
void physx::PhysXIndicator::setIsGpu(bool isGpu)
{
if(!mPhysXDataPtr)
return;
updateCounter(-1);
mIsGpu = isGpu;
updateCounter(1);
}
PX_INLINE void physx::PhysXIndicator::updateCounter(int delta)
{
(mIsGpu ? mPhysXDataPtr->bGpuPhysicsPresent
: mPhysXDataPtr->bCpuPhysicsPresent) += delta;
}
| 4,203 | C++ | 31.84375 | 90 | 0.748037 |
NVIDIA-Omniverse/PhysX/physx/source/physx/src/gpu/PxPhysXGpuModuleLoader.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#include "PxPhysXConfig.h"
#if PX_SUPPORT_GPU_PHYSX
#include "foundation/Px.h"
#include "gpu/PxGpu.h"
#include "cudamanager/PxCudaContextManager.h"
#include "PxPhysics.h"
#if PX_WINDOWS
#include "common/windows/PxWindowsDelayLoadHook.h"
#include "foundation/windows/PxWindowsInclude.h"
#include "windows/CmWindowsModuleUpdateLoader.h"
#elif PX_LINUX
#include <dlfcn.h>
#endif // ~PX_LINUX
#include "stdio.h"
#if PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-reinterpret-cast"
#endif
#define STRINGIFY(x) #x
#define GETSTRING(x) STRINGIFY(x)
#define PHYSX_GPU_SHARED_LIB_NAME GETSTRING(PX_PHYSX_GPU_SHARED_LIB_NAME)
static const char* gPhysXGpuLibraryName = PHYSX_GPU_SHARED_LIB_NAME;
#undef GETSTRING
#undef STRINGIFY
// Use reportError to handle cases where PxFoundation has not been created yet
static void reportError(const char* file, int line, const char* format, ...)
{
va_list args;
va_start(args, format);
physx::PxFoundation* foundation = PxIsFoundationValid();
if(foundation)
{
foundation->error(physx::PxErrorCode::eINTERNAL_ERROR, file, line, format, args);
}
else
{
fprintf(stderr, "Error in %s:%i: ", file, line);
vfprintf(stderr, format, args);
}
va_end(args);
}
void PxSetPhysXGpuLoadHook(const PxGpuLoadHook* hook)
{
gPhysXGpuLibraryName = hook->getPhysXGpuDllName();
}
namespace physx
{
#if PX_VC
#pragma warning(disable: 4191) //'operator/operation' : unsafe conversion from 'type of expression' to 'type required'
#endif
class PxFoundation;
class PxPhysXGpu;
class PxPhysicsGpu;
typedef physx::PxPhysXGpu* (PxCreatePhysXGpu_FUNC)();
typedef physx::PxCudaContextManager* (PxCreateCudaContextManager_FUNC)(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback, bool launchSynchronous);
typedef int (PxGetSuggestedCudaDeviceOrdinal_FUNC)(physx::PxErrorCallback& errc);
typedef void (PxSetPhysXGpuProfilerCallback_FUNC)(physx::PxProfilerCallback* cbk);
typedef void (PxCudaRegisterFunction_FUNC)(int, const char*);
typedef void** (PxCudaRegisterFatBinary_FUNC)(void*);
typedef physx::PxKernelIndex* (PxGetCudaFunctionTable_FUNC)();
typedef PxU32 (PxGetCudaFunctionTableSize_FUNC)();
typedef void** PxGetCudaModuleTable_FUNC();
typedef PxPhysicsGpu* PxCreatePhysicsGpu_FUNC();
PxCreatePhysXGpu_FUNC* g_PxCreatePhysXGpu_Func = NULL;
PxCreateCudaContextManager_FUNC* g_PxCreateCudaContextManager_Func = NULL;
PxGetSuggestedCudaDeviceOrdinal_FUNC* g_PxGetSuggestedCudaDeviceOrdinal_Func = NULL;
PxSetPhysXGpuProfilerCallback_FUNC* g_PxSetPhysXGpuProfilerCallback_Func = NULL;
PxCudaRegisterFunction_FUNC* g_PxCudaRegisterFunction_Func = NULL;
PxCudaRegisterFatBinary_FUNC* g_PxCudaRegisterFatBinary_Func = NULL;
PxGetCudaFunctionTable_FUNC* g_PxGetCudaFunctionTable_Func = NULL;
PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaFunctionTableSize_Func = NULL;
PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaModuleTableSize_Func = NULL;
PxGetCudaModuleTable_FUNC* g_PxGetCudaModuleTable_Func = NULL;
PxCreatePhysicsGpu_FUNC* g_PxCreatePhysicsGpu_Func = NULL;
void PxUnloadPhysxGPUModule()
{
g_PxCreatePhysXGpu_Func = NULL;
g_PxCreateCudaContextManager_Func = NULL;
g_PxGetSuggestedCudaDeviceOrdinal_Func = NULL;
g_PxSetPhysXGpuProfilerCallback_Func = NULL;
g_PxCudaRegisterFunction_Func = NULL;
g_PxCudaRegisterFatBinary_Func = NULL;
g_PxGetCudaFunctionTable_Func = NULL;
g_PxGetCudaFunctionTableSize_Func = NULL;
g_PxGetCudaModuleTableSize_Func = NULL;
g_PxGetCudaModuleTable_Func = NULL;
g_PxCreatePhysicsGpu_Func = NULL;
}
#if PX_WINDOWS
typedef void (PxSetPhysXGpuDelayLoadHook_FUNC)(const PxDelayLoadHook* delayLoadHook);
#define DEFAULT_PHYSX_GPU_GUID "D79FA4BF-177C-4841-8091-4375D311D6A3"
void PxLoadPhysxGPUModule(const char* appGUID)
{
HMODULE s_library = GetModuleHandle(gPhysXGpuLibraryName);
bool freshlyLoaded = false;
if (s_library == NULL)
{
Cm::CmModuleUpdateLoader moduleLoader(UPDATE_LOADER_DLL_NAME);
s_library = moduleLoader.LoadModule(gPhysXGpuLibraryName, appGUID == NULL ? DEFAULT_PHYSX_GPU_GUID : appGUID);
freshlyLoaded = true;
}
if (s_library && (freshlyLoaded || g_PxCreatePhysXGpu_Func == NULL))
{
g_PxCreatePhysXGpu_Func = (PxCreatePhysXGpu_FUNC*)GetProcAddress(s_library, "PxCreatePhysXGpu");
g_PxCreateCudaContextManager_Func = (PxCreateCudaContextManager_FUNC*)GetProcAddress(s_library, "PxCreateCudaContextManager");
g_PxGetSuggestedCudaDeviceOrdinal_Func = (PxGetSuggestedCudaDeviceOrdinal_FUNC*)GetProcAddress(s_library, "PxGetSuggestedCudaDeviceOrdinal");
g_PxSetPhysXGpuProfilerCallback_Func = (PxSetPhysXGpuProfilerCallback_FUNC*)GetProcAddress(s_library, "PxSetPhysXGpuProfilerCallback");
g_PxCudaRegisterFunction_Func = (PxCudaRegisterFunction_FUNC*)GetProcAddress(s_library, "PxGpuCudaRegisterFunction");
g_PxCudaRegisterFatBinary_Func = (PxCudaRegisterFatBinary_FUNC*)GetProcAddress(s_library, "PxGpuCudaRegisterFatBinary");
g_PxGetCudaFunctionTable_Func = (PxGetCudaFunctionTable_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaFunctionTable");
g_PxGetCudaFunctionTableSize_Func = (PxGetCudaFunctionTableSize_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaFunctionTableSize");
g_PxGetCudaModuleTableSize_Func = (PxGetCudaFunctionTableSize_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaModuleTableSize");
g_PxGetCudaModuleTable_Func = (PxGetCudaModuleTable_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaModuleTable");
g_PxCreatePhysicsGpu_Func = (PxCreatePhysicsGpu_FUNC*)GetProcAddress(s_library, "PxGpuCreatePhysicsGpu");
}
// Check for errors
if (s_library == NULL)
{
reportError(PX_FL, "Failed to load %s!\n", gPhysXGpuLibraryName);
return;
}
if (g_PxCreatePhysXGpu_Func == NULL || g_PxCreateCudaContextManager_Func == NULL || g_PxGetSuggestedCudaDeviceOrdinal_Func == NULL || g_PxSetPhysXGpuProfilerCallback_Func == NULL)
{
reportError(PX_FL, "PhysXGpu dll is incompatible with this version of PhysX!\n");
return;
}
}
#elif PX_LINUX
void PxLoadPhysxGPUModule(const char*)
{
static void* s_library = NULL;
if (s_library == NULL)
{
// load libcuda.so here since gcc configured with --as-needed won't link to it
// if there is no call from the binary to it.
void* hLibCuda = dlopen("libcuda.so", RTLD_NOW | RTLD_GLOBAL);
if (hLibCuda)
{
s_library = dlopen(gPhysXGpuLibraryName, RTLD_NOW);
}
else
{
char* error = dlerror();
reportError(PX_FL, "Could not load libcuda.so: %s\n", error);
return;
}
}
// no UpdateLoader
if (s_library)
{
*reinterpret_cast<void**>(&g_PxCreatePhysXGpu_Func) = dlsym(s_library, "PxCreatePhysXGpu");
*reinterpret_cast<void**>(&g_PxCreateCudaContextManager_Func) = dlsym(s_library, "PxCreateCudaContextManager");
*reinterpret_cast<void**>(&g_PxGetSuggestedCudaDeviceOrdinal_Func) = dlsym(s_library, "PxGetSuggestedCudaDeviceOrdinal");
*reinterpret_cast<void**>(&g_PxSetPhysXGpuProfilerCallback_Func) = dlsym(s_library, "PxSetPhysXGpuProfilerCallback");
*reinterpret_cast<void**>(&g_PxCudaRegisterFunction_Func) = dlsym(s_library, "PxGpuCudaRegisterFunction");
*reinterpret_cast<void**>(&g_PxCudaRegisterFatBinary_Func) = dlsym(s_library, "PxGpuCudaRegisterFatBinary");
*reinterpret_cast<void**>(&g_PxGetCudaFunctionTable_Func) = dlsym(s_library, "PxGpuGetCudaFunctionTable");
*reinterpret_cast<void**>(&g_PxGetCudaFunctionTableSize_Func) = dlsym(s_library, "PxGpuGetCudaFunctionTableSize");
*reinterpret_cast<void**>(&g_PxGetCudaModuleTableSize_Func) = dlsym(s_library, "PxGpuGetCudaModuleTableSize");
*reinterpret_cast<void**>(&g_PxGetCudaModuleTable_Func) = dlsym(s_library, "PxGpuGetCudaModuleTable");
*reinterpret_cast<void**>(&g_PxCreatePhysicsGpu_Func) = dlsym(s_library, "PxGpuCreatePhysicsGpu");
}
// Check for errors
if (s_library == NULL)
{
char* error = dlerror();
reportError(PX_FL, "Failed to load %s!: %s\n", gPhysXGpuLibraryName, error);
return;
}
if (g_PxCreatePhysXGpu_Func == NULL || g_PxCreateCudaContextManager_Func == NULL || g_PxGetSuggestedCudaDeviceOrdinal_Func == NULL)
{
reportError(PX_FL, "%s is incompatible with this version of PhysX!\n", gPhysXGpuLibraryName);
return;
}
}
#endif // PX_LINUX
} // end physx namespace
#if PX_CLANG
#pragma clang diagnostic pop
#endif
#endif // PX_SUPPORT_GPU_PHYSX
| 9,989 | C++ | 39.942623 | 219 | 0.76404 |
NVIDIA-Omniverse/PhysX/physx/source/physx/src/gpu/PxGpu.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#include "PxPhysXConfig.h"
#if PX_SUPPORT_GPU_PHYSX
#include "gpu/PxGpu.h"
#ifndef PX_PHYSX_GPU_STATIC
namespace physx
{
//forward declare stuff from PxPhysXGpuModuleLoader.cpp
void PxLoadPhysxGPUModule(const char* appGUID);
typedef physx::PxCudaContextManager* (PxCreateCudaContextManager_FUNC)(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback, bool launchSynchronous);
typedef int (PxGetSuggestedCudaDeviceOrdinal_FUNC)(physx::PxErrorCallback& errc);
typedef void (PxSetPhysXGpuProfilerCallback_FUNC)(physx::PxProfilerCallback* cbk);
typedef void (PxCudaRegisterFunction_FUNC)(int, const char*);
typedef void** (PxCudaRegisterFatBinary_FUNC)(void*);
typedef physx::PxKernelIndex* (PxGetCudaFunctionTable_FUNC)();
typedef PxU32 (PxGetCudaFunctionTableSize_FUNC)();
typedef void** PxGetCudaModuleTable_FUNC();
typedef PxPhysicsGpu* PxCreatePhysicsGpu_FUNC();
extern PxCreateCudaContextManager_FUNC* g_PxCreateCudaContextManager_Func;
extern PxGetSuggestedCudaDeviceOrdinal_FUNC* g_PxGetSuggestedCudaDeviceOrdinal_Func;
extern PxSetPhysXGpuProfilerCallback_FUNC* g_PxSetPhysXGpuProfilerCallback_Func;
extern PxCudaRegisterFunction_FUNC* g_PxCudaRegisterFunction_Func;
extern PxCudaRegisterFatBinary_FUNC* g_PxCudaRegisterFatBinary_Func;
extern PxGetCudaFunctionTable_FUNC* g_PxGetCudaFunctionTable_Func;
extern PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaFunctionTableSize_Func;
extern PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaModuleTableSize_Func;
extern PxGetCudaModuleTable_FUNC* g_PxGetCudaModuleTable_Func;
extern PxCreatePhysicsGpu_FUNC* g_PxCreatePhysicsGpu_Func;
} // end of physx namespace
physx::PxCudaContextManager* PxCreateCudaContextManager(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback, bool launchSynchronous)
{
physx::PxLoadPhysxGPUModule(desc.appGUID);
if (physx::g_PxCreateCudaContextManager_Func)
return physx::g_PxCreateCudaContextManager_Func(foundation, desc, profilerCallback, launchSynchronous);
else
return NULL;
}
int PxGetSuggestedCudaDeviceOrdinal(physx::PxErrorCallback& errc)
{
physx::PxLoadPhysxGPUModule(NULL);
if (physx::g_PxGetSuggestedCudaDeviceOrdinal_Func)
return physx::g_PxGetSuggestedCudaDeviceOrdinal_Func(errc);
else
return -1;
}
void PxSetPhysXGpuProfilerCallback(physx::PxProfilerCallback* profilerCallback)
{
physx::PxLoadPhysxGPUModule(NULL);
if (physx::g_PxSetPhysXGpuProfilerCallback_Func)
physx::g_PxSetPhysXGpuProfilerCallback_Func(profilerCallback);
}
void PxCudaRegisterFunction(int moduleIndex, const char* functionName)
{
physx::PxLoadPhysxGPUModule(NULL);
if (physx::g_PxCudaRegisterFunction_Func)
physx::g_PxCudaRegisterFunction_Func(moduleIndex, functionName);
}
void** PxCudaRegisterFatBinary(void* fatBin)
{
physx::PxLoadPhysxGPUModule(NULL);
if (physx::g_PxCudaRegisterFatBinary_Func)
return physx::g_PxCudaRegisterFatBinary_Func(fatBin);
return NULL;
}
physx::PxKernelIndex* PxGetCudaFunctionTable()
{
physx::PxLoadPhysxGPUModule(NULL);
if(physx::g_PxGetCudaFunctionTable_Func)
return physx::g_PxGetCudaFunctionTable_Func();
return NULL;
}
physx::PxU32 PxGetCudaFunctionTableSize()
{
physx::PxLoadPhysxGPUModule(NULL);
if(physx::g_PxGetCudaFunctionTableSize_Func)
return physx::g_PxGetCudaFunctionTableSize_Func();
return 0;
}
void** PxGetCudaModuleTable()
{
physx::PxLoadPhysxGPUModule(NULL);
if(physx::g_PxGetCudaModuleTable_Func)
return physx::g_PxGetCudaModuleTable_Func();
return NULL;
}
physx::PxU32 PxGetCudaModuleTableSize()
{
physx::PxLoadPhysxGPUModule(NULL);
if(physx::g_PxGetCudaModuleTableSize_Func)
return physx::g_PxGetCudaModuleTableSize_Func();
return 0;
}
physx::PxPhysicsGpu* PxGetPhysicsGpu()
{
physx::PxLoadPhysxGPUModule(NULL);
if (physx::g_PxCreatePhysicsGpu_Func)
return physx::g_PxCreatePhysicsGpu_Func();
return NULL;
}
#endif // PX_PHYSX_GPU_STATIC
#endif // PX_SUPPORT_GPU_PHYSX
| 5,599 | C++ | 32.333333 | 219 | 0.795856 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/src/PxExtensionAutoGeneratedMetaDataObjects.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be
// prepared for your edits to be quietly ignored next time the clang metadata generator is
// run. You can find the most recent version of clang metadata generator by contacting
// Chris Nuernberger <[email protected]> or Dilip or Adam.
// The source code for the generate was at one time checked into:
// physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp
#include "foundation/PxPreprocessor.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
#include "PxExtensionMetaDataObjects.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic pop
#endif
#include "PxMetaDataCppPrefix.h"
#include "extensions/PxExtensionsAPI.h"
using namespace physx;
void setPxJoint_Actors( PxJoint* inObj, PxRigidActor * inArg0, PxRigidActor * inArg1 ) { inObj->setActors( inArg0, inArg1 ); }
void getPxJoint_Actors( const PxJoint* inObj, PxRigidActor *& inArg0, PxRigidActor *& inArg1 ) { inObj->getActors( inArg0, inArg1 ); }
void setPxJoint_LocalPose( PxJoint* inObj, PxJointActorIndex::Enum inIndex, PxTransform inArg ){ inObj->setLocalPose( inIndex, inArg ); }
PxTransform getPxJoint_LocalPose( const PxJoint* inObj, PxJointActorIndex::Enum inIndex ) { return inObj->getLocalPose( inIndex ); }
PxTransform getPxJoint_RelativeTransform( const PxJoint* inObj ) { return inObj->getRelativeTransform(); }
PxVec3 getPxJoint_RelativeLinearVelocity( const PxJoint* inObj ) { return inObj->getRelativeLinearVelocity(); }
PxVec3 getPxJoint_RelativeAngularVelocity( const PxJoint* inObj ) { return inObj->getRelativeAngularVelocity(); }
void setPxJoint_BreakForce( PxJoint* inObj, PxReal inArg0, PxReal inArg1 ) { inObj->setBreakForce( inArg0, inArg1 ); }
void getPxJoint_BreakForce( const PxJoint* inObj, PxReal& inArg0, PxReal& inArg1 ) { inObj->getBreakForce( inArg0, inArg1 ); }
void setPxJoint_ConstraintFlags( PxJoint* inObj, PxConstraintFlags inArg){ inObj->setConstraintFlags( inArg ); }
PxConstraintFlags getPxJoint_ConstraintFlags( const PxJoint* inObj ) { return inObj->getConstraintFlags(); }
void setPxJoint_InvMassScale0( PxJoint* inObj, PxReal inArg){ inObj->setInvMassScale0( inArg ); }
PxReal getPxJoint_InvMassScale0( const PxJoint* inObj ) { return inObj->getInvMassScale0(); }
void setPxJoint_InvInertiaScale0( PxJoint* inObj, PxReal inArg){ inObj->setInvInertiaScale0( inArg ); }
PxReal getPxJoint_InvInertiaScale0( const PxJoint* inObj ) { return inObj->getInvInertiaScale0(); }
void setPxJoint_InvMassScale1( PxJoint* inObj, PxReal inArg){ inObj->setInvMassScale1( inArg ); }
PxReal getPxJoint_InvMassScale1( const PxJoint* inObj ) { return inObj->getInvMassScale1(); }
void setPxJoint_InvInertiaScale1( PxJoint* inObj, PxReal inArg){ inObj->setInvInertiaScale1( inArg ); }
PxReal getPxJoint_InvInertiaScale1( const PxJoint* inObj ) { return inObj->getInvInertiaScale1(); }
PxConstraint * getPxJoint_Constraint( const PxJoint* inObj ) { return inObj->getConstraint(); }
void setPxJoint_Name( PxJoint* inObj, const char * inArg){ inObj->setName( inArg ); }
const char * getPxJoint_Name( const PxJoint* inObj ) { return inObj->getName(); }
PxScene * getPxJoint_Scene( const PxJoint* inObj ) { return inObj->getScene(); }
inline void * getPxJointUserData( const PxJoint* inOwner ) { return inOwner->userData; }
inline void setPxJointUserData( PxJoint* inOwner, void * inData) { inOwner->userData = inData; }
PxJointGeneratedInfo::PxJointGeneratedInfo()
: Actors( "Actors", "actor0", "actor1", setPxJoint_Actors, getPxJoint_Actors)
, LocalPose( "LocalPose", setPxJoint_LocalPose, getPxJoint_LocalPose)
, RelativeTransform( "RelativeTransform", getPxJoint_RelativeTransform)
, RelativeLinearVelocity( "RelativeLinearVelocity", getPxJoint_RelativeLinearVelocity)
, RelativeAngularVelocity( "RelativeAngularVelocity", getPxJoint_RelativeAngularVelocity)
, BreakForce( "BreakForce", "force", "torque", setPxJoint_BreakForce, getPxJoint_BreakForce)
, ConstraintFlags( "ConstraintFlags", setPxJoint_ConstraintFlags, getPxJoint_ConstraintFlags)
, InvMassScale0( "InvMassScale0", setPxJoint_InvMassScale0, getPxJoint_InvMassScale0)
, InvInertiaScale0( "InvInertiaScale0", setPxJoint_InvInertiaScale0, getPxJoint_InvInertiaScale0)
, InvMassScale1( "InvMassScale1", setPxJoint_InvMassScale1, getPxJoint_InvMassScale1)
, InvInertiaScale1( "InvInertiaScale1", setPxJoint_InvInertiaScale1, getPxJoint_InvInertiaScale1)
, Constraint( "Constraint", getPxJoint_Constraint)
, Name( "Name", setPxJoint_Name, getPxJoint_Name)
, Scene( "Scene", getPxJoint_Scene)
, UserData( "UserData", setPxJointUserData, getPxJointUserData )
{}
PxJointGeneratedValues::PxJointGeneratedValues( const PxJoint* inSource )
:RelativeTransform( getPxJoint_RelativeTransform( inSource ) )
,RelativeLinearVelocity( getPxJoint_RelativeLinearVelocity( inSource ) )
,RelativeAngularVelocity( getPxJoint_RelativeAngularVelocity( inSource ) )
,ConstraintFlags( getPxJoint_ConstraintFlags( inSource ) )
,InvMassScale0( getPxJoint_InvMassScale0( inSource ) )
,InvInertiaScale0( getPxJoint_InvInertiaScale0( inSource ) )
,InvMassScale1( getPxJoint_InvMassScale1( inSource ) )
,InvInertiaScale1( getPxJoint_InvInertiaScale1( inSource ) )
,Constraint( getPxJoint_Constraint( inSource ) )
,Name( getPxJoint_Name( inSource ) )
,Scene( getPxJoint_Scene( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
getPxJoint_Actors( inSource, Actors[0], Actors[1] );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxJointActorIndex::COUNT ); ++idx )
LocalPose[idx] = getPxJoint_LocalPose( inSource, static_cast< PxJointActorIndex::Enum >( idx ) );
getPxJoint_BreakForce( inSource, BreakForce[0], BreakForce[1] );
}
void setPxRackAndPinionJoint_Ratio( PxRackAndPinionJoint* inObj, float inArg){ inObj->setRatio( inArg ); }
float getPxRackAndPinionJoint_Ratio( const PxRackAndPinionJoint* inObj ) { return inObj->getRatio(); }
const char * getPxRackAndPinionJoint_ConcreteTypeName( const PxRackAndPinionJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxRackAndPinionJointGeneratedInfo::PxRackAndPinionJointGeneratedInfo()
: Ratio( "Ratio", setPxRackAndPinionJoint_Ratio, getPxRackAndPinionJoint_Ratio)
, ConcreteTypeName( "ConcreteTypeName", getPxRackAndPinionJoint_ConcreteTypeName)
{}
PxRackAndPinionJointGeneratedValues::PxRackAndPinionJointGeneratedValues( const PxRackAndPinionJoint* inSource )
:PxJointGeneratedValues( inSource )
,Ratio( getPxRackAndPinionJoint_Ratio( inSource ) )
,ConcreteTypeName( getPxRackAndPinionJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxGearJoint_GearRatio( PxGearJoint* inObj, float inArg){ inObj->setGearRatio( inArg ); }
float getPxGearJoint_GearRatio( const PxGearJoint* inObj ) { return inObj->getGearRatio(); }
const char * getPxGearJoint_ConcreteTypeName( const PxGearJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxGearJointGeneratedInfo::PxGearJointGeneratedInfo()
: GearRatio( "GearRatio", setPxGearJoint_GearRatio, getPxGearJoint_GearRatio)
, ConcreteTypeName( "ConcreteTypeName", getPxGearJoint_ConcreteTypeName)
{}
PxGearJointGeneratedValues::PxGearJointGeneratedValues( const PxGearJoint* inSource )
:PxJointGeneratedValues( inSource )
,GearRatio( getPxGearJoint_GearRatio( inSource ) )
,ConcreteTypeName( getPxGearJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxD6Joint_Motion( PxD6Joint* inObj, PxD6Axis::Enum inIndex, PxD6Motion::Enum inArg ){ inObj->setMotion( inIndex, inArg ); }
PxD6Motion::Enum getPxD6Joint_Motion( const PxD6Joint* inObj, PxD6Axis::Enum inIndex ) { return inObj->getMotion( inIndex ); }
PxReal getPxD6Joint_TwistAngle( const PxD6Joint* inObj ) { return inObj->getTwistAngle(); }
PxReal getPxD6Joint_Twist( const PxD6Joint* inObj ) { return inObj->getTwist(); }
PxReal getPxD6Joint_SwingYAngle( const PxD6Joint* inObj ) { return inObj->getSwingYAngle(); }
PxReal getPxD6Joint_SwingZAngle( const PxD6Joint* inObj ) { return inObj->getSwingZAngle(); }
void setPxD6Joint_DistanceLimit( PxD6Joint* inObj, const PxJointLinearLimit & inArg){ inObj->setDistanceLimit( inArg ); }
PxJointLinearLimit getPxD6Joint_DistanceLimit( const PxD6Joint* inObj ) { return inObj->getDistanceLimit(); }
void setPxD6Joint_LinearLimit( PxD6Joint* inObj, const PxJointLinearLimit & inArg){ inObj->setLinearLimit( inArg ); }
PxJointLinearLimit getPxD6Joint_LinearLimit( const PxD6Joint* inObj ) { return inObj->getLinearLimit(); }
void setPxD6Joint_TwistLimit( PxD6Joint* inObj, const PxJointAngularLimitPair & inArg){ inObj->setTwistLimit( inArg ); }
PxJointAngularLimitPair getPxD6Joint_TwistLimit( const PxD6Joint* inObj ) { return inObj->getTwistLimit(); }
void setPxD6Joint_SwingLimit( PxD6Joint* inObj, const PxJointLimitCone & inArg){ inObj->setSwingLimit( inArg ); }
PxJointLimitCone getPxD6Joint_SwingLimit( const PxD6Joint* inObj ) { return inObj->getSwingLimit(); }
void setPxD6Joint_PyramidSwingLimit( PxD6Joint* inObj, const PxJointLimitPyramid & inArg){ inObj->setPyramidSwingLimit( inArg ); }
PxJointLimitPyramid getPxD6Joint_PyramidSwingLimit( const PxD6Joint* inObj ) { return inObj->getPyramidSwingLimit(); }
void setPxD6Joint_Drive( PxD6Joint* inObj, PxD6Drive::Enum inIndex, PxD6JointDrive inArg ){ inObj->setDrive( inIndex, inArg ); }
PxD6JointDrive getPxD6Joint_Drive( const PxD6Joint* inObj, PxD6Drive::Enum inIndex ) { return inObj->getDrive( inIndex ); }
void setPxD6Joint_DrivePosition( PxD6Joint* inObj, const PxTransform & inArg){ inObj->setDrivePosition( inArg ); }
PxTransform getPxD6Joint_DrivePosition( const PxD6Joint* inObj ) { return inObj->getDrivePosition(); }
const char * getPxD6Joint_ConcreteTypeName( const PxD6Joint* inObj ) { return inObj->getConcreteTypeName(); }
PxD6JointGeneratedInfo::PxD6JointGeneratedInfo()
: Motion( "Motion", setPxD6Joint_Motion, getPxD6Joint_Motion)
, TwistAngle( "TwistAngle", getPxD6Joint_TwistAngle)
, Twist( "Twist", getPxD6Joint_Twist)
, SwingYAngle( "SwingYAngle", getPxD6Joint_SwingYAngle)
, SwingZAngle( "SwingZAngle", getPxD6Joint_SwingZAngle)
, DistanceLimit( "DistanceLimit", setPxD6Joint_DistanceLimit, getPxD6Joint_DistanceLimit)
, LinearLimit( "LinearLimit", setPxD6Joint_LinearLimit, getPxD6Joint_LinearLimit)
, TwistLimit( "TwistLimit", setPxD6Joint_TwistLimit, getPxD6Joint_TwistLimit)
, SwingLimit( "SwingLimit", setPxD6Joint_SwingLimit, getPxD6Joint_SwingLimit)
, PyramidSwingLimit( "PyramidSwingLimit", setPxD6Joint_PyramidSwingLimit, getPxD6Joint_PyramidSwingLimit)
, Drive( "Drive", setPxD6Joint_Drive, getPxD6Joint_Drive)
, DrivePosition( "DrivePosition", setPxD6Joint_DrivePosition, getPxD6Joint_DrivePosition)
, ConcreteTypeName( "ConcreteTypeName", getPxD6Joint_ConcreteTypeName)
{}
PxD6JointGeneratedValues::PxD6JointGeneratedValues( const PxD6Joint* inSource )
:PxJointGeneratedValues( inSource )
,TwistAngle( getPxD6Joint_TwistAngle( inSource ) )
,Twist( getPxD6Joint_Twist( inSource ) )
,SwingYAngle( getPxD6Joint_SwingYAngle( inSource ) )
,SwingZAngle( getPxD6Joint_SwingZAngle( inSource ) )
,DistanceLimit( getPxD6Joint_DistanceLimit( inSource ) )
,LinearLimit( getPxD6Joint_LinearLimit( inSource ) )
,TwistLimit( getPxD6Joint_TwistLimit( inSource ) )
,SwingLimit( getPxD6Joint_SwingLimit( inSource ) )
,PyramidSwingLimit( getPxD6Joint_PyramidSwingLimit( inSource ) )
,DrivePosition( getPxD6Joint_DrivePosition( inSource ) )
,ConcreteTypeName( getPxD6Joint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxD6Axis::eCOUNT ); ++idx )
Motion[idx] = getPxD6Joint_Motion( inSource, static_cast< PxD6Axis::Enum >( idx ) );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxD6Drive::eCOUNT ); ++idx )
Drive[idx] = getPxD6Joint_Drive( inSource, static_cast< PxD6Drive::Enum >( idx ) );
}
PxReal getPxDistanceJoint_Distance( const PxDistanceJoint* inObj ) { return inObj->getDistance(); }
void setPxDistanceJoint_MinDistance( PxDistanceJoint* inObj, PxReal inArg){ inObj->setMinDistance( inArg ); }
PxReal getPxDistanceJoint_MinDistance( const PxDistanceJoint* inObj ) { return inObj->getMinDistance(); }
void setPxDistanceJoint_MaxDistance( PxDistanceJoint* inObj, PxReal inArg){ inObj->setMaxDistance( inArg ); }
PxReal getPxDistanceJoint_MaxDistance( const PxDistanceJoint* inObj ) { return inObj->getMaxDistance(); }
void setPxDistanceJoint_Tolerance( PxDistanceJoint* inObj, PxReal inArg){ inObj->setTolerance( inArg ); }
PxReal getPxDistanceJoint_Tolerance( const PxDistanceJoint* inObj ) { return inObj->getTolerance(); }
void setPxDistanceJoint_Stiffness( PxDistanceJoint* inObj, PxReal inArg){ inObj->setStiffness( inArg ); }
PxReal getPxDistanceJoint_Stiffness( const PxDistanceJoint* inObj ) { return inObj->getStiffness(); }
void setPxDistanceJoint_Damping( PxDistanceJoint* inObj, PxReal inArg){ inObj->setDamping( inArg ); }
PxReal getPxDistanceJoint_Damping( const PxDistanceJoint* inObj ) { return inObj->getDamping(); }
void setPxDistanceJoint_DistanceJointFlags( PxDistanceJoint* inObj, PxDistanceJointFlags inArg){ inObj->setDistanceJointFlags( inArg ); }
PxDistanceJointFlags getPxDistanceJoint_DistanceJointFlags( const PxDistanceJoint* inObj ) { return inObj->getDistanceJointFlags(); }
const char * getPxDistanceJoint_ConcreteTypeName( const PxDistanceJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxDistanceJointGeneratedInfo::PxDistanceJointGeneratedInfo()
: Distance( "Distance", getPxDistanceJoint_Distance)
, MinDistance( "MinDistance", setPxDistanceJoint_MinDistance, getPxDistanceJoint_MinDistance)
, MaxDistance( "MaxDistance", setPxDistanceJoint_MaxDistance, getPxDistanceJoint_MaxDistance)
, Tolerance( "Tolerance", setPxDistanceJoint_Tolerance, getPxDistanceJoint_Tolerance)
, Stiffness( "Stiffness", setPxDistanceJoint_Stiffness, getPxDistanceJoint_Stiffness)
, Damping( "Damping", setPxDistanceJoint_Damping, getPxDistanceJoint_Damping)
, DistanceJointFlags( "DistanceJointFlags", setPxDistanceJoint_DistanceJointFlags, getPxDistanceJoint_DistanceJointFlags)
, ConcreteTypeName( "ConcreteTypeName", getPxDistanceJoint_ConcreteTypeName)
{}
PxDistanceJointGeneratedValues::PxDistanceJointGeneratedValues( const PxDistanceJoint* inSource )
:PxJointGeneratedValues( inSource )
,Distance( getPxDistanceJoint_Distance( inSource ) )
,MinDistance( getPxDistanceJoint_MinDistance( inSource ) )
,MaxDistance( getPxDistanceJoint_MaxDistance( inSource ) )
,Tolerance( getPxDistanceJoint_Tolerance( inSource ) )
,Stiffness( getPxDistanceJoint_Stiffness( inSource ) )
,Damping( getPxDistanceJoint_Damping( inSource ) )
,DistanceJointFlags( getPxDistanceJoint_DistanceJointFlags( inSource ) )
,ConcreteTypeName( getPxDistanceJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxContactJoint_Contact( PxContactJoint* inObj, const PxVec3 & inArg){ inObj->setContact( inArg ); }
PxVec3 getPxContactJoint_Contact( const PxContactJoint* inObj ) { return inObj->getContact(); }
void setPxContactJoint_ContactNormal( PxContactJoint* inObj, const PxVec3 & inArg){ inObj->setContactNormal( inArg ); }
PxVec3 getPxContactJoint_ContactNormal( const PxContactJoint* inObj ) { return inObj->getContactNormal(); }
void setPxContactJoint_Penetration( PxContactJoint* inObj, const PxReal inArg){ inObj->setPenetration( inArg ); }
PxReal getPxContactJoint_Penetration( const PxContactJoint* inObj ) { return inObj->getPenetration(); }
void setPxContactJoint_Restitution( PxContactJoint* inObj, const PxReal inArg){ inObj->setRestitution( inArg ); }
PxReal getPxContactJoint_Restitution( const PxContactJoint* inObj ) { return inObj->getRestitution(); }
void setPxContactJoint_BounceThreshold( PxContactJoint* inObj, const PxReal inArg){ inObj->setBounceThreshold( inArg ); }
PxReal getPxContactJoint_BounceThreshold( const PxContactJoint* inObj ) { return inObj->getBounceThreshold(); }
const char * getPxContactJoint_ConcreteTypeName( const PxContactJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxContactJointGeneratedInfo::PxContactJointGeneratedInfo()
: Contact( "Contact", setPxContactJoint_Contact, getPxContactJoint_Contact)
, ContactNormal( "ContactNormal", setPxContactJoint_ContactNormal, getPxContactJoint_ContactNormal)
, Penetration( "Penetration", setPxContactJoint_Penetration, getPxContactJoint_Penetration)
, Restitution( "Restitution", setPxContactJoint_Restitution, getPxContactJoint_Restitution)
, BounceThreshold( "BounceThreshold", setPxContactJoint_BounceThreshold, getPxContactJoint_BounceThreshold)
, ConcreteTypeName( "ConcreteTypeName", getPxContactJoint_ConcreteTypeName)
{}
PxContactJointGeneratedValues::PxContactJointGeneratedValues( const PxContactJoint* inSource )
:PxJointGeneratedValues( inSource )
,Contact( getPxContactJoint_Contact( inSource ) )
,ContactNormal( getPxContactJoint_ContactNormal( inSource ) )
,Penetration( getPxContactJoint_Penetration( inSource ) )
,Restitution( getPxContactJoint_Restitution( inSource ) )
,BounceThreshold( getPxContactJoint_BounceThreshold( inSource ) )
,ConcreteTypeName( getPxContactJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
const char * getPxFixedJoint_ConcreteTypeName( const PxFixedJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxFixedJointGeneratedInfo::PxFixedJointGeneratedInfo()
: ConcreteTypeName( "ConcreteTypeName", getPxFixedJoint_ConcreteTypeName)
{}
PxFixedJointGeneratedValues::PxFixedJointGeneratedValues( const PxFixedJoint* inSource )
:PxJointGeneratedValues( inSource )
,ConcreteTypeName( getPxFixedJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
PxReal getPxPrismaticJoint_Position( const PxPrismaticJoint* inObj ) { return inObj->getPosition(); }
PxReal getPxPrismaticJoint_Velocity( const PxPrismaticJoint* inObj ) { return inObj->getVelocity(); }
void setPxPrismaticJoint_Limit( PxPrismaticJoint* inObj, const PxJointLinearLimitPair & inArg){ inObj->setLimit( inArg ); }
PxJointLinearLimitPair getPxPrismaticJoint_Limit( const PxPrismaticJoint* inObj ) { return inObj->getLimit(); }
void setPxPrismaticJoint_PrismaticJointFlags( PxPrismaticJoint* inObj, PxPrismaticJointFlags inArg){ inObj->setPrismaticJointFlags( inArg ); }
PxPrismaticJointFlags getPxPrismaticJoint_PrismaticJointFlags( const PxPrismaticJoint* inObj ) { return inObj->getPrismaticJointFlags(); }
const char * getPxPrismaticJoint_ConcreteTypeName( const PxPrismaticJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxPrismaticJointGeneratedInfo::PxPrismaticJointGeneratedInfo()
: Position( "Position", getPxPrismaticJoint_Position)
, Velocity( "Velocity", getPxPrismaticJoint_Velocity)
, Limit( "Limit", setPxPrismaticJoint_Limit, getPxPrismaticJoint_Limit)
, PrismaticJointFlags( "PrismaticJointFlags", setPxPrismaticJoint_PrismaticJointFlags, getPxPrismaticJoint_PrismaticJointFlags)
, ConcreteTypeName( "ConcreteTypeName", getPxPrismaticJoint_ConcreteTypeName)
{}
PxPrismaticJointGeneratedValues::PxPrismaticJointGeneratedValues( const PxPrismaticJoint* inSource )
:PxJointGeneratedValues( inSource )
,Position( getPxPrismaticJoint_Position( inSource ) )
,Velocity( getPxPrismaticJoint_Velocity( inSource ) )
,Limit( getPxPrismaticJoint_Limit( inSource ) )
,PrismaticJointFlags( getPxPrismaticJoint_PrismaticJointFlags( inSource ) )
,ConcreteTypeName( getPxPrismaticJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
PxReal getPxRevoluteJoint_Angle( const PxRevoluteJoint* inObj ) { return inObj->getAngle(); }
PxReal getPxRevoluteJoint_Velocity( const PxRevoluteJoint* inObj ) { return inObj->getVelocity(); }
void setPxRevoluteJoint_Limit( PxRevoluteJoint* inObj, const PxJointAngularLimitPair & inArg){ inObj->setLimit( inArg ); }
PxJointAngularLimitPair getPxRevoluteJoint_Limit( const PxRevoluteJoint* inObj ) { return inObj->getLimit(); }
void setPxRevoluteJoint_DriveVelocity( PxRevoluteJoint* inObj, PxReal inArg){ inObj->setDriveVelocity( inArg ); }
PxReal getPxRevoluteJoint_DriveVelocity( const PxRevoluteJoint* inObj ) { return inObj->getDriveVelocity(); }
void setPxRevoluteJoint_DriveForceLimit( PxRevoluteJoint* inObj, PxReal inArg){ inObj->setDriveForceLimit( inArg ); }
PxReal getPxRevoluteJoint_DriveForceLimit( const PxRevoluteJoint* inObj ) { return inObj->getDriveForceLimit(); }
void setPxRevoluteJoint_DriveGearRatio( PxRevoluteJoint* inObj, PxReal inArg){ inObj->setDriveGearRatio( inArg ); }
PxReal getPxRevoluteJoint_DriveGearRatio( const PxRevoluteJoint* inObj ) { return inObj->getDriveGearRatio(); }
void setPxRevoluteJoint_RevoluteJointFlags( PxRevoluteJoint* inObj, PxRevoluteJointFlags inArg){ inObj->setRevoluteJointFlags( inArg ); }
PxRevoluteJointFlags getPxRevoluteJoint_RevoluteJointFlags( const PxRevoluteJoint* inObj ) { return inObj->getRevoluteJointFlags(); }
const char * getPxRevoluteJoint_ConcreteTypeName( const PxRevoluteJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxRevoluteJointGeneratedInfo::PxRevoluteJointGeneratedInfo()
: Angle( "Angle", getPxRevoluteJoint_Angle)
, Velocity( "Velocity", getPxRevoluteJoint_Velocity)
, Limit( "Limit", setPxRevoluteJoint_Limit, getPxRevoluteJoint_Limit)
, DriveVelocity( "DriveVelocity", setPxRevoluteJoint_DriveVelocity, getPxRevoluteJoint_DriveVelocity)
, DriveForceLimit( "DriveForceLimit", setPxRevoluteJoint_DriveForceLimit, getPxRevoluteJoint_DriveForceLimit)
, DriveGearRatio( "DriveGearRatio", setPxRevoluteJoint_DriveGearRatio, getPxRevoluteJoint_DriveGearRatio)
, RevoluteJointFlags( "RevoluteJointFlags", setPxRevoluteJoint_RevoluteJointFlags, getPxRevoluteJoint_RevoluteJointFlags)
, ConcreteTypeName( "ConcreteTypeName", getPxRevoluteJoint_ConcreteTypeName)
{}
PxRevoluteJointGeneratedValues::PxRevoluteJointGeneratedValues( const PxRevoluteJoint* inSource )
:PxJointGeneratedValues( inSource )
,Angle( getPxRevoluteJoint_Angle( inSource ) )
,Velocity( getPxRevoluteJoint_Velocity( inSource ) )
,Limit( getPxRevoluteJoint_Limit( inSource ) )
,DriveVelocity( getPxRevoluteJoint_DriveVelocity( inSource ) )
,DriveForceLimit( getPxRevoluteJoint_DriveForceLimit( inSource ) )
,DriveGearRatio( getPxRevoluteJoint_DriveGearRatio( inSource ) )
,RevoluteJointFlags( getPxRevoluteJoint_RevoluteJointFlags( inSource ) )
,ConcreteTypeName( getPxRevoluteJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxSphericalJoint_LimitCone( PxSphericalJoint* inObj, const PxJointLimitCone & inArg){ inObj->setLimitCone( inArg ); }
PxJointLimitCone getPxSphericalJoint_LimitCone( const PxSphericalJoint* inObj ) { return inObj->getLimitCone(); }
PxReal getPxSphericalJoint_SwingYAngle( const PxSphericalJoint* inObj ) { return inObj->getSwingYAngle(); }
PxReal getPxSphericalJoint_SwingZAngle( const PxSphericalJoint* inObj ) { return inObj->getSwingZAngle(); }
void setPxSphericalJoint_SphericalJointFlags( PxSphericalJoint* inObj, PxSphericalJointFlags inArg){ inObj->setSphericalJointFlags( inArg ); }
PxSphericalJointFlags getPxSphericalJoint_SphericalJointFlags( const PxSphericalJoint* inObj ) { return inObj->getSphericalJointFlags(); }
const char * getPxSphericalJoint_ConcreteTypeName( const PxSphericalJoint* inObj ) { return inObj->getConcreteTypeName(); }
PxSphericalJointGeneratedInfo::PxSphericalJointGeneratedInfo()
: LimitCone( "LimitCone", setPxSphericalJoint_LimitCone, getPxSphericalJoint_LimitCone)
, SwingYAngle( "SwingYAngle", getPxSphericalJoint_SwingYAngle)
, SwingZAngle( "SwingZAngle", getPxSphericalJoint_SwingZAngle)
, SphericalJointFlags( "SphericalJointFlags", setPxSphericalJoint_SphericalJointFlags, getPxSphericalJoint_SphericalJointFlags)
, ConcreteTypeName( "ConcreteTypeName", getPxSphericalJoint_ConcreteTypeName)
{}
PxSphericalJointGeneratedValues::PxSphericalJointGeneratedValues( const PxSphericalJoint* inSource )
:PxJointGeneratedValues( inSource )
,LimitCone( getPxSphericalJoint_LimitCone( inSource ) )
,SwingYAngle( getPxSphericalJoint_SwingYAngle( inSource ) )
,SwingZAngle( getPxSphericalJoint_SwingZAngle( inSource ) )
,SphericalJointFlags( getPxSphericalJoint_SphericalJointFlags( inSource ) )
,ConcreteTypeName( getPxSphericalJoint_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
inline PxReal getPxJointLimitParametersRestitution( const PxJointLimitParameters* inOwner ) { return inOwner->restitution; }
inline void setPxJointLimitParametersRestitution( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->restitution = inData; }
inline PxReal getPxJointLimitParametersBounceThreshold( const PxJointLimitParameters* inOwner ) { return inOwner->bounceThreshold; }
inline void setPxJointLimitParametersBounceThreshold( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->bounceThreshold = inData; }
inline PxReal getPxJointLimitParametersStiffness( const PxJointLimitParameters* inOwner ) { return inOwner->stiffness; }
inline void setPxJointLimitParametersStiffness( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->stiffness = inData; }
inline PxReal getPxJointLimitParametersDamping( const PxJointLimitParameters* inOwner ) { return inOwner->damping; }
inline void setPxJointLimitParametersDamping( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->damping = inData; }
PxJointLimitParametersGeneratedInfo::PxJointLimitParametersGeneratedInfo()
: Restitution( "Restitution", setPxJointLimitParametersRestitution, getPxJointLimitParametersRestitution )
, BounceThreshold( "BounceThreshold", setPxJointLimitParametersBounceThreshold, getPxJointLimitParametersBounceThreshold )
, Stiffness( "Stiffness", setPxJointLimitParametersStiffness, getPxJointLimitParametersStiffness )
, Damping( "Damping", setPxJointLimitParametersDamping, getPxJointLimitParametersDamping )
{}
PxJointLimitParametersGeneratedValues::PxJointLimitParametersGeneratedValues( const PxJointLimitParameters* inSource )
:Restitution( inSource->restitution )
,BounceThreshold( inSource->bounceThreshold )
,Stiffness( inSource->stiffness )
,Damping( inSource->damping )
{
PX_UNUSED(inSource);
}
inline PxReal getPxJointLinearLimitValue( const PxJointLinearLimit* inOwner ) { return inOwner->value; }
inline void setPxJointLinearLimitValue( PxJointLinearLimit* inOwner, PxReal inData) { inOwner->value = inData; }
PxJointLinearLimitGeneratedInfo::PxJointLinearLimitGeneratedInfo()
: Value( "Value", setPxJointLinearLimitValue, getPxJointLinearLimitValue )
{}
PxJointLinearLimitGeneratedValues::PxJointLinearLimitGeneratedValues( const PxJointLinearLimit* inSource )
:PxJointLimitParametersGeneratedValues( inSource )
,Value( inSource->value )
{
PX_UNUSED(inSource);
}
inline PxReal getPxJointLinearLimitPairUpper( const PxJointLinearLimitPair* inOwner ) { return inOwner->upper; }
inline void setPxJointLinearLimitPairUpper( PxJointLinearLimitPair* inOwner, PxReal inData) { inOwner->upper = inData; }
inline PxReal getPxJointLinearLimitPairLower( const PxJointLinearLimitPair* inOwner ) { return inOwner->lower; }
inline void setPxJointLinearLimitPairLower( PxJointLinearLimitPair* inOwner, PxReal inData) { inOwner->lower = inData; }
PxJointLinearLimitPairGeneratedInfo::PxJointLinearLimitPairGeneratedInfo()
: Upper( "Upper", setPxJointLinearLimitPairUpper, getPxJointLinearLimitPairUpper )
, Lower( "Lower", setPxJointLinearLimitPairLower, getPxJointLinearLimitPairLower )
{}
PxJointLinearLimitPairGeneratedValues::PxJointLinearLimitPairGeneratedValues( const PxJointLinearLimitPair* inSource )
:PxJointLimitParametersGeneratedValues( inSource )
,Upper( inSource->upper )
,Lower( inSource->lower )
{
PX_UNUSED(inSource);
}
inline PxReal getPxJointAngularLimitPairUpper( const PxJointAngularLimitPair* inOwner ) { return inOwner->upper; }
inline void setPxJointAngularLimitPairUpper( PxJointAngularLimitPair* inOwner, PxReal inData) { inOwner->upper = inData; }
inline PxReal getPxJointAngularLimitPairLower( const PxJointAngularLimitPair* inOwner ) { return inOwner->lower; }
inline void setPxJointAngularLimitPairLower( PxJointAngularLimitPair* inOwner, PxReal inData) { inOwner->lower = inData; }
PxJointAngularLimitPairGeneratedInfo::PxJointAngularLimitPairGeneratedInfo()
: Upper( "Upper", setPxJointAngularLimitPairUpper, getPxJointAngularLimitPairUpper )
, Lower( "Lower", setPxJointAngularLimitPairLower, getPxJointAngularLimitPairLower )
{}
PxJointAngularLimitPairGeneratedValues::PxJointAngularLimitPairGeneratedValues( const PxJointAngularLimitPair* inSource )
:PxJointLimitParametersGeneratedValues( inSource )
,Upper( inSource->upper )
,Lower( inSource->lower )
{
PX_UNUSED(inSource);
}
inline PxReal getPxJointLimitConeYAngle( const PxJointLimitCone* inOwner ) { return inOwner->yAngle; }
inline void setPxJointLimitConeYAngle( PxJointLimitCone* inOwner, PxReal inData) { inOwner->yAngle = inData; }
inline PxReal getPxJointLimitConeZAngle( const PxJointLimitCone* inOwner ) { return inOwner->zAngle; }
inline void setPxJointLimitConeZAngle( PxJointLimitCone* inOwner, PxReal inData) { inOwner->zAngle = inData; }
PxJointLimitConeGeneratedInfo::PxJointLimitConeGeneratedInfo()
: YAngle( "YAngle", setPxJointLimitConeYAngle, getPxJointLimitConeYAngle )
, ZAngle( "ZAngle", setPxJointLimitConeZAngle, getPxJointLimitConeZAngle )
{}
PxJointLimitConeGeneratedValues::PxJointLimitConeGeneratedValues( const PxJointLimitCone* inSource )
:PxJointLimitParametersGeneratedValues( inSource )
,YAngle( inSource->yAngle )
,ZAngle( inSource->zAngle )
{
PX_UNUSED(inSource);
}
inline PxReal getPxJointLimitPyramidYAngleMin( const PxJointLimitPyramid* inOwner ) { return inOwner->yAngleMin; }
inline void setPxJointLimitPyramidYAngleMin( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->yAngleMin = inData; }
inline PxReal getPxJointLimitPyramidYAngleMax( const PxJointLimitPyramid* inOwner ) { return inOwner->yAngleMax; }
inline void setPxJointLimitPyramidYAngleMax( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->yAngleMax = inData; }
inline PxReal getPxJointLimitPyramidZAngleMin( const PxJointLimitPyramid* inOwner ) { return inOwner->zAngleMin; }
inline void setPxJointLimitPyramidZAngleMin( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->zAngleMin = inData; }
inline PxReal getPxJointLimitPyramidZAngleMax( const PxJointLimitPyramid* inOwner ) { return inOwner->zAngleMax; }
inline void setPxJointLimitPyramidZAngleMax( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->zAngleMax = inData; }
PxJointLimitPyramidGeneratedInfo::PxJointLimitPyramidGeneratedInfo()
: YAngleMin( "YAngleMin", setPxJointLimitPyramidYAngleMin, getPxJointLimitPyramidYAngleMin )
, YAngleMax( "YAngleMax", setPxJointLimitPyramidYAngleMax, getPxJointLimitPyramidYAngleMax )
, ZAngleMin( "ZAngleMin", setPxJointLimitPyramidZAngleMin, getPxJointLimitPyramidZAngleMin )
, ZAngleMax( "ZAngleMax", setPxJointLimitPyramidZAngleMax, getPxJointLimitPyramidZAngleMax )
{}
PxJointLimitPyramidGeneratedValues::PxJointLimitPyramidGeneratedValues( const PxJointLimitPyramid* inSource )
:PxJointLimitParametersGeneratedValues( inSource )
,YAngleMin( inSource->yAngleMin )
,YAngleMax( inSource->yAngleMax )
,ZAngleMin( inSource->zAngleMin )
,ZAngleMax( inSource->zAngleMax )
{
PX_UNUSED(inSource);
}
inline PxReal getPxSpringStiffness( const PxSpring* inOwner ) { return inOwner->stiffness; }
inline void setPxSpringStiffness( PxSpring* inOwner, PxReal inData) { inOwner->stiffness = inData; }
inline PxReal getPxSpringDamping( const PxSpring* inOwner ) { return inOwner->damping; }
inline void setPxSpringDamping( PxSpring* inOwner, PxReal inData) { inOwner->damping = inData; }
PxSpringGeneratedInfo::PxSpringGeneratedInfo()
: Stiffness( "Stiffness", setPxSpringStiffness, getPxSpringStiffness )
, Damping( "Damping", setPxSpringDamping, getPxSpringDamping )
{}
PxSpringGeneratedValues::PxSpringGeneratedValues( const PxSpring* inSource )
:Stiffness( inSource->stiffness )
,Damping( inSource->damping )
{
PX_UNUSED(inSource);
}
inline PxReal getPxD6JointDriveForceLimit( const PxD6JointDrive* inOwner ) { return inOwner->forceLimit; }
inline void setPxD6JointDriveForceLimit( PxD6JointDrive* inOwner, PxReal inData) { inOwner->forceLimit = inData; }
inline PxD6JointDriveFlags getPxD6JointDriveFlags( const PxD6JointDrive* inOwner ) { return inOwner->flags; }
inline void setPxD6JointDriveFlags( PxD6JointDrive* inOwner, PxD6JointDriveFlags inData) { inOwner->flags = inData; }
PxD6JointDriveGeneratedInfo::PxD6JointDriveGeneratedInfo()
: ForceLimit( "ForceLimit", setPxD6JointDriveForceLimit, getPxD6JointDriveForceLimit )
, Flags( "Flags", setPxD6JointDriveFlags, getPxD6JointDriveFlags )
{}
PxD6JointDriveGeneratedValues::PxD6JointDriveGeneratedValues( const PxD6JointDrive* inSource )
:PxSpringGeneratedValues( inSource )
,ForceLimit( inSource->forceLimit )
,Flags( inSource->flags )
{
PX_UNUSED(inSource);
}
| 34,601 | C++ | 70.34433 | 142 | 0.80411 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/include/PxExtensionAutoGeneratedMetaDataObjects.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be
// prepared for your edits to be quietly ignored next time the clang metadata generator is
// run. You can find the most recent version of clang metadata generator by contacting
// Chris Nuernberger <[email protected]> or Dilip or Adam.
// The source code for the generate was at one time checked into:
// physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp
#define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
#define PX_PROPERTY_INFO_NAME PxExtensionsPropertyInfoName
static PxU32ToName g_physx__PxJointActorIndex__EnumConversion[] = {
{ "eACTOR0", static_cast<PxU32>( physx::PxJointActorIndex::eACTOR0 ) },
{ "eACTOR1", static_cast<PxU32>( physx::PxJointActorIndex::eACTOR1 ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxJointActorIndex::Enum > { PxEnumTraits() : NameConversion( g_physx__PxJointActorIndex__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxJoint;
struct PxJointGeneratedValues
{
PxRigidActor * Actors[2];
PxTransform LocalPose[physx::PxJointActorIndex::COUNT];
PxTransform RelativeTransform;
PxVec3 RelativeLinearVelocity;
PxVec3 RelativeAngularVelocity;
PxReal BreakForce[2];
PxConstraintFlags ConstraintFlags;
PxReal InvMassScale0;
PxReal InvInertiaScale0;
PxReal InvMassScale1;
PxReal InvInertiaScale1;
PxConstraint * Constraint;
const char * Name;
PxScene * Scene;
void * UserData;
PxJointGeneratedValues( const PxJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Actors, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, LocalPose, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, RelativeTransform, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, RelativeLinearVelocity, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, RelativeAngularVelocity, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, BreakForce, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, ConstraintFlags, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvMassScale0, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvInertiaScale0, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvMassScale1, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvInertiaScale1, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Constraint, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Name, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Scene, PxJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, UserData, PxJointGeneratedValues)
struct PxJointGeneratedInfo
{
static const char* getClassName() { return "PxJoint"; }
PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Actors, PxJoint, PxRigidActor * > Actors;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_LocalPose, PxJoint, PxJointActorIndex::Enum, PxTransform > LocalPose;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_RelativeTransform, PxJoint, PxTransform > RelativeTransform;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_RelativeLinearVelocity, PxJoint, PxVec3 > RelativeLinearVelocity;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_RelativeAngularVelocity, PxJoint, PxVec3 > RelativeAngularVelocity;
PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_BreakForce, PxJoint, PxReal > BreakForce;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_ConstraintFlags, PxJoint, PxConstraintFlags, PxConstraintFlags > ConstraintFlags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvMassScale0, PxJoint, PxReal, PxReal > InvMassScale0;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvInertiaScale0, PxJoint, PxReal, PxReal > InvInertiaScale0;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvMassScale1, PxJoint, PxReal, PxReal > InvMassScale1;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvInertiaScale1, PxJoint, PxReal, PxReal > InvInertiaScale1;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Constraint, PxJoint, PxConstraint * > Constraint;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Name, PxJoint, const char *, const char * > Name;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Scene, PxJoint, PxScene * > Scene;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_UserData, PxJoint, void *, void * > UserData;
PxJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 15; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Actors, inStartIndex + 0 );;
inOperator( LocalPose, inStartIndex + 1 );;
inOperator( RelativeTransform, inStartIndex + 2 );;
inOperator( RelativeLinearVelocity, inStartIndex + 3 );;
inOperator( RelativeAngularVelocity, inStartIndex + 4 );;
inOperator( BreakForce, inStartIndex + 5 );;
inOperator( ConstraintFlags, inStartIndex + 6 );;
inOperator( InvMassScale0, inStartIndex + 7 );;
inOperator( InvInertiaScale0, inStartIndex + 8 );;
inOperator( InvMassScale1, inStartIndex + 9 );;
inOperator( InvInertiaScale1, inStartIndex + 10 );;
inOperator( Constraint, inStartIndex + 11 );;
inOperator( Name, inStartIndex + 12 );;
inOperator( Scene, inStartIndex + 13 );;
inOperator( UserData, inStartIndex + 14 );;
return 15 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJoint>
{
PxJointGeneratedInfo Info;
const PxJointGeneratedInfo* getInfo() { return &Info; }
};
class PxRackAndPinionJoint;
struct PxRackAndPinionJointGeneratedValues
: PxJointGeneratedValues {
float Ratio;
const char * ConcreteTypeName;
PxRackAndPinionJointGeneratedValues( const PxRackAndPinionJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRackAndPinionJoint, Ratio, PxRackAndPinionJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRackAndPinionJoint, ConcreteTypeName, PxRackAndPinionJointGeneratedValues)
struct PxRackAndPinionJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxRackAndPinionJoint"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRackAndPinionJoint_Ratio, PxRackAndPinionJoint, float, float > Ratio;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRackAndPinionJoint_ConcreteTypeName, PxRackAndPinionJoint, const char * > ConcreteTypeName;
PxRackAndPinionJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRackAndPinionJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Ratio, inStartIndex + 0 );;
inOperator( ConcreteTypeName, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRackAndPinionJoint>
{
PxRackAndPinionJointGeneratedInfo Info;
const PxRackAndPinionJointGeneratedInfo* getInfo() { return &Info; }
};
class PxGearJoint;
struct PxGearJointGeneratedValues
: PxJointGeneratedValues {
float GearRatio;
const char * ConcreteTypeName;
PxGearJointGeneratedValues( const PxGearJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxGearJoint, GearRatio, PxGearJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxGearJoint, ConcreteTypeName, PxGearJointGeneratedValues)
struct PxGearJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxGearJoint"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxGearJoint_GearRatio, PxGearJoint, float, float > GearRatio;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxGearJoint_ConcreteTypeName, PxGearJoint, const char * > ConcreteTypeName;
PxGearJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxGearJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( GearRatio, inStartIndex + 0 );;
inOperator( ConcreteTypeName, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxGearJoint>
{
PxGearJointGeneratedInfo Info;
const PxGearJointGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxD6Axis__EnumConversion[] = {
{ "eX", static_cast<PxU32>( physx::PxD6Axis::eX ) },
{ "eY", static_cast<PxU32>( physx::PxD6Axis::eY ) },
{ "eZ", static_cast<PxU32>( physx::PxD6Axis::eZ ) },
{ "eTWIST", static_cast<PxU32>( physx::PxD6Axis::eTWIST ) },
{ "eSWING1", static_cast<PxU32>( physx::PxD6Axis::eSWING1 ) },
{ "eSWING2", static_cast<PxU32>( physx::PxD6Axis::eSWING2 ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxD6Axis::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6Axis__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxD6Motion__EnumConversion[] = {
{ "eLOCKED", static_cast<PxU32>( physx::PxD6Motion::eLOCKED ) },
{ "eLIMITED", static_cast<PxU32>( physx::PxD6Motion::eLIMITED ) },
{ "eFREE", static_cast<PxU32>( physx::PxD6Motion::eFREE ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxD6Motion::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6Motion__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxD6Drive__EnumConversion[] = {
{ "eX", static_cast<PxU32>( physx::PxD6Drive::eX ) },
{ "eY", static_cast<PxU32>( physx::PxD6Drive::eY ) },
{ "eZ", static_cast<PxU32>( physx::PxD6Drive::eZ ) },
{ "eSWING", static_cast<PxU32>( physx::PxD6Drive::eSWING ) },
{ "eTWIST", static_cast<PxU32>( physx::PxD6Drive::eTWIST ) },
{ "eSLERP", static_cast<PxU32>( physx::PxD6Drive::eSLERP ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxD6Drive::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6Drive__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxD6Joint;
struct PxD6JointGeneratedValues
: PxJointGeneratedValues {
PxD6Motion::Enum Motion[physx::PxD6Axis::eCOUNT];
PxReal TwistAngle;
PxReal Twist;
PxReal SwingYAngle;
PxReal SwingZAngle;
PxJointLinearLimit DistanceLimit;
PxJointLinearLimit LinearLimit;
PxJointAngularLimitPair TwistLimit;
PxJointLimitCone SwingLimit;
PxJointLimitPyramid PyramidSwingLimit;
PxD6JointDrive Drive[physx::PxD6Drive::eCOUNT];
PxTransform DrivePosition;
const char * ConcreteTypeName;
PxD6JointGeneratedValues( const PxD6Joint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, Motion, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, TwistAngle, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, Twist, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, SwingYAngle, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, SwingZAngle, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, DistanceLimit, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, LinearLimit, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, TwistLimit, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, SwingLimit, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, PyramidSwingLimit, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, Drive, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, DrivePosition, PxD6JointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, ConcreteTypeName, PxD6JointGeneratedValues)
struct PxD6JointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxD6Joint"; }
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_Motion, PxD6Joint, PxD6Axis::Enum, PxD6Motion::Enum > Motion;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_TwistAngle, PxD6Joint, PxReal > TwistAngle;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_Twist, PxD6Joint, PxReal > Twist;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_SwingYAngle, PxD6Joint, PxReal > SwingYAngle;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_SwingZAngle, PxD6Joint, PxReal > SwingZAngle;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_DistanceLimit, PxD6Joint, const PxJointLinearLimit &, PxJointLinearLimit > DistanceLimit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_LinearLimit, PxD6Joint, const PxJointLinearLimit &, PxJointLinearLimit > LinearLimit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_TwistLimit, PxD6Joint, const PxJointAngularLimitPair &, PxJointAngularLimitPair > TwistLimit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_SwingLimit, PxD6Joint, const PxJointLimitCone &, PxJointLimitCone > SwingLimit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_PyramidSwingLimit, PxD6Joint, const PxJointLimitPyramid &, PxJointLimitPyramid > PyramidSwingLimit;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_Drive, PxD6Joint, PxD6Drive::Enum, PxD6JointDrive > Drive;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_DrivePosition, PxD6Joint, const PxTransform &, PxTransform > DrivePosition;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_ConcreteTypeName, PxD6Joint, const char * > ConcreteTypeName;
PxD6JointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxD6Joint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 13; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Motion, inStartIndex + 0 );;
inOperator( TwistAngle, inStartIndex + 1 );;
inOperator( Twist, inStartIndex + 2 );;
inOperator( SwingYAngle, inStartIndex + 3 );;
inOperator( SwingZAngle, inStartIndex + 4 );;
inOperator( DistanceLimit, inStartIndex + 5 );;
inOperator( LinearLimit, inStartIndex + 6 );;
inOperator( TwistLimit, inStartIndex + 7 );;
inOperator( SwingLimit, inStartIndex + 8 );;
inOperator( PyramidSwingLimit, inStartIndex + 9 );;
inOperator( Drive, inStartIndex + 10 );;
inOperator( DrivePosition, inStartIndex + 11 );;
inOperator( ConcreteTypeName, inStartIndex + 12 );;
return 13 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxD6Joint>
{
PxD6JointGeneratedInfo Info;
const PxD6JointGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxDistanceJointFlag__EnumConversion[] = {
{ "eMAX_DISTANCE_ENABLED", static_cast<PxU32>( physx::PxDistanceJointFlag::eMAX_DISTANCE_ENABLED ) },
{ "eMIN_DISTANCE_ENABLED", static_cast<PxU32>( physx::PxDistanceJointFlag::eMIN_DISTANCE_ENABLED ) },
{ "eSPRING_ENABLED", static_cast<PxU32>( physx::PxDistanceJointFlag::eSPRING_ENABLED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxDistanceJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxDistanceJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxDistanceJoint;
struct PxDistanceJointGeneratedValues
: PxJointGeneratedValues {
PxReal Distance;
PxReal MinDistance;
PxReal MaxDistance;
PxReal Tolerance;
PxReal Stiffness;
PxReal Damping;
PxDistanceJointFlags DistanceJointFlags;
const char * ConcreteTypeName;
PxDistanceJointGeneratedValues( const PxDistanceJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Distance, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, MinDistance, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, MaxDistance, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Tolerance, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Stiffness, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Damping, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, DistanceJointFlags, PxDistanceJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, ConcreteTypeName, PxDistanceJointGeneratedValues)
struct PxDistanceJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxDistanceJoint"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Distance, PxDistanceJoint, PxReal > Distance;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_MinDistance, PxDistanceJoint, PxReal, PxReal > MinDistance;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_MaxDistance, PxDistanceJoint, PxReal, PxReal > MaxDistance;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Tolerance, PxDistanceJoint, PxReal, PxReal > Tolerance;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Stiffness, PxDistanceJoint, PxReal, PxReal > Stiffness;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Damping, PxDistanceJoint, PxReal, PxReal > Damping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_DistanceJointFlags, PxDistanceJoint, PxDistanceJointFlags, PxDistanceJointFlags > DistanceJointFlags;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_ConcreteTypeName, PxDistanceJoint, const char * > ConcreteTypeName;
PxDistanceJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxDistanceJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 8; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Distance, inStartIndex + 0 );;
inOperator( MinDistance, inStartIndex + 1 );;
inOperator( MaxDistance, inStartIndex + 2 );;
inOperator( Tolerance, inStartIndex + 3 );;
inOperator( Stiffness, inStartIndex + 4 );;
inOperator( Damping, inStartIndex + 5 );;
inOperator( DistanceJointFlags, inStartIndex + 6 );;
inOperator( ConcreteTypeName, inStartIndex + 7 );;
return 8 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxDistanceJoint>
{
PxDistanceJointGeneratedInfo Info;
const PxDistanceJointGeneratedInfo* getInfo() { return &Info; }
};
class PxContactJoint;
struct PxContactJointGeneratedValues
: PxJointGeneratedValues {
PxVec3 Contact;
PxVec3 ContactNormal;
PxReal Penetration;
PxReal Restitution;
PxReal BounceThreshold;
const char * ConcreteTypeName;
PxContactJointGeneratedValues( const PxContactJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, Contact, PxContactJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, ContactNormal, PxContactJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, Penetration, PxContactJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, Restitution, PxContactJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, BounceThreshold, PxContactJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, ConcreteTypeName, PxContactJointGeneratedValues)
struct PxContactJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxContactJoint"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_Contact, PxContactJoint, const PxVec3 &, PxVec3 > Contact;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_ContactNormal, PxContactJoint, const PxVec3 &, PxVec3 > ContactNormal;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_Penetration, PxContactJoint, const PxReal, PxReal > Penetration;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_Restitution, PxContactJoint, const PxReal, PxReal > Restitution;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_BounceThreshold, PxContactJoint, const PxReal, PxReal > BounceThreshold;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_ConcreteTypeName, PxContactJoint, const char * > ConcreteTypeName;
PxContactJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxContactJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 6; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Contact, inStartIndex + 0 );;
inOperator( ContactNormal, inStartIndex + 1 );;
inOperator( Penetration, inStartIndex + 2 );;
inOperator( Restitution, inStartIndex + 3 );;
inOperator( BounceThreshold, inStartIndex + 4 );;
inOperator( ConcreteTypeName, inStartIndex + 5 );;
return 6 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxContactJoint>
{
PxContactJointGeneratedInfo Info;
const PxContactJointGeneratedInfo* getInfo() { return &Info; }
};
class PxFixedJoint;
struct PxFixedJointGeneratedValues
: PxJointGeneratedValues {
const char * ConcreteTypeName;
PxFixedJointGeneratedValues( const PxFixedJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFixedJoint, ConcreteTypeName, PxFixedJointGeneratedValues)
struct PxFixedJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxFixedJoint"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxFixedJoint_ConcreteTypeName, PxFixedJoint, const char * > ConcreteTypeName;
PxFixedJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxFixedJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( ConcreteTypeName, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxFixedJoint>
{
PxFixedJointGeneratedInfo Info;
const PxFixedJointGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxPrismaticJointFlag__EnumConversion[] = {
{ "eLIMIT_ENABLED", static_cast<PxU32>( physx::PxPrismaticJointFlag::eLIMIT_ENABLED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxPrismaticJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxPrismaticJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxPrismaticJoint;
struct PxPrismaticJointGeneratedValues
: PxJointGeneratedValues {
PxReal Position;
PxReal Velocity;
PxJointLinearLimitPair Limit;
PxPrismaticJointFlags PrismaticJointFlags;
const char * ConcreteTypeName;
PxPrismaticJointGeneratedValues( const PxPrismaticJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, Position, PxPrismaticJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, Velocity, PxPrismaticJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, Limit, PxPrismaticJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, PrismaticJointFlags, PxPrismaticJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, ConcreteTypeName, PxPrismaticJointGeneratedValues)
struct PxPrismaticJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxPrismaticJoint"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_Position, PxPrismaticJoint, PxReal > Position;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_Velocity, PxPrismaticJoint, PxReal > Velocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_Limit, PxPrismaticJoint, const PxJointLinearLimitPair &, PxJointLinearLimitPair > Limit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_PrismaticJointFlags, PxPrismaticJoint, PxPrismaticJointFlags, PxPrismaticJointFlags > PrismaticJointFlags;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_ConcreteTypeName, PxPrismaticJoint, const char * > ConcreteTypeName;
PxPrismaticJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxPrismaticJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 5; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Position, inStartIndex + 0 );;
inOperator( Velocity, inStartIndex + 1 );;
inOperator( Limit, inStartIndex + 2 );;
inOperator( PrismaticJointFlags, inStartIndex + 3 );;
inOperator( ConcreteTypeName, inStartIndex + 4 );;
return 5 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxPrismaticJoint>
{
PxPrismaticJointGeneratedInfo Info;
const PxPrismaticJointGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxRevoluteJointFlag__EnumConversion[] = {
{ "eLIMIT_ENABLED", static_cast<PxU32>( physx::PxRevoluteJointFlag::eLIMIT_ENABLED ) },
{ "eDRIVE_ENABLED", static_cast<PxU32>( physx::PxRevoluteJointFlag::eDRIVE_ENABLED ) },
{ "eDRIVE_FREESPIN", static_cast<PxU32>( physx::PxRevoluteJointFlag::eDRIVE_FREESPIN ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxRevoluteJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxRevoluteJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxRevoluteJoint;
struct PxRevoluteJointGeneratedValues
: PxJointGeneratedValues {
PxReal Angle;
PxReal Velocity;
PxJointAngularLimitPair Limit;
PxReal DriveVelocity;
PxReal DriveForceLimit;
PxReal DriveGearRatio;
PxRevoluteJointFlags RevoluteJointFlags;
const char * ConcreteTypeName;
PxRevoluteJointGeneratedValues( const PxRevoluteJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, Angle, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, Velocity, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, Limit, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, DriveVelocity, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, DriveForceLimit, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, DriveGearRatio, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, RevoluteJointFlags, PxRevoluteJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, ConcreteTypeName, PxRevoluteJointGeneratedValues)
struct PxRevoluteJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxRevoluteJoint"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_Angle, PxRevoluteJoint, PxReal > Angle;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_Velocity, PxRevoluteJoint, PxReal > Velocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_Limit, PxRevoluteJoint, const PxJointAngularLimitPair &, PxJointAngularLimitPair > Limit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_DriveVelocity, PxRevoluteJoint, PxReal, PxReal > DriveVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_DriveForceLimit, PxRevoluteJoint, PxReal, PxReal > DriveForceLimit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_DriveGearRatio, PxRevoluteJoint, PxReal, PxReal > DriveGearRatio;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_RevoluteJointFlags, PxRevoluteJoint, PxRevoluteJointFlags, PxRevoluteJointFlags > RevoluteJointFlags;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_ConcreteTypeName, PxRevoluteJoint, const char * > ConcreteTypeName;
PxRevoluteJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRevoluteJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 8; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Angle, inStartIndex + 0 );;
inOperator( Velocity, inStartIndex + 1 );;
inOperator( Limit, inStartIndex + 2 );;
inOperator( DriveVelocity, inStartIndex + 3 );;
inOperator( DriveForceLimit, inStartIndex + 4 );;
inOperator( DriveGearRatio, inStartIndex + 5 );;
inOperator( RevoluteJointFlags, inStartIndex + 6 );;
inOperator( ConcreteTypeName, inStartIndex + 7 );;
return 8 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRevoluteJoint>
{
PxRevoluteJointGeneratedInfo Info;
const PxRevoluteJointGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxSphericalJointFlag__EnumConversion[] = {
{ "eLIMIT_ENABLED", static_cast<PxU32>( physx::PxSphericalJointFlag::eLIMIT_ENABLED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxSphericalJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSphericalJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxSphericalJoint;
struct PxSphericalJointGeneratedValues
: PxJointGeneratedValues {
PxJointLimitCone LimitCone;
PxReal SwingYAngle;
PxReal SwingZAngle;
PxSphericalJointFlags SphericalJointFlags;
const char * ConcreteTypeName;
PxSphericalJointGeneratedValues( const PxSphericalJoint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, LimitCone, PxSphericalJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, SwingYAngle, PxSphericalJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, SwingZAngle, PxSphericalJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, SphericalJointFlags, PxSphericalJointGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, ConcreteTypeName, PxSphericalJointGeneratedValues)
struct PxSphericalJointGeneratedInfo
: PxJointGeneratedInfo
{
static const char* getClassName() { return "PxSphericalJoint"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_LimitCone, PxSphericalJoint, const PxJointLimitCone &, PxJointLimitCone > LimitCone;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_SwingYAngle, PxSphericalJoint, PxReal > SwingYAngle;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_SwingZAngle, PxSphericalJoint, PxReal > SwingZAngle;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_SphericalJointFlags, PxSphericalJoint, PxSphericalJointFlags, PxSphericalJointFlags > SphericalJointFlags;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_ConcreteTypeName, PxSphericalJoint, const char * > ConcreteTypeName;
PxSphericalJointGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSphericalJoint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 5; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( LimitCone, inStartIndex + 0 );;
inOperator( SwingYAngle, inStartIndex + 1 );;
inOperator( SwingZAngle, inStartIndex + 2 );;
inOperator( SphericalJointFlags, inStartIndex + 3 );;
inOperator( ConcreteTypeName, inStartIndex + 4 );;
return 5 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSphericalJoint>
{
PxSphericalJointGeneratedInfo Info;
const PxSphericalJointGeneratedInfo* getInfo() { return &Info; }
};
class PxJointLimitParameters;
struct PxJointLimitParametersGeneratedValues
{
PxReal Restitution;
PxReal BounceThreshold;
PxReal Stiffness;
PxReal Damping;
PxJointLimitParametersGeneratedValues( const PxJointLimitParameters* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, Restitution, PxJointLimitParametersGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, BounceThreshold, PxJointLimitParametersGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, Stiffness, PxJointLimitParametersGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, Damping, PxJointLimitParametersGeneratedValues)
struct PxJointLimitParametersGeneratedInfo
{
static const char* getClassName() { return "PxJointLimitParameters"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_Restitution, PxJointLimitParameters, PxReal, PxReal > Restitution;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_BounceThreshold, PxJointLimitParameters, PxReal, PxReal > BounceThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_Stiffness, PxJointLimitParameters, PxReal, PxReal > Stiffness;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_Damping, PxJointLimitParameters, PxReal, PxReal > Damping;
PxJointLimitParametersGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJointLimitParameters*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 4; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Restitution, inStartIndex + 0 );;
inOperator( BounceThreshold, inStartIndex + 1 );;
inOperator( Stiffness, inStartIndex + 2 );;
inOperator( Damping, inStartIndex + 3 );;
return 4 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJointLimitParameters>
{
PxJointLimitParametersGeneratedInfo Info;
const PxJointLimitParametersGeneratedInfo* getInfo() { return &Info; }
};
class PxJointLinearLimit;
struct PxJointLinearLimitGeneratedValues
: PxJointLimitParametersGeneratedValues {
PxReal Value;
PxJointLinearLimitGeneratedValues( const PxJointLinearLimit* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLinearLimit, Value, PxJointLinearLimitGeneratedValues)
struct PxJointLinearLimitGeneratedInfo
: PxJointLimitParametersGeneratedInfo
{
static const char* getClassName() { return "PxJointLinearLimit"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLinearLimit_Value, PxJointLinearLimit, PxReal, PxReal > Value;
PxJointLinearLimitGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJointLinearLimit*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointLimitParametersGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Value, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJointLinearLimit>
{
PxJointLinearLimitGeneratedInfo Info;
const PxJointLinearLimitGeneratedInfo* getInfo() { return &Info; }
};
class PxJointLinearLimitPair;
struct PxJointLinearLimitPairGeneratedValues
: PxJointLimitParametersGeneratedValues {
PxReal Upper;
PxReal Lower;
PxJointLinearLimitPairGeneratedValues( const PxJointLinearLimitPair* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLinearLimitPair, Upper, PxJointLinearLimitPairGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLinearLimitPair, Lower, PxJointLinearLimitPairGeneratedValues)
struct PxJointLinearLimitPairGeneratedInfo
: PxJointLimitParametersGeneratedInfo
{
static const char* getClassName() { return "PxJointLinearLimitPair"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLinearLimitPair_Upper, PxJointLinearLimitPair, PxReal, PxReal > Upper;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLinearLimitPair_Lower, PxJointLinearLimitPair, PxReal, PxReal > Lower;
PxJointLinearLimitPairGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJointLinearLimitPair*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointLimitParametersGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Upper, inStartIndex + 0 );;
inOperator( Lower, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJointLinearLimitPair>
{
PxJointLinearLimitPairGeneratedInfo Info;
const PxJointLinearLimitPairGeneratedInfo* getInfo() { return &Info; }
};
class PxJointAngularLimitPair;
struct PxJointAngularLimitPairGeneratedValues
: PxJointLimitParametersGeneratedValues {
PxReal Upper;
PxReal Lower;
PxJointAngularLimitPairGeneratedValues( const PxJointAngularLimitPair* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointAngularLimitPair, Upper, PxJointAngularLimitPairGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointAngularLimitPair, Lower, PxJointAngularLimitPairGeneratedValues)
struct PxJointAngularLimitPairGeneratedInfo
: PxJointLimitParametersGeneratedInfo
{
static const char* getClassName() { return "PxJointAngularLimitPair"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointAngularLimitPair_Upper, PxJointAngularLimitPair, PxReal, PxReal > Upper;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointAngularLimitPair_Lower, PxJointAngularLimitPair, PxReal, PxReal > Lower;
PxJointAngularLimitPairGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJointAngularLimitPair*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointLimitParametersGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Upper, inStartIndex + 0 );;
inOperator( Lower, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJointAngularLimitPair>
{
PxJointAngularLimitPairGeneratedInfo Info;
const PxJointAngularLimitPairGeneratedInfo* getInfo() { return &Info; }
};
class PxJointLimitCone;
struct PxJointLimitConeGeneratedValues
: PxJointLimitParametersGeneratedValues {
PxReal YAngle;
PxReal ZAngle;
PxJointLimitConeGeneratedValues( const PxJointLimitCone* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitCone, YAngle, PxJointLimitConeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitCone, ZAngle, PxJointLimitConeGeneratedValues)
struct PxJointLimitConeGeneratedInfo
: PxJointLimitParametersGeneratedInfo
{
static const char* getClassName() { return "PxJointLimitCone"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitCone_YAngle, PxJointLimitCone, PxReal, PxReal > YAngle;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitCone_ZAngle, PxJointLimitCone, PxReal, PxReal > ZAngle;
PxJointLimitConeGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJointLimitCone*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointLimitParametersGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( YAngle, inStartIndex + 0 );;
inOperator( ZAngle, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJointLimitCone>
{
PxJointLimitConeGeneratedInfo Info;
const PxJointLimitConeGeneratedInfo* getInfo() { return &Info; }
};
class PxJointLimitPyramid;
struct PxJointLimitPyramidGeneratedValues
: PxJointLimitParametersGeneratedValues {
PxReal YAngleMin;
PxReal YAngleMax;
PxReal ZAngleMin;
PxReal ZAngleMax;
PxJointLimitPyramidGeneratedValues( const PxJointLimitPyramid* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, YAngleMin, PxJointLimitPyramidGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, YAngleMax, PxJointLimitPyramidGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, ZAngleMin, PxJointLimitPyramidGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, ZAngleMax, PxJointLimitPyramidGeneratedValues)
struct PxJointLimitPyramidGeneratedInfo
: PxJointLimitParametersGeneratedInfo
{
static const char* getClassName() { return "PxJointLimitPyramid"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_YAngleMin, PxJointLimitPyramid, PxReal, PxReal > YAngleMin;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_YAngleMax, PxJointLimitPyramid, PxReal, PxReal > YAngleMax;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_ZAngleMin, PxJointLimitPyramid, PxReal, PxReal > ZAngleMin;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_ZAngleMax, PxJointLimitPyramid, PxReal, PxReal > ZAngleMax;
PxJointLimitPyramidGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxJointLimitPyramid*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 4; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxJointLimitParametersGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( YAngleMin, inStartIndex + 0 );;
inOperator( YAngleMax, inStartIndex + 1 );;
inOperator( ZAngleMin, inStartIndex + 2 );;
inOperator( ZAngleMax, inStartIndex + 3 );;
return 4 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxJointLimitPyramid>
{
PxJointLimitPyramidGeneratedInfo Info;
const PxJointLimitPyramidGeneratedInfo* getInfo() { return &Info; }
};
class PxSpring;
struct PxSpringGeneratedValues
{
PxReal Stiffness;
PxReal Damping;
PxSpringGeneratedValues( const PxSpring* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSpring, Stiffness, PxSpringGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSpring, Damping, PxSpringGeneratedValues)
struct PxSpringGeneratedInfo
{
static const char* getClassName() { return "PxSpring"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSpring_Stiffness, PxSpring, PxReal, PxReal > Stiffness;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSpring_Damping, PxSpring, PxReal, PxReal > Damping;
PxSpringGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSpring*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Stiffness, inStartIndex + 0 );;
inOperator( Damping, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSpring>
{
PxSpringGeneratedInfo Info;
const PxSpringGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxD6JointDriveFlag__EnumConversion[] = {
{ "eACCELERATION", static_cast<PxU32>( physx::PxD6JointDriveFlag::eACCELERATION ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxD6JointDriveFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6JointDriveFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxD6JointDrive;
struct PxD6JointDriveGeneratedValues
: PxSpringGeneratedValues {
PxReal ForceLimit;
PxD6JointDriveFlags Flags;
PxD6JointDriveGeneratedValues( const PxD6JointDrive* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6JointDrive, ForceLimit, PxD6JointDriveGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6JointDrive, Flags, PxD6JointDriveGeneratedValues)
struct PxD6JointDriveGeneratedInfo
: PxSpringGeneratedInfo
{
static const char* getClassName() { return "PxD6JointDrive"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6JointDrive_ForceLimit, PxD6JointDrive, PxReal, PxReal > ForceLimit;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6JointDrive_Flags, PxD6JointDrive, PxD6JointDriveFlags, PxD6JointDriveFlags > Flags;
PxD6JointDriveGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxD6JointDrive*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxSpringGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxSpringGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxSpringGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxSpringGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( ForceLimit, inStartIndex + 0 );;
inOperator( Flags, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxD6JointDrive>
{
PxD6JointDriveGeneratedInfo Info;
const PxD6JointDriveGeneratedInfo* getInfo() { return &Info; }
};
#undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
#undef PX_PROPERTY_INFO_NAME
| 59,955 | C | 45.08455 | 192 | 0.780252 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/include/PxExtensionMetaDataObjects.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_EXTENSION_METADATAOBJECTS_H
#define PX_EXTENSION_METADATAOBJECTS_H
#include "PxPhysicsAPI.h"
#include "extensions/PxExtensionsAPI.h"
#include "PxMetaDataObjects.h"
/** \addtogroup physics
@{
*/
namespace physx
{
class PxD6Joint;
class PxJointLimitCone;
struct PxExtensionsPropertyInfoName
{
enum Enum
{
Unnamed = PxPropertyInfoName::LastPxPropertyInfoName,
#include "PxExtensionAutoGeneratedMetaDataObjectNames.h"
LastPxPropertyInfoName
};
};
#define DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( type, prop, valueStruct ) \
template<> struct PxPropertyToValueStructMemberMap< PxExtensionsPropertyInfoName::type##_##prop > \
{ \
PxU32 Offset; \
PxPropertyToValueStructMemberMap< PxExtensionsPropertyInfoName::type##_##prop >() : Offset( PX_OFFSET_OF_RT( valueStruct, prop ) ) {} \
template<typename TOperator> void visitProp( TOperator inOperator, valueStruct& inStruct ) { inOperator( inStruct.prop ); } \
};
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
#include "PxExtensionAutoGeneratedMetaDataObjects.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic pop
#endif
#undef DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP
}
/** @} */
#endif
| 3,022 | C | 37.75641 | 137 | 0.742886 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/include/PxExtensionAutoGeneratedMetaDataObjectNames.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be
// prepared for your edits to be quietly ignored next time the clang metadata generator is
// run. You can find the most recent version of clang metadata generator by contacting
// Chris Nuernberger <[email protected]> or Dilip or Adam.
// The source code for the generate was at one time checked into:
// physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp
#define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
PxJoint_PropertiesStart,
PxJoint_Actors,
PxJoint_LocalPose,
PxJoint_RelativeTransform,
PxJoint_RelativeLinearVelocity,
PxJoint_RelativeAngularVelocity,
PxJoint_BreakForce,
PxJoint_ConstraintFlags,
PxJoint_InvMassScale0,
PxJoint_InvInertiaScale0,
PxJoint_InvMassScale1,
PxJoint_InvInertiaScale1,
PxJoint_Constraint,
PxJoint_Name,
PxJoint_Scene,
PxJoint_UserData,
PxJoint_PropertiesStop,
PxRackAndPinionJoint_PropertiesStart,
PxRackAndPinionJoint_Ratio,
PxRackAndPinionJoint_ConcreteTypeName,
PxRackAndPinionJoint_PropertiesStop,
PxGearJoint_PropertiesStart,
PxGearJoint_GearRatio,
PxGearJoint_ConcreteTypeName,
PxGearJoint_PropertiesStop,
PxD6Joint_PropertiesStart,
PxD6Joint_Motion,
PxD6Joint_TwistAngle,
PxD6Joint_Twist,
PxD6Joint_SwingYAngle,
PxD6Joint_SwingZAngle,
PxD6Joint_DistanceLimit,
PxD6Joint_LinearLimit,
PxD6Joint_TwistLimit,
PxD6Joint_SwingLimit,
PxD6Joint_PyramidSwingLimit,
PxD6Joint_Drive,
PxD6Joint_DrivePosition,
PxD6Joint_ConcreteTypeName,
PxD6Joint_PropertiesStop,
PxDistanceJoint_PropertiesStart,
PxDistanceJoint_Distance,
PxDistanceJoint_MinDistance,
PxDistanceJoint_MaxDistance,
PxDistanceJoint_Tolerance,
PxDistanceJoint_Stiffness,
PxDistanceJoint_Damping,
PxDistanceJoint_DistanceJointFlags,
PxDistanceJoint_ConcreteTypeName,
PxDistanceJoint_PropertiesStop,
PxContactJoint_PropertiesStart,
PxContactJoint_Contact,
PxContactJoint_ContactNormal,
PxContactJoint_Penetration,
PxContactJoint_Restitution,
PxContactJoint_BounceThreshold,
PxContactJoint_ConcreteTypeName,
PxContactJoint_PropertiesStop,
PxFixedJoint_PropertiesStart,
PxFixedJoint_ConcreteTypeName,
PxFixedJoint_PropertiesStop,
PxPrismaticJoint_PropertiesStart,
PxPrismaticJoint_Position,
PxPrismaticJoint_Velocity,
PxPrismaticJoint_Limit,
PxPrismaticJoint_PrismaticJointFlags,
PxPrismaticJoint_ConcreteTypeName,
PxPrismaticJoint_PropertiesStop,
PxRevoluteJoint_PropertiesStart,
PxRevoluteJoint_Angle,
PxRevoluteJoint_Velocity,
PxRevoluteJoint_Limit,
PxRevoluteJoint_DriveVelocity,
PxRevoluteJoint_DriveForceLimit,
PxRevoluteJoint_DriveGearRatio,
PxRevoluteJoint_RevoluteJointFlags,
PxRevoluteJoint_ConcreteTypeName,
PxRevoluteJoint_PropertiesStop,
PxSphericalJoint_PropertiesStart,
PxSphericalJoint_LimitCone,
PxSphericalJoint_SwingYAngle,
PxSphericalJoint_SwingZAngle,
PxSphericalJoint_SphericalJointFlags,
PxSphericalJoint_ConcreteTypeName,
PxSphericalJoint_PropertiesStop,
PxJointLimitParameters_PropertiesStart,
PxJointLimitParameters_Restitution,
PxJointLimitParameters_BounceThreshold,
PxJointLimitParameters_Stiffness,
PxJointLimitParameters_Damping,
PxJointLimitParameters_PropertiesStop,
PxJointLinearLimit_PropertiesStart,
PxJointLinearLimit_Value,
PxJointLinearLimit_PropertiesStop,
PxJointLinearLimitPair_PropertiesStart,
PxJointLinearLimitPair_Upper,
PxJointLinearLimitPair_Lower,
PxJointLinearLimitPair_PropertiesStop,
PxJointAngularLimitPair_PropertiesStart,
PxJointAngularLimitPair_Upper,
PxJointAngularLimitPair_Lower,
PxJointAngularLimitPair_PropertiesStop,
PxJointLimitCone_PropertiesStart,
PxJointLimitCone_YAngle,
PxJointLimitCone_ZAngle,
PxJointLimitCone_PropertiesStop,
PxJointLimitPyramid_PropertiesStart,
PxJointLimitPyramid_YAngleMin,
PxJointLimitPyramid_YAngleMax,
PxJointLimitPyramid_ZAngleMin,
PxJointLimitPyramid_ZAngleMax,
PxJointLimitPyramid_PropertiesStop,
PxSpring_PropertiesStart,
PxSpring_Stiffness,
PxSpring_Damping,
PxSpring_PropertiesStop,
PxD6JointDrive_PropertiesStart,
PxD6JointDrive_ForceLimit,
PxD6JointDrive_Flags,
PxD6JointDrive_PropertiesStop,
#undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
| 5,756 | C | 34.98125 | 90 | 0.846942 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/src/PxMetaDataObjects.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxUtilities.h"
#include "foundation/PxFoundation.h"
#include "foundation/PxErrors.h"
#include "PxMetaDataObjects.h"
using namespace physx;
namespace {
template<class T>
PX_FORCE_INLINE bool getGeometryT(PxGeometryType::Enum type, const PxShape* inShape, T& geom)
{
const PxGeometry& inGeometry = inShape->getGeometry();
if(inShape == NULL || inGeometry.getType() != type)
return false;
geom = static_cast<const T&>(inGeometry);
return true;
}
}
PX_PHYSX_CORE_API PxGeometryType::Enum PxShapeGeomPropertyHelper::getGeometryType(const PxShape* inShape) const { return inShape->getGeometry().getType(); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxBoxGeometry& geometry) const { return getGeometryT(PxGeometryType::eBOX, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxSphereGeometry& geometry) const { return getGeometryT(PxGeometryType::eSPHERE, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxCapsuleGeometry& geometry) const { return getGeometryT(PxGeometryType::eCAPSULE, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxPlaneGeometry& geometry) const { return getGeometryT(PxGeometryType::ePLANE, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxConvexMeshGeometry& geometry) const { return getGeometryT(PxGeometryType::eCONVEXMESH, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxTetrahedronMeshGeometry& geometry) const { return getGeometryT(PxGeometryType::eTETRAHEDRONMESH, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxParticleSystemGeometry& geometry) const { return getGeometryT(PxGeometryType::ePARTICLESYSTEM, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxTriangleMeshGeometry& geometry) const { return getGeometryT(PxGeometryType::eTRIANGLEMESH, inShape, geometry); }
PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxHeightFieldGeometry& geometry) const { return getGeometryT(PxGeometryType::eHEIGHTFIELD, inShape, geometry); }
PX_PHYSX_CORE_API void PxShapeMaterialsPropertyHelper::setMaterials(PxShape* inShape, PxMaterial*const* materials, PxU16 materialCount) const
{
inShape->setMaterials( materials, materialCount );
}
PX_PHYSX_CORE_API PxShape* PxRigidActorShapeCollectionHelper::createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial& material,
PxShapeFlags shapeFlags ) const
{
PxMaterial* materialPtr = const_cast<PxMaterial*>(&material);
PxShape* shape = PxGetPhysics().createShape(geometry, &materialPtr, 1, true, shapeFlags);
if (shape)
{
inActor->attachShape(*shape); // attach can fail, if e.g. we try and attach a trimesh simulation shape to a dynamic actor
shape->release(); // if attach fails, we hold the only counted reference, and so this cleans up properly
}
return shape;
}
PX_PHYSX_CORE_API PxShape* PxRigidActorShapeCollectionHelper::createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial *const* materials,
PxU16 materialCount, PxShapeFlags shapeFlags ) const
{
PxShape* shape = PxGetPhysics().createShape(geometry, materials, materialCount, true, shapeFlags);
if (shape)
{
inActor->attachShape(*shape); // attach can fail, if e.g. we try and attach a trimesh simulation shape to a dynamic actor
shape->release(); // if attach fails, we hold the only counted reference, and so this cleans up properly
}
return shape;
}
PX_PHYSX_CORE_API PxArticulationLink* PxArticulationReducedCoordinateLinkCollectionPropHelper::createLink(PxArticulationReducedCoordinate* inArticulation, PxArticulationLink* parent,
const PxTransform& pose) const
{
PX_CHECK_AND_RETURN_NULL(pose.isValid(), "PxArticulationReducedCoordinateLinkCollectionPropHelper::createLink pose is not valid.");
return inArticulation->createLink(parent, pose );
}
inline void SetNbShape( PxSimulationStatistics* inStats, PxGeometryType::Enum data, PxU32 val ) { inStats->nbShapes[data] = val; }
inline PxU32 GetNbShape( const PxSimulationStatistics* inStats, PxGeometryType::Enum data) { return inStats->nbShapes[data]; }
PX_PHYSX_CORE_API NbShapesProperty::NbShapesProperty()
: PxIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbShapes
, PxSimulationStatistics
, PxGeometryType::Enum
, PxU32> ( "NbShapes", SetNbShape, GetNbShape )
{
}
inline void SetNbDiscreteContactPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbDiscreteContactPairs[idx1][idx2] = val; }
inline PxU32 GetNbDiscreteContactPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbDiscreteContactPairs[idx1][idx2]; }
PX_PHYSX_CORE_API NbDiscreteContactPairsProperty::NbDiscreteContactPairsProperty()
: PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbDiscreteContactPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32> ( "NbDiscreteContactPairs", SetNbDiscreteContactPairs, GetNbDiscreteContactPairs )
{
}
inline void SetNbModifiedContactPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbModifiedContactPairs[idx1][idx2] = val; }
inline PxU32 GetNbModifiedContactPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbModifiedContactPairs[idx1][idx2]; }
PX_PHYSX_CORE_API NbModifiedContactPairsProperty::NbModifiedContactPairsProperty()
: PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbModifiedContactPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32> ( "NbModifiedContactPairs", SetNbModifiedContactPairs, GetNbModifiedContactPairs )
{
}
inline void SetNbCCDPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbCCDPairs[idx1][idx2] = val; }
inline PxU32 GetNbCCDPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbCCDPairs[idx1][idx2]; }
PX_PHYSX_CORE_API NbCCDPairsProperty::NbCCDPairsProperty()
: PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbCCDPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32> ( "NbCCDPairs", SetNbCCDPairs, GetNbCCDPairs )
{
}
inline void SetNbTriggerPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbTriggerPairs[idx1][idx2] = val; }
inline PxU32 GetNbTriggerPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbTriggerPairs[idx1][idx2]; }
PX_PHYSX_CORE_API NbTriggerPairsProperty::NbTriggerPairsProperty()
: PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbTriggerPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32> ( "NbTriggerPairs", SetNbTriggerPairs, GetNbTriggerPairs )
{
}
inline PxSimulationStatistics GetStats( const PxScene* inScene ) { PxSimulationStatistics stats; inScene->getSimulationStatistics( stats ); return stats; }
PX_PHYSX_CORE_API SimulationStatisticsProperty::SimulationStatisticsProperty()
: PxReadOnlyPropertyInfo<PxPropertyInfoName::PxScene_SimulationStatistics, PxScene, PxSimulationStatistics >( "SimulationStatistics", GetStats )
{
}
inline PxU32 GetCustomType(const PxCustomGeometry* inGeom) { PxCustomGeometry::Type t = inGeom->callbacks->getCustomType(); return *reinterpret_cast<const PxU32*>(&t); }
PX_PHYSX_CORE_API PxCustomGeometryCustomTypeProperty::PxCustomGeometryCustomTypeProperty()
: PxReadOnlyPropertyInfo<PxPropertyInfoName::PxCustomGeometry_CustomType, PxCustomGeometry, PxU32 >("CustomType", GetCustomType)
{
}
| 10,195 | C++ | 58.625731 | 206 | 0.777146 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/src/PxAutoGeneratedMetaDataObjects.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be
// prepared for your edits to be quietly ignored next time the clang metadata generator is
// run. You can find the most recent version of clang metadata generator by contacting
// Chris Nuernberger <[email protected]> or Dilip or Adam.
// The source code for the generate was at one time checked into:
// physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp
#include "foundation/PxPreprocessor.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
#include "PxMetaDataObjects.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic pop
#endif
#include "PxMetaDataCppPrefix.h"
using namespace physx;
const PxTolerancesScale getPxPhysics_TolerancesScale( const PxPhysics* inObj ) { return inObj->getTolerancesScale(); }
PxU32 getPxPhysics_TriangleMeshes( const PxPhysics* inObj, PxTriangleMesh ** outBuffer, PxU32 inBufSize ) { return inObj->getTriangleMeshes( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_TriangleMeshes( const PxPhysics* inObj ) { return inObj->getNbTriangleMeshes( ); }
PxTriangleMesh * createPxPhysics_TriangleMeshes( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createTriangleMesh( inCreateParam ); }
PxU32 getPxPhysics_TetrahedronMeshes( const PxPhysics* inObj, PxTetrahedronMesh ** outBuffer, PxU32 inBufSize ) { return inObj->getTetrahedronMeshes( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_TetrahedronMeshes( const PxPhysics* inObj ) { return inObj->getNbTetrahedronMeshes( ); }
PxTetrahedronMesh * createPxPhysics_TetrahedronMeshes( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createTetrahedronMesh( inCreateParam ); }
PxU32 getPxPhysics_HeightFields( const PxPhysics* inObj, PxHeightField ** outBuffer, PxU32 inBufSize ) { return inObj->getHeightFields( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_HeightFields( const PxPhysics* inObj ) { return inObj->getNbHeightFields( ); }
PxHeightField * createPxPhysics_HeightFields( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createHeightField( inCreateParam ); }
PxU32 getPxPhysics_ConvexMeshes( const PxPhysics* inObj, PxConvexMesh ** outBuffer, PxU32 inBufSize ) { return inObj->getConvexMeshes( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_ConvexMeshes( const PxPhysics* inObj ) { return inObj->getNbConvexMeshes( ); }
PxConvexMesh * createPxPhysics_ConvexMeshes( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createConvexMesh( inCreateParam ); }
PxU32 getPxPhysics_BVHs( const PxPhysics* inObj, PxBVH ** outBuffer, PxU32 inBufSize ) { return inObj->getBVHs( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_BVHs( const PxPhysics* inObj ) { return inObj->getNbBVHs( ); }
PxBVH * createPxPhysics_BVHs( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createBVH( inCreateParam ); }
PxU32 getPxPhysics_Scenes( const PxPhysics* inObj, PxScene ** outBuffer, PxU32 inBufSize ) { return inObj->getScenes( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_Scenes( const PxPhysics* inObj ) { return inObj->getNbScenes( ); }
PxScene * createPxPhysics_Scenes( PxPhysics* inObj, const PxSceneDesc & inCreateParam ){ return inObj->createScene( inCreateParam ); }
PxU32 getPxPhysics_Shapes( const PxPhysics* inObj, PxShape ** outBuffer, PxU32 inBufSize ) { return inObj->getShapes( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_Shapes( const PxPhysics* inObj ) { return inObj->getNbShapes( ); }
PxU32 getPxPhysics_Materials( const PxPhysics* inObj, PxMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getMaterials( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_Materials( const PxPhysics* inObj ) { return inObj->getNbMaterials( ); }
PxU32 getPxPhysics_FEMSoftBodyMaterials( const PxPhysics* inObj, PxFEMSoftBodyMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getFEMSoftBodyMaterials( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_FEMSoftBodyMaterials( const PxPhysics* inObj ) { return inObj->getNbFEMSoftBodyMaterials( ); }
PxU32 getPxPhysics_FEMClothMaterials( const PxPhysics* inObj, PxFEMClothMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getFEMClothMaterials( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_FEMClothMaterials( const PxPhysics* inObj ) { return inObj->getNbFEMClothMaterials( ); }
PxU32 getPxPhysics_PBDMaterials( const PxPhysics* inObj, PxPBDMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getPBDMaterials( outBuffer, inBufSize ); }
PxU32 getNbPxPhysics_PBDMaterials( const PxPhysics* inObj ) { return inObj->getNbPBDMaterials( ); }
PX_PHYSX_CORE_API PxPhysicsGeneratedInfo::PxPhysicsGeneratedInfo()
: TolerancesScale( "TolerancesScale", getPxPhysics_TolerancesScale)
, TriangleMeshes( "TriangleMeshes", getPxPhysics_TriangleMeshes, getNbPxPhysics_TriangleMeshes, createPxPhysics_TriangleMeshes )
, TetrahedronMeshes( "TetrahedronMeshes", getPxPhysics_TetrahedronMeshes, getNbPxPhysics_TetrahedronMeshes, createPxPhysics_TetrahedronMeshes )
, HeightFields( "HeightFields", getPxPhysics_HeightFields, getNbPxPhysics_HeightFields, createPxPhysics_HeightFields )
, ConvexMeshes( "ConvexMeshes", getPxPhysics_ConvexMeshes, getNbPxPhysics_ConvexMeshes, createPxPhysics_ConvexMeshes )
, BVHs( "BVHs", getPxPhysics_BVHs, getNbPxPhysics_BVHs, createPxPhysics_BVHs )
, Scenes( "Scenes", getPxPhysics_Scenes, getNbPxPhysics_Scenes, createPxPhysics_Scenes )
, Shapes( "Shapes", getPxPhysics_Shapes, getNbPxPhysics_Shapes )
, Materials( "Materials", getPxPhysics_Materials, getNbPxPhysics_Materials )
, FEMSoftBodyMaterials( "FEMSoftBodyMaterials", getPxPhysics_FEMSoftBodyMaterials, getNbPxPhysics_FEMSoftBodyMaterials )
, FEMClothMaterials( "FEMClothMaterials", getPxPhysics_FEMClothMaterials, getNbPxPhysics_FEMClothMaterials )
, PBDMaterials( "PBDMaterials", getPxPhysics_PBDMaterials, getNbPxPhysics_PBDMaterials )
{}
PX_PHYSX_CORE_API PxPhysicsGeneratedValues::PxPhysicsGeneratedValues( const PxPhysics* inSource )
:TolerancesScale( getPxPhysics_TolerancesScale( inSource ) )
{
PX_UNUSED(inSource);
}
PxU32 getPxRefCounted_ReferenceCount( const PxRefCounted* inObj ) { return inObj->getReferenceCount(); }
PX_PHYSX_CORE_API PxRefCountedGeneratedInfo::PxRefCountedGeneratedInfo()
: ReferenceCount( "ReferenceCount", getPxRefCounted_ReferenceCount)
{}
PX_PHYSX_CORE_API PxRefCountedGeneratedValues::PxRefCountedGeneratedValues( const PxRefCounted* inSource )
:ReferenceCount( getPxRefCounted_ReferenceCount( inSource ) )
{
PX_UNUSED(inSource);
}
inline void * getPxBaseMaterialUserData( const PxBaseMaterial* inOwner ) { return inOwner->userData; }
inline void setPxBaseMaterialUserData( PxBaseMaterial* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxBaseMaterialGeneratedInfo::PxBaseMaterialGeneratedInfo()
: UserData( "UserData", setPxBaseMaterialUserData, getPxBaseMaterialUserData )
{}
PX_PHYSX_CORE_API PxBaseMaterialGeneratedValues::PxBaseMaterialGeneratedValues( const PxBaseMaterial* inSource )
:PxRefCountedGeneratedValues( inSource )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
}
void setPxMaterial_DynamicFriction( PxMaterial* inObj, PxReal inArg){ inObj->setDynamicFriction( inArg ); }
PxReal getPxMaterial_DynamicFriction( const PxMaterial* inObj ) { return inObj->getDynamicFriction(); }
void setPxMaterial_StaticFriction( PxMaterial* inObj, PxReal inArg){ inObj->setStaticFriction( inArg ); }
PxReal getPxMaterial_StaticFriction( const PxMaterial* inObj ) { return inObj->getStaticFriction(); }
void setPxMaterial_Restitution( PxMaterial* inObj, PxReal inArg){ inObj->setRestitution( inArg ); }
PxReal getPxMaterial_Restitution( const PxMaterial* inObj ) { return inObj->getRestitution(); }
void setPxMaterial_Damping( PxMaterial* inObj, PxReal inArg){ inObj->setDamping( inArg ); }
PxReal getPxMaterial_Damping( const PxMaterial* inObj ) { return inObj->getDamping(); }
void setPxMaterial_Flags( PxMaterial* inObj, PxMaterialFlags inArg){ inObj->setFlags( inArg ); }
PxMaterialFlags getPxMaterial_Flags( const PxMaterial* inObj ) { return inObj->getFlags(); }
void setPxMaterial_FrictionCombineMode( PxMaterial* inObj, PxCombineMode::Enum inArg){ inObj->setFrictionCombineMode( inArg ); }
PxCombineMode::Enum getPxMaterial_FrictionCombineMode( const PxMaterial* inObj ) { return inObj->getFrictionCombineMode(); }
void setPxMaterial_RestitutionCombineMode( PxMaterial* inObj, PxCombineMode::Enum inArg){ inObj->setRestitutionCombineMode( inArg ); }
PxCombineMode::Enum getPxMaterial_RestitutionCombineMode( const PxMaterial* inObj ) { return inObj->getRestitutionCombineMode(); }
const char * getPxMaterial_ConcreteTypeName( const PxMaterial* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxMaterialGeneratedInfo::PxMaterialGeneratedInfo()
: DynamicFriction( "DynamicFriction", setPxMaterial_DynamicFriction, getPxMaterial_DynamicFriction)
, StaticFriction( "StaticFriction", setPxMaterial_StaticFriction, getPxMaterial_StaticFriction)
, Restitution( "Restitution", setPxMaterial_Restitution, getPxMaterial_Restitution)
, Damping( "Damping", setPxMaterial_Damping, getPxMaterial_Damping)
, Flags( "Flags", setPxMaterial_Flags, getPxMaterial_Flags)
, FrictionCombineMode( "FrictionCombineMode", setPxMaterial_FrictionCombineMode, getPxMaterial_FrictionCombineMode)
, RestitutionCombineMode( "RestitutionCombineMode", setPxMaterial_RestitutionCombineMode, getPxMaterial_RestitutionCombineMode)
, ConcreteTypeName( "ConcreteTypeName", getPxMaterial_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxMaterialGeneratedValues::PxMaterialGeneratedValues( const PxMaterial* inSource )
:PxBaseMaterialGeneratedValues( inSource )
,DynamicFriction( getPxMaterial_DynamicFriction( inSource ) )
,StaticFriction( getPxMaterial_StaticFriction( inSource ) )
,Restitution( getPxMaterial_Restitution( inSource ) )
,Damping( getPxMaterial_Damping( inSource ) )
,Flags( getPxMaterial_Flags( inSource ) )
,FrictionCombineMode( getPxMaterial_FrictionCombineMode( inSource ) )
,RestitutionCombineMode( getPxMaterial_RestitutionCombineMode( inSource ) )
,ConcreteTypeName( getPxMaterial_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxFEMMaterial_YoungsModulus( PxFEMMaterial* inObj, PxReal inArg){ inObj->setYoungsModulus( inArg ); }
PxReal getPxFEMMaterial_YoungsModulus( const PxFEMMaterial* inObj ) { return inObj->getYoungsModulus(); }
void setPxFEMMaterial_Poissons( PxFEMMaterial* inObj, PxReal inArg){ inObj->setPoissons( inArg ); }
PxReal getPxFEMMaterial_Poissons( const PxFEMMaterial* inObj ) { return inObj->getPoissons(); }
void setPxFEMMaterial_DynamicFriction( PxFEMMaterial* inObj, PxReal inArg){ inObj->setDynamicFriction( inArg ); }
PxReal getPxFEMMaterial_DynamicFriction( const PxFEMMaterial* inObj ) { return inObj->getDynamicFriction(); }
PX_PHYSX_CORE_API PxFEMMaterialGeneratedInfo::PxFEMMaterialGeneratedInfo()
: YoungsModulus( "YoungsModulus", setPxFEMMaterial_YoungsModulus, getPxFEMMaterial_YoungsModulus)
, Poissons( "Poissons", setPxFEMMaterial_Poissons, getPxFEMMaterial_Poissons)
, DynamicFriction( "DynamicFriction", setPxFEMMaterial_DynamicFriction, getPxFEMMaterial_DynamicFriction)
{}
PX_PHYSX_CORE_API PxFEMMaterialGeneratedValues::PxFEMMaterialGeneratedValues( const PxFEMMaterial* inSource )
:PxBaseMaterialGeneratedValues( inSource )
,YoungsModulus( getPxFEMMaterial_YoungsModulus( inSource ) )
,Poissons( getPxFEMMaterial_Poissons( inSource ) )
,DynamicFriction( getPxFEMMaterial_DynamicFriction( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxFEMSoftBodyMaterial_Damping( PxFEMSoftBodyMaterial* inObj, PxReal inArg){ inObj->setDamping( inArg ); }
PxReal getPxFEMSoftBodyMaterial_Damping( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getDamping(); }
void setPxFEMSoftBodyMaterial_DampingScale( PxFEMSoftBodyMaterial* inObj, PxReal inArg){ inObj->setDampingScale( inArg ); }
PxReal getPxFEMSoftBodyMaterial_DampingScale( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getDampingScale(); }
void setPxFEMSoftBodyMaterial_MaterialModel( PxFEMSoftBodyMaterial* inObj, PxFEMSoftBodyMaterialModel::Enum inArg){ inObj->setMaterialModel( inArg ); }
PxFEMSoftBodyMaterialModel::Enum getPxFEMSoftBodyMaterial_MaterialModel( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getMaterialModel(); }
const char * getPxFEMSoftBodyMaterial_ConcreteTypeName( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedInfo::PxFEMSoftBodyMaterialGeneratedInfo()
: Damping( "Damping", setPxFEMSoftBodyMaterial_Damping, getPxFEMSoftBodyMaterial_Damping)
, DampingScale( "DampingScale", setPxFEMSoftBodyMaterial_DampingScale, getPxFEMSoftBodyMaterial_DampingScale)
, MaterialModel( "MaterialModel", setPxFEMSoftBodyMaterial_MaterialModel, getPxFEMSoftBodyMaterial_MaterialModel)
, ConcreteTypeName( "ConcreteTypeName", getPxFEMSoftBodyMaterial_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedValues::PxFEMSoftBodyMaterialGeneratedValues( const PxFEMSoftBodyMaterial* inSource )
:PxFEMMaterialGeneratedValues( inSource )
,Damping( getPxFEMSoftBodyMaterial_Damping( inSource ) )
,DampingScale( getPxFEMSoftBodyMaterial_DampingScale( inSource ) )
,MaterialModel( getPxFEMSoftBodyMaterial_MaterialModel( inSource ) )
,ConcreteTypeName( getPxFEMSoftBodyMaterial_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxParticleMaterial_Friction( PxParticleMaterial* inObj, PxReal inArg){ inObj->setFriction( inArg ); }
PxReal getPxParticleMaterial_Friction( const PxParticleMaterial* inObj ) { return inObj->getFriction(); }
void setPxParticleMaterial_Damping( PxParticleMaterial* inObj, PxReal inArg){ inObj->setDamping( inArg ); }
PxReal getPxParticleMaterial_Damping( const PxParticleMaterial* inObj ) { return inObj->getDamping(); }
void setPxParticleMaterial_Adhesion( PxParticleMaterial* inObj, PxReal inArg){ inObj->setAdhesion( inArg ); }
PxReal getPxParticleMaterial_Adhesion( const PxParticleMaterial* inObj ) { return inObj->getAdhesion(); }
void setPxParticleMaterial_GravityScale( PxParticleMaterial* inObj, PxReal inArg){ inObj->setGravityScale( inArg ); }
PxReal getPxParticleMaterial_GravityScale( const PxParticleMaterial* inObj ) { return inObj->getGravityScale(); }
void setPxParticleMaterial_AdhesionRadiusScale( PxParticleMaterial* inObj, PxReal inArg){ inObj->setAdhesionRadiusScale( inArg ); }
PxReal getPxParticleMaterial_AdhesionRadiusScale( const PxParticleMaterial* inObj ) { return inObj->getAdhesionRadiusScale(); }
PX_PHYSX_CORE_API PxParticleMaterialGeneratedInfo::PxParticleMaterialGeneratedInfo()
: Friction( "Friction", setPxParticleMaterial_Friction, getPxParticleMaterial_Friction)
, Damping( "Damping", setPxParticleMaterial_Damping, getPxParticleMaterial_Damping)
, Adhesion( "Adhesion", setPxParticleMaterial_Adhesion, getPxParticleMaterial_Adhesion)
, GravityScale( "GravityScale", setPxParticleMaterial_GravityScale, getPxParticleMaterial_GravityScale)
, AdhesionRadiusScale( "AdhesionRadiusScale", setPxParticleMaterial_AdhesionRadiusScale, getPxParticleMaterial_AdhesionRadiusScale)
{}
PX_PHYSX_CORE_API PxParticleMaterialGeneratedValues::PxParticleMaterialGeneratedValues( const PxParticleMaterial* inSource )
:PxBaseMaterialGeneratedValues( inSource )
,Friction( getPxParticleMaterial_Friction( inSource ) )
,Damping( getPxParticleMaterial_Damping( inSource ) )
,Adhesion( getPxParticleMaterial_Adhesion( inSource ) )
,GravityScale( getPxParticleMaterial_GravityScale( inSource ) )
,AdhesionRadiusScale( getPxParticleMaterial_AdhesionRadiusScale( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxPBDMaterial_Viscosity( PxPBDMaterial* inObj, PxReal inArg){ inObj->setViscosity( inArg ); }
PxReal getPxPBDMaterial_Viscosity( const PxPBDMaterial* inObj ) { return inObj->getViscosity(); }
void setPxPBDMaterial_VorticityConfinement( PxPBDMaterial* inObj, PxReal inArg){ inObj->setVorticityConfinement( inArg ); }
PxReal getPxPBDMaterial_VorticityConfinement( const PxPBDMaterial* inObj ) { return inObj->getVorticityConfinement(); }
void setPxPBDMaterial_SurfaceTension( PxPBDMaterial* inObj, PxReal inArg){ inObj->setSurfaceTension( inArg ); }
PxReal getPxPBDMaterial_SurfaceTension( const PxPBDMaterial* inObj ) { return inObj->getSurfaceTension(); }
void setPxPBDMaterial_Cohesion( PxPBDMaterial* inObj, PxReal inArg){ inObj->setCohesion( inArg ); }
PxReal getPxPBDMaterial_Cohesion( const PxPBDMaterial* inObj ) { return inObj->getCohesion(); }
void setPxPBDMaterial_Lift( PxPBDMaterial* inObj, PxReal inArg){ inObj->setLift( inArg ); }
PxReal getPxPBDMaterial_Lift( const PxPBDMaterial* inObj ) { return inObj->getLift(); }
void setPxPBDMaterial_Drag( PxPBDMaterial* inObj, PxReal inArg){ inObj->setDrag( inArg ); }
PxReal getPxPBDMaterial_Drag( const PxPBDMaterial* inObj ) { return inObj->getDrag(); }
void setPxPBDMaterial_CFLCoefficient( PxPBDMaterial* inObj, PxReal inArg){ inObj->setCFLCoefficient( inArg ); }
PxReal getPxPBDMaterial_CFLCoefficient( const PxPBDMaterial* inObj ) { return inObj->getCFLCoefficient(); }
void setPxPBDMaterial_ParticleFrictionScale( PxPBDMaterial* inObj, PxReal inArg){ inObj->setParticleFrictionScale( inArg ); }
PxReal getPxPBDMaterial_ParticleFrictionScale( const PxPBDMaterial* inObj ) { return inObj->getParticleFrictionScale(); }
void setPxPBDMaterial_ParticleAdhesionScale( PxPBDMaterial* inObj, PxReal inArg){ inObj->setParticleAdhesionScale( inArg ); }
PxReal getPxPBDMaterial_ParticleAdhesionScale( const PxPBDMaterial* inObj ) { return inObj->getParticleAdhesionScale(); }
const char * getPxPBDMaterial_ConcreteTypeName( const PxPBDMaterial* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxPBDMaterialGeneratedInfo::PxPBDMaterialGeneratedInfo()
: Viscosity( "Viscosity", setPxPBDMaterial_Viscosity, getPxPBDMaterial_Viscosity)
, VorticityConfinement( "VorticityConfinement", setPxPBDMaterial_VorticityConfinement, getPxPBDMaterial_VorticityConfinement)
, SurfaceTension( "SurfaceTension", setPxPBDMaterial_SurfaceTension, getPxPBDMaterial_SurfaceTension)
, Cohesion( "Cohesion", setPxPBDMaterial_Cohesion, getPxPBDMaterial_Cohesion)
, Lift( "Lift", setPxPBDMaterial_Lift, getPxPBDMaterial_Lift)
, Drag( "Drag", setPxPBDMaterial_Drag, getPxPBDMaterial_Drag)
, CFLCoefficient( "CFLCoefficient", setPxPBDMaterial_CFLCoefficient, getPxPBDMaterial_CFLCoefficient)
, ParticleFrictionScale( "ParticleFrictionScale", setPxPBDMaterial_ParticleFrictionScale, getPxPBDMaterial_ParticleFrictionScale)
, ParticleAdhesionScale( "ParticleAdhesionScale", setPxPBDMaterial_ParticleAdhesionScale, getPxPBDMaterial_ParticleAdhesionScale)
, ConcreteTypeName( "ConcreteTypeName", getPxPBDMaterial_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxPBDMaterialGeneratedValues::PxPBDMaterialGeneratedValues( const PxPBDMaterial* inSource )
:PxParticleMaterialGeneratedValues( inSource )
,Viscosity( getPxPBDMaterial_Viscosity( inSource ) )
,VorticityConfinement( getPxPBDMaterial_VorticityConfinement( inSource ) )
,SurfaceTension( getPxPBDMaterial_SurfaceTension( inSource ) )
,Cohesion( getPxPBDMaterial_Cohesion( inSource ) )
,Lift( getPxPBDMaterial_Lift( inSource ) )
,Drag( getPxPBDMaterial_Drag( inSource ) )
,CFLCoefficient( getPxPBDMaterial_CFLCoefficient( inSource ) )
,ParticleFrictionScale( getPxPBDMaterial_ParticleFrictionScale( inSource ) )
,ParticleAdhesionScale( getPxPBDMaterial_ParticleAdhesionScale( inSource ) )
,ConcreteTypeName( getPxPBDMaterial_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
PxScene * getPxActor_Scene( const PxActor* inObj ) { return inObj->getScene(); }
void setPxActor_Name( PxActor* inObj, const char * inArg){ inObj->setName( inArg ); }
const char * getPxActor_Name( const PxActor* inObj ) { return inObj->getName(); }
void setPxActor_ActorFlags( PxActor* inObj, PxActorFlags inArg){ inObj->setActorFlags( inArg ); }
PxActorFlags getPxActor_ActorFlags( const PxActor* inObj ) { return inObj->getActorFlags(); }
void setPxActor_DominanceGroup( PxActor* inObj, PxDominanceGroup inArg){ inObj->setDominanceGroup( inArg ); }
PxDominanceGroup getPxActor_DominanceGroup( const PxActor* inObj ) { return inObj->getDominanceGroup(); }
void setPxActor_OwnerClient( PxActor* inObj, PxClientID inArg){ inObj->setOwnerClient( inArg ); }
PxClientID getPxActor_OwnerClient( const PxActor* inObj ) { return inObj->getOwnerClient(); }
PxAggregate * getPxActor_Aggregate( const PxActor* inObj ) { return inObj->getAggregate(); }
inline void * getPxActorUserData( const PxActor* inOwner ) { return inOwner->userData; }
inline void setPxActorUserData( PxActor* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxActorGeneratedInfo::PxActorGeneratedInfo()
: Scene( "Scene", getPxActor_Scene)
, Name( "Name", setPxActor_Name, getPxActor_Name)
, ActorFlags( "ActorFlags", setPxActor_ActorFlags, getPxActor_ActorFlags)
, DominanceGroup( "DominanceGroup", setPxActor_DominanceGroup, getPxActor_DominanceGroup)
, OwnerClient( "OwnerClient", setPxActor_OwnerClient, getPxActor_OwnerClient)
, Aggregate( "Aggregate", getPxActor_Aggregate)
, UserData( "UserData", setPxActorUserData, getPxActorUserData )
{}
PX_PHYSX_CORE_API PxActorGeneratedValues::PxActorGeneratedValues( const PxActor* inSource )
:Scene( getPxActor_Scene( inSource ) )
,Name( getPxActor_Name( inSource ) )
,ActorFlags( getPxActor_ActorFlags( inSource ) )
,DominanceGroup( getPxActor_DominanceGroup( inSource ) )
,OwnerClient( getPxActor_OwnerClient( inSource ) )
,Aggregate( getPxActor_Aggregate( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
}
void setPxRigidActor_GlobalPose( PxRigidActor* inObj, const PxTransform & inArg){ inObj->setGlobalPose( inArg ); }
PxTransform getPxRigidActor_GlobalPose( const PxRigidActor* inObj ) { return inObj->getGlobalPose(); }
PxU32 getPxRigidActor_Shapes( const PxRigidActor* inObj, PxShape ** outBuffer, PxU32 inBufSize ) { return inObj->getShapes( outBuffer, inBufSize ); }
PxU32 getNbPxRigidActor_Shapes( const PxRigidActor* inObj ) { return inObj->getNbShapes( ); }
PxU32 getPxRigidActor_Constraints( const PxRigidActor* inObj, PxConstraint ** outBuffer, PxU32 inBufSize ) { return inObj->getConstraints( outBuffer, inBufSize ); }
PxU32 getNbPxRigidActor_Constraints( const PxRigidActor* inObj ) { return inObj->getNbConstraints( ); }
PX_PHYSX_CORE_API PxRigidActorGeneratedInfo::PxRigidActorGeneratedInfo()
: GlobalPose( "GlobalPose", setPxRigidActor_GlobalPose, getPxRigidActor_GlobalPose)
, Shapes( "Shapes", getPxRigidActor_Shapes, getNbPxRigidActor_Shapes )
, Constraints( "Constraints", getPxRigidActor_Constraints, getNbPxRigidActor_Constraints )
{}
PX_PHYSX_CORE_API PxRigidActorGeneratedValues::PxRigidActorGeneratedValues( const PxRigidActor* inSource )
:PxActorGeneratedValues( inSource )
,GlobalPose( getPxRigidActor_GlobalPose( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxRigidBody_CMassLocalPose( PxRigidBody* inObj, const PxTransform & inArg){ inObj->setCMassLocalPose( inArg ); }
PxTransform getPxRigidBody_CMassLocalPose( const PxRigidBody* inObj ) { return inObj->getCMassLocalPose(); }
void setPxRigidBody_Mass( PxRigidBody* inObj, PxReal inArg){ inObj->setMass( inArg ); }
PxReal getPxRigidBody_Mass( const PxRigidBody* inObj ) { return inObj->getMass(); }
PxReal getPxRigidBody_InvMass( const PxRigidBody* inObj ) { return inObj->getInvMass(); }
void setPxRigidBody_MassSpaceInertiaTensor( PxRigidBody* inObj, const PxVec3 & inArg){ inObj->setMassSpaceInertiaTensor( inArg ); }
PxVec3 getPxRigidBody_MassSpaceInertiaTensor( const PxRigidBody* inObj ) { return inObj->getMassSpaceInertiaTensor(); }
PxVec3 getPxRigidBody_MassSpaceInvInertiaTensor( const PxRigidBody* inObj ) { return inObj->getMassSpaceInvInertiaTensor(); }
void setPxRigidBody_LinearDamping( PxRigidBody* inObj, PxReal inArg){ inObj->setLinearDamping( inArg ); }
PxReal getPxRigidBody_LinearDamping( const PxRigidBody* inObj ) { return inObj->getLinearDamping(); }
void setPxRigidBody_AngularDamping( PxRigidBody* inObj, PxReal inArg){ inObj->setAngularDamping( inArg ); }
PxReal getPxRigidBody_AngularDamping( const PxRigidBody* inObj ) { return inObj->getAngularDamping(); }
void setPxRigidBody_MaxLinearVelocity( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxLinearVelocity( inArg ); }
PxReal getPxRigidBody_MaxLinearVelocity( const PxRigidBody* inObj ) { return inObj->getMaxLinearVelocity(); }
void setPxRigidBody_MaxAngularVelocity( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxAngularVelocity( inArg ); }
PxReal getPxRigidBody_MaxAngularVelocity( const PxRigidBody* inObj ) { return inObj->getMaxAngularVelocity(); }
void setPxRigidBody_RigidBodyFlags( PxRigidBody* inObj, PxRigidBodyFlags inArg){ inObj->setRigidBodyFlags( inArg ); }
PxRigidBodyFlags getPxRigidBody_RigidBodyFlags( const PxRigidBody* inObj ) { return inObj->getRigidBodyFlags(); }
void setPxRigidBody_MinCCDAdvanceCoefficient( PxRigidBody* inObj, PxReal inArg){ inObj->setMinCCDAdvanceCoefficient( inArg ); }
PxReal getPxRigidBody_MinCCDAdvanceCoefficient( const PxRigidBody* inObj ) { return inObj->getMinCCDAdvanceCoefficient(); }
void setPxRigidBody_MaxDepenetrationVelocity( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxDepenetrationVelocity( inArg ); }
PxReal getPxRigidBody_MaxDepenetrationVelocity( const PxRigidBody* inObj ) { return inObj->getMaxDepenetrationVelocity(); }
void setPxRigidBody_MaxContactImpulse( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxContactImpulse( inArg ); }
PxReal getPxRigidBody_MaxContactImpulse( const PxRigidBody* inObj ) { return inObj->getMaxContactImpulse(); }
void setPxRigidBody_ContactSlopCoefficient( PxRigidBody* inObj, PxReal inArg){ inObj->setContactSlopCoefficient( inArg ); }
PxReal getPxRigidBody_ContactSlopCoefficient( const PxRigidBody* inObj ) { return inObj->getContactSlopCoefficient(); }
PX_PHYSX_CORE_API PxRigidBodyGeneratedInfo::PxRigidBodyGeneratedInfo()
: CMassLocalPose( "CMassLocalPose", setPxRigidBody_CMassLocalPose, getPxRigidBody_CMassLocalPose)
, Mass( "Mass", setPxRigidBody_Mass, getPxRigidBody_Mass)
, InvMass( "InvMass", getPxRigidBody_InvMass)
, MassSpaceInertiaTensor( "MassSpaceInertiaTensor", setPxRigidBody_MassSpaceInertiaTensor, getPxRigidBody_MassSpaceInertiaTensor)
, MassSpaceInvInertiaTensor( "MassSpaceInvInertiaTensor", getPxRigidBody_MassSpaceInvInertiaTensor)
, LinearDamping( "LinearDamping", setPxRigidBody_LinearDamping, getPxRigidBody_LinearDamping)
, AngularDamping( "AngularDamping", setPxRigidBody_AngularDamping, getPxRigidBody_AngularDamping)
, MaxLinearVelocity( "MaxLinearVelocity", setPxRigidBody_MaxLinearVelocity, getPxRigidBody_MaxLinearVelocity)
, MaxAngularVelocity( "MaxAngularVelocity", setPxRigidBody_MaxAngularVelocity, getPxRigidBody_MaxAngularVelocity)
, RigidBodyFlags( "RigidBodyFlags", setPxRigidBody_RigidBodyFlags, getPxRigidBody_RigidBodyFlags)
, MinCCDAdvanceCoefficient( "MinCCDAdvanceCoefficient", setPxRigidBody_MinCCDAdvanceCoefficient, getPxRigidBody_MinCCDAdvanceCoefficient)
, MaxDepenetrationVelocity( "MaxDepenetrationVelocity", setPxRigidBody_MaxDepenetrationVelocity, getPxRigidBody_MaxDepenetrationVelocity)
, MaxContactImpulse( "MaxContactImpulse", setPxRigidBody_MaxContactImpulse, getPxRigidBody_MaxContactImpulse)
, ContactSlopCoefficient( "ContactSlopCoefficient", setPxRigidBody_ContactSlopCoefficient, getPxRigidBody_ContactSlopCoefficient)
{}
PX_PHYSX_CORE_API PxRigidBodyGeneratedValues::PxRigidBodyGeneratedValues( const PxRigidBody* inSource )
:PxRigidActorGeneratedValues( inSource )
,CMassLocalPose( getPxRigidBody_CMassLocalPose( inSource ) )
,Mass( getPxRigidBody_Mass( inSource ) )
,InvMass( getPxRigidBody_InvMass( inSource ) )
,MassSpaceInertiaTensor( getPxRigidBody_MassSpaceInertiaTensor( inSource ) )
,MassSpaceInvInertiaTensor( getPxRigidBody_MassSpaceInvInertiaTensor( inSource ) )
,LinearDamping( getPxRigidBody_LinearDamping( inSource ) )
,AngularDamping( getPxRigidBody_AngularDamping( inSource ) )
,MaxLinearVelocity( getPxRigidBody_MaxLinearVelocity( inSource ) )
,MaxAngularVelocity( getPxRigidBody_MaxAngularVelocity( inSource ) )
,RigidBodyFlags( getPxRigidBody_RigidBodyFlags( inSource ) )
,MinCCDAdvanceCoefficient( getPxRigidBody_MinCCDAdvanceCoefficient( inSource ) )
,MaxDepenetrationVelocity( getPxRigidBody_MaxDepenetrationVelocity( inSource ) )
,MaxContactImpulse( getPxRigidBody_MaxContactImpulse( inSource ) )
,ContactSlopCoefficient( getPxRigidBody_ContactSlopCoefficient( inSource ) )
{
PX_UNUSED(inSource);
}
_Bool getPxRigidDynamic_IsSleeping( const PxRigidDynamic* inObj ) { return inObj->isSleeping(); }
void setPxRigidDynamic_SleepThreshold( PxRigidDynamic* inObj, PxReal inArg){ inObj->setSleepThreshold( inArg ); }
PxReal getPxRigidDynamic_SleepThreshold( const PxRigidDynamic* inObj ) { return inObj->getSleepThreshold(); }
void setPxRigidDynamic_StabilizationThreshold( PxRigidDynamic* inObj, PxReal inArg){ inObj->setStabilizationThreshold( inArg ); }
PxReal getPxRigidDynamic_StabilizationThreshold( const PxRigidDynamic* inObj ) { return inObj->getStabilizationThreshold(); }
void setPxRigidDynamic_RigidDynamicLockFlags( PxRigidDynamic* inObj, PxRigidDynamicLockFlags inArg){ inObj->setRigidDynamicLockFlags( inArg ); }
PxRigidDynamicLockFlags getPxRigidDynamic_RigidDynamicLockFlags( const PxRigidDynamic* inObj ) { return inObj->getRigidDynamicLockFlags(); }
void setPxRigidDynamic_LinearVelocity( PxRigidDynamic* inObj, const PxVec3 & inArg){ inObj->setLinearVelocity( inArg ); }
PxVec3 getPxRigidDynamic_LinearVelocity( const PxRigidDynamic* inObj ) { return inObj->getLinearVelocity(); }
void setPxRigidDynamic_AngularVelocity( PxRigidDynamic* inObj, const PxVec3 & inArg){ inObj->setAngularVelocity( inArg ); }
PxVec3 getPxRigidDynamic_AngularVelocity( const PxRigidDynamic* inObj ) { return inObj->getAngularVelocity(); }
void setPxRigidDynamic_WakeCounter( PxRigidDynamic* inObj, PxReal inArg){ inObj->setWakeCounter( inArg ); }
PxReal getPxRigidDynamic_WakeCounter( const PxRigidDynamic* inObj ) { return inObj->getWakeCounter(); }
void setPxRigidDynamic_SolverIterationCounts( PxRigidDynamic* inObj, PxU32 inArg0, PxU32 inArg1 ) { inObj->setSolverIterationCounts( inArg0, inArg1 ); }
void getPxRigidDynamic_SolverIterationCounts( const PxRigidDynamic* inObj, PxU32& inArg0, PxU32& inArg1 ) { inObj->getSolverIterationCounts( inArg0, inArg1 ); }
void setPxRigidDynamic_ContactReportThreshold( PxRigidDynamic* inObj, PxReal inArg){ inObj->setContactReportThreshold( inArg ); }
PxReal getPxRigidDynamic_ContactReportThreshold( const PxRigidDynamic* inObj ) { return inObj->getContactReportThreshold(); }
const char * getPxRigidDynamic_ConcreteTypeName( const PxRigidDynamic* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxRigidDynamicGeneratedInfo::PxRigidDynamicGeneratedInfo()
: IsSleeping( "IsSleeping", getPxRigidDynamic_IsSleeping)
, SleepThreshold( "SleepThreshold", setPxRigidDynamic_SleepThreshold, getPxRigidDynamic_SleepThreshold)
, StabilizationThreshold( "StabilizationThreshold", setPxRigidDynamic_StabilizationThreshold, getPxRigidDynamic_StabilizationThreshold)
, RigidDynamicLockFlags( "RigidDynamicLockFlags", setPxRigidDynamic_RigidDynamicLockFlags, getPxRigidDynamic_RigidDynamicLockFlags)
, LinearVelocity( "LinearVelocity", setPxRigidDynamic_LinearVelocity, getPxRigidDynamic_LinearVelocity)
, AngularVelocity( "AngularVelocity", setPxRigidDynamic_AngularVelocity, getPxRigidDynamic_AngularVelocity)
, WakeCounter( "WakeCounter", setPxRigidDynamic_WakeCounter, getPxRigidDynamic_WakeCounter)
, SolverIterationCounts( "SolverIterationCounts", "minPositionIters", "minVelocityIters", setPxRigidDynamic_SolverIterationCounts, getPxRigidDynamic_SolverIterationCounts)
, ContactReportThreshold( "ContactReportThreshold", setPxRigidDynamic_ContactReportThreshold, getPxRigidDynamic_ContactReportThreshold)
, ConcreteTypeName( "ConcreteTypeName", getPxRigidDynamic_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxRigidDynamicGeneratedValues::PxRigidDynamicGeneratedValues( const PxRigidDynamic* inSource )
:PxRigidBodyGeneratedValues( inSource )
,IsSleeping( getPxRigidDynamic_IsSleeping( inSource ) )
,SleepThreshold( getPxRigidDynamic_SleepThreshold( inSource ) )
,StabilizationThreshold( getPxRigidDynamic_StabilizationThreshold( inSource ) )
,RigidDynamicLockFlags( getPxRigidDynamic_RigidDynamicLockFlags( inSource ) )
,LinearVelocity( getPxRigidDynamic_LinearVelocity( inSource ) )
,AngularVelocity( getPxRigidDynamic_AngularVelocity( inSource ) )
,WakeCounter( getPxRigidDynamic_WakeCounter( inSource ) )
,ContactReportThreshold( getPxRigidDynamic_ContactReportThreshold( inSource ) )
,ConcreteTypeName( getPxRigidDynamic_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
getPxRigidDynamic_SolverIterationCounts( inSource, SolverIterationCounts[0], SolverIterationCounts[1] );
}
const char * getPxRigidStatic_ConcreteTypeName( const PxRigidStatic* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxRigidStaticGeneratedInfo::PxRigidStaticGeneratedInfo()
: ConcreteTypeName( "ConcreteTypeName", getPxRigidStatic_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxRigidStaticGeneratedValues::PxRigidStaticGeneratedValues( const PxRigidStatic* inSource )
:PxRigidActorGeneratedValues( inSource )
,ConcreteTypeName( getPxRigidStatic_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
PxArticulationJointReducedCoordinate * getPxArticulationLink_InboundJoint( const PxArticulationLink* inObj ) { return inObj->getInboundJoint(); }
PxU32 getPxArticulationLink_InboundJointDof( const PxArticulationLink* inObj ) { return inObj->getInboundJointDof(); }
PxU32 getPxArticulationLink_LinkIndex( const PxArticulationLink* inObj ) { return inObj->getLinkIndex(); }
PxU32 getPxArticulationLink_Children( const PxArticulationLink* inObj, PxArticulationLink ** outBuffer, PxU32 inBufSize ) { return inObj->getChildren( outBuffer, inBufSize ); }
PxU32 getNbPxArticulationLink_Children( const PxArticulationLink* inObj ) { return inObj->getNbChildren( ); }
void setPxArticulationLink_CfmScale( PxArticulationLink* inObj, const PxReal inArg){ inObj->setCfmScale( inArg ); }
PxReal getPxArticulationLink_CfmScale( const PxArticulationLink* inObj ) { return inObj->getCfmScale(); }
PxVec3 getPxArticulationLink_LinearVelocity( const PxArticulationLink* inObj ) { return inObj->getLinearVelocity(); }
PxVec3 getPxArticulationLink_AngularVelocity( const PxArticulationLink* inObj ) { return inObj->getAngularVelocity(); }
const char * getPxArticulationLink_ConcreteTypeName( const PxArticulationLink* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxArticulationLinkGeneratedInfo::PxArticulationLinkGeneratedInfo()
: InboundJoint( "InboundJoint", getPxArticulationLink_InboundJoint)
, InboundJointDof( "InboundJointDof", getPxArticulationLink_InboundJointDof)
, LinkIndex( "LinkIndex", getPxArticulationLink_LinkIndex)
, Children( "Children", getPxArticulationLink_Children, getNbPxArticulationLink_Children )
, CfmScale( "CfmScale", setPxArticulationLink_CfmScale, getPxArticulationLink_CfmScale)
, LinearVelocity( "LinearVelocity", getPxArticulationLink_LinearVelocity)
, AngularVelocity( "AngularVelocity", getPxArticulationLink_AngularVelocity)
, ConcreteTypeName( "ConcreteTypeName", getPxArticulationLink_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxArticulationLinkGeneratedValues::PxArticulationLinkGeneratedValues( const PxArticulationLink* inSource )
:PxRigidBodyGeneratedValues( inSource )
,InboundJoint( getPxArticulationLink_InboundJoint( inSource ) )
,InboundJointDof( getPxArticulationLink_InboundJointDof( inSource ) )
,LinkIndex( getPxArticulationLink_LinkIndex( inSource ) )
,CfmScale( getPxArticulationLink_CfmScale( inSource ) )
,LinearVelocity( getPxArticulationLink_LinearVelocity( inSource ) )
,AngularVelocity( getPxArticulationLink_AngularVelocity( inSource ) )
,ConcreteTypeName( getPxArticulationLink_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxArticulationJointReducedCoordinate_ParentPose( PxArticulationJointReducedCoordinate* inObj, const PxTransform & inArg){ inObj->setParentPose( inArg ); }
PxTransform getPxArticulationJointReducedCoordinate_ParentPose( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getParentPose(); }
void setPxArticulationJointReducedCoordinate_ChildPose( PxArticulationJointReducedCoordinate* inObj, const PxTransform & inArg){ inObj->setChildPose( inArg ); }
PxTransform getPxArticulationJointReducedCoordinate_ChildPose( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getChildPose(); }
void setPxArticulationJointReducedCoordinate_JointType( PxArticulationJointReducedCoordinate* inObj, PxArticulationJointType::Enum inArg){ inObj->setJointType( inArg ); }
PxArticulationJointType::Enum getPxArticulationJointReducedCoordinate_JointType( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getJointType(); }
void setPxArticulationJointReducedCoordinate_Motion( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxArticulationMotion::Enum inArg ){ inObj->setMotion( inIndex, inArg ); }
PxArticulationMotion::Enum getPxArticulationJointReducedCoordinate_Motion( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getMotion( inIndex ); }
void setPxArticulationJointReducedCoordinate_LimitParams( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxArticulationLimit inArg ){ inObj->setLimitParams( inIndex, inArg ); }
PxArticulationLimit getPxArticulationJointReducedCoordinate_LimitParams( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getLimitParams( inIndex ); }
void setPxArticulationJointReducedCoordinate_DriveParams( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxArticulationDrive inArg ){ inObj->setDriveParams( inIndex, inArg ); }
PxArticulationDrive getPxArticulationJointReducedCoordinate_DriveParams( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getDriveParams( inIndex ); }
void setPxArticulationJointReducedCoordinate_Armature( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxReal inArg ){ inObj->setArmature( inIndex, inArg ); }
PxReal getPxArticulationJointReducedCoordinate_Armature( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getArmature( inIndex ); }
void setPxArticulationJointReducedCoordinate_FrictionCoefficient( PxArticulationJointReducedCoordinate* inObj, const PxReal inArg){ inObj->setFrictionCoefficient( inArg ); }
PxReal getPxArticulationJointReducedCoordinate_FrictionCoefficient( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getFrictionCoefficient(); }
void setPxArticulationJointReducedCoordinate_MaxJointVelocity( PxArticulationJointReducedCoordinate* inObj, const PxReal inArg){ inObj->setMaxJointVelocity( inArg ); }
PxReal getPxArticulationJointReducedCoordinate_MaxJointVelocity( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getMaxJointVelocity(); }
void setPxArticulationJointReducedCoordinate_JointPosition( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxReal inArg ){ inObj->setJointPosition( inIndex, inArg ); }
PxReal getPxArticulationJointReducedCoordinate_JointPosition( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getJointPosition( inIndex ); }
void setPxArticulationJointReducedCoordinate_JointVelocity( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxReal inArg ){ inObj->setJointVelocity( inIndex, inArg ); }
PxReal getPxArticulationJointReducedCoordinate_JointVelocity( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getJointVelocity( inIndex ); }
const char * getPxArticulationJointReducedCoordinate_ConcreteTypeName( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getConcreteTypeName(); }
inline void * getPxArticulationJointReducedCoordinateUserData( const PxArticulationJointReducedCoordinate* inOwner ) { return inOwner->userData; }
inline void setPxArticulationJointReducedCoordinateUserData( PxArticulationJointReducedCoordinate* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedInfo::PxArticulationJointReducedCoordinateGeneratedInfo()
: ParentPose( "ParentPose", setPxArticulationJointReducedCoordinate_ParentPose, getPxArticulationJointReducedCoordinate_ParentPose)
, ChildPose( "ChildPose", setPxArticulationJointReducedCoordinate_ChildPose, getPxArticulationJointReducedCoordinate_ChildPose)
, JointType( "JointType", setPxArticulationJointReducedCoordinate_JointType, getPxArticulationJointReducedCoordinate_JointType)
, Motion( "Motion", setPxArticulationJointReducedCoordinate_Motion, getPxArticulationJointReducedCoordinate_Motion)
, LimitParams( "LimitParams", setPxArticulationJointReducedCoordinate_LimitParams, getPxArticulationJointReducedCoordinate_LimitParams)
, DriveParams( "DriveParams", setPxArticulationJointReducedCoordinate_DriveParams, getPxArticulationJointReducedCoordinate_DriveParams)
, Armature( "Armature", setPxArticulationJointReducedCoordinate_Armature, getPxArticulationJointReducedCoordinate_Armature)
, FrictionCoefficient( "FrictionCoefficient", setPxArticulationJointReducedCoordinate_FrictionCoefficient, getPxArticulationJointReducedCoordinate_FrictionCoefficient)
, MaxJointVelocity( "MaxJointVelocity", setPxArticulationJointReducedCoordinate_MaxJointVelocity, getPxArticulationJointReducedCoordinate_MaxJointVelocity)
, JointPosition( "JointPosition", setPxArticulationJointReducedCoordinate_JointPosition, getPxArticulationJointReducedCoordinate_JointPosition)
, JointVelocity( "JointVelocity", setPxArticulationJointReducedCoordinate_JointVelocity, getPxArticulationJointReducedCoordinate_JointVelocity)
, ConcreteTypeName( "ConcreteTypeName", getPxArticulationJointReducedCoordinate_ConcreteTypeName)
, UserData( "UserData", setPxArticulationJointReducedCoordinateUserData, getPxArticulationJointReducedCoordinateUserData )
{}
PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedValues::PxArticulationJointReducedCoordinateGeneratedValues( const PxArticulationJointReducedCoordinate* inSource )
:ParentPose( getPxArticulationJointReducedCoordinate_ParentPose( inSource ) )
,ChildPose( getPxArticulationJointReducedCoordinate_ChildPose( inSource ) )
,JointType( getPxArticulationJointReducedCoordinate_JointType( inSource ) )
,FrictionCoefficient( getPxArticulationJointReducedCoordinate_FrictionCoefficient( inSource ) )
,MaxJointVelocity( getPxArticulationJointReducedCoordinate_MaxJointVelocity( inSource ) )
,ConcreteTypeName( getPxArticulationJointReducedCoordinate_ConcreteTypeName( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx )
Motion[idx] = getPxArticulationJointReducedCoordinate_Motion( inSource, static_cast< PxArticulationAxis::Enum >( idx ) );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx )
LimitParams[idx] = getPxArticulationJointReducedCoordinate_LimitParams( inSource, static_cast< PxArticulationAxis::Enum >( idx ) );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx )
DriveParams[idx] = getPxArticulationJointReducedCoordinate_DriveParams( inSource, static_cast< PxArticulationAxis::Enum >( idx ) );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx )
Armature[idx] = getPxArticulationJointReducedCoordinate_Armature( inSource, static_cast< PxArticulationAxis::Enum >( idx ) );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx )
JointPosition[idx] = getPxArticulationJointReducedCoordinate_JointPosition( inSource, static_cast< PxArticulationAxis::Enum >( idx ) );
for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx )
JointVelocity[idx] = getPxArticulationJointReducedCoordinate_JointVelocity( inSource, static_cast< PxArticulationAxis::Enum >( idx ) );
}
PxScene * getPxArticulationReducedCoordinate_Scene( const PxArticulationReducedCoordinate* inObj ) { return inObj->getScene(); }
void setPxArticulationReducedCoordinate_SolverIterationCounts( PxArticulationReducedCoordinate* inObj, PxU32 inArg0, PxU32 inArg1 ) { inObj->setSolverIterationCounts( inArg0, inArg1 ); }
void getPxArticulationReducedCoordinate_SolverIterationCounts( const PxArticulationReducedCoordinate* inObj, PxU32& inArg0, PxU32& inArg1 ) { inObj->getSolverIterationCounts( inArg0, inArg1 ); }
_Bool getPxArticulationReducedCoordinate_IsSleeping( const PxArticulationReducedCoordinate* inObj ) { return inObj->isSleeping(); }
void setPxArticulationReducedCoordinate_SleepThreshold( PxArticulationReducedCoordinate* inObj, PxReal inArg){ inObj->setSleepThreshold( inArg ); }
PxReal getPxArticulationReducedCoordinate_SleepThreshold( const PxArticulationReducedCoordinate* inObj ) { return inObj->getSleepThreshold(); }
void setPxArticulationReducedCoordinate_StabilizationThreshold( PxArticulationReducedCoordinate* inObj, PxReal inArg){ inObj->setStabilizationThreshold( inArg ); }
PxReal getPxArticulationReducedCoordinate_StabilizationThreshold( const PxArticulationReducedCoordinate* inObj ) { return inObj->getStabilizationThreshold(); }
void setPxArticulationReducedCoordinate_WakeCounter( PxArticulationReducedCoordinate* inObj, PxReal inArg){ inObj->setWakeCounter( inArg ); }
PxReal getPxArticulationReducedCoordinate_WakeCounter( const PxArticulationReducedCoordinate* inObj ) { return inObj->getWakeCounter(); }
void setPxArticulationReducedCoordinate_MaxCOMLinearVelocity( PxArticulationReducedCoordinate* inObj, const PxReal inArg){ inObj->setMaxCOMLinearVelocity( inArg ); }
PxReal getPxArticulationReducedCoordinate_MaxCOMLinearVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getMaxCOMLinearVelocity(); }
void setPxArticulationReducedCoordinate_MaxCOMAngularVelocity( PxArticulationReducedCoordinate* inObj, const PxReal inArg){ inObj->setMaxCOMAngularVelocity( inArg ); }
PxReal getPxArticulationReducedCoordinate_MaxCOMAngularVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getMaxCOMAngularVelocity(); }
PxU32 getPxArticulationReducedCoordinate_Links( const PxArticulationReducedCoordinate* inObj, PxArticulationLink ** outBuffer, PxU32 inBufSize ) { return inObj->getLinks( outBuffer, inBufSize ); }
PxU32 getNbPxArticulationReducedCoordinate_Links( const PxArticulationReducedCoordinate* inObj ) { return inObj->getNbLinks( ); }
void setPxArticulationReducedCoordinate_Name( PxArticulationReducedCoordinate* inObj, const char * inArg){ inObj->setName( inArg ); }
const char * getPxArticulationReducedCoordinate_Name( const PxArticulationReducedCoordinate* inObj ) { return inObj->getName(); }
PxAggregate * getPxArticulationReducedCoordinate_Aggregate( const PxArticulationReducedCoordinate* inObj ) { return inObj->getAggregate(); }
void setPxArticulationReducedCoordinate_ArticulationFlags( PxArticulationReducedCoordinate* inObj, PxArticulationFlags inArg){ inObj->setArticulationFlags( inArg ); }
PxArticulationFlags getPxArticulationReducedCoordinate_ArticulationFlags( const PxArticulationReducedCoordinate* inObj ) { return inObj->getArticulationFlags(); }
void setPxArticulationReducedCoordinate_RootGlobalPose( PxArticulationReducedCoordinate* inObj, const PxTransform & inArg){ inObj->setRootGlobalPose( inArg ); }
PxTransform getPxArticulationReducedCoordinate_RootGlobalPose( const PxArticulationReducedCoordinate* inObj ) { return inObj->getRootGlobalPose(); }
void setPxArticulationReducedCoordinate_RootLinearVelocity( PxArticulationReducedCoordinate* inObj, const PxVec3 & inArg){ inObj->setRootLinearVelocity( inArg ); }
PxVec3 getPxArticulationReducedCoordinate_RootLinearVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getRootLinearVelocity(); }
void setPxArticulationReducedCoordinate_RootAngularVelocity( PxArticulationReducedCoordinate* inObj, const PxVec3 & inArg){ inObj->setRootAngularVelocity( inArg ); }
PxVec3 getPxArticulationReducedCoordinate_RootAngularVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getRootAngularVelocity(); }
inline void * getPxArticulationReducedCoordinateUserData( const PxArticulationReducedCoordinate* inOwner ) { return inOwner->userData; }
inline void setPxArticulationReducedCoordinateUserData( PxArticulationReducedCoordinate* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedInfo::PxArticulationReducedCoordinateGeneratedInfo()
: Scene( "Scene", getPxArticulationReducedCoordinate_Scene)
, SolverIterationCounts( "SolverIterationCounts", "minPositionIters", "minVelocityIters", setPxArticulationReducedCoordinate_SolverIterationCounts, getPxArticulationReducedCoordinate_SolverIterationCounts)
, IsSleeping( "IsSleeping", getPxArticulationReducedCoordinate_IsSleeping)
, SleepThreshold( "SleepThreshold", setPxArticulationReducedCoordinate_SleepThreshold, getPxArticulationReducedCoordinate_SleepThreshold)
, StabilizationThreshold( "StabilizationThreshold", setPxArticulationReducedCoordinate_StabilizationThreshold, getPxArticulationReducedCoordinate_StabilizationThreshold)
, WakeCounter( "WakeCounter", setPxArticulationReducedCoordinate_WakeCounter, getPxArticulationReducedCoordinate_WakeCounter)
, MaxCOMLinearVelocity( "MaxCOMLinearVelocity", setPxArticulationReducedCoordinate_MaxCOMLinearVelocity, getPxArticulationReducedCoordinate_MaxCOMLinearVelocity)
, MaxCOMAngularVelocity( "MaxCOMAngularVelocity", setPxArticulationReducedCoordinate_MaxCOMAngularVelocity, getPxArticulationReducedCoordinate_MaxCOMAngularVelocity)
, Links( "Links", getPxArticulationReducedCoordinate_Links, getNbPxArticulationReducedCoordinate_Links )
, Name( "Name", setPxArticulationReducedCoordinate_Name, getPxArticulationReducedCoordinate_Name)
, Aggregate( "Aggregate", getPxArticulationReducedCoordinate_Aggregate)
, ArticulationFlags( "ArticulationFlags", setPxArticulationReducedCoordinate_ArticulationFlags, getPxArticulationReducedCoordinate_ArticulationFlags)
, RootGlobalPose( "RootGlobalPose", setPxArticulationReducedCoordinate_RootGlobalPose, getPxArticulationReducedCoordinate_RootGlobalPose)
, RootLinearVelocity( "RootLinearVelocity", setPxArticulationReducedCoordinate_RootLinearVelocity, getPxArticulationReducedCoordinate_RootLinearVelocity)
, RootAngularVelocity( "RootAngularVelocity", setPxArticulationReducedCoordinate_RootAngularVelocity, getPxArticulationReducedCoordinate_RootAngularVelocity)
, UserData( "UserData", setPxArticulationReducedCoordinateUserData, getPxArticulationReducedCoordinateUserData )
{}
PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedValues::PxArticulationReducedCoordinateGeneratedValues( const PxArticulationReducedCoordinate* inSource )
:Scene( getPxArticulationReducedCoordinate_Scene( inSource ) )
,IsSleeping( getPxArticulationReducedCoordinate_IsSleeping( inSource ) )
,SleepThreshold( getPxArticulationReducedCoordinate_SleepThreshold( inSource ) )
,StabilizationThreshold( getPxArticulationReducedCoordinate_StabilizationThreshold( inSource ) )
,WakeCounter( getPxArticulationReducedCoordinate_WakeCounter( inSource ) )
,MaxCOMLinearVelocity( getPxArticulationReducedCoordinate_MaxCOMLinearVelocity( inSource ) )
,MaxCOMAngularVelocity( getPxArticulationReducedCoordinate_MaxCOMAngularVelocity( inSource ) )
,Name( getPxArticulationReducedCoordinate_Name( inSource ) )
,Aggregate( getPxArticulationReducedCoordinate_Aggregate( inSource ) )
,ArticulationFlags( getPxArticulationReducedCoordinate_ArticulationFlags( inSource ) )
,RootGlobalPose( getPxArticulationReducedCoordinate_RootGlobalPose( inSource ) )
,RootLinearVelocity( getPxArticulationReducedCoordinate_RootLinearVelocity( inSource ) )
,RootAngularVelocity( getPxArticulationReducedCoordinate_RootAngularVelocity( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
getPxArticulationReducedCoordinate_SolverIterationCounts( inSource, SolverIterationCounts[0], SolverIterationCounts[1] );
}
PxU32 getPxAggregate_MaxNbActors( const PxAggregate* inObj ) { return inObj->getMaxNbActors(); }
PxU32 getPxAggregate_MaxNbShapes( const PxAggregate* inObj ) { return inObj->getMaxNbShapes(); }
PxU32 getPxAggregate_Actors( const PxAggregate* inObj, PxActor ** outBuffer, PxU32 inBufSize ) { return inObj->getActors( outBuffer, inBufSize ); }
PxU32 getNbPxAggregate_Actors( const PxAggregate* inObj ) { return inObj->getNbActors( ); }
_Bool getPxAggregate_SelfCollision( const PxAggregate* inObj ) { return inObj->getSelfCollision(); }
const char * getPxAggregate_ConcreteTypeName( const PxAggregate* inObj ) { return inObj->getConcreteTypeName(); }
inline void * getPxAggregateUserData( const PxAggregate* inOwner ) { return inOwner->userData; }
inline void setPxAggregateUserData( PxAggregate* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxAggregateGeneratedInfo::PxAggregateGeneratedInfo()
: MaxNbActors( "MaxNbActors", getPxAggregate_MaxNbActors)
, MaxNbShapes( "MaxNbShapes", getPxAggregate_MaxNbShapes)
, Actors( "Actors", getPxAggregate_Actors, getNbPxAggregate_Actors )
, SelfCollision( "SelfCollision", getPxAggregate_SelfCollision)
, ConcreteTypeName( "ConcreteTypeName", getPxAggregate_ConcreteTypeName)
, UserData( "UserData", setPxAggregateUserData, getPxAggregateUserData )
{}
PX_PHYSX_CORE_API PxAggregateGeneratedValues::PxAggregateGeneratedValues( const PxAggregate* inSource )
:MaxNbActors( getPxAggregate_MaxNbActors( inSource ) )
,MaxNbShapes( getPxAggregate_MaxNbShapes( inSource ) )
,SelfCollision( getPxAggregate_SelfCollision( inSource ) )
,ConcreteTypeName( getPxAggregate_ConcreteTypeName( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
}
PxScene * getPxConstraint_Scene( const PxConstraint* inObj ) { return inObj->getScene(); }
void setPxConstraint_Actors( PxConstraint* inObj, PxRigidActor * inArg0, PxRigidActor * inArg1 ) { inObj->setActors( inArg0, inArg1 ); }
void getPxConstraint_Actors( const PxConstraint* inObj, PxRigidActor *& inArg0, PxRigidActor *& inArg1 ) { inObj->getActors( inArg0, inArg1 ); }
void setPxConstraint_Flags( PxConstraint* inObj, PxConstraintFlags inArg){ inObj->setFlags( inArg ); }
PxConstraintFlags getPxConstraint_Flags( const PxConstraint* inObj ) { return inObj->getFlags(); }
_Bool getPxConstraint_IsValid( const PxConstraint* inObj ) { return inObj->isValid(); }
void setPxConstraint_BreakForce( PxConstraint* inObj, PxReal inArg0, PxReal inArg1 ) { inObj->setBreakForce( inArg0, inArg1 ); }
void getPxConstraint_BreakForce( const PxConstraint* inObj, PxReal& inArg0, PxReal& inArg1 ) { inObj->getBreakForce( inArg0, inArg1 ); }
void setPxConstraint_MinResponseThreshold( PxConstraint* inObj, PxReal inArg){ inObj->setMinResponseThreshold( inArg ); }
PxReal getPxConstraint_MinResponseThreshold( const PxConstraint* inObj ) { return inObj->getMinResponseThreshold(); }
const char * getPxConstraint_ConcreteTypeName( const PxConstraint* inObj ) { return inObj->getConcreteTypeName(); }
inline void * getPxConstraintUserData( const PxConstraint* inOwner ) { return inOwner->userData; }
inline void setPxConstraintUserData( PxConstraint* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxConstraintGeneratedInfo::PxConstraintGeneratedInfo()
: Scene( "Scene", getPxConstraint_Scene)
, Actors( "Actors", "actor0", "actor1", setPxConstraint_Actors, getPxConstraint_Actors)
, Flags( "Flags", setPxConstraint_Flags, getPxConstraint_Flags)
, IsValid( "IsValid", getPxConstraint_IsValid)
, BreakForce( "BreakForce", "linear", "angular", setPxConstraint_BreakForce, getPxConstraint_BreakForce)
, MinResponseThreshold( "MinResponseThreshold", setPxConstraint_MinResponseThreshold, getPxConstraint_MinResponseThreshold)
, ConcreteTypeName( "ConcreteTypeName", getPxConstraint_ConcreteTypeName)
, UserData( "UserData", setPxConstraintUserData, getPxConstraintUserData )
{}
PX_PHYSX_CORE_API PxConstraintGeneratedValues::PxConstraintGeneratedValues( const PxConstraint* inSource )
:Scene( getPxConstraint_Scene( inSource ) )
,Flags( getPxConstraint_Flags( inSource ) )
,IsValid( getPxConstraint_IsValid( inSource ) )
,MinResponseThreshold( getPxConstraint_MinResponseThreshold( inSource ) )
,ConcreteTypeName( getPxConstraint_ConcreteTypeName( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
getPxConstraint_Actors( inSource, Actors[0], Actors[1] );
getPxConstraint_BreakForce( inSource, BreakForce[0], BreakForce[1] );
}
void setPxShape_LocalPose( PxShape* inObj, const PxTransform & inArg){ inObj->setLocalPose( inArg ); }
PxTransform getPxShape_LocalPose( const PxShape* inObj ) { return inObj->getLocalPose(); }
void setPxShape_SimulationFilterData( PxShape* inObj, const PxFilterData & inArg){ inObj->setSimulationFilterData( inArg ); }
PxFilterData getPxShape_SimulationFilterData( const PxShape* inObj ) { return inObj->getSimulationFilterData(); }
void setPxShape_QueryFilterData( PxShape* inObj, const PxFilterData & inArg){ inObj->setQueryFilterData( inArg ); }
PxFilterData getPxShape_QueryFilterData( const PxShape* inObj ) { return inObj->getQueryFilterData(); }
PxU32 getPxShape_Materials( const PxShape* inObj, PxMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getMaterials( outBuffer, inBufSize ); }
PxU32 getNbPxShape_Materials( const PxShape* inObj ) { return inObj->getNbMaterials( ); }
void setPxShape_ContactOffset( PxShape* inObj, PxReal inArg){ inObj->setContactOffset( inArg ); }
PxReal getPxShape_ContactOffset( const PxShape* inObj ) { return inObj->getContactOffset(); }
void setPxShape_RestOffset( PxShape* inObj, PxReal inArg){ inObj->setRestOffset( inArg ); }
PxReal getPxShape_RestOffset( const PxShape* inObj ) { return inObj->getRestOffset(); }
void setPxShape_DensityForFluid( PxShape* inObj, PxReal inArg){ inObj->setDensityForFluid( inArg ); }
PxReal getPxShape_DensityForFluid( const PxShape* inObj ) { return inObj->getDensityForFluid(); }
void setPxShape_TorsionalPatchRadius( PxShape* inObj, PxReal inArg){ inObj->setTorsionalPatchRadius( inArg ); }
PxReal getPxShape_TorsionalPatchRadius( const PxShape* inObj ) { return inObj->getTorsionalPatchRadius(); }
void setPxShape_MinTorsionalPatchRadius( PxShape* inObj, PxReal inArg){ inObj->setMinTorsionalPatchRadius( inArg ); }
PxReal getPxShape_MinTorsionalPatchRadius( const PxShape* inObj ) { return inObj->getMinTorsionalPatchRadius(); }
PxU32 getPxShape_InternalShapeIndex( const PxShape* inObj ) { return inObj->getInternalShapeIndex(); }
void setPxShape_Flags( PxShape* inObj, PxShapeFlags inArg){ inObj->setFlags( inArg ); }
PxShapeFlags getPxShape_Flags( const PxShape* inObj ) { return inObj->getFlags(); }
_Bool getPxShape_IsExclusive( const PxShape* inObj ) { return inObj->isExclusive(); }
void setPxShape_Name( PxShape* inObj, const char * inArg){ inObj->setName( inArg ); }
const char * getPxShape_Name( const PxShape* inObj ) { return inObj->getName(); }
const char * getPxShape_ConcreteTypeName( const PxShape* inObj ) { return inObj->getConcreteTypeName(); }
inline void * getPxShapeUserData( const PxShape* inOwner ) { return inOwner->userData; }
inline void setPxShapeUserData( PxShape* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxShapeGeneratedInfo::PxShapeGeneratedInfo()
: LocalPose( "LocalPose", setPxShape_LocalPose, getPxShape_LocalPose)
, SimulationFilterData( "SimulationFilterData", setPxShape_SimulationFilterData, getPxShape_SimulationFilterData)
, QueryFilterData( "QueryFilterData", setPxShape_QueryFilterData, getPxShape_QueryFilterData)
, Materials( "Materials", getPxShape_Materials, getNbPxShape_Materials )
, ContactOffset( "ContactOffset", setPxShape_ContactOffset, getPxShape_ContactOffset)
, RestOffset( "RestOffset", setPxShape_RestOffset, getPxShape_RestOffset)
, DensityForFluid( "DensityForFluid", setPxShape_DensityForFluid, getPxShape_DensityForFluid)
, TorsionalPatchRadius( "TorsionalPatchRadius", setPxShape_TorsionalPatchRadius, getPxShape_TorsionalPatchRadius)
, MinTorsionalPatchRadius( "MinTorsionalPatchRadius", setPxShape_MinTorsionalPatchRadius, getPxShape_MinTorsionalPatchRadius)
, InternalShapeIndex( "InternalShapeIndex", getPxShape_InternalShapeIndex)
, Flags( "Flags", setPxShape_Flags, getPxShape_Flags)
, IsExclusive( "IsExclusive", getPxShape_IsExclusive)
, Name( "Name", setPxShape_Name, getPxShape_Name)
, ConcreteTypeName( "ConcreteTypeName", getPxShape_ConcreteTypeName)
, UserData( "UserData", setPxShapeUserData, getPxShapeUserData )
{}
PX_PHYSX_CORE_API PxShapeGeneratedValues::PxShapeGeneratedValues( const PxShape* inSource )
:PxRefCountedGeneratedValues( inSource )
,LocalPose( getPxShape_LocalPose( inSource ) )
,SimulationFilterData( getPxShape_SimulationFilterData( inSource ) )
,QueryFilterData( getPxShape_QueryFilterData( inSource ) )
,ContactOffset( getPxShape_ContactOffset( inSource ) )
,RestOffset( getPxShape_RestOffset( inSource ) )
,DensityForFluid( getPxShape_DensityForFluid( inSource ) )
,TorsionalPatchRadius( getPxShape_TorsionalPatchRadius( inSource ) )
,MinTorsionalPatchRadius( getPxShape_MinTorsionalPatchRadius( inSource ) )
,InternalShapeIndex( getPxShape_InternalShapeIndex( inSource ) )
,Flags( getPxShape_Flags( inSource ) )
,IsExclusive( getPxShape_IsExclusive( inSource ) )
,Name( getPxShape_Name( inSource ) )
,ConcreteTypeName( getPxShape_ConcreteTypeName( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
Geom = PxGeometryHolder(inSource->getGeometry());
}
PxU32 getPxPruningStructure_RigidActors( const PxPruningStructure* inObj, PxRigidActor ** outBuffer, PxU32 inBufSize ) { return inObj->getRigidActors( outBuffer, inBufSize ); }
PxU32 getNbPxPruningStructure_RigidActors( const PxPruningStructure* inObj ) { return inObj->getNbRigidActors( ); }
const void * getPxPruningStructure_StaticMergeData( const PxPruningStructure* inObj ) { return inObj->getStaticMergeData(); }
const void * getPxPruningStructure_DynamicMergeData( const PxPruningStructure* inObj ) { return inObj->getDynamicMergeData(); }
const char * getPxPruningStructure_ConcreteTypeName( const PxPruningStructure* inObj ) { return inObj->getConcreteTypeName(); }
PX_PHYSX_CORE_API PxPruningStructureGeneratedInfo::PxPruningStructureGeneratedInfo()
: RigidActors( "RigidActors", getPxPruningStructure_RigidActors, getNbPxPruningStructure_RigidActors )
, StaticMergeData( "StaticMergeData", getPxPruningStructure_StaticMergeData)
, DynamicMergeData( "DynamicMergeData", getPxPruningStructure_DynamicMergeData)
, ConcreteTypeName( "ConcreteTypeName", getPxPruningStructure_ConcreteTypeName)
{}
PX_PHYSX_CORE_API PxPruningStructureGeneratedValues::PxPruningStructureGeneratedValues( const PxPruningStructure* inSource )
:StaticMergeData( getPxPruningStructure_StaticMergeData( inSource ) )
,DynamicMergeData( getPxPruningStructure_DynamicMergeData( inSource ) )
,ConcreteTypeName( getPxPruningStructure_ConcreteTypeName( inSource ) )
{
PX_UNUSED(inSource);
}
_Bool getPxTolerancesScale_IsValid( const PxTolerancesScale* inObj ) { return inObj->isValid(); }
inline PxReal getPxTolerancesScaleLength( const PxTolerancesScale* inOwner ) { return inOwner->length; }
inline void setPxTolerancesScaleLength( PxTolerancesScale* inOwner, PxReal inData) { inOwner->length = inData; }
inline PxReal getPxTolerancesScaleSpeed( const PxTolerancesScale* inOwner ) { return inOwner->speed; }
inline void setPxTolerancesScaleSpeed( PxTolerancesScale* inOwner, PxReal inData) { inOwner->speed = inData; }
PX_PHYSX_CORE_API PxTolerancesScaleGeneratedInfo::PxTolerancesScaleGeneratedInfo()
: IsValid( "IsValid", getPxTolerancesScale_IsValid)
, Length( "Length", setPxTolerancesScaleLength, getPxTolerancesScaleLength )
, Speed( "Speed", setPxTolerancesScaleSpeed, getPxTolerancesScaleSpeed )
{}
PX_PHYSX_CORE_API PxTolerancesScaleGeneratedValues::PxTolerancesScaleGeneratedValues( const PxTolerancesScale* inSource )
:IsValid( getPxTolerancesScale_IsValid( inSource ) )
,Length( inSource->length )
,Speed( inSource->speed )
{
PX_UNUSED(inSource);
}
PX_PHYSX_CORE_API PxGeometryGeneratedInfo::PxGeometryGeneratedInfo()
{}
PX_PHYSX_CORE_API PxGeometryGeneratedValues::PxGeometryGeneratedValues( const PxGeometry* inSource )
{
PX_UNUSED(inSource);
}
inline PxVec3 getPxBoxGeometryHalfExtents( const PxBoxGeometry* inOwner ) { return inOwner->halfExtents; }
inline void setPxBoxGeometryHalfExtents( PxBoxGeometry* inOwner, PxVec3 inData) { inOwner->halfExtents = inData; }
PX_PHYSX_CORE_API PxBoxGeometryGeneratedInfo::PxBoxGeometryGeneratedInfo()
: HalfExtents( "HalfExtents", setPxBoxGeometryHalfExtents, getPxBoxGeometryHalfExtents )
{}
PX_PHYSX_CORE_API PxBoxGeometryGeneratedValues::PxBoxGeometryGeneratedValues( const PxBoxGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,HalfExtents( inSource->halfExtents )
{
PX_UNUSED(inSource);
}
inline PxReal getPxCapsuleGeometryRadius( const PxCapsuleGeometry* inOwner ) { return inOwner->radius; }
inline void setPxCapsuleGeometryRadius( PxCapsuleGeometry* inOwner, PxReal inData) { inOwner->radius = inData; }
inline PxReal getPxCapsuleGeometryHalfHeight( const PxCapsuleGeometry* inOwner ) { return inOwner->halfHeight; }
inline void setPxCapsuleGeometryHalfHeight( PxCapsuleGeometry* inOwner, PxReal inData) { inOwner->halfHeight = inData; }
PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedInfo::PxCapsuleGeometryGeneratedInfo()
: Radius( "Radius", setPxCapsuleGeometryRadius, getPxCapsuleGeometryRadius )
, HalfHeight( "HalfHeight", setPxCapsuleGeometryHalfHeight, getPxCapsuleGeometryHalfHeight )
{}
PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedValues::PxCapsuleGeometryGeneratedValues( const PxCapsuleGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,Radius( inSource->radius )
,HalfHeight( inSource->halfHeight )
{
PX_UNUSED(inSource);
}
inline PxVec3 getPxMeshScaleScale( const PxMeshScale* inOwner ) { return inOwner->scale; }
inline void setPxMeshScaleScale( PxMeshScale* inOwner, PxVec3 inData) { inOwner->scale = inData; }
inline PxQuat getPxMeshScaleRotation( const PxMeshScale* inOwner ) { return inOwner->rotation; }
inline void setPxMeshScaleRotation( PxMeshScale* inOwner, PxQuat inData) { inOwner->rotation = inData; }
PX_PHYSX_CORE_API PxMeshScaleGeneratedInfo::PxMeshScaleGeneratedInfo()
: Scale( "Scale", setPxMeshScaleScale, getPxMeshScaleScale )
, Rotation( "Rotation", setPxMeshScaleRotation, getPxMeshScaleRotation )
{}
PX_PHYSX_CORE_API PxMeshScaleGeneratedValues::PxMeshScaleGeneratedValues( const PxMeshScale* inSource )
:Scale( inSource->scale )
,Rotation( inSource->rotation )
{
PX_UNUSED(inSource);
}
inline PxMeshScale getPxConvexMeshGeometryScale( const PxConvexMeshGeometry* inOwner ) { return inOwner->scale; }
inline void setPxConvexMeshGeometryScale( PxConvexMeshGeometry* inOwner, PxMeshScale inData) { inOwner->scale = inData; }
inline PxConvexMesh * getPxConvexMeshGeometryConvexMesh( const PxConvexMeshGeometry* inOwner ) { return inOwner->convexMesh; }
inline void setPxConvexMeshGeometryConvexMesh( PxConvexMeshGeometry* inOwner, PxConvexMesh * inData) { inOwner->convexMesh = inData; }
inline PxConvexMeshGeometryFlags getPxConvexMeshGeometryMeshFlags( const PxConvexMeshGeometry* inOwner ) { return inOwner->meshFlags; }
inline void setPxConvexMeshGeometryMeshFlags( PxConvexMeshGeometry* inOwner, PxConvexMeshGeometryFlags inData) { inOwner->meshFlags = inData; }
PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedInfo::PxConvexMeshGeometryGeneratedInfo()
: Scale( "Scale", setPxConvexMeshGeometryScale, getPxConvexMeshGeometryScale )
, ConvexMesh( "ConvexMesh", setPxConvexMeshGeometryConvexMesh, getPxConvexMeshGeometryConvexMesh )
, MeshFlags( "MeshFlags", setPxConvexMeshGeometryMeshFlags, getPxConvexMeshGeometryMeshFlags )
{}
PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedValues::PxConvexMeshGeometryGeneratedValues( const PxConvexMeshGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,Scale( inSource->scale )
,ConvexMesh( inSource->convexMesh )
,MeshFlags( inSource->meshFlags )
{
PX_UNUSED(inSource);
}
inline PxReal getPxSphereGeometryRadius( const PxSphereGeometry* inOwner ) { return inOwner->radius; }
inline void setPxSphereGeometryRadius( PxSphereGeometry* inOwner, PxReal inData) { inOwner->radius = inData; }
PX_PHYSX_CORE_API PxSphereGeometryGeneratedInfo::PxSphereGeometryGeneratedInfo()
: Radius( "Radius", setPxSphereGeometryRadius, getPxSphereGeometryRadius )
{}
PX_PHYSX_CORE_API PxSphereGeometryGeneratedValues::PxSphereGeometryGeneratedValues( const PxSphereGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,Radius( inSource->radius )
{
PX_UNUSED(inSource);
}
PX_PHYSX_CORE_API PxPlaneGeometryGeneratedInfo::PxPlaneGeometryGeneratedInfo()
{}
PX_PHYSX_CORE_API PxPlaneGeometryGeneratedValues::PxPlaneGeometryGeneratedValues( const PxPlaneGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
{
PX_UNUSED(inSource);
}
inline PxMeshScale getPxTriangleMeshGeometryScale( const PxTriangleMeshGeometry* inOwner ) { return inOwner->scale; }
inline void setPxTriangleMeshGeometryScale( PxTriangleMeshGeometry* inOwner, PxMeshScale inData) { inOwner->scale = inData; }
inline PxMeshGeometryFlags getPxTriangleMeshGeometryMeshFlags( const PxTriangleMeshGeometry* inOwner ) { return inOwner->meshFlags; }
inline void setPxTriangleMeshGeometryMeshFlags( PxTriangleMeshGeometry* inOwner, PxMeshGeometryFlags inData) { inOwner->meshFlags = inData; }
inline PxTriangleMesh * getPxTriangleMeshGeometryTriangleMesh( const PxTriangleMeshGeometry* inOwner ) { return inOwner->triangleMesh; }
inline void setPxTriangleMeshGeometryTriangleMesh( PxTriangleMeshGeometry* inOwner, PxTriangleMesh * inData) { inOwner->triangleMesh = inData; }
PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedInfo::PxTriangleMeshGeometryGeneratedInfo()
: Scale( "Scale", setPxTriangleMeshGeometryScale, getPxTriangleMeshGeometryScale )
, MeshFlags( "MeshFlags", setPxTriangleMeshGeometryMeshFlags, getPxTriangleMeshGeometryMeshFlags )
, TriangleMesh( "TriangleMesh", setPxTriangleMeshGeometryTriangleMesh, getPxTriangleMeshGeometryTriangleMesh )
{}
PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedValues::PxTriangleMeshGeometryGeneratedValues( const PxTriangleMeshGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,Scale( inSource->scale )
,MeshFlags( inSource->meshFlags )
,TriangleMesh( inSource->triangleMesh )
{
PX_UNUSED(inSource);
}
inline PxHeightField * getPxHeightFieldGeometryHeightField( const PxHeightFieldGeometry* inOwner ) { return inOwner->heightField; }
inline void setPxHeightFieldGeometryHeightField( PxHeightFieldGeometry* inOwner, PxHeightField * inData) { inOwner->heightField = inData; }
inline PxReal getPxHeightFieldGeometryHeightScale( const PxHeightFieldGeometry* inOwner ) { return inOwner->heightScale; }
inline void setPxHeightFieldGeometryHeightScale( PxHeightFieldGeometry* inOwner, PxReal inData) { inOwner->heightScale = inData; }
inline PxReal getPxHeightFieldGeometryRowScale( const PxHeightFieldGeometry* inOwner ) { return inOwner->rowScale; }
inline void setPxHeightFieldGeometryRowScale( PxHeightFieldGeometry* inOwner, PxReal inData) { inOwner->rowScale = inData; }
inline PxReal getPxHeightFieldGeometryColumnScale( const PxHeightFieldGeometry* inOwner ) { return inOwner->columnScale; }
inline void setPxHeightFieldGeometryColumnScale( PxHeightFieldGeometry* inOwner, PxReal inData) { inOwner->columnScale = inData; }
inline PxMeshGeometryFlags getPxHeightFieldGeometryHeightFieldFlags( const PxHeightFieldGeometry* inOwner ) { return inOwner->heightFieldFlags; }
inline void setPxHeightFieldGeometryHeightFieldFlags( PxHeightFieldGeometry* inOwner, PxMeshGeometryFlags inData) { inOwner->heightFieldFlags = inData; }
PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedInfo::PxHeightFieldGeometryGeneratedInfo()
: HeightField( "HeightField", setPxHeightFieldGeometryHeightField, getPxHeightFieldGeometryHeightField )
, HeightScale( "HeightScale", setPxHeightFieldGeometryHeightScale, getPxHeightFieldGeometryHeightScale )
, RowScale( "RowScale", setPxHeightFieldGeometryRowScale, getPxHeightFieldGeometryRowScale )
, ColumnScale( "ColumnScale", setPxHeightFieldGeometryColumnScale, getPxHeightFieldGeometryColumnScale )
, HeightFieldFlags( "HeightFieldFlags", setPxHeightFieldGeometryHeightFieldFlags, getPxHeightFieldGeometryHeightFieldFlags )
{}
PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedValues::PxHeightFieldGeometryGeneratedValues( const PxHeightFieldGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,HeightField( inSource->heightField )
,HeightScale( inSource->heightScale )
,RowScale( inSource->rowScale )
,ColumnScale( inSource->columnScale )
,HeightFieldFlags( inSource->heightFieldFlags )
{
PX_UNUSED(inSource);
}
void setPxSceneQuerySystemBase_DynamicTreeRebuildRateHint( PxSceneQuerySystemBase* inObj, PxU32 inArg){ inObj->setDynamicTreeRebuildRateHint( inArg ); }
PxU32 getPxSceneQuerySystemBase_DynamicTreeRebuildRateHint( const PxSceneQuerySystemBase* inObj ) { return inObj->getDynamicTreeRebuildRateHint(); }
void setPxSceneQuerySystemBase_UpdateMode( PxSceneQuerySystemBase* inObj, PxSceneQueryUpdateMode::Enum inArg){ inObj->setUpdateMode( inArg ); }
PxSceneQueryUpdateMode::Enum getPxSceneQuerySystemBase_UpdateMode( const PxSceneQuerySystemBase* inObj ) { return inObj->getUpdateMode(); }
PxU32 getPxSceneQuerySystemBase_StaticTimestamp( const PxSceneQuerySystemBase* inObj ) { return inObj->getStaticTimestamp(); }
PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedInfo::PxSceneQuerySystemBaseGeneratedInfo()
: DynamicTreeRebuildRateHint( "DynamicTreeRebuildRateHint", setPxSceneQuerySystemBase_DynamicTreeRebuildRateHint, getPxSceneQuerySystemBase_DynamicTreeRebuildRateHint)
, UpdateMode( "UpdateMode", setPxSceneQuerySystemBase_UpdateMode, getPxSceneQuerySystemBase_UpdateMode)
, StaticTimestamp( "StaticTimestamp", getPxSceneQuerySystemBase_StaticTimestamp)
{}
PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedValues::PxSceneQuerySystemBaseGeneratedValues( const PxSceneQuerySystemBase* inSource )
:DynamicTreeRebuildRateHint( getPxSceneQuerySystemBase_DynamicTreeRebuildRateHint( inSource ) )
,UpdateMode( getPxSceneQuerySystemBase_UpdateMode( inSource ) )
,StaticTimestamp( getPxSceneQuerySystemBase_StaticTimestamp( inSource ) )
{
PX_UNUSED(inSource);
}
void setPxSceneSQSystem_SceneQueryUpdateMode( PxSceneSQSystem* inObj, PxSceneQueryUpdateMode::Enum inArg){ inObj->setSceneQueryUpdateMode( inArg ); }
PxSceneQueryUpdateMode::Enum getPxSceneSQSystem_SceneQueryUpdateMode( const PxSceneSQSystem* inObj ) { return inObj->getSceneQueryUpdateMode(); }
PxU32 getPxSceneSQSystem_SceneQueryStaticTimestamp( const PxSceneSQSystem* inObj ) { return inObj->getSceneQueryStaticTimestamp(); }
PxPruningStructureType::Enum getPxSceneSQSystem_StaticStructure( const PxSceneSQSystem* inObj ) { return inObj->getStaticStructure(); }
PxPruningStructureType::Enum getPxSceneSQSystem_DynamicStructure( const PxSceneSQSystem* inObj ) { return inObj->getDynamicStructure(); }
PX_PHYSX_CORE_API PxSceneSQSystemGeneratedInfo::PxSceneSQSystemGeneratedInfo()
: SceneQueryUpdateMode( "SceneQueryUpdateMode", setPxSceneSQSystem_SceneQueryUpdateMode, getPxSceneSQSystem_SceneQueryUpdateMode)
, SceneQueryStaticTimestamp( "SceneQueryStaticTimestamp", getPxSceneSQSystem_SceneQueryStaticTimestamp)
, StaticStructure( "StaticStructure", getPxSceneSQSystem_StaticStructure)
, DynamicStructure( "DynamicStructure", getPxSceneSQSystem_DynamicStructure)
{}
PX_PHYSX_CORE_API PxSceneSQSystemGeneratedValues::PxSceneSQSystemGeneratedValues( const PxSceneSQSystem* inSource )
:PxSceneQuerySystemBaseGeneratedValues( inSource )
,SceneQueryUpdateMode( getPxSceneSQSystem_SceneQueryUpdateMode( inSource ) )
,SceneQueryStaticTimestamp( getPxSceneSQSystem_SceneQueryStaticTimestamp( inSource ) )
,StaticStructure( getPxSceneSQSystem_StaticStructure( inSource ) )
,DynamicStructure( getPxSceneSQSystem_DynamicStructure( inSource ) )
{
PX_UNUSED(inSource);
}
PxSceneFlags getPxScene_Flags( const PxScene* inObj ) { return inObj->getFlags(); }
void setPxScene_Limits( PxScene* inObj, const PxSceneLimits & inArg){ inObj->setLimits( inArg ); }
PxSceneLimits getPxScene_Limits( const PxScene* inObj ) { return inObj->getLimits(); }
PxU32 getPxScene_Timestamp( const PxScene* inObj ) { return inObj->getTimestamp(); }
void setPxScene_Name( PxScene* inObj, const char * inArg){ inObj->setName( inArg ); }
const char * getPxScene_Name( const PxScene* inObj ) { return inObj->getName(); }
PxU32 getPxScene_Actors( const PxScene* inObj, PxActorTypeFlags inFilter, PxActor ** outBuffer, PxU32 inBufSize ) { return inObj->getActors( inFilter, outBuffer, inBufSize ); }
PxU32 getNbPxScene_Actors( const PxScene* inObj, PxActorTypeFlags inFilter ) { return inObj->getNbActors( inFilter ); }
PxU32 getPxScene_SoftBodies( const PxScene* inObj, PxSoftBody ** outBuffer, PxU32 inBufSize ) { return inObj->getSoftBodies( outBuffer, inBufSize ); }
PxU32 getNbPxScene_SoftBodies( const PxScene* inObj ) { return inObj->getNbSoftBodies( ); }
PxU32 getPxScene_Articulations( const PxScene* inObj, PxArticulationReducedCoordinate ** outBuffer, PxU32 inBufSize ) { return inObj->getArticulations( outBuffer, inBufSize ); }
PxU32 getNbPxScene_Articulations( const PxScene* inObj ) { return inObj->getNbArticulations( ); }
PxU32 getPxScene_Constraints( const PxScene* inObj, PxConstraint ** outBuffer, PxU32 inBufSize ) { return inObj->getConstraints( outBuffer, inBufSize ); }
PxU32 getNbPxScene_Constraints( const PxScene* inObj ) { return inObj->getNbConstraints( ); }
PxU32 getPxScene_Aggregates( const PxScene* inObj, PxAggregate ** outBuffer, PxU32 inBufSize ) { return inObj->getAggregates( outBuffer, inBufSize ); }
PxU32 getNbPxScene_Aggregates( const PxScene* inObj ) { return inObj->getNbAggregates( ); }
PxCpuDispatcher * getPxScene_CpuDispatcher( const PxScene* inObj ) { return inObj->getCpuDispatcher(); }
PxCudaContextManager * getPxScene_CudaContextManager( const PxScene* inObj ) { return inObj->getCudaContextManager(); }
void setPxScene_SimulationEventCallback( PxScene* inObj, PxSimulationEventCallback * inArg){ inObj->setSimulationEventCallback( inArg ); }
PxSimulationEventCallback * getPxScene_SimulationEventCallback( const PxScene* inObj ) { return inObj->getSimulationEventCallback(); }
void setPxScene_ContactModifyCallback( PxScene* inObj, PxContactModifyCallback * inArg){ inObj->setContactModifyCallback( inArg ); }
PxContactModifyCallback * getPxScene_ContactModifyCallback( const PxScene* inObj ) { return inObj->getContactModifyCallback(); }
void setPxScene_CCDContactModifyCallback( PxScene* inObj, PxCCDContactModifyCallback * inArg){ inObj->setCCDContactModifyCallback( inArg ); }
PxCCDContactModifyCallback * getPxScene_CCDContactModifyCallback( const PxScene* inObj ) { return inObj->getCCDContactModifyCallback(); }
void setPxScene_BroadPhaseCallback( PxScene* inObj, PxBroadPhaseCallback * inArg){ inObj->setBroadPhaseCallback( inArg ); }
PxBroadPhaseCallback * getPxScene_BroadPhaseCallback( const PxScene* inObj ) { return inObj->getBroadPhaseCallback(); }
PxU32 getPxScene_FilterShaderDataSize( const PxScene* inObj ) { return inObj->getFilterShaderDataSize(); }
PxSimulationFilterShader getPxScene_FilterShader( const PxScene* inObj ) { return inObj->getFilterShader(); }
PxSimulationFilterCallback * getPxScene_FilterCallback( const PxScene* inObj ) { return inObj->getFilterCallback(); }
PxPairFilteringMode::Enum getPxScene_KinematicKinematicFilteringMode( const PxScene* inObj ) { return inObj->getKinematicKinematicFilteringMode(); }
PxPairFilteringMode::Enum getPxScene_StaticKinematicFilteringMode( const PxScene* inObj ) { return inObj->getStaticKinematicFilteringMode(); }
void setPxScene_Gravity( PxScene* inObj, const PxVec3 & inArg){ inObj->setGravity( inArg ); }
PxVec3 getPxScene_Gravity( const PxScene* inObj ) { return inObj->getGravity(); }
void setPxScene_BounceThresholdVelocity( PxScene* inObj, const PxReal inArg){ inObj->setBounceThresholdVelocity( inArg ); }
PxReal getPxScene_BounceThresholdVelocity( const PxScene* inObj ) { return inObj->getBounceThresholdVelocity(); }
void setPxScene_CCDMaxPasses( PxScene* inObj, PxU32 inArg){ inObj->setCCDMaxPasses( inArg ); }
PxU32 getPxScene_CCDMaxPasses( const PxScene* inObj ) { return inObj->getCCDMaxPasses(); }
void setPxScene_CCDMaxSeparation( PxScene* inObj, const PxReal inArg){ inObj->setCCDMaxSeparation( inArg ); }
PxReal getPxScene_CCDMaxSeparation( const PxScene* inObj ) { return inObj->getCCDMaxSeparation(); }
void setPxScene_CCDThreshold( PxScene* inObj, const PxReal inArg){ inObj->setCCDThreshold( inArg ); }
PxReal getPxScene_CCDThreshold( const PxScene* inObj ) { return inObj->getCCDThreshold(); }
void setPxScene_MaxBiasCoefficient( PxScene* inObj, const PxReal inArg){ inObj->setMaxBiasCoefficient( inArg ); }
PxReal getPxScene_MaxBiasCoefficient( const PxScene* inObj ) { return inObj->getMaxBiasCoefficient(); }
void setPxScene_FrictionOffsetThreshold( PxScene* inObj, const PxReal inArg){ inObj->setFrictionOffsetThreshold( inArg ); }
PxReal getPxScene_FrictionOffsetThreshold( const PxScene* inObj ) { return inObj->getFrictionOffsetThreshold(); }
void setPxScene_FrictionCorrelationDistance( PxScene* inObj, const PxReal inArg){ inObj->setFrictionCorrelationDistance( inArg ); }
PxReal getPxScene_FrictionCorrelationDistance( const PxScene* inObj ) { return inObj->getFrictionCorrelationDistance(); }
PxFrictionType::Enum getPxScene_FrictionType( const PxScene* inObj ) { return inObj->getFrictionType(); }
PxSolverType::Enum getPxScene_SolverType( const PxScene* inObj ) { return inObj->getSolverType(); }
void setPxScene_VisualizationCullingBox( PxScene* inObj, const PxBounds3 & inArg){ inObj->setVisualizationCullingBox( inArg ); }
PxBounds3 getPxScene_VisualizationCullingBox( const PxScene* inObj ) { return inObj->getVisualizationCullingBox(); }
PxBroadPhaseType::Enum getPxScene_BroadPhaseType( const PxScene* inObj ) { return inObj->getBroadPhaseType(); }
PxU32 getPxScene_BroadPhaseRegions( const PxScene* inObj, PxBroadPhaseRegionInfo* outBuffer, PxU32 inBufSize ) { return inObj->getBroadPhaseRegions( outBuffer, inBufSize ); }
PxU32 getNbPxScene_BroadPhaseRegions( const PxScene* inObj ) { return inObj->getNbBroadPhaseRegions( ); }
PxTaskManager * getPxScene_TaskManager( const PxScene* inObj ) { return inObj->getTaskManager(); }
void setPxScene_NbContactDataBlocks( PxScene* inObj, PxU32 inArg){ inObj->setNbContactDataBlocks( inArg ); }
PxU32 getPxScene_MaxNbContactDataBlocksUsed( const PxScene* inObj ) { return inObj->getMaxNbContactDataBlocksUsed(); }
PxU32 getPxScene_ContactReportStreamBufferSize( const PxScene* inObj ) { return inObj->getContactReportStreamBufferSize(); }
void setPxScene_SolverBatchSize( PxScene* inObj, PxU32 inArg){ inObj->setSolverBatchSize( inArg ); }
PxU32 getPxScene_SolverBatchSize( const PxScene* inObj ) { return inObj->getSolverBatchSize(); }
void setPxScene_SolverArticulationBatchSize( PxScene* inObj, PxU32 inArg){ inObj->setSolverArticulationBatchSize( inArg ); }
PxU32 getPxScene_SolverArticulationBatchSize( const PxScene* inObj ) { return inObj->getSolverArticulationBatchSize(); }
PxReal getPxScene_WakeCounterResetValue( const PxScene* inObj ) { return inObj->getWakeCounterResetValue(); }
PxgDynamicsMemoryConfig getPxScene_GpuDynamicsConfig( const PxScene* inObj ) { return inObj->getGpuDynamicsConfig(); }
inline void * getPxSceneUserData( const PxScene* inOwner ) { return inOwner->userData; }
inline void setPxSceneUserData( PxScene* inOwner, void * inData) { inOwner->userData = inData; }
PX_PHYSX_CORE_API PxSceneGeneratedInfo::PxSceneGeneratedInfo()
: Flags( "Flags", getPxScene_Flags)
, Limits( "Limits", setPxScene_Limits, getPxScene_Limits)
, Timestamp( "Timestamp", getPxScene_Timestamp)
, Name( "Name", setPxScene_Name, getPxScene_Name)
, Actors( "Actors", getPxScene_Actors, getNbPxScene_Actors )
, SoftBodies( "SoftBodies", getPxScene_SoftBodies, getNbPxScene_SoftBodies )
, Articulations( "Articulations", getPxScene_Articulations, getNbPxScene_Articulations )
, Constraints( "Constraints", getPxScene_Constraints, getNbPxScene_Constraints )
, Aggregates( "Aggregates", getPxScene_Aggregates, getNbPxScene_Aggregates )
, CpuDispatcher( "CpuDispatcher", getPxScene_CpuDispatcher)
, CudaContextManager( "CudaContextManager", getPxScene_CudaContextManager)
, SimulationEventCallback( "SimulationEventCallback", setPxScene_SimulationEventCallback, getPxScene_SimulationEventCallback)
, ContactModifyCallback( "ContactModifyCallback", setPxScene_ContactModifyCallback, getPxScene_ContactModifyCallback)
, CCDContactModifyCallback( "CCDContactModifyCallback", setPxScene_CCDContactModifyCallback, getPxScene_CCDContactModifyCallback)
, BroadPhaseCallback( "BroadPhaseCallback", setPxScene_BroadPhaseCallback, getPxScene_BroadPhaseCallback)
, FilterShaderDataSize( "FilterShaderDataSize", getPxScene_FilterShaderDataSize)
, FilterShader( "FilterShader", getPxScene_FilterShader)
, FilterCallback( "FilterCallback", getPxScene_FilterCallback)
, KinematicKinematicFilteringMode( "KinematicKinematicFilteringMode", getPxScene_KinematicKinematicFilteringMode)
, StaticKinematicFilteringMode( "StaticKinematicFilteringMode", getPxScene_StaticKinematicFilteringMode)
, Gravity( "Gravity", setPxScene_Gravity, getPxScene_Gravity)
, BounceThresholdVelocity( "BounceThresholdVelocity", setPxScene_BounceThresholdVelocity, getPxScene_BounceThresholdVelocity)
, CCDMaxPasses( "CCDMaxPasses", setPxScene_CCDMaxPasses, getPxScene_CCDMaxPasses)
, CCDMaxSeparation( "CCDMaxSeparation", setPxScene_CCDMaxSeparation, getPxScene_CCDMaxSeparation)
, CCDThreshold( "CCDThreshold", setPxScene_CCDThreshold, getPxScene_CCDThreshold)
, MaxBiasCoefficient( "MaxBiasCoefficient", setPxScene_MaxBiasCoefficient, getPxScene_MaxBiasCoefficient)
, FrictionOffsetThreshold( "FrictionOffsetThreshold", setPxScene_FrictionOffsetThreshold, getPxScene_FrictionOffsetThreshold)
, FrictionCorrelationDistance( "FrictionCorrelationDistance", setPxScene_FrictionCorrelationDistance, getPxScene_FrictionCorrelationDistance)
, FrictionType( "FrictionType", getPxScene_FrictionType)
, SolverType( "SolverType", getPxScene_SolverType)
, VisualizationCullingBox( "VisualizationCullingBox", setPxScene_VisualizationCullingBox, getPxScene_VisualizationCullingBox)
, BroadPhaseType( "BroadPhaseType", getPxScene_BroadPhaseType)
, BroadPhaseRegions( "BroadPhaseRegions", getPxScene_BroadPhaseRegions, getNbPxScene_BroadPhaseRegions )
, TaskManager( "TaskManager", getPxScene_TaskManager)
, NbContactDataBlocks( "NbContactDataBlocks", setPxScene_NbContactDataBlocks)
, MaxNbContactDataBlocksUsed( "MaxNbContactDataBlocksUsed", getPxScene_MaxNbContactDataBlocksUsed)
, ContactReportStreamBufferSize( "ContactReportStreamBufferSize", getPxScene_ContactReportStreamBufferSize)
, SolverBatchSize( "SolverBatchSize", setPxScene_SolverBatchSize, getPxScene_SolverBatchSize)
, SolverArticulationBatchSize( "SolverArticulationBatchSize", setPxScene_SolverArticulationBatchSize, getPxScene_SolverArticulationBatchSize)
, WakeCounterResetValue( "WakeCounterResetValue", getPxScene_WakeCounterResetValue)
, GpuDynamicsConfig( "GpuDynamicsConfig", getPxScene_GpuDynamicsConfig)
, UserData( "UserData", setPxSceneUserData, getPxSceneUserData )
{}
PX_PHYSX_CORE_API PxSceneGeneratedValues::PxSceneGeneratedValues( const PxScene* inSource )
:PxSceneSQSystemGeneratedValues( inSource )
,Flags( getPxScene_Flags( inSource ) )
,Limits( getPxScene_Limits( inSource ) )
,Timestamp( getPxScene_Timestamp( inSource ) )
,Name( getPxScene_Name( inSource ) )
,CpuDispatcher( getPxScene_CpuDispatcher( inSource ) )
,CudaContextManager( getPxScene_CudaContextManager( inSource ) )
,SimulationEventCallback( getPxScene_SimulationEventCallback( inSource ) )
,ContactModifyCallback( getPxScene_ContactModifyCallback( inSource ) )
,CCDContactModifyCallback( getPxScene_CCDContactModifyCallback( inSource ) )
,BroadPhaseCallback( getPxScene_BroadPhaseCallback( inSource ) )
,FilterShaderDataSize( getPxScene_FilterShaderDataSize( inSource ) )
,FilterShader( getPxScene_FilterShader( inSource ) )
,FilterCallback( getPxScene_FilterCallback( inSource ) )
,KinematicKinematicFilteringMode( getPxScene_KinematicKinematicFilteringMode( inSource ) )
,StaticKinematicFilteringMode( getPxScene_StaticKinematicFilteringMode( inSource ) )
,Gravity( getPxScene_Gravity( inSource ) )
,BounceThresholdVelocity( getPxScene_BounceThresholdVelocity( inSource ) )
,CCDMaxPasses( getPxScene_CCDMaxPasses( inSource ) )
,CCDMaxSeparation( getPxScene_CCDMaxSeparation( inSource ) )
,CCDThreshold( getPxScene_CCDThreshold( inSource ) )
,MaxBiasCoefficient( getPxScene_MaxBiasCoefficient( inSource ) )
,FrictionOffsetThreshold( getPxScene_FrictionOffsetThreshold( inSource ) )
,FrictionCorrelationDistance( getPxScene_FrictionCorrelationDistance( inSource ) )
,FrictionType( getPxScene_FrictionType( inSource ) )
,SolverType( getPxScene_SolverType( inSource ) )
,VisualizationCullingBox( getPxScene_VisualizationCullingBox( inSource ) )
,BroadPhaseType( getPxScene_BroadPhaseType( inSource ) )
,TaskManager( getPxScene_TaskManager( inSource ) )
,MaxNbContactDataBlocksUsed( getPxScene_MaxNbContactDataBlocksUsed( inSource ) )
,ContactReportStreamBufferSize( getPxScene_ContactReportStreamBufferSize( inSource ) )
,SolverBatchSize( getPxScene_SolverBatchSize( inSource ) )
,SolverArticulationBatchSize( getPxScene_SolverArticulationBatchSize( inSource ) )
,WakeCounterResetValue( getPxScene_WakeCounterResetValue( inSource ) )
,GpuDynamicsConfig( getPxScene_GpuDynamicsConfig( inSource ) )
,UserData( inSource->userData )
{
PX_UNUSED(inSource);
inSource->getSimulationStatistics(SimulationStatistics);
}
inline PxTetrahedronMesh * getPxTetrahedronMeshGeometryTetrahedronMesh( const PxTetrahedronMeshGeometry* inOwner ) { return inOwner->tetrahedronMesh; }
inline void setPxTetrahedronMeshGeometryTetrahedronMesh( PxTetrahedronMeshGeometry* inOwner, PxTetrahedronMesh * inData) { inOwner->tetrahedronMesh = inData; }
PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedInfo::PxTetrahedronMeshGeometryGeneratedInfo()
: TetrahedronMesh( "TetrahedronMesh", setPxTetrahedronMeshGeometryTetrahedronMesh, getPxTetrahedronMeshGeometryTetrahedronMesh )
{}
PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedValues::PxTetrahedronMeshGeometryGeneratedValues( const PxTetrahedronMeshGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
,TetrahedronMesh( inSource->tetrahedronMesh )
{
PX_UNUSED(inSource);
}
PX_PHYSX_CORE_API PxCustomGeometryGeneratedInfo::PxCustomGeometryGeneratedInfo()
{}
PX_PHYSX_CORE_API PxCustomGeometryGeneratedValues::PxCustomGeometryGeneratedValues( const PxCustomGeometry* inSource )
:PxGeometryGeneratedValues( inSource )
{
PX_UNUSED(inSource);
PxCustomGeometry::Type t = inSource->callbacks->getCustomType(); CustomType = *reinterpret_cast<const PxU32*>(&t);
}
inline PxU32 getPxHeightFieldDescNbRows( const PxHeightFieldDesc* inOwner ) { return inOwner->nbRows; }
inline void setPxHeightFieldDescNbRows( PxHeightFieldDesc* inOwner, PxU32 inData) { inOwner->nbRows = inData; }
inline PxU32 getPxHeightFieldDescNbColumns( const PxHeightFieldDesc* inOwner ) { return inOwner->nbColumns; }
inline void setPxHeightFieldDescNbColumns( PxHeightFieldDesc* inOwner, PxU32 inData) { inOwner->nbColumns = inData; }
inline PxHeightFieldFormat::Enum getPxHeightFieldDescFormat( const PxHeightFieldDesc* inOwner ) { return inOwner->format; }
inline void setPxHeightFieldDescFormat( PxHeightFieldDesc* inOwner, PxHeightFieldFormat::Enum inData) { inOwner->format = inData; }
inline PxStridedData getPxHeightFieldDescSamples( const PxHeightFieldDesc* inOwner ) { return inOwner->samples; }
inline void setPxHeightFieldDescSamples( PxHeightFieldDesc* inOwner, PxStridedData inData) { inOwner->samples = inData; }
inline PxReal getPxHeightFieldDescConvexEdgeThreshold( const PxHeightFieldDesc* inOwner ) { return inOwner->convexEdgeThreshold; }
inline void setPxHeightFieldDescConvexEdgeThreshold( PxHeightFieldDesc* inOwner, PxReal inData) { inOwner->convexEdgeThreshold = inData; }
inline PxHeightFieldFlags getPxHeightFieldDescFlags( const PxHeightFieldDesc* inOwner ) { return inOwner->flags; }
inline void setPxHeightFieldDescFlags( PxHeightFieldDesc* inOwner, PxHeightFieldFlags inData) { inOwner->flags = inData; }
PX_PHYSX_CORE_API PxHeightFieldDescGeneratedInfo::PxHeightFieldDescGeneratedInfo()
: NbRows( "NbRows", setPxHeightFieldDescNbRows, getPxHeightFieldDescNbRows )
, NbColumns( "NbColumns", setPxHeightFieldDescNbColumns, getPxHeightFieldDescNbColumns )
, Format( "Format", setPxHeightFieldDescFormat, getPxHeightFieldDescFormat )
, Samples( "Samples", setPxHeightFieldDescSamples, getPxHeightFieldDescSamples )
, ConvexEdgeThreshold( "ConvexEdgeThreshold", setPxHeightFieldDescConvexEdgeThreshold, getPxHeightFieldDescConvexEdgeThreshold )
, Flags( "Flags", setPxHeightFieldDescFlags, getPxHeightFieldDescFlags )
{}
PX_PHYSX_CORE_API PxHeightFieldDescGeneratedValues::PxHeightFieldDescGeneratedValues( const PxHeightFieldDesc* inSource )
:NbRows( inSource->nbRows )
,NbColumns( inSource->nbColumns )
,Format( inSource->format )
,Samples( inSource->samples )
,ConvexEdgeThreshold( inSource->convexEdgeThreshold )
,Flags( inSource->flags )
{
PX_UNUSED(inSource);
}
inline PxReal getPxArticulationLimitLow( const PxArticulationLimit* inOwner ) { return inOwner->low; }
inline void setPxArticulationLimitLow( PxArticulationLimit* inOwner, PxReal inData) { inOwner->low = inData; }
inline PxReal getPxArticulationLimitHigh( const PxArticulationLimit* inOwner ) { return inOwner->high; }
inline void setPxArticulationLimitHigh( PxArticulationLimit* inOwner, PxReal inData) { inOwner->high = inData; }
PX_PHYSX_CORE_API PxArticulationLimitGeneratedInfo::PxArticulationLimitGeneratedInfo()
: Low( "Low", setPxArticulationLimitLow, getPxArticulationLimitLow )
, High( "High", setPxArticulationLimitHigh, getPxArticulationLimitHigh )
{}
PX_PHYSX_CORE_API PxArticulationLimitGeneratedValues::PxArticulationLimitGeneratedValues( const PxArticulationLimit* inSource )
:Low( inSource->low )
,High( inSource->high )
{
PX_UNUSED(inSource);
}
inline PxReal getPxArticulationDriveStiffness( const PxArticulationDrive* inOwner ) { return inOwner->stiffness; }
inline void setPxArticulationDriveStiffness( PxArticulationDrive* inOwner, PxReal inData) { inOwner->stiffness = inData; }
inline PxReal getPxArticulationDriveDamping( const PxArticulationDrive* inOwner ) { return inOwner->damping; }
inline void setPxArticulationDriveDamping( PxArticulationDrive* inOwner, PxReal inData) { inOwner->damping = inData; }
inline PxReal getPxArticulationDriveMaxForce( const PxArticulationDrive* inOwner ) { return inOwner->maxForce; }
inline void setPxArticulationDriveMaxForce( PxArticulationDrive* inOwner, PxReal inData) { inOwner->maxForce = inData; }
inline PxArticulationDriveType::Enum getPxArticulationDriveDriveType( const PxArticulationDrive* inOwner ) { return inOwner->driveType; }
inline void setPxArticulationDriveDriveType( PxArticulationDrive* inOwner, PxArticulationDriveType::Enum inData) { inOwner->driveType = inData; }
PX_PHYSX_CORE_API PxArticulationDriveGeneratedInfo::PxArticulationDriveGeneratedInfo()
: Stiffness( "Stiffness", setPxArticulationDriveStiffness, getPxArticulationDriveStiffness )
, Damping( "Damping", setPxArticulationDriveDamping, getPxArticulationDriveDamping )
, MaxForce( "MaxForce", setPxArticulationDriveMaxForce, getPxArticulationDriveMaxForce )
, DriveType( "DriveType", setPxArticulationDriveDriveType, getPxArticulationDriveDriveType )
{}
PX_PHYSX_CORE_API PxArticulationDriveGeneratedValues::PxArticulationDriveGeneratedValues( const PxArticulationDrive* inSource )
:Stiffness( inSource->stiffness )
,Damping( inSource->damping )
,MaxForce( inSource->maxForce )
,DriveType( inSource->driveType )
{
PX_UNUSED(inSource);
}
_Bool getPxSceneQueryDesc_IsValid( const PxSceneQueryDesc* inObj ) { return inObj->isValid(); }
inline PxPruningStructureType::Enum getPxSceneQueryDescStaticStructure( const PxSceneQueryDesc* inOwner ) { return inOwner->staticStructure; }
inline void setPxSceneQueryDescStaticStructure( PxSceneQueryDesc* inOwner, PxPruningStructureType::Enum inData) { inOwner->staticStructure = inData; }
inline PxPruningStructureType::Enum getPxSceneQueryDescDynamicStructure( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicStructure; }
inline void setPxSceneQueryDescDynamicStructure( PxSceneQueryDesc* inOwner, PxPruningStructureType::Enum inData) { inOwner->dynamicStructure = inData; }
inline PxU32 getPxSceneQueryDescDynamicTreeRebuildRateHint( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicTreeRebuildRateHint; }
inline void setPxSceneQueryDescDynamicTreeRebuildRateHint( PxSceneQueryDesc* inOwner, PxU32 inData) { inOwner->dynamicTreeRebuildRateHint = inData; }
inline PxDynamicTreeSecondaryPruner::Enum getPxSceneQueryDescDynamicTreeSecondaryPruner( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicTreeSecondaryPruner; }
inline void setPxSceneQueryDescDynamicTreeSecondaryPruner( PxSceneQueryDesc* inOwner, PxDynamicTreeSecondaryPruner::Enum inData) { inOwner->dynamicTreeSecondaryPruner = inData; }
inline PxBVHBuildStrategy::Enum getPxSceneQueryDescStaticBVHBuildStrategy( const PxSceneQueryDesc* inOwner ) { return inOwner->staticBVHBuildStrategy; }
inline void setPxSceneQueryDescStaticBVHBuildStrategy( PxSceneQueryDesc* inOwner, PxBVHBuildStrategy::Enum inData) { inOwner->staticBVHBuildStrategy = inData; }
inline PxBVHBuildStrategy::Enum getPxSceneQueryDescDynamicBVHBuildStrategy( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicBVHBuildStrategy; }
inline void setPxSceneQueryDescDynamicBVHBuildStrategy( PxSceneQueryDesc* inOwner, PxBVHBuildStrategy::Enum inData) { inOwner->dynamicBVHBuildStrategy = inData; }
inline PxU32 getPxSceneQueryDescStaticNbObjectsPerNode( const PxSceneQueryDesc* inOwner ) { return inOwner->staticNbObjectsPerNode; }
inline void setPxSceneQueryDescStaticNbObjectsPerNode( PxSceneQueryDesc* inOwner, PxU32 inData) { inOwner->staticNbObjectsPerNode = inData; }
inline PxU32 getPxSceneQueryDescDynamicNbObjectsPerNode( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicNbObjectsPerNode; }
inline void setPxSceneQueryDescDynamicNbObjectsPerNode( PxSceneQueryDesc* inOwner, PxU32 inData) { inOwner->dynamicNbObjectsPerNode = inData; }
inline PxSceneQueryUpdateMode::Enum getPxSceneQueryDescSceneQueryUpdateMode( const PxSceneQueryDesc* inOwner ) { return inOwner->sceneQueryUpdateMode; }
inline void setPxSceneQueryDescSceneQueryUpdateMode( PxSceneQueryDesc* inOwner, PxSceneQueryUpdateMode::Enum inData) { inOwner->sceneQueryUpdateMode = inData; }
PX_PHYSX_CORE_API PxSceneQueryDescGeneratedInfo::PxSceneQueryDescGeneratedInfo()
: IsValid( "IsValid", getPxSceneQueryDesc_IsValid)
, StaticStructure( "StaticStructure", setPxSceneQueryDescStaticStructure, getPxSceneQueryDescStaticStructure )
, DynamicStructure( "DynamicStructure", setPxSceneQueryDescDynamicStructure, getPxSceneQueryDescDynamicStructure )
, DynamicTreeRebuildRateHint( "DynamicTreeRebuildRateHint", setPxSceneQueryDescDynamicTreeRebuildRateHint, getPxSceneQueryDescDynamicTreeRebuildRateHint )
, DynamicTreeSecondaryPruner( "DynamicTreeSecondaryPruner", setPxSceneQueryDescDynamicTreeSecondaryPruner, getPxSceneQueryDescDynamicTreeSecondaryPruner )
, StaticBVHBuildStrategy( "StaticBVHBuildStrategy", setPxSceneQueryDescStaticBVHBuildStrategy, getPxSceneQueryDescStaticBVHBuildStrategy )
, DynamicBVHBuildStrategy( "DynamicBVHBuildStrategy", setPxSceneQueryDescDynamicBVHBuildStrategy, getPxSceneQueryDescDynamicBVHBuildStrategy )
, StaticNbObjectsPerNode( "StaticNbObjectsPerNode", setPxSceneQueryDescStaticNbObjectsPerNode, getPxSceneQueryDescStaticNbObjectsPerNode )
, DynamicNbObjectsPerNode( "DynamicNbObjectsPerNode", setPxSceneQueryDescDynamicNbObjectsPerNode, getPxSceneQueryDescDynamicNbObjectsPerNode )
, SceneQueryUpdateMode( "SceneQueryUpdateMode", setPxSceneQueryDescSceneQueryUpdateMode, getPxSceneQueryDescSceneQueryUpdateMode )
{}
PX_PHYSX_CORE_API PxSceneQueryDescGeneratedValues::PxSceneQueryDescGeneratedValues( const PxSceneQueryDesc* inSource )
:IsValid( getPxSceneQueryDesc_IsValid( inSource ) )
,StaticStructure( inSource->staticStructure )
,DynamicStructure( inSource->dynamicStructure )
,DynamicTreeRebuildRateHint( inSource->dynamicTreeRebuildRateHint )
,DynamicTreeSecondaryPruner( inSource->dynamicTreeSecondaryPruner )
,StaticBVHBuildStrategy( inSource->staticBVHBuildStrategy )
,DynamicBVHBuildStrategy( inSource->dynamicBVHBuildStrategy )
,StaticNbObjectsPerNode( inSource->staticNbObjectsPerNode )
,DynamicNbObjectsPerNode( inSource->dynamicNbObjectsPerNode )
,SceneQueryUpdateMode( inSource->sceneQueryUpdateMode )
{
PX_UNUSED(inSource);
}
void setPxSceneDesc_ToDefault( PxSceneDesc* inObj, const PxTolerancesScale & inArg){ inObj->setToDefault( inArg ); }
inline PxVec3 getPxSceneDescGravity( const PxSceneDesc* inOwner ) { return inOwner->gravity; }
inline void setPxSceneDescGravity( PxSceneDesc* inOwner, PxVec3 inData) { inOwner->gravity = inData; }
inline PxSimulationEventCallback * getPxSceneDescSimulationEventCallback( const PxSceneDesc* inOwner ) { return inOwner->simulationEventCallback; }
inline void setPxSceneDescSimulationEventCallback( PxSceneDesc* inOwner, PxSimulationEventCallback * inData) { inOwner->simulationEventCallback = inData; }
inline PxContactModifyCallback * getPxSceneDescContactModifyCallback( const PxSceneDesc* inOwner ) { return inOwner->contactModifyCallback; }
inline void setPxSceneDescContactModifyCallback( PxSceneDesc* inOwner, PxContactModifyCallback * inData) { inOwner->contactModifyCallback = inData; }
inline PxCCDContactModifyCallback * getPxSceneDescCcdContactModifyCallback( const PxSceneDesc* inOwner ) { return inOwner->ccdContactModifyCallback; }
inline void setPxSceneDescCcdContactModifyCallback( PxSceneDesc* inOwner, PxCCDContactModifyCallback * inData) { inOwner->ccdContactModifyCallback = inData; }
inline const void * getPxSceneDescFilterShaderData( const PxSceneDesc* inOwner ) { return inOwner->filterShaderData; }
inline void setPxSceneDescFilterShaderData( PxSceneDesc* inOwner, const void * inData) { inOwner->filterShaderData = inData; }
inline PxU32 getPxSceneDescFilterShaderDataSize( const PxSceneDesc* inOwner ) { return inOwner->filterShaderDataSize; }
inline void setPxSceneDescFilterShaderDataSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->filterShaderDataSize = inData; }
inline PxSimulationFilterShader getPxSceneDescFilterShader( const PxSceneDesc* inOwner ) { return inOwner->filterShader; }
inline void setPxSceneDescFilterShader( PxSceneDesc* inOwner, PxSimulationFilterShader inData) { inOwner->filterShader = inData; }
inline PxSimulationFilterCallback * getPxSceneDescFilterCallback( const PxSceneDesc* inOwner ) { return inOwner->filterCallback; }
inline void setPxSceneDescFilterCallback( PxSceneDesc* inOwner, PxSimulationFilterCallback * inData) { inOwner->filterCallback = inData; }
inline PxPairFilteringMode::Enum getPxSceneDescKineKineFilteringMode( const PxSceneDesc* inOwner ) { return inOwner->kineKineFilteringMode; }
inline void setPxSceneDescKineKineFilteringMode( PxSceneDesc* inOwner, PxPairFilteringMode::Enum inData) { inOwner->kineKineFilteringMode = inData; }
inline PxPairFilteringMode::Enum getPxSceneDescStaticKineFilteringMode( const PxSceneDesc* inOwner ) { return inOwner->staticKineFilteringMode; }
inline void setPxSceneDescStaticKineFilteringMode( PxSceneDesc* inOwner, PxPairFilteringMode::Enum inData) { inOwner->staticKineFilteringMode = inData; }
inline PxBroadPhaseType::Enum getPxSceneDescBroadPhaseType( const PxSceneDesc* inOwner ) { return inOwner->broadPhaseType; }
inline void setPxSceneDescBroadPhaseType( PxSceneDesc* inOwner, PxBroadPhaseType::Enum inData) { inOwner->broadPhaseType = inData; }
inline PxBroadPhaseCallback * getPxSceneDescBroadPhaseCallback( const PxSceneDesc* inOwner ) { return inOwner->broadPhaseCallback; }
inline void setPxSceneDescBroadPhaseCallback( PxSceneDesc* inOwner, PxBroadPhaseCallback * inData) { inOwner->broadPhaseCallback = inData; }
inline PxSceneLimits getPxSceneDescLimits( const PxSceneDesc* inOwner ) { return inOwner->limits; }
inline void setPxSceneDescLimits( PxSceneDesc* inOwner, PxSceneLimits inData) { inOwner->limits = inData; }
inline PxFrictionType::Enum getPxSceneDescFrictionType( const PxSceneDesc* inOwner ) { return inOwner->frictionType; }
inline void setPxSceneDescFrictionType( PxSceneDesc* inOwner, PxFrictionType::Enum inData) { inOwner->frictionType = inData; }
inline PxSolverType::Enum getPxSceneDescSolverType( const PxSceneDesc* inOwner ) { return inOwner->solverType; }
inline void setPxSceneDescSolverType( PxSceneDesc* inOwner, PxSolverType::Enum inData) { inOwner->solverType = inData; }
inline PxReal getPxSceneDescBounceThresholdVelocity( const PxSceneDesc* inOwner ) { return inOwner->bounceThresholdVelocity; }
inline void setPxSceneDescBounceThresholdVelocity( PxSceneDesc* inOwner, PxReal inData) { inOwner->bounceThresholdVelocity = inData; }
inline PxReal getPxSceneDescFrictionOffsetThreshold( const PxSceneDesc* inOwner ) { return inOwner->frictionOffsetThreshold; }
inline void setPxSceneDescFrictionOffsetThreshold( PxSceneDesc* inOwner, PxReal inData) { inOwner->frictionOffsetThreshold = inData; }
inline PxReal getPxSceneDescFrictionCorrelationDistance( const PxSceneDesc* inOwner ) { return inOwner->frictionCorrelationDistance; }
inline void setPxSceneDescFrictionCorrelationDistance( PxSceneDesc* inOwner, PxReal inData) { inOwner->frictionCorrelationDistance = inData; }
inline PxSceneFlags getPxSceneDescFlags( const PxSceneDesc* inOwner ) { return inOwner->flags; }
inline void setPxSceneDescFlags( PxSceneDesc* inOwner, PxSceneFlags inData) { inOwner->flags = inData; }
inline PxCpuDispatcher * getPxSceneDescCpuDispatcher( const PxSceneDesc* inOwner ) { return inOwner->cpuDispatcher; }
inline void setPxSceneDescCpuDispatcher( PxSceneDesc* inOwner, PxCpuDispatcher * inData) { inOwner->cpuDispatcher = inData; }
inline PxCudaContextManager * getPxSceneDescCudaContextManager( const PxSceneDesc* inOwner ) { return inOwner->cudaContextManager; }
inline void setPxSceneDescCudaContextManager( PxSceneDesc* inOwner, PxCudaContextManager * inData) { inOwner->cudaContextManager = inData; }
inline void * getPxSceneDescUserData( const PxSceneDesc* inOwner ) { return inOwner->userData; }
inline void setPxSceneDescUserData( PxSceneDesc* inOwner, void * inData) { inOwner->userData = inData; }
inline PxU32 getPxSceneDescSolverBatchSize( const PxSceneDesc* inOwner ) { return inOwner->solverBatchSize; }
inline void setPxSceneDescSolverBatchSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->solverBatchSize = inData; }
inline PxU32 getPxSceneDescSolverArticulationBatchSize( const PxSceneDesc* inOwner ) { return inOwner->solverArticulationBatchSize; }
inline void setPxSceneDescSolverArticulationBatchSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->solverArticulationBatchSize = inData; }
inline PxU32 getPxSceneDescNbContactDataBlocks( const PxSceneDesc* inOwner ) { return inOwner->nbContactDataBlocks; }
inline void setPxSceneDescNbContactDataBlocks( PxSceneDesc* inOwner, PxU32 inData) { inOwner->nbContactDataBlocks = inData; }
inline PxU32 getPxSceneDescMaxNbContactDataBlocks( const PxSceneDesc* inOwner ) { return inOwner->maxNbContactDataBlocks; }
inline void setPxSceneDescMaxNbContactDataBlocks( PxSceneDesc* inOwner, PxU32 inData) { inOwner->maxNbContactDataBlocks = inData; }
inline PxReal getPxSceneDescMaxBiasCoefficient( const PxSceneDesc* inOwner ) { return inOwner->maxBiasCoefficient; }
inline void setPxSceneDescMaxBiasCoefficient( PxSceneDesc* inOwner, PxReal inData) { inOwner->maxBiasCoefficient = inData; }
inline PxU32 getPxSceneDescContactReportStreamBufferSize( const PxSceneDesc* inOwner ) { return inOwner->contactReportStreamBufferSize; }
inline void setPxSceneDescContactReportStreamBufferSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->contactReportStreamBufferSize = inData; }
inline PxU32 getPxSceneDescCcdMaxPasses( const PxSceneDesc* inOwner ) { return inOwner->ccdMaxPasses; }
inline void setPxSceneDescCcdMaxPasses( PxSceneDesc* inOwner, PxU32 inData) { inOwner->ccdMaxPasses = inData; }
inline PxReal getPxSceneDescCcdThreshold( const PxSceneDesc* inOwner ) { return inOwner->ccdThreshold; }
inline void setPxSceneDescCcdThreshold( PxSceneDesc* inOwner, PxReal inData) { inOwner->ccdThreshold = inData; }
inline PxReal getPxSceneDescCcdMaxSeparation( const PxSceneDesc* inOwner ) { return inOwner->ccdMaxSeparation; }
inline void setPxSceneDescCcdMaxSeparation( PxSceneDesc* inOwner, PxReal inData) { inOwner->ccdMaxSeparation = inData; }
inline PxReal getPxSceneDescWakeCounterResetValue( const PxSceneDesc* inOwner ) { return inOwner->wakeCounterResetValue; }
inline void setPxSceneDescWakeCounterResetValue( PxSceneDesc* inOwner, PxReal inData) { inOwner->wakeCounterResetValue = inData; }
inline PxBounds3 getPxSceneDescSanityBounds( const PxSceneDesc* inOwner ) { return inOwner->sanityBounds; }
inline void setPxSceneDescSanityBounds( PxSceneDesc* inOwner, PxBounds3 inData) { inOwner->sanityBounds = inData; }
inline PxgDynamicsMemoryConfig getPxSceneDescGpuDynamicsConfig( const PxSceneDesc* inOwner ) { return inOwner->gpuDynamicsConfig; }
inline void setPxSceneDescGpuDynamicsConfig( PxSceneDesc* inOwner, PxgDynamicsMemoryConfig inData) { inOwner->gpuDynamicsConfig = inData; }
inline PxU32 getPxSceneDescGpuMaxNumPartitions( const PxSceneDesc* inOwner ) { return inOwner->gpuMaxNumPartitions; }
inline void setPxSceneDescGpuMaxNumPartitions( PxSceneDesc* inOwner, PxU32 inData) { inOwner->gpuMaxNumPartitions = inData; }
inline PxU32 getPxSceneDescGpuMaxNumStaticPartitions( const PxSceneDesc* inOwner ) { return inOwner->gpuMaxNumStaticPartitions; }
inline void setPxSceneDescGpuMaxNumStaticPartitions( PxSceneDesc* inOwner, PxU32 inData) { inOwner->gpuMaxNumStaticPartitions = inData; }
inline PxU32 getPxSceneDescGpuComputeVersion( const PxSceneDesc* inOwner ) { return inOwner->gpuComputeVersion; }
inline void setPxSceneDescGpuComputeVersion( PxSceneDesc* inOwner, PxU32 inData) { inOwner->gpuComputeVersion = inData; }
inline PxU32 getPxSceneDescContactPairSlabSize( const PxSceneDesc* inOwner ) { return inOwner->contactPairSlabSize; }
inline void setPxSceneDescContactPairSlabSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->contactPairSlabSize = inData; }
PX_PHYSX_CORE_API PxSceneDescGeneratedInfo::PxSceneDescGeneratedInfo()
: ToDefault( "ToDefault", setPxSceneDesc_ToDefault)
, Gravity( "Gravity", setPxSceneDescGravity, getPxSceneDescGravity )
, SimulationEventCallback( "SimulationEventCallback", setPxSceneDescSimulationEventCallback, getPxSceneDescSimulationEventCallback )
, ContactModifyCallback( "ContactModifyCallback", setPxSceneDescContactModifyCallback, getPxSceneDescContactModifyCallback )
, CcdContactModifyCallback( "CcdContactModifyCallback", setPxSceneDescCcdContactModifyCallback, getPxSceneDescCcdContactModifyCallback )
, FilterShaderData( "FilterShaderData", setPxSceneDescFilterShaderData, getPxSceneDescFilterShaderData )
, FilterShaderDataSize( "FilterShaderDataSize", setPxSceneDescFilterShaderDataSize, getPxSceneDescFilterShaderDataSize )
, FilterShader( "FilterShader", setPxSceneDescFilterShader, getPxSceneDescFilterShader )
, FilterCallback( "FilterCallback", setPxSceneDescFilterCallback, getPxSceneDescFilterCallback )
, KineKineFilteringMode( "KineKineFilteringMode", setPxSceneDescKineKineFilteringMode, getPxSceneDescKineKineFilteringMode )
, StaticKineFilteringMode( "StaticKineFilteringMode", setPxSceneDescStaticKineFilteringMode, getPxSceneDescStaticKineFilteringMode )
, BroadPhaseType( "BroadPhaseType", setPxSceneDescBroadPhaseType, getPxSceneDescBroadPhaseType )
, BroadPhaseCallback( "BroadPhaseCallback", setPxSceneDescBroadPhaseCallback, getPxSceneDescBroadPhaseCallback )
, Limits( "Limits", setPxSceneDescLimits, getPxSceneDescLimits )
, FrictionType( "FrictionType", setPxSceneDescFrictionType, getPxSceneDescFrictionType )
, SolverType( "SolverType", setPxSceneDescSolverType, getPxSceneDescSolverType )
, BounceThresholdVelocity( "BounceThresholdVelocity", setPxSceneDescBounceThresholdVelocity, getPxSceneDescBounceThresholdVelocity )
, FrictionOffsetThreshold( "FrictionOffsetThreshold", setPxSceneDescFrictionOffsetThreshold, getPxSceneDescFrictionOffsetThreshold )
, FrictionCorrelationDistance( "FrictionCorrelationDistance", setPxSceneDescFrictionCorrelationDistance, getPxSceneDescFrictionCorrelationDistance )
, Flags( "Flags", setPxSceneDescFlags, getPxSceneDescFlags )
, CpuDispatcher( "CpuDispatcher", setPxSceneDescCpuDispatcher, getPxSceneDescCpuDispatcher )
, CudaContextManager( "CudaContextManager", setPxSceneDescCudaContextManager, getPxSceneDescCudaContextManager )
, UserData( "UserData", setPxSceneDescUserData, getPxSceneDescUserData )
, SolverBatchSize( "SolverBatchSize", setPxSceneDescSolverBatchSize, getPxSceneDescSolverBatchSize )
, SolverArticulationBatchSize( "SolverArticulationBatchSize", setPxSceneDescSolverArticulationBatchSize, getPxSceneDescSolverArticulationBatchSize )
, NbContactDataBlocks( "NbContactDataBlocks", setPxSceneDescNbContactDataBlocks, getPxSceneDescNbContactDataBlocks )
, MaxNbContactDataBlocks( "MaxNbContactDataBlocks", setPxSceneDescMaxNbContactDataBlocks, getPxSceneDescMaxNbContactDataBlocks )
, MaxBiasCoefficient( "MaxBiasCoefficient", setPxSceneDescMaxBiasCoefficient, getPxSceneDescMaxBiasCoefficient )
, ContactReportStreamBufferSize( "ContactReportStreamBufferSize", setPxSceneDescContactReportStreamBufferSize, getPxSceneDescContactReportStreamBufferSize )
, CcdMaxPasses( "CcdMaxPasses", setPxSceneDescCcdMaxPasses, getPxSceneDescCcdMaxPasses )
, CcdThreshold( "CcdThreshold", setPxSceneDescCcdThreshold, getPxSceneDescCcdThreshold )
, CcdMaxSeparation( "CcdMaxSeparation", setPxSceneDescCcdMaxSeparation, getPxSceneDescCcdMaxSeparation )
, WakeCounterResetValue( "WakeCounterResetValue", setPxSceneDescWakeCounterResetValue, getPxSceneDescWakeCounterResetValue )
, SanityBounds( "SanityBounds", setPxSceneDescSanityBounds, getPxSceneDescSanityBounds )
, GpuDynamicsConfig( "GpuDynamicsConfig", setPxSceneDescGpuDynamicsConfig, getPxSceneDescGpuDynamicsConfig )
, GpuMaxNumPartitions( "GpuMaxNumPartitions", setPxSceneDescGpuMaxNumPartitions, getPxSceneDescGpuMaxNumPartitions )
, GpuMaxNumStaticPartitions( "GpuMaxNumStaticPartitions", setPxSceneDescGpuMaxNumStaticPartitions, getPxSceneDescGpuMaxNumStaticPartitions )
, GpuComputeVersion( "GpuComputeVersion", setPxSceneDescGpuComputeVersion, getPxSceneDescGpuComputeVersion )
, ContactPairSlabSize( "ContactPairSlabSize", setPxSceneDescContactPairSlabSize, getPxSceneDescContactPairSlabSize )
{}
PX_PHYSX_CORE_API PxSceneDescGeneratedValues::PxSceneDescGeneratedValues( const PxSceneDesc* inSource )
:PxSceneQueryDescGeneratedValues( inSource )
,Gravity( inSource->gravity )
,SimulationEventCallback( inSource->simulationEventCallback )
,ContactModifyCallback( inSource->contactModifyCallback )
,CcdContactModifyCallback( inSource->ccdContactModifyCallback )
,FilterShaderData( inSource->filterShaderData )
,FilterShaderDataSize( inSource->filterShaderDataSize )
,FilterShader( inSource->filterShader )
,FilterCallback( inSource->filterCallback )
,KineKineFilteringMode( inSource->kineKineFilteringMode )
,StaticKineFilteringMode( inSource->staticKineFilteringMode )
,BroadPhaseType( inSource->broadPhaseType )
,BroadPhaseCallback( inSource->broadPhaseCallback )
,Limits( inSource->limits )
,FrictionType( inSource->frictionType )
,SolverType( inSource->solverType )
,BounceThresholdVelocity( inSource->bounceThresholdVelocity )
,FrictionOffsetThreshold( inSource->frictionOffsetThreshold )
,FrictionCorrelationDistance( inSource->frictionCorrelationDistance )
,Flags( inSource->flags )
,CpuDispatcher( inSource->cpuDispatcher )
,CudaContextManager( inSource->cudaContextManager )
,UserData( inSource->userData )
,SolverBatchSize( inSource->solverBatchSize )
,SolverArticulationBatchSize( inSource->solverArticulationBatchSize )
,NbContactDataBlocks( inSource->nbContactDataBlocks )
,MaxNbContactDataBlocks( inSource->maxNbContactDataBlocks )
,MaxBiasCoefficient( inSource->maxBiasCoefficient )
,ContactReportStreamBufferSize( inSource->contactReportStreamBufferSize )
,CcdMaxPasses( inSource->ccdMaxPasses )
,CcdThreshold( inSource->ccdThreshold )
,CcdMaxSeparation( inSource->ccdMaxSeparation )
,WakeCounterResetValue( inSource->wakeCounterResetValue )
,SanityBounds( inSource->sanityBounds )
,GpuDynamicsConfig( inSource->gpuDynamicsConfig )
,GpuMaxNumPartitions( inSource->gpuMaxNumPartitions )
,GpuMaxNumStaticPartitions( inSource->gpuMaxNumStaticPartitions )
,GpuComputeVersion( inSource->gpuComputeVersion )
,ContactPairSlabSize( inSource->contactPairSlabSize )
{
PX_UNUSED(inSource);
}
_Bool getPxBroadPhaseDesc_IsValid( const PxBroadPhaseDesc* inObj ) { return inObj->isValid(); }
inline PxBroadPhaseType::Enum getPxBroadPhaseDescMType( const PxBroadPhaseDesc* inOwner ) { return inOwner->mType; }
inline void setPxBroadPhaseDescMType( PxBroadPhaseDesc* inOwner, PxBroadPhaseType::Enum inData) { inOwner->mType = inData; }
inline PxU64 getPxBroadPhaseDescMContextID( const PxBroadPhaseDesc* inOwner ) { return inOwner->mContextID; }
inline void setPxBroadPhaseDescMContextID( PxBroadPhaseDesc* inOwner, PxU64 inData) { inOwner->mContextID = inData; }
inline PxCudaContextManager * getPxBroadPhaseDescMContextManager( const PxBroadPhaseDesc* inOwner ) { return inOwner->mContextManager; }
inline void setPxBroadPhaseDescMContextManager( PxBroadPhaseDesc* inOwner, PxCudaContextManager * inData) { inOwner->mContextManager = inData; }
inline PxU32 getPxBroadPhaseDescMFoundLostPairsCapacity( const PxBroadPhaseDesc* inOwner ) { return inOwner->mFoundLostPairsCapacity; }
inline void setPxBroadPhaseDescMFoundLostPairsCapacity( PxBroadPhaseDesc* inOwner, PxU32 inData) { inOwner->mFoundLostPairsCapacity = inData; }
inline _Bool getPxBroadPhaseDescMDiscardStaticVsKinematic( const PxBroadPhaseDesc* inOwner ) { return inOwner->mDiscardStaticVsKinematic; }
inline void setPxBroadPhaseDescMDiscardStaticVsKinematic( PxBroadPhaseDesc* inOwner, _Bool inData) { inOwner->mDiscardStaticVsKinematic = inData; }
inline _Bool getPxBroadPhaseDescMDiscardKinematicVsKinematic( const PxBroadPhaseDesc* inOwner ) { return inOwner->mDiscardKinematicVsKinematic; }
inline void setPxBroadPhaseDescMDiscardKinematicVsKinematic( PxBroadPhaseDesc* inOwner, _Bool inData) { inOwner->mDiscardKinematicVsKinematic = inData; }
PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedInfo::PxBroadPhaseDescGeneratedInfo()
: IsValid( "IsValid", getPxBroadPhaseDesc_IsValid)
, MType( "MType", setPxBroadPhaseDescMType, getPxBroadPhaseDescMType )
, MContextID( "MContextID", setPxBroadPhaseDescMContextID, getPxBroadPhaseDescMContextID )
, MContextManager( "MContextManager", setPxBroadPhaseDescMContextManager, getPxBroadPhaseDescMContextManager )
, MFoundLostPairsCapacity( "MFoundLostPairsCapacity", setPxBroadPhaseDescMFoundLostPairsCapacity, getPxBroadPhaseDescMFoundLostPairsCapacity )
, MDiscardStaticVsKinematic( "MDiscardStaticVsKinematic", setPxBroadPhaseDescMDiscardStaticVsKinematic, getPxBroadPhaseDescMDiscardStaticVsKinematic )
, MDiscardKinematicVsKinematic( "MDiscardKinematicVsKinematic", setPxBroadPhaseDescMDiscardKinematicVsKinematic, getPxBroadPhaseDescMDiscardKinematicVsKinematic )
{}
PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedValues::PxBroadPhaseDescGeneratedValues( const PxBroadPhaseDesc* inSource )
:IsValid( getPxBroadPhaseDesc_IsValid( inSource ) )
,MType( inSource->mType )
,MContextID( inSource->mContextID )
,MContextManager( inSource->mContextManager )
,MFoundLostPairsCapacity( inSource->mFoundLostPairsCapacity )
,MDiscardStaticVsKinematic( inSource->mDiscardStaticVsKinematic )
,MDiscardKinematicVsKinematic( inSource->mDiscardKinematicVsKinematic )
{
PX_UNUSED(inSource);
}
inline PxU32 getPxSceneLimitsMaxNbActors( const PxSceneLimits* inOwner ) { return inOwner->maxNbActors; }
inline void setPxSceneLimitsMaxNbActors( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbActors = inData; }
inline PxU32 getPxSceneLimitsMaxNbBodies( const PxSceneLimits* inOwner ) { return inOwner->maxNbBodies; }
inline void setPxSceneLimitsMaxNbBodies( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbBodies = inData; }
inline PxU32 getPxSceneLimitsMaxNbStaticShapes( const PxSceneLimits* inOwner ) { return inOwner->maxNbStaticShapes; }
inline void setPxSceneLimitsMaxNbStaticShapes( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbStaticShapes = inData; }
inline PxU32 getPxSceneLimitsMaxNbDynamicShapes( const PxSceneLimits* inOwner ) { return inOwner->maxNbDynamicShapes; }
inline void setPxSceneLimitsMaxNbDynamicShapes( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbDynamicShapes = inData; }
inline PxU32 getPxSceneLimitsMaxNbAggregates( const PxSceneLimits* inOwner ) { return inOwner->maxNbAggregates; }
inline void setPxSceneLimitsMaxNbAggregates( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbAggregates = inData; }
inline PxU32 getPxSceneLimitsMaxNbConstraints( const PxSceneLimits* inOwner ) { return inOwner->maxNbConstraints; }
inline void setPxSceneLimitsMaxNbConstraints( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbConstraints = inData; }
inline PxU32 getPxSceneLimitsMaxNbRegions( const PxSceneLimits* inOwner ) { return inOwner->maxNbRegions; }
inline void setPxSceneLimitsMaxNbRegions( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbRegions = inData; }
inline PxU32 getPxSceneLimitsMaxNbBroadPhaseOverlaps( const PxSceneLimits* inOwner ) { return inOwner->maxNbBroadPhaseOverlaps; }
inline void setPxSceneLimitsMaxNbBroadPhaseOverlaps( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbBroadPhaseOverlaps = inData; }
PX_PHYSX_CORE_API PxSceneLimitsGeneratedInfo::PxSceneLimitsGeneratedInfo()
: MaxNbActors( "MaxNbActors", setPxSceneLimitsMaxNbActors, getPxSceneLimitsMaxNbActors )
, MaxNbBodies( "MaxNbBodies", setPxSceneLimitsMaxNbBodies, getPxSceneLimitsMaxNbBodies )
, MaxNbStaticShapes( "MaxNbStaticShapes", setPxSceneLimitsMaxNbStaticShapes, getPxSceneLimitsMaxNbStaticShapes )
, MaxNbDynamicShapes( "MaxNbDynamicShapes", setPxSceneLimitsMaxNbDynamicShapes, getPxSceneLimitsMaxNbDynamicShapes )
, MaxNbAggregates( "MaxNbAggregates", setPxSceneLimitsMaxNbAggregates, getPxSceneLimitsMaxNbAggregates )
, MaxNbConstraints( "MaxNbConstraints", setPxSceneLimitsMaxNbConstraints, getPxSceneLimitsMaxNbConstraints )
, MaxNbRegions( "MaxNbRegions", setPxSceneLimitsMaxNbRegions, getPxSceneLimitsMaxNbRegions )
, MaxNbBroadPhaseOverlaps( "MaxNbBroadPhaseOverlaps", setPxSceneLimitsMaxNbBroadPhaseOverlaps, getPxSceneLimitsMaxNbBroadPhaseOverlaps )
{}
PX_PHYSX_CORE_API PxSceneLimitsGeneratedValues::PxSceneLimitsGeneratedValues( const PxSceneLimits* inSource )
:MaxNbActors( inSource->maxNbActors )
,MaxNbBodies( inSource->maxNbBodies )
,MaxNbStaticShapes( inSource->maxNbStaticShapes )
,MaxNbDynamicShapes( inSource->maxNbDynamicShapes )
,MaxNbAggregates( inSource->maxNbAggregates )
,MaxNbConstraints( inSource->maxNbConstraints )
,MaxNbRegions( inSource->maxNbRegions )
,MaxNbBroadPhaseOverlaps( inSource->maxNbBroadPhaseOverlaps )
{
PX_UNUSED(inSource);
}
_Bool getPxgDynamicsMemoryConfig_IsValid( const PxgDynamicsMemoryConfig* inObj ) { return inObj->isValid(); }
inline PxU32 getPxgDynamicsMemoryConfigTempBufferCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->tempBufferCapacity; }
inline void setPxgDynamicsMemoryConfigTempBufferCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->tempBufferCapacity = inData; }
inline PxU32 getPxgDynamicsMemoryConfigMaxRigidContactCount( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxRigidContactCount; }
inline void setPxgDynamicsMemoryConfigMaxRigidContactCount( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxRigidContactCount = inData; }
inline PxU32 getPxgDynamicsMemoryConfigMaxRigidPatchCount( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxRigidPatchCount; }
inline void setPxgDynamicsMemoryConfigMaxRigidPatchCount( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxRigidPatchCount = inData; }
inline PxU32 getPxgDynamicsMemoryConfigHeapCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->heapCapacity; }
inline void setPxgDynamicsMemoryConfigHeapCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->heapCapacity = inData; }
inline PxU32 getPxgDynamicsMemoryConfigFoundLostPairsCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->foundLostPairsCapacity; }
inline void setPxgDynamicsMemoryConfigFoundLostPairsCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->foundLostPairsCapacity = inData; }
inline PxU32 getPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->foundLostAggregatePairsCapacity; }
inline void setPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->foundLostAggregatePairsCapacity = inData; }
inline PxU32 getPxgDynamicsMemoryConfigTotalAggregatePairsCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->totalAggregatePairsCapacity; }
inline void setPxgDynamicsMemoryConfigTotalAggregatePairsCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->totalAggregatePairsCapacity = inData; }
inline PxU32 getPxgDynamicsMemoryConfigMaxSoftBodyContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxSoftBodyContacts; }
inline void setPxgDynamicsMemoryConfigMaxSoftBodyContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxSoftBodyContacts = inData; }
inline PxU32 getPxgDynamicsMemoryConfigMaxFemClothContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxFemClothContacts; }
inline void setPxgDynamicsMemoryConfigMaxFemClothContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxFemClothContacts = inData; }
inline PxU32 getPxgDynamicsMemoryConfigMaxParticleContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxParticleContacts; }
inline void setPxgDynamicsMemoryConfigMaxParticleContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxParticleContacts = inData; }
inline PxU32 getPxgDynamicsMemoryConfigCollisionStackSize( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->collisionStackSize; }
inline void setPxgDynamicsMemoryConfigCollisionStackSize( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->collisionStackSize = inData; }
inline PxU32 getPxgDynamicsMemoryConfigMaxHairContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxHairContacts; }
inline void setPxgDynamicsMemoryConfigMaxHairContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxHairContacts = inData; }
PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedInfo::PxgDynamicsMemoryConfigGeneratedInfo()
: IsValid( "IsValid", getPxgDynamicsMemoryConfig_IsValid)
, TempBufferCapacity( "TempBufferCapacity", setPxgDynamicsMemoryConfigTempBufferCapacity, getPxgDynamicsMemoryConfigTempBufferCapacity )
, MaxRigidContactCount( "MaxRigidContactCount", setPxgDynamicsMemoryConfigMaxRigidContactCount, getPxgDynamicsMemoryConfigMaxRigidContactCount )
, MaxRigidPatchCount( "MaxRigidPatchCount", setPxgDynamicsMemoryConfigMaxRigidPatchCount, getPxgDynamicsMemoryConfigMaxRigidPatchCount )
, HeapCapacity( "HeapCapacity", setPxgDynamicsMemoryConfigHeapCapacity, getPxgDynamicsMemoryConfigHeapCapacity )
, FoundLostPairsCapacity( "FoundLostPairsCapacity", setPxgDynamicsMemoryConfigFoundLostPairsCapacity, getPxgDynamicsMemoryConfigFoundLostPairsCapacity )
, FoundLostAggregatePairsCapacity( "FoundLostAggregatePairsCapacity", setPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity, getPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity )
, TotalAggregatePairsCapacity( "TotalAggregatePairsCapacity", setPxgDynamicsMemoryConfigTotalAggregatePairsCapacity, getPxgDynamicsMemoryConfigTotalAggregatePairsCapacity )
, MaxSoftBodyContacts( "MaxSoftBodyContacts", setPxgDynamicsMemoryConfigMaxSoftBodyContacts, getPxgDynamicsMemoryConfigMaxSoftBodyContacts )
, MaxFemClothContacts( "MaxFemClothContacts", setPxgDynamicsMemoryConfigMaxFemClothContacts, getPxgDynamicsMemoryConfigMaxFemClothContacts )
, MaxParticleContacts( "MaxParticleContacts", setPxgDynamicsMemoryConfigMaxParticleContacts, getPxgDynamicsMemoryConfigMaxParticleContacts )
, CollisionStackSize( "CollisionStackSize", setPxgDynamicsMemoryConfigCollisionStackSize, getPxgDynamicsMemoryConfigCollisionStackSize )
, MaxHairContacts( "MaxHairContacts", setPxgDynamicsMemoryConfigMaxHairContacts, getPxgDynamicsMemoryConfigMaxHairContacts )
{}
PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedValues::PxgDynamicsMemoryConfigGeneratedValues( const PxgDynamicsMemoryConfig* inSource )
:IsValid( getPxgDynamicsMemoryConfig_IsValid( inSource ) )
,TempBufferCapacity( inSource->tempBufferCapacity )
,MaxRigidContactCount( inSource->maxRigidContactCount )
,MaxRigidPatchCount( inSource->maxRigidPatchCount )
,HeapCapacity( inSource->heapCapacity )
,FoundLostPairsCapacity( inSource->foundLostPairsCapacity )
,FoundLostAggregatePairsCapacity( inSource->foundLostAggregatePairsCapacity )
,TotalAggregatePairsCapacity( inSource->totalAggregatePairsCapacity )
,MaxSoftBodyContacts( inSource->maxSoftBodyContacts )
,MaxFemClothContacts( inSource->maxFemClothContacts )
,MaxParticleContacts( inSource->maxParticleContacts )
,CollisionStackSize( inSource->collisionStackSize )
,MaxHairContacts( inSource->maxHairContacts )
{
PX_UNUSED(inSource);
}
inline PxU32 getPxSimulationStatisticsNbActiveConstraints( const PxSimulationStatistics* inOwner ) { return inOwner->nbActiveConstraints; }
inline void setPxSimulationStatisticsNbActiveConstraints( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbActiveConstraints = inData; }
inline PxU32 getPxSimulationStatisticsNbActiveDynamicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbActiveDynamicBodies; }
inline void setPxSimulationStatisticsNbActiveDynamicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbActiveDynamicBodies = inData; }
inline PxU32 getPxSimulationStatisticsNbActiveKinematicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbActiveKinematicBodies; }
inline void setPxSimulationStatisticsNbActiveKinematicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbActiveKinematicBodies = inData; }
inline PxU32 getPxSimulationStatisticsNbStaticBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbStaticBodies; }
inline void setPxSimulationStatisticsNbStaticBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbStaticBodies = inData; }
inline PxU32 getPxSimulationStatisticsNbDynamicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbDynamicBodies; }
inline void setPxSimulationStatisticsNbDynamicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDynamicBodies = inData; }
inline PxU32 getPxSimulationStatisticsNbKinematicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbKinematicBodies; }
inline void setPxSimulationStatisticsNbKinematicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbKinematicBodies = inData; }
inline PxU32 getPxSimulationStatisticsNbAggregates( const PxSimulationStatistics* inOwner ) { return inOwner->nbAggregates; }
inline void setPxSimulationStatisticsNbAggregates( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbAggregates = inData; }
inline PxU32 getPxSimulationStatisticsNbArticulations( const PxSimulationStatistics* inOwner ) { return inOwner->nbArticulations; }
inline void setPxSimulationStatisticsNbArticulations( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbArticulations = inData; }
inline PxU32 getPxSimulationStatisticsNbAxisSolverConstraints( const PxSimulationStatistics* inOwner ) { return inOwner->nbAxisSolverConstraints; }
inline void setPxSimulationStatisticsNbAxisSolverConstraints( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbAxisSolverConstraints = inData; }
inline PxU32 getPxSimulationStatisticsCompressedContactSize( const PxSimulationStatistics* inOwner ) { return inOwner->compressedContactSize; }
inline void setPxSimulationStatisticsCompressedContactSize( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->compressedContactSize = inData; }
inline PxU32 getPxSimulationStatisticsRequiredContactConstraintMemory( const PxSimulationStatistics* inOwner ) { return inOwner->requiredContactConstraintMemory; }
inline void setPxSimulationStatisticsRequiredContactConstraintMemory( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->requiredContactConstraintMemory = inData; }
inline PxU32 getPxSimulationStatisticsPeakConstraintMemory( const PxSimulationStatistics* inOwner ) { return inOwner->peakConstraintMemory; }
inline void setPxSimulationStatisticsPeakConstraintMemory( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->peakConstraintMemory = inData; }
inline PxU32 getPxSimulationStatisticsNbDiscreteContactPairsTotal( const PxSimulationStatistics* inOwner ) { return inOwner->nbDiscreteContactPairsTotal; }
inline void setPxSimulationStatisticsNbDiscreteContactPairsTotal( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDiscreteContactPairsTotal = inData; }
inline PxU32 getPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits( const PxSimulationStatistics* inOwner ) { return inOwner->nbDiscreteContactPairsWithCacheHits; }
inline void setPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDiscreteContactPairsWithCacheHits = inData; }
inline PxU32 getPxSimulationStatisticsNbDiscreteContactPairsWithContacts( const PxSimulationStatistics* inOwner ) { return inOwner->nbDiscreteContactPairsWithContacts; }
inline void setPxSimulationStatisticsNbDiscreteContactPairsWithContacts( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDiscreteContactPairsWithContacts = inData; }
inline PxU32 getPxSimulationStatisticsNbNewPairs( const PxSimulationStatistics* inOwner ) { return inOwner->nbNewPairs; }
inline void setPxSimulationStatisticsNbNewPairs( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbNewPairs = inData; }
inline PxU32 getPxSimulationStatisticsNbLostPairs( const PxSimulationStatistics* inOwner ) { return inOwner->nbLostPairs; }
inline void setPxSimulationStatisticsNbLostPairs( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbLostPairs = inData; }
inline PxU32 getPxSimulationStatisticsNbNewTouches( const PxSimulationStatistics* inOwner ) { return inOwner->nbNewTouches; }
inline void setPxSimulationStatisticsNbNewTouches( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbNewTouches = inData; }
inline PxU32 getPxSimulationStatisticsNbLostTouches( const PxSimulationStatistics* inOwner ) { return inOwner->nbLostTouches; }
inline void setPxSimulationStatisticsNbLostTouches( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbLostTouches = inData; }
inline PxU32 getPxSimulationStatisticsNbPartitions( const PxSimulationStatistics* inOwner ) { return inOwner->nbPartitions; }
inline void setPxSimulationStatisticsNbPartitions( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbPartitions = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemParticles( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemParticles; }
inline void setPxSimulationStatisticsGpuMemParticles( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemParticles = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemSoftBodies( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemSoftBodies; }
inline void setPxSimulationStatisticsGpuMemSoftBodies( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemSoftBodies = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemFEMCloths( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemFEMCloths; }
inline void setPxSimulationStatisticsGpuMemFEMCloths( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemFEMCloths = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHairSystems( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHairSystems; }
inline void setPxSimulationStatisticsGpuMemHairSystems( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHairSystems = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeap( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeap; }
inline void setPxSimulationStatisticsGpuMemHeap( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeap = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapBroadPhase( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapBroadPhase; }
inline void setPxSimulationStatisticsGpuMemHeapBroadPhase( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapBroadPhase = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapNarrowPhase( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapNarrowPhase; }
inline void setPxSimulationStatisticsGpuMemHeapNarrowPhase( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapNarrowPhase = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSolver( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSolver; }
inline void setPxSimulationStatisticsGpuMemHeapSolver( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSolver = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapArticulation( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapArticulation; }
inline void setPxSimulationStatisticsGpuMemHeapArticulation( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapArticulation = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulation( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulation; }
inline void setPxSimulationStatisticsGpuMemHeapSimulation( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulation = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationArticulation( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationArticulation; }
inline void setPxSimulationStatisticsGpuMemHeapSimulationArticulation( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationArticulation = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationParticles( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationParticles; }
inline void setPxSimulationStatisticsGpuMemHeapSimulationParticles( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationParticles = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationSoftBody( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationSoftBody; }
inline void setPxSimulationStatisticsGpuMemHeapSimulationSoftBody( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationSoftBody = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationFEMCloth( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationFEMCloth; }
inline void setPxSimulationStatisticsGpuMemHeapSimulationFEMCloth( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationFEMCloth = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationHairSystem( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationHairSystem; }
inline void setPxSimulationStatisticsGpuMemHeapSimulationHairSystem( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationHairSystem = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapParticles( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapParticles; }
inline void setPxSimulationStatisticsGpuMemHeapParticles( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapParticles = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapSoftBodies( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSoftBodies; }
inline void setPxSimulationStatisticsGpuMemHeapSoftBodies( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSoftBodies = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapFEMCloths( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapFEMCloths; }
inline void setPxSimulationStatisticsGpuMemHeapFEMCloths( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapFEMCloths = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapHairSystems( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapHairSystems; }
inline void setPxSimulationStatisticsGpuMemHeapHairSystems( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapHairSystems = inData; }
inline PxU64 getPxSimulationStatisticsGpuMemHeapOther( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapOther; }
inline void setPxSimulationStatisticsGpuMemHeapOther( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapOther = inData; }
inline PxU32 getPxSimulationStatisticsNbBroadPhaseAdds( const PxSimulationStatistics* inOwner ) { return inOwner->nbBroadPhaseAdds; }
inline void setPxSimulationStatisticsNbBroadPhaseAdds( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbBroadPhaseAdds = inData; }
inline PxU32 getPxSimulationStatisticsNbBroadPhaseRemoves( const PxSimulationStatistics* inOwner ) { return inOwner->nbBroadPhaseRemoves; }
inline void setPxSimulationStatisticsNbBroadPhaseRemoves( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbBroadPhaseRemoves = inData; }
PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedInfo::PxSimulationStatisticsGeneratedInfo()
: NbActiveConstraints( "NbActiveConstraints", setPxSimulationStatisticsNbActiveConstraints, getPxSimulationStatisticsNbActiveConstraints )
, NbActiveDynamicBodies( "NbActiveDynamicBodies", setPxSimulationStatisticsNbActiveDynamicBodies, getPxSimulationStatisticsNbActiveDynamicBodies )
, NbActiveKinematicBodies( "NbActiveKinematicBodies", setPxSimulationStatisticsNbActiveKinematicBodies, getPxSimulationStatisticsNbActiveKinematicBodies )
, NbStaticBodies( "NbStaticBodies", setPxSimulationStatisticsNbStaticBodies, getPxSimulationStatisticsNbStaticBodies )
, NbDynamicBodies( "NbDynamicBodies", setPxSimulationStatisticsNbDynamicBodies, getPxSimulationStatisticsNbDynamicBodies )
, NbKinematicBodies( "NbKinematicBodies", setPxSimulationStatisticsNbKinematicBodies, getPxSimulationStatisticsNbKinematicBodies )
, NbAggregates( "NbAggregates", setPxSimulationStatisticsNbAggregates, getPxSimulationStatisticsNbAggregates )
, NbArticulations( "NbArticulations", setPxSimulationStatisticsNbArticulations, getPxSimulationStatisticsNbArticulations )
, NbAxisSolverConstraints( "NbAxisSolverConstraints", setPxSimulationStatisticsNbAxisSolverConstraints, getPxSimulationStatisticsNbAxisSolverConstraints )
, CompressedContactSize( "CompressedContactSize", setPxSimulationStatisticsCompressedContactSize, getPxSimulationStatisticsCompressedContactSize )
, RequiredContactConstraintMemory( "RequiredContactConstraintMemory", setPxSimulationStatisticsRequiredContactConstraintMemory, getPxSimulationStatisticsRequiredContactConstraintMemory )
, PeakConstraintMemory( "PeakConstraintMemory", setPxSimulationStatisticsPeakConstraintMemory, getPxSimulationStatisticsPeakConstraintMemory )
, NbDiscreteContactPairsTotal( "NbDiscreteContactPairsTotal", setPxSimulationStatisticsNbDiscreteContactPairsTotal, getPxSimulationStatisticsNbDiscreteContactPairsTotal )
, NbDiscreteContactPairsWithCacheHits( "NbDiscreteContactPairsWithCacheHits", setPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits, getPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits )
, NbDiscreteContactPairsWithContacts( "NbDiscreteContactPairsWithContacts", setPxSimulationStatisticsNbDiscreteContactPairsWithContacts, getPxSimulationStatisticsNbDiscreteContactPairsWithContacts )
, NbNewPairs( "NbNewPairs", setPxSimulationStatisticsNbNewPairs, getPxSimulationStatisticsNbNewPairs )
, NbLostPairs( "NbLostPairs", setPxSimulationStatisticsNbLostPairs, getPxSimulationStatisticsNbLostPairs )
, NbNewTouches( "NbNewTouches", setPxSimulationStatisticsNbNewTouches, getPxSimulationStatisticsNbNewTouches )
, NbLostTouches( "NbLostTouches", setPxSimulationStatisticsNbLostTouches, getPxSimulationStatisticsNbLostTouches )
, NbPartitions( "NbPartitions", setPxSimulationStatisticsNbPartitions, getPxSimulationStatisticsNbPartitions )
, GpuMemParticles( "GpuMemParticles", setPxSimulationStatisticsGpuMemParticles, getPxSimulationStatisticsGpuMemParticles )
, GpuMemSoftBodies( "GpuMemSoftBodies", setPxSimulationStatisticsGpuMemSoftBodies, getPxSimulationStatisticsGpuMemSoftBodies )
, GpuMemFEMCloths( "GpuMemFEMCloths", setPxSimulationStatisticsGpuMemFEMCloths, getPxSimulationStatisticsGpuMemFEMCloths )
, GpuMemHairSystems( "GpuMemHairSystems", setPxSimulationStatisticsGpuMemHairSystems, getPxSimulationStatisticsGpuMemHairSystems )
, GpuMemHeap( "GpuMemHeap", setPxSimulationStatisticsGpuMemHeap, getPxSimulationStatisticsGpuMemHeap )
, GpuMemHeapBroadPhase( "GpuMemHeapBroadPhase", setPxSimulationStatisticsGpuMemHeapBroadPhase, getPxSimulationStatisticsGpuMemHeapBroadPhase )
, GpuMemHeapNarrowPhase( "GpuMemHeapNarrowPhase", setPxSimulationStatisticsGpuMemHeapNarrowPhase, getPxSimulationStatisticsGpuMemHeapNarrowPhase )
, GpuMemHeapSolver( "GpuMemHeapSolver", setPxSimulationStatisticsGpuMemHeapSolver, getPxSimulationStatisticsGpuMemHeapSolver )
, GpuMemHeapArticulation( "GpuMemHeapArticulation", setPxSimulationStatisticsGpuMemHeapArticulation, getPxSimulationStatisticsGpuMemHeapArticulation )
, GpuMemHeapSimulation( "GpuMemHeapSimulation", setPxSimulationStatisticsGpuMemHeapSimulation, getPxSimulationStatisticsGpuMemHeapSimulation )
, GpuMemHeapSimulationArticulation( "GpuMemHeapSimulationArticulation", setPxSimulationStatisticsGpuMemHeapSimulationArticulation, getPxSimulationStatisticsGpuMemHeapSimulationArticulation )
, GpuMemHeapSimulationParticles( "GpuMemHeapSimulationParticles", setPxSimulationStatisticsGpuMemHeapSimulationParticles, getPxSimulationStatisticsGpuMemHeapSimulationParticles )
, GpuMemHeapSimulationSoftBody( "GpuMemHeapSimulationSoftBody", setPxSimulationStatisticsGpuMemHeapSimulationSoftBody, getPxSimulationStatisticsGpuMemHeapSimulationSoftBody )
, GpuMemHeapSimulationFEMCloth( "GpuMemHeapSimulationFEMCloth", setPxSimulationStatisticsGpuMemHeapSimulationFEMCloth, getPxSimulationStatisticsGpuMemHeapSimulationFEMCloth )
, GpuMemHeapSimulationHairSystem( "GpuMemHeapSimulationHairSystem", setPxSimulationStatisticsGpuMemHeapSimulationHairSystem, getPxSimulationStatisticsGpuMemHeapSimulationHairSystem )
, GpuMemHeapParticles( "GpuMemHeapParticles", setPxSimulationStatisticsGpuMemHeapParticles, getPxSimulationStatisticsGpuMemHeapParticles )
, GpuMemHeapSoftBodies( "GpuMemHeapSoftBodies", setPxSimulationStatisticsGpuMemHeapSoftBodies, getPxSimulationStatisticsGpuMemHeapSoftBodies )
, GpuMemHeapFEMCloths( "GpuMemHeapFEMCloths", setPxSimulationStatisticsGpuMemHeapFEMCloths, getPxSimulationStatisticsGpuMemHeapFEMCloths )
, GpuMemHeapHairSystems( "GpuMemHeapHairSystems", setPxSimulationStatisticsGpuMemHeapHairSystems, getPxSimulationStatisticsGpuMemHeapHairSystems )
, GpuMemHeapOther( "GpuMemHeapOther", setPxSimulationStatisticsGpuMemHeapOther, getPxSimulationStatisticsGpuMemHeapOther )
, NbBroadPhaseAdds( "NbBroadPhaseAdds", setPxSimulationStatisticsNbBroadPhaseAdds, getPxSimulationStatisticsNbBroadPhaseAdds )
, NbBroadPhaseRemoves( "NbBroadPhaseRemoves", setPxSimulationStatisticsNbBroadPhaseRemoves, getPxSimulationStatisticsNbBroadPhaseRemoves )
{}
PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedValues::PxSimulationStatisticsGeneratedValues( const PxSimulationStatistics* inSource )
:NbActiveConstraints( inSource->nbActiveConstraints )
,NbActiveDynamicBodies( inSource->nbActiveDynamicBodies )
,NbActiveKinematicBodies( inSource->nbActiveKinematicBodies )
,NbStaticBodies( inSource->nbStaticBodies )
,NbDynamicBodies( inSource->nbDynamicBodies )
,NbKinematicBodies( inSource->nbKinematicBodies )
,NbAggregates( inSource->nbAggregates )
,NbArticulations( inSource->nbArticulations )
,NbAxisSolverConstraints( inSource->nbAxisSolverConstraints )
,CompressedContactSize( inSource->compressedContactSize )
,RequiredContactConstraintMemory( inSource->requiredContactConstraintMemory )
,PeakConstraintMemory( inSource->peakConstraintMemory )
,NbDiscreteContactPairsTotal( inSource->nbDiscreteContactPairsTotal )
,NbDiscreteContactPairsWithCacheHits( inSource->nbDiscreteContactPairsWithCacheHits )
,NbDiscreteContactPairsWithContacts( inSource->nbDiscreteContactPairsWithContacts )
,NbNewPairs( inSource->nbNewPairs )
,NbLostPairs( inSource->nbLostPairs )
,NbNewTouches( inSource->nbNewTouches )
,NbLostTouches( inSource->nbLostTouches )
,NbPartitions( inSource->nbPartitions )
,GpuMemParticles( inSource->gpuMemParticles )
,GpuMemSoftBodies( inSource->gpuMemSoftBodies )
,GpuMemFEMCloths( inSource->gpuMemFEMCloths )
,GpuMemHairSystems( inSource->gpuMemHairSystems )
,GpuMemHeap( inSource->gpuMemHeap )
,GpuMemHeapBroadPhase( inSource->gpuMemHeapBroadPhase )
,GpuMemHeapNarrowPhase( inSource->gpuMemHeapNarrowPhase )
,GpuMemHeapSolver( inSource->gpuMemHeapSolver )
,GpuMemHeapArticulation( inSource->gpuMemHeapArticulation )
,GpuMemHeapSimulation( inSource->gpuMemHeapSimulation )
,GpuMemHeapSimulationArticulation( inSource->gpuMemHeapSimulationArticulation )
,GpuMemHeapSimulationParticles( inSource->gpuMemHeapSimulationParticles )
,GpuMemHeapSimulationSoftBody( inSource->gpuMemHeapSimulationSoftBody )
,GpuMemHeapSimulationFEMCloth( inSource->gpuMemHeapSimulationFEMCloth )
,GpuMemHeapSimulationHairSystem( inSource->gpuMemHeapSimulationHairSystem )
,GpuMemHeapParticles( inSource->gpuMemHeapParticles )
,GpuMemHeapSoftBodies( inSource->gpuMemHeapSoftBodies )
,GpuMemHeapFEMCloths( inSource->gpuMemHeapFEMCloths )
,GpuMemHeapHairSystems( inSource->gpuMemHeapHairSystems )
,GpuMemHeapOther( inSource->gpuMemHeapOther )
,NbBroadPhaseAdds( inSource->nbBroadPhaseAdds )
,NbBroadPhaseRemoves( inSource->nbBroadPhaseRemoves )
{
PX_UNUSED(inSource);
PxMemCopy( NbDiscreteContactPairs, inSource->nbDiscreteContactPairs, sizeof( NbDiscreteContactPairs ) );
PxMemCopy( NbModifiedContactPairs, inSource->nbModifiedContactPairs, sizeof( NbModifiedContactPairs ) );
PxMemCopy( NbCCDPairs, inSource->nbCCDPairs, sizeof( NbCCDPairs ) );
PxMemCopy( NbTriggerPairs, inSource->nbTriggerPairs, sizeof( NbTriggerPairs ) );
PxMemCopy( NbShapes, inSource->nbShapes, sizeof( NbShapes ) );
}
| 154,103 | C++ | 91.443911 | 208 | 0.831859 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PvdMetaDataPropertyVisitor.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_META_DATA_PROPERTY_VISITOR_H
#define PX_META_DATA_PROPERTY_VISITOR_H
#include <stdio.h>
#include "PvdMetaDataExtensions.h"
namespace physx
{
namespace Vd
{
//PVD only deals with read-only properties, indexed, and properties like this by in large.
//so we have a filter that expands properties to a level where we can get to them and expands them into
//named functions that make more sense and are easier to read than operator()
template<typename TOperatorType>
struct PvdPropertyFilter
{
private:
PvdPropertyFilter& operator=(const PvdPropertyFilter&);
public:
TOperatorType mOperator;
PxU32* mKeyOverride;
PxU32* mOffsetOverride;
PvdPropertyFilter( TOperatorType& inOperator )
: mOperator( inOperator )
, mKeyOverride( 0 )
, mOffsetOverride( 0 ) {}
PvdPropertyFilter( TOperatorType& inOperator, PxU32* inKeyOverride, PxU32* inOffsetOverride )
: mOperator( inOperator )
, mKeyOverride( inKeyOverride )
, mOffsetOverride( inOffsetOverride ) {}
PvdPropertyFilter( const PvdPropertyFilter& inOther ) : mOperator( inOther.mOperator ), mKeyOverride( inOther.mKeyOverride ), mOffsetOverride( inOther.mOffsetOverride ) {}
template<PxU32 TKey, typename TAccessorType>
void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, bool, bool, bool)
{
mOperator.simpleProperty(inKey, inAccessor );
}
template<PxU32 TKey, typename TAccessorType>
void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, bool, bool, const PxU32ToName* inConversions )
{
mOperator.flagsProperty(inKey, inAccessor, inConversions );
}
template<PxU32 TKey, typename TAccessorType>
void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, const PxU32ToName* inConversions, bool, bool )
{
mOperator.enumProperty( inKey, inAccessor, inConversions );
}
template<PxU32 TKey, typename TAccessorType, typename TInfoType>
void dispatchAccessor(PxU32, const TAccessorType& inAccessor, bool, const TInfoType* inInfo, bool )
{
PxU32 rangeStart = TKey;
PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride;
mOperator.complexProperty( &propIdx, inAccessor, *inInfo );
}
PxU32 getKeyValue( PxU32 inPropertyKey )
{
PxU32 retval = inPropertyKey;
if ( mKeyOverride )
{
retval = *mKeyOverride;
(*mKeyOverride)++;
}
return retval;
}
void setupValueStructOffset( const ValueStructOffsetRecord&, bool, PxU32* ) {}
void setupValueStructOffset( const ValueStructOffsetRecord& inAccessor, PxU32 inOffset, PxU32* inAdditionalOffset )
{
//This allows us to nest properties correctly.
if ( inAdditionalOffset ) inOffset += *inAdditionalOffset;
inAccessor.setupValueStructOffset( inOffset );
}
template<PxU32 TKey, typename TAccessorType>
void handleAccessor( PxU32 inKey, const TAccessorType& inAccessor )
{
typedef typename TAccessorType::prop_type TPropertyType;
dispatchAccessor<TKey>( inKey
, inAccessor
, PxEnumTraits<TPropertyType>().NameConversion
, PxClassInfoTraits<TPropertyType>().getInfo()
, IsFlagsType<TPropertyType>().FlagData );
}
template<PxU32 TKey, typename TAccessorType>
void handleAccessor( const TAccessorType& inAccessor )
{
setupValueStructOffset( inAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, mOffsetOverride );
handleAccessor<TKey>( getKeyValue( TKey ), inAccessor );
}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,TPropertyType>& inProperty, PxU32 )
{
PxPvdReadOnlyPropertyAccessor< TKey, TObjType, TPropertyType > theAccessor( inProperty );
mOperator.pushName( inProperty.mName );
handleAccessor<TKey>( theAccessor );
mOperator.popName();
}
//We don't handle unbounded indexed properties
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType, typename TValueConversionType, typename TInfoType>
void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >&, bool, TValueConversionType, const TInfoType& ) {}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const PxU32ToName* theConversions, const PxUnknownClassInfo& )
{
mOperator.pushName( inProp.mName );
PxU32 rangeStart = TKey;
PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride;
PxU32 theOffset = 0;
if ( mOffsetOverride ) theOffset = *mOffsetOverride;
while( theConversions->mName != NULL )
{
mOperator.pushBracketedName( theConversions->mName );
PxPvdIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, theConversions->mValue );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
handleAccessor<TKey>( propIdx, theAccessor );
mOperator.popName();
++propIdx;
++theConversions;
theOffset += sizeof( TPropertyType );
}
mOperator.popName();
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType, typename TInfoType>
void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const PxU32ToName* theConversions, const TInfoType& inInfo )
{
//ouch, not nice. Indexed complex property.
mOperator.pushName( inProp.mName );
PxU32 propIdx = TKey;
PxU32 theOffset = 0;
if ( mOffsetOverride ) theOffset = *mOffsetOverride;
while( theConversions->mName != NULL )
{
mOperator.pushBracketedName( theConversions->mName );
PxPvdIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, theConversions->mValue );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
PX_ASSERT( theAccessor.mHasValidOffset );
mOperator.complexProperty( &propIdx, theAccessor, inInfo );
mOperator.popName();
++theConversions;
theOffset += sizeof( TPropertyType );
}
mOperator.popName();
}
static char* myStrcat(const char* a,const char * b)
{
size_t len = strlen(a)+strlen(b);
char* result = new char[len+1];
strcpy(result,a);
strcat(result,b);
result[len] = 0;
return result;
}
template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TInfoType>
void handleBufferCollectionProperty(PxU32 , const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType >& inProp, const TInfoType& inInfo)
{
//append 'Collection' to buffer properties
char* name = myStrcat(inProp.mName, "Collection");
mOperator.pushName(name);
PxU32 propIdx = TKey;
PxU32 theOffset = 0;
PxBufferCollectionPropertyAccessor<TKey, TObjType, TPropertyType> theAccessor( inProp, inProp.mName );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
mOperator.bufferCollectionProperty( &propIdx, theAccessor, inInfo );
mOperator.popName();
delete []name;
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex )
{
indexedProperty( inIndex, inProp, IndexerToNameMap<TKey,TIndexType>().Converter.NameConversion
, PxClassInfoTraits<TPropertyType>().Info );
}
template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TIndexType, typename TInfoType>
void handleExtendedIndexProperty(PxU32 inIndex, const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const TInfoType& inInfo)
{
mOperator.pushName(inProp.mName);
PxU32 propIdx = TKey;
PxU32 theOffset = 0;
PxPvdExtendedIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, inIndex );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
mOperator.extendedIndexedProperty( &propIdx, theAccessor, inInfo );
mOperator.popName();
}
template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TIndexType, typename TInfoType>
void handlePxFixedSizeLookupTableProperty( const PxU32 inIndex, const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const TInfoType& inInfo)
{
mOperator.pushName(inProp.mName);
PxU32 propIdx = TKey;
PxU32 theOffset = 0;
PxPvdFixedSizeLookupTablePropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, inIndex );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
mOperator.PxFixedSizeLookupTableProperty( &propIdx, theAccessor, inInfo );
mOperator.popName();
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void operator()( const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex )
{
handleExtendedIndexProperty( inIndex, inProp, PxClassInfoTraits<TPropertyType>().Info );
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void operator()( const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex)
{
handlePxFixedSizeLookupTableProperty(inIndex, inProp, PxClassInfoTraits<TPropertyType>().Info);
}
//We don't handle unbounded indexed properties
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType, typename TNameConv, typename TNameConv2 >
void dualIndexedProperty( PxU32 idx, const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >&, TNameConv, TNameConv2 ) { PX_UNUSED(idx); }
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType>
void dualIndexedProperty( PxU32 /*idx*/, const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, const PxU32ToName* c1, const PxU32ToName* c2 )
{
mOperator.pushName( inProp.mName );
PxU32 rangeStart = TKey;
PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride;
PxU32 theOffset = 0;
if ( mOffsetOverride ) theOffset = *mOffsetOverride;
while( c1->mName != NULL )
{
mOperator.pushBracketedName( c1->mName );
const PxU32ToName* c2Idx = c2;
while( c2Idx->mName != NULL )
{
mOperator.pushBracketedName( c2Idx->mName );
PxPvdDualIndexedPropertyAccessor<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType> theAccessor( inProp, c1->mValue, c2Idx->mValue );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
handleAccessor<TKey>( propIdx, theAccessor );
mOperator.popName();
++propIdx;
++c2Idx;
theOffset += sizeof( TPropertyType );
}
mOperator.popName();
++c1;
}
mOperator.popName();
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType>
void extendedDualIndexedProperty( PxU32 /*idx*/, const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 id0Count, PxU32 id1Count )
{
mOperator.pushName( inProp.mName );
PxU32 rangeStart = TKey;
PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride;
PxU32 theOffset = 0;
if ( mOffsetOverride ) theOffset = *mOffsetOverride;
for(PxU32 i = 0; i < id0Count; ++i)
{
char buffer1[32] = { 0 };
sprintf( buffer1, "eId1_%u", i );
mOperator.pushBracketedName( buffer1 );
for(PxU32 j = 0; j < id1Count; ++j)
{
char buffer2[32] = { 0 };
sprintf( buffer2, "eId2_%u", j );
mOperator.pushBracketedName( buffer2 );
PxPvdExtendedDualIndexedPropertyAccessor<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType> theAccessor( inProp, i, j );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
handleAccessor<TKey>( propIdx, theAccessor );
mOperator.popName();
++propIdx;
theOffset += sizeof( TPropertyType );
}
mOperator.popName();
}
mOperator.popName();
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType>
void operator()( const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx )
{
dualIndexedProperty( idx, inProp
, IndexerToNameMap<TKey,TIndexType>().Converter.NameConversion
, IndexerToNameMap<TKey,TIndex2Type>().Converter.NameConversion );
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType>
void operator()( const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx )
{
extendedDualIndexedProperty( idx, inProp, inProp.mId0Count, inProp.mId1Count );
}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropertyType>& inProperty, PxU32 /*idx*/)
{
PxU32 rangeStart = TKey;
PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride;
PxU32 theOffset = 0;
if ( mOffsetOverride ) theOffset = *mOffsetOverride;
mOperator.pushName( inProperty.mName );
mOperator.pushName( inProperty.mArg0Name );
PxPvdRangePropertyAccessor<TKey, TObjType, TPropertyType> theAccessor( inProperty, true );
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
handleAccessor<TKey>( propIdx, theAccessor );
++propIdx;
theOffset += sizeof( TPropertyType );
mOperator.popName();
mOperator.pushName( inProperty.mArg1Name );
theAccessor.mFirstValue = false;
setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset );
handleAccessor<TKey>( propIdx, theAccessor );
mOperator.popName();
mOperator.popName();
}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 count )
{
handleBufferCollectionProperty( count, inProp, PxClassInfoTraits<TPropertyType>().Info );
}
template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag>
void handleBuffer( const PxBufferPropertyInfo<TKey, TObjectType, TPropertyType, TEnableFlag>& inProp )
{
mOperator.handleBuffer( inProp );
}
template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag>
void operator()( const PxBufferPropertyInfo<TKey, TObjectType, TPropertyType, TEnableFlag>& inProp, PxU32 )
{
handleBuffer( inProp );
}
template<PxU32 TKey, typename TObjType>
void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, PxU32>& prop, PxU32 )
{
mOperator.handleCollection( prop );
}
template<PxU32 TKey, typename TObjType>
void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, PxReal>& prop, PxU32 )
{
mOperator.handleCollection( prop );
}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxWriteOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {}
template<PxU32 TKey, typename TObjType, typename TCollectionType>
void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType>&, PxU32 ) {}
template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType>
void operator()( const PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType >&, PxU32 ) {}
//We don't deal with these property datatypes.
#define DEFINE_PVD_PROPERTY_NOP(datatype) \
template<PxU32 TKey, typename TObjType> \
void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,datatype>& inProperty, PxU32 ){PX_UNUSED(inProperty); }
DEFINE_PVD_PROPERTY_NOP( const void* )
DEFINE_PVD_PROPERTY_NOP( void* )
DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterCallback * )
DEFINE_PVD_PROPERTY_NOP( physx::PxTaskManager * )
DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterShader * )
DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterShader)
DEFINE_PVD_PROPERTY_NOP( PxContactModifyCallback * )
DEFINE_PVD_PROPERTY_NOP( PxCCDContactModifyCallback * )
DEFINE_PVD_PROPERTY_NOP( PxSimulationEventCallback * )
DEFINE_PVD_PROPERTY_NOP( physx::PxCudaContextManager* )
DEFINE_PVD_PROPERTY_NOP( physx::PxCpuDispatcher * )
DEFINE_PVD_PROPERTY_NOP( PxRigidActor )
DEFINE_PVD_PROPERTY_NOP( const PxRigidActor )
DEFINE_PVD_PROPERTY_NOP( PxRigidActor& )
DEFINE_PVD_PROPERTY_NOP( const PxRigidActor& )
DEFINE_PVD_PROPERTY_NOP( PxScene* )
DEFINE_PVD_PROPERTY_NOP( PxConstraint )
DEFINE_PVD_PROPERTY_NOP( PxConstraint* )
DEFINE_PVD_PROPERTY_NOP( PxConstraint& )
DEFINE_PVD_PROPERTY_NOP( const PxConstraint& )
DEFINE_PVD_PROPERTY_NOP( PxAggregate * )
DEFINE_PVD_PROPERTY_NOP( PxArticulationReducedCoordinate&)
DEFINE_PVD_PROPERTY_NOP( const PxArticulationLink * )
DEFINE_PVD_PROPERTY_NOP( const PxRigidDynamic * )
DEFINE_PVD_PROPERTY_NOP( const PxRigidStatic * )
DEFINE_PVD_PROPERTY_NOP( PxArticulationJointReducedCoordinate * )
DEFINE_PVD_PROPERTY_NOP( PxBroadPhaseCallback * )
DEFINE_PVD_PROPERTY_NOP( const PxBroadPhaseRegion * )
DEFINE_PVD_PROPERTY_NOP( PxU32 * )
};
template<typename TOperator>
inline PvdPropertyFilter<TOperator> makePvdPropertyFilter( TOperator inOperator )
{
return PvdPropertyFilter<TOperator>( inOperator );
}
template<typename TOperator>
inline PvdPropertyFilter<TOperator> makePvdPropertyFilter( TOperator inOperator, PxU32* inKey, PxU32* inOffset )
{
return PvdPropertyFilter<TOperator>( inOperator, inKey, inOffset );
}
template<typename TOperator, typename TFuncType>
inline void visitWithPvdFilter( TOperator inOperator, TFuncType inFuncType )
{
PX_UNUSED(inFuncType);
TFuncType( makePvdPropertyFilter( inOperator ) );
}
template<typename TObjType, typename TOperator>
inline void visitInstancePvdProperties( TOperator inOperator )
{
visitInstanceProperties<TObjType>( makePvdPropertyFilter( inOperator ) );
}
template<typename TOperator>
struct PvdAllPropertyVisitor
{
TOperator mOperator;
PvdAllPropertyVisitor( TOperator op ) : mOperator( op ) {}
template<typename TObjectType>
bool operator()( const TObjectType* ) { visitInstancePvdProperties<TObjectType>( mOperator ); return false; }
};
template<typename TOperator>
struct PvdAllInfoVisitor
{
TOperator mOperator;
PvdAllInfoVisitor( TOperator op ) : mOperator( op ) {}
template<typename TInfoType>
void operator()( TInfoType inInfo )
{
inInfo.template visitType<bool>( PvdAllPropertyVisitor<TOperator>( mOperator ) );
inInfo.visitBases( *this );
}
};
template<typename TObjType, typename TOperator>
inline void visitAllPvdProperties( TOperator inOperator )
{
visitAllProperties<TObjType>( makePvdPropertyFilter( inOperator ) );
}
template<typename TOperator>
inline void visitRigidDynamicPerFrameProperties( TOperator inOperator )
{
PvdPropertyFilter<TOperator> theFilter( inOperator );
PxRigidDynamicGeneratedInfo theInfo;
theFilter( theInfo.GlobalPose, 0 );
theFilter( theInfo.LinearVelocity, 1 );
theFilter( theInfo.AngularVelocity, 2 );
theFilter( theInfo.IsSleeping, 3 );
}
template<typename TOperator>
inline void visitArticulationLinkPerFrameProperties( TOperator inOperator )
{
PvdPropertyFilter<TOperator> theFilter( inOperator );
PxArticulationLinkGeneratedInfo theInfo;
theFilter( theInfo.GlobalPose, 0 );
}
}
}
#endif
| 21,250 | C | 38.945489 | 188 | 0.766306 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxAutoGeneratedMetaDataObjectNames.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be
// prepared for your edits to be quietly ignored next time the clang metadata generator is
// run. You can find the most recent version of clang metadata generator by contacting
// Chris Nuernberger <[email protected]> or Dilip or Adam.
// The source code for the generate was at one time checked into:
// physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp
#define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
PxPhysics_PropertiesStart,
PxPhysics_TolerancesScale,
PxPhysics_TriangleMeshes,
PxPhysics_TetrahedronMeshes,
PxPhysics_HeightFields,
PxPhysics_ConvexMeshes,
PxPhysics_BVHs,
PxPhysics_Scenes,
PxPhysics_Shapes,
PxPhysics_Materials,
PxPhysics_FEMSoftBodyMaterials,
PxPhysics_FEMClothMaterials,
PxPhysics_PBDMaterials,
PxPhysics_PropertiesStop,
PxRefCounted_PropertiesStart,
PxRefCounted_ReferenceCount,
PxRefCounted_PropertiesStop,
PxBaseMaterial_PropertiesStart,
PxBaseMaterial_UserData,
PxBaseMaterial_PropertiesStop,
PxMaterial_PropertiesStart,
PxMaterial_DynamicFriction,
PxMaterial_StaticFriction,
PxMaterial_Restitution,
PxMaterial_Damping,
PxMaterial_Flags,
PxMaterial_FrictionCombineMode,
PxMaterial_RestitutionCombineMode,
PxMaterial_ConcreteTypeName,
PxMaterial_PropertiesStop,
PxFEMMaterial_PropertiesStart,
PxFEMMaterial_YoungsModulus,
PxFEMMaterial_Poissons,
PxFEMMaterial_DynamicFriction,
PxFEMMaterial_PropertiesStop,
PxFEMSoftBodyMaterial_PropertiesStart,
PxFEMSoftBodyMaterial_Damping,
PxFEMSoftBodyMaterial_DampingScale,
PxFEMSoftBodyMaterial_MaterialModel,
PxFEMSoftBodyMaterial_ConcreteTypeName,
PxFEMSoftBodyMaterial_PropertiesStop,
PxParticleMaterial_PropertiesStart,
PxParticleMaterial_Friction,
PxParticleMaterial_Damping,
PxParticleMaterial_Adhesion,
PxParticleMaterial_GravityScale,
PxParticleMaterial_AdhesionRadiusScale,
PxParticleMaterial_PropertiesStop,
PxPBDMaterial_PropertiesStart,
PxPBDMaterial_Viscosity,
PxPBDMaterial_VorticityConfinement,
PxPBDMaterial_SurfaceTension,
PxPBDMaterial_Cohesion,
PxPBDMaterial_Lift,
PxPBDMaterial_Drag,
PxPBDMaterial_CFLCoefficient,
PxPBDMaterial_ParticleFrictionScale,
PxPBDMaterial_ParticleAdhesionScale,
PxPBDMaterial_ConcreteTypeName,
PxPBDMaterial_PropertiesStop,
PxActor_PropertiesStart,
PxActor_Scene,
PxActor_Name,
PxActor_ActorFlags,
PxActor_DominanceGroup,
PxActor_OwnerClient,
PxActor_Aggregate,
PxActor_UserData,
PxActor_PropertiesStop,
PxRigidActor_PropertiesStart,
PxRigidActor_GlobalPose,
PxRigidActor_Shapes,
PxRigidActor_Constraints,
PxRigidActor_PropertiesStop,
PxRigidBody_PropertiesStart,
PxRigidBody_CMassLocalPose,
PxRigidBody_Mass,
PxRigidBody_InvMass,
PxRigidBody_MassSpaceInertiaTensor,
PxRigidBody_MassSpaceInvInertiaTensor,
PxRigidBody_LinearDamping,
PxRigidBody_AngularDamping,
PxRigidBody_MaxLinearVelocity,
PxRigidBody_MaxAngularVelocity,
PxRigidBody_RigidBodyFlags,
PxRigidBody_MinCCDAdvanceCoefficient,
PxRigidBody_MaxDepenetrationVelocity,
PxRigidBody_MaxContactImpulse,
PxRigidBody_ContactSlopCoefficient,
PxRigidBody_PropertiesStop,
PxRigidDynamic_PropertiesStart,
PxRigidDynamic_IsSleeping,
PxRigidDynamic_SleepThreshold,
PxRigidDynamic_StabilizationThreshold,
PxRigidDynamic_RigidDynamicLockFlags,
PxRigidDynamic_LinearVelocity,
PxRigidDynamic_AngularVelocity,
PxRigidDynamic_WakeCounter,
PxRigidDynamic_SolverIterationCounts,
PxRigidDynamic_ContactReportThreshold,
PxRigidDynamic_ConcreteTypeName,
PxRigidDynamic_PropertiesStop,
PxRigidStatic_PropertiesStart,
PxRigidStatic_ConcreteTypeName,
PxRigidStatic_PropertiesStop,
PxArticulationLink_PropertiesStart,
PxArticulationLink_InboundJoint,
PxArticulationLink_InboundJointDof,
PxArticulationLink_LinkIndex,
PxArticulationLink_Children,
PxArticulationLink_CfmScale,
PxArticulationLink_LinearVelocity,
PxArticulationLink_AngularVelocity,
PxArticulationLink_ConcreteTypeName,
PxArticulationLink_PropertiesStop,
PxArticulationJointReducedCoordinate_PropertiesStart,
PxArticulationJointReducedCoordinate_ParentPose,
PxArticulationJointReducedCoordinate_ChildPose,
PxArticulationJointReducedCoordinate_JointType,
PxArticulationJointReducedCoordinate_Motion,
PxArticulationJointReducedCoordinate_LimitParams,
PxArticulationJointReducedCoordinate_DriveParams,
PxArticulationJointReducedCoordinate_Armature,
PxArticulationJointReducedCoordinate_FrictionCoefficient,
PxArticulationJointReducedCoordinate_MaxJointVelocity,
PxArticulationJointReducedCoordinate_JointPosition,
PxArticulationJointReducedCoordinate_JointVelocity,
PxArticulationJointReducedCoordinate_ConcreteTypeName,
PxArticulationJointReducedCoordinate_UserData,
PxArticulationJointReducedCoordinate_PropertiesStop,
PxArticulationReducedCoordinate_PropertiesStart,
PxArticulationReducedCoordinate_Scene,
PxArticulationReducedCoordinate_SolverIterationCounts,
PxArticulationReducedCoordinate_IsSleeping,
PxArticulationReducedCoordinate_SleepThreshold,
PxArticulationReducedCoordinate_StabilizationThreshold,
PxArticulationReducedCoordinate_WakeCounter,
PxArticulationReducedCoordinate_MaxCOMLinearVelocity,
PxArticulationReducedCoordinate_MaxCOMAngularVelocity,
PxArticulationReducedCoordinate_Links,
PxArticulationReducedCoordinate_Name,
PxArticulationReducedCoordinate_Aggregate,
PxArticulationReducedCoordinate_ArticulationFlags,
PxArticulationReducedCoordinate_RootGlobalPose,
PxArticulationReducedCoordinate_RootLinearVelocity,
PxArticulationReducedCoordinate_RootAngularVelocity,
PxArticulationReducedCoordinate_UserData,
PxArticulationReducedCoordinate_PropertiesStop,
PxAggregate_PropertiesStart,
PxAggregate_MaxNbActors,
PxAggregate_MaxNbShapes,
PxAggregate_Actors,
PxAggregate_SelfCollision,
PxAggregate_ConcreteTypeName,
PxAggregate_UserData,
PxAggregate_PropertiesStop,
PxConstraint_PropertiesStart,
PxConstraint_Scene,
PxConstraint_Actors,
PxConstraint_Flags,
PxConstraint_IsValid,
PxConstraint_BreakForce,
PxConstraint_MinResponseThreshold,
PxConstraint_ConcreteTypeName,
PxConstraint_UserData,
PxConstraint_PropertiesStop,
PxShape_PropertiesStart,
PxShape_LocalPose,
PxShape_SimulationFilterData,
PxShape_QueryFilterData,
PxShape_Materials,
PxShape_ContactOffset,
PxShape_RestOffset,
PxShape_DensityForFluid,
PxShape_TorsionalPatchRadius,
PxShape_MinTorsionalPatchRadius,
PxShape_InternalShapeIndex,
PxShape_Flags,
PxShape_IsExclusive,
PxShape_Name,
PxShape_ConcreteTypeName,
PxShape_UserData,
PxShape_Geom,
PxShape_PropertiesStop,
PxPruningStructure_PropertiesStart,
PxPruningStructure_RigidActors,
PxPruningStructure_StaticMergeData,
PxPruningStructure_DynamicMergeData,
PxPruningStructure_ConcreteTypeName,
PxPruningStructure_PropertiesStop,
PxTolerancesScale_PropertiesStart,
PxTolerancesScale_IsValid,
PxTolerancesScale_Length,
PxTolerancesScale_Speed,
PxTolerancesScale_PropertiesStop,
PxGeometry_PropertiesStart,
PxGeometry_PropertiesStop,
PxBoxGeometry_PropertiesStart,
PxBoxGeometry_HalfExtents,
PxBoxGeometry_PropertiesStop,
PxCapsuleGeometry_PropertiesStart,
PxCapsuleGeometry_Radius,
PxCapsuleGeometry_HalfHeight,
PxCapsuleGeometry_PropertiesStop,
PxMeshScale_PropertiesStart,
PxMeshScale_Scale,
PxMeshScale_Rotation,
PxMeshScale_PropertiesStop,
PxConvexMeshGeometry_PropertiesStart,
PxConvexMeshGeometry_Scale,
PxConvexMeshGeometry_ConvexMesh,
PxConvexMeshGeometry_MeshFlags,
PxConvexMeshGeometry_PropertiesStop,
PxSphereGeometry_PropertiesStart,
PxSphereGeometry_Radius,
PxSphereGeometry_PropertiesStop,
PxPlaneGeometry_PropertiesStart,
PxPlaneGeometry_PropertiesStop,
PxTriangleMeshGeometry_PropertiesStart,
PxTriangleMeshGeometry_Scale,
PxTriangleMeshGeometry_MeshFlags,
PxTriangleMeshGeometry_TriangleMesh,
PxTriangleMeshGeometry_PropertiesStop,
PxHeightFieldGeometry_PropertiesStart,
PxHeightFieldGeometry_HeightField,
PxHeightFieldGeometry_HeightScale,
PxHeightFieldGeometry_RowScale,
PxHeightFieldGeometry_ColumnScale,
PxHeightFieldGeometry_HeightFieldFlags,
PxHeightFieldGeometry_PropertiesStop,
PxSceneQuerySystemBase_PropertiesStart,
PxSceneQuerySystemBase_DynamicTreeRebuildRateHint,
PxSceneQuerySystemBase_UpdateMode,
PxSceneQuerySystemBase_StaticTimestamp,
PxSceneQuerySystemBase_PropertiesStop,
PxSceneSQSystem_PropertiesStart,
PxSceneSQSystem_SceneQueryUpdateMode,
PxSceneSQSystem_SceneQueryStaticTimestamp,
PxSceneSQSystem_StaticStructure,
PxSceneSQSystem_DynamicStructure,
PxSceneSQSystem_PropertiesStop,
PxScene_PropertiesStart,
PxScene_Flags,
PxScene_Limits,
PxScene_Timestamp,
PxScene_Name,
PxScene_Actors,
PxScene_SoftBodies,
PxScene_Articulations,
PxScene_Constraints,
PxScene_Aggregates,
PxScene_CpuDispatcher,
PxScene_CudaContextManager,
PxScene_SimulationEventCallback,
PxScene_ContactModifyCallback,
PxScene_CCDContactModifyCallback,
PxScene_BroadPhaseCallback,
PxScene_FilterShaderDataSize,
PxScene_FilterShader,
PxScene_FilterCallback,
PxScene_KinematicKinematicFilteringMode,
PxScene_StaticKinematicFilteringMode,
PxScene_Gravity,
PxScene_BounceThresholdVelocity,
PxScene_CCDMaxPasses,
PxScene_CCDMaxSeparation,
PxScene_CCDThreshold,
PxScene_MaxBiasCoefficient,
PxScene_FrictionOffsetThreshold,
PxScene_FrictionCorrelationDistance,
PxScene_FrictionType,
PxScene_SolverType,
PxScene_VisualizationCullingBox,
PxScene_BroadPhaseType,
PxScene_BroadPhaseRegions,
PxScene_TaskManager,
PxScene_NbContactDataBlocks,
PxScene_MaxNbContactDataBlocksUsed,
PxScene_ContactReportStreamBufferSize,
PxScene_SolverBatchSize,
PxScene_SolverArticulationBatchSize,
PxScene_WakeCounterResetValue,
PxScene_GpuDynamicsConfig,
PxScene_UserData,
PxScene_SimulationStatistics,
PxScene_PropertiesStop,
PxTetrahedronMeshGeometry_PropertiesStart,
PxTetrahedronMeshGeometry_TetrahedronMesh,
PxTetrahedronMeshGeometry_PropertiesStop,
PxCustomGeometry_PropertiesStart,
PxCustomGeometry_CustomType,
PxCustomGeometry_PropertiesStop,
PxHeightFieldDesc_PropertiesStart,
PxHeightFieldDesc_NbRows,
PxHeightFieldDesc_NbColumns,
PxHeightFieldDesc_Format,
PxHeightFieldDesc_Samples,
PxHeightFieldDesc_ConvexEdgeThreshold,
PxHeightFieldDesc_Flags,
PxHeightFieldDesc_PropertiesStop,
PxArticulationLimit_PropertiesStart,
PxArticulationLimit_Low,
PxArticulationLimit_High,
PxArticulationLimit_PropertiesStop,
PxArticulationDrive_PropertiesStart,
PxArticulationDrive_Stiffness,
PxArticulationDrive_Damping,
PxArticulationDrive_MaxForce,
PxArticulationDrive_DriveType,
PxArticulationDrive_PropertiesStop,
PxSceneQueryDesc_PropertiesStart,
PxSceneQueryDesc_IsValid,
PxSceneQueryDesc_StaticStructure,
PxSceneQueryDesc_DynamicStructure,
PxSceneQueryDesc_DynamicTreeRebuildRateHint,
PxSceneQueryDesc_DynamicTreeSecondaryPruner,
PxSceneQueryDesc_StaticBVHBuildStrategy,
PxSceneQueryDesc_DynamicBVHBuildStrategy,
PxSceneQueryDesc_StaticNbObjectsPerNode,
PxSceneQueryDesc_DynamicNbObjectsPerNode,
PxSceneQueryDesc_SceneQueryUpdateMode,
PxSceneQueryDesc_PropertiesStop,
PxSceneDesc_PropertiesStart,
PxSceneDesc_ToDefault,
PxSceneDesc_Gravity,
PxSceneDesc_SimulationEventCallback,
PxSceneDesc_ContactModifyCallback,
PxSceneDesc_CcdContactModifyCallback,
PxSceneDesc_FilterShaderData,
PxSceneDesc_FilterShaderDataSize,
PxSceneDesc_FilterShader,
PxSceneDesc_FilterCallback,
PxSceneDesc_KineKineFilteringMode,
PxSceneDesc_StaticKineFilteringMode,
PxSceneDesc_BroadPhaseType,
PxSceneDesc_BroadPhaseCallback,
PxSceneDesc_Limits,
PxSceneDesc_FrictionType,
PxSceneDesc_SolverType,
PxSceneDesc_BounceThresholdVelocity,
PxSceneDesc_FrictionOffsetThreshold,
PxSceneDesc_FrictionCorrelationDistance,
PxSceneDesc_Flags,
PxSceneDesc_CpuDispatcher,
PxSceneDesc_CudaContextManager,
PxSceneDesc_UserData,
PxSceneDesc_SolverBatchSize,
PxSceneDesc_SolverArticulationBatchSize,
PxSceneDesc_NbContactDataBlocks,
PxSceneDesc_MaxNbContactDataBlocks,
PxSceneDesc_MaxBiasCoefficient,
PxSceneDesc_ContactReportStreamBufferSize,
PxSceneDesc_CcdMaxPasses,
PxSceneDesc_CcdThreshold,
PxSceneDesc_CcdMaxSeparation,
PxSceneDesc_WakeCounterResetValue,
PxSceneDesc_SanityBounds,
PxSceneDesc_GpuDynamicsConfig,
PxSceneDesc_GpuMaxNumPartitions,
PxSceneDesc_GpuMaxNumStaticPartitions,
PxSceneDesc_GpuComputeVersion,
PxSceneDesc_ContactPairSlabSize,
PxSceneDesc_PropertiesStop,
PxBroadPhaseDesc_PropertiesStart,
PxBroadPhaseDesc_IsValid,
PxBroadPhaseDesc_MType,
PxBroadPhaseDesc_MContextID,
PxBroadPhaseDesc_MContextManager,
PxBroadPhaseDesc_MFoundLostPairsCapacity,
PxBroadPhaseDesc_MDiscardStaticVsKinematic,
PxBroadPhaseDesc_MDiscardKinematicVsKinematic,
PxBroadPhaseDesc_PropertiesStop,
PxSceneLimits_PropertiesStart,
PxSceneLimits_MaxNbActors,
PxSceneLimits_MaxNbBodies,
PxSceneLimits_MaxNbStaticShapes,
PxSceneLimits_MaxNbDynamicShapes,
PxSceneLimits_MaxNbAggregates,
PxSceneLimits_MaxNbConstraints,
PxSceneLimits_MaxNbRegions,
PxSceneLimits_MaxNbBroadPhaseOverlaps,
PxSceneLimits_PropertiesStop,
PxgDynamicsMemoryConfig_PropertiesStart,
PxgDynamicsMemoryConfig_IsValid,
PxgDynamicsMemoryConfig_TempBufferCapacity,
PxgDynamicsMemoryConfig_MaxRigidContactCount,
PxgDynamicsMemoryConfig_MaxRigidPatchCount,
PxgDynamicsMemoryConfig_HeapCapacity,
PxgDynamicsMemoryConfig_FoundLostPairsCapacity,
PxgDynamicsMemoryConfig_FoundLostAggregatePairsCapacity,
PxgDynamicsMemoryConfig_TotalAggregatePairsCapacity,
PxgDynamicsMemoryConfig_MaxSoftBodyContacts,
PxgDynamicsMemoryConfig_MaxFemClothContacts,
PxgDynamicsMemoryConfig_MaxParticleContacts,
PxgDynamicsMemoryConfig_CollisionStackSize,
PxgDynamicsMemoryConfig_MaxHairContacts,
PxgDynamicsMemoryConfig_PropertiesStop,
PxSimulationStatistics_PropertiesStart,
PxSimulationStatistics_NbActiveConstraints,
PxSimulationStatistics_NbActiveDynamicBodies,
PxSimulationStatistics_NbActiveKinematicBodies,
PxSimulationStatistics_NbStaticBodies,
PxSimulationStatistics_NbDynamicBodies,
PxSimulationStatistics_NbKinematicBodies,
PxSimulationStatistics_NbAggregates,
PxSimulationStatistics_NbArticulations,
PxSimulationStatistics_NbAxisSolverConstraints,
PxSimulationStatistics_CompressedContactSize,
PxSimulationStatistics_RequiredContactConstraintMemory,
PxSimulationStatistics_PeakConstraintMemory,
PxSimulationStatistics_NbDiscreteContactPairsTotal,
PxSimulationStatistics_NbDiscreteContactPairsWithCacheHits,
PxSimulationStatistics_NbDiscreteContactPairsWithContacts,
PxSimulationStatistics_NbNewPairs,
PxSimulationStatistics_NbLostPairs,
PxSimulationStatistics_NbNewTouches,
PxSimulationStatistics_NbLostTouches,
PxSimulationStatistics_NbPartitions,
PxSimulationStatistics_GpuMemParticles,
PxSimulationStatistics_GpuMemSoftBodies,
PxSimulationStatistics_GpuMemFEMCloths,
PxSimulationStatistics_GpuMemHairSystems,
PxSimulationStatistics_GpuMemHeap,
PxSimulationStatistics_GpuMemHeapBroadPhase,
PxSimulationStatistics_GpuMemHeapNarrowPhase,
PxSimulationStatistics_GpuMemHeapSolver,
PxSimulationStatistics_GpuMemHeapArticulation,
PxSimulationStatistics_GpuMemHeapSimulation,
PxSimulationStatistics_GpuMemHeapSimulationArticulation,
PxSimulationStatistics_GpuMemHeapSimulationParticles,
PxSimulationStatistics_GpuMemHeapSimulationSoftBody,
PxSimulationStatistics_GpuMemHeapSimulationFEMCloth,
PxSimulationStatistics_GpuMemHeapSimulationHairSystem,
PxSimulationStatistics_GpuMemHeapParticles,
PxSimulationStatistics_GpuMemHeapSoftBodies,
PxSimulationStatistics_GpuMemHeapFEMCloths,
PxSimulationStatistics_GpuMemHeapHairSystems,
PxSimulationStatistics_GpuMemHeapOther,
PxSimulationStatistics_NbBroadPhaseAdds,
PxSimulationStatistics_NbBroadPhaseRemoves,
PxSimulationStatistics_NbDiscreteContactPairs,
PxSimulationStatistics_NbModifiedContactPairs,
PxSimulationStatistics_NbCCDPairs,
PxSimulationStatistics_NbTriggerPairs,
PxSimulationStatistics_NbShapes,
PxSimulationStatistics_PropertiesStop,
#undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
| 17,181 | C | 34.353909 | 90 | 0.891799 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxAutoGeneratedMetaDataObjects.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be
// prepared for your edits to be quietly ignored next time the clang metadata generator is
// run. You can find the most recent version of clang metadata generator by contacting
// Chris Nuernberger <[email protected]> or Dilip or Adam.
// The source code for the generate was at one time checked into:
// physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp
#define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
#define PX_PROPERTY_INFO_NAME PxPropertyInfoName
static PxU32ToName g_physx__PxShapeFlag__EnumConversion[] = {
{ "eSIMULATION_SHAPE", static_cast<PxU32>( physx::PxShapeFlag::eSIMULATION_SHAPE ) },
{ "eSCENE_QUERY_SHAPE", static_cast<PxU32>( physx::PxShapeFlag::eSCENE_QUERY_SHAPE ) },
{ "eTRIGGER_SHAPE", static_cast<PxU32>( physx::PxShapeFlag::eTRIGGER_SHAPE ) },
{ "eVISUALIZATION", static_cast<PxU32>( physx::PxShapeFlag::eVISUALIZATION ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxShapeFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxShapeFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxPhysics;
struct PxPhysicsGeneratedValues
{
PxTolerancesScale TolerancesScale;
PX_PHYSX_CORE_API PxPhysicsGeneratedValues( const PxPhysics* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPhysics, TolerancesScale, PxPhysicsGeneratedValues)
struct PxPhysicsGeneratedInfo
{
static const char* getClassName() { return "PxPhysics"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_TolerancesScale, PxPhysics, const PxTolerancesScale > TolerancesScale;
PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_TriangleMeshes, PxPhysics, PxTriangleMesh *, PxInputStream & > TriangleMeshes;
PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_TetrahedronMeshes, PxPhysics, PxTetrahedronMesh *, PxInputStream & > TetrahedronMeshes;
PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_HeightFields, PxPhysics, PxHeightField *, PxInputStream & > HeightFields;
PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_ConvexMeshes, PxPhysics, PxConvexMesh *, PxInputStream & > ConvexMeshes;
PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_BVHs, PxPhysics, PxBVH *, PxInputStream & > BVHs;
PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_Scenes, PxPhysics, PxScene *, const PxSceneDesc & > Scenes;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_Shapes, PxPhysics, PxShape * > Shapes;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_Materials, PxPhysics, PxMaterial * > Materials;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_FEMSoftBodyMaterials, PxPhysics, PxFEMSoftBodyMaterial * > FEMSoftBodyMaterials;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_FEMClothMaterials, PxPhysics, PxFEMClothMaterial * > FEMClothMaterials;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_PBDMaterials, PxPhysics, PxPBDMaterial * > PBDMaterials;
PX_PHYSX_CORE_API PxPhysicsGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxPhysics*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 12; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( TolerancesScale, inStartIndex + 0 );;
inOperator( TriangleMeshes, inStartIndex + 1 );;
inOperator( TetrahedronMeshes, inStartIndex + 2 );;
inOperator( HeightFields, inStartIndex + 3 );;
inOperator( ConvexMeshes, inStartIndex + 4 );;
inOperator( BVHs, inStartIndex + 5 );;
inOperator( Scenes, inStartIndex + 6 );;
inOperator( Shapes, inStartIndex + 7 );;
inOperator( Materials, inStartIndex + 8 );;
inOperator( FEMSoftBodyMaterials, inStartIndex + 9 );;
inOperator( FEMClothMaterials, inStartIndex + 10 );;
inOperator( PBDMaterials, inStartIndex + 11 );;
return 12 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxPhysics>
{
PxPhysicsGeneratedInfo Info;
const PxPhysicsGeneratedInfo* getInfo() { return &Info; }
};
class PxRefCounted;
struct PxRefCountedGeneratedValues
{
PxU32 ReferenceCount;
PX_PHYSX_CORE_API PxRefCountedGeneratedValues( const PxRefCounted* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRefCounted, ReferenceCount, PxRefCountedGeneratedValues)
struct PxRefCountedGeneratedInfo
{
static const char* getClassName() { return "PxRefCounted"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRefCounted_ReferenceCount, PxRefCounted, PxU32 > ReferenceCount;
PX_PHYSX_CORE_API PxRefCountedGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRefCounted*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( ReferenceCount, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRefCounted>
{
PxRefCountedGeneratedInfo Info;
const PxRefCountedGeneratedInfo* getInfo() { return &Info; }
};
class PxBaseMaterial;
struct PxBaseMaterialGeneratedValues
: PxRefCountedGeneratedValues {
void * UserData;
PX_PHYSX_CORE_API PxBaseMaterialGeneratedValues( const PxBaseMaterial* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBaseMaterial, UserData, PxBaseMaterialGeneratedValues)
struct PxBaseMaterialGeneratedInfo
: PxRefCountedGeneratedInfo
{
static const char* getClassName() { return "PxBaseMaterial"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBaseMaterial_UserData, PxBaseMaterial, void *, void * > UserData;
PX_PHYSX_CORE_API PxBaseMaterialGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxBaseMaterial*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxRefCountedGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxRefCountedGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxRefCountedGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxRefCountedGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( UserData, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxBaseMaterial>
{
PxBaseMaterialGeneratedInfo Info;
const PxBaseMaterialGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxMaterialFlag__EnumConversion[] = {
{ "eDISABLE_FRICTION", static_cast<PxU32>( physx::PxMaterialFlag::eDISABLE_FRICTION ) },
{ "eDISABLE_STRONG_FRICTION", static_cast<PxU32>( physx::PxMaterialFlag::eDISABLE_STRONG_FRICTION ) },
{ "eIMPROVED_PATCH_FRICTION", static_cast<PxU32>( physx::PxMaterialFlag::eIMPROVED_PATCH_FRICTION ) },
{ "eCOMPLIANT_CONTACT", static_cast<PxU32>( physx::PxMaterialFlag::eCOMPLIANT_CONTACT ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxMaterialFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxMaterialFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxCombineMode__EnumConversion[] = {
{ "eAVERAGE", static_cast<PxU32>( physx::PxCombineMode::eAVERAGE ) },
{ "eMIN", static_cast<PxU32>( physx::PxCombineMode::eMIN ) },
{ "eMULTIPLY", static_cast<PxU32>( physx::PxCombineMode::eMULTIPLY ) },
{ "eMAX", static_cast<PxU32>( physx::PxCombineMode::eMAX ) },
{ "eN_VALUES", static_cast<PxU32>( physx::PxCombineMode::eN_VALUES ) },
{ "ePAD_32", static_cast<PxU32>( physx::PxCombineMode::ePAD_32 ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxCombineMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxCombineMode__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxMaterial;
struct PxMaterialGeneratedValues
: PxBaseMaterialGeneratedValues {
PxReal DynamicFriction;
PxReal StaticFriction;
PxReal Restitution;
PxReal Damping;
PxMaterialFlags Flags;
PxCombineMode::Enum FrictionCombineMode;
PxCombineMode::Enum RestitutionCombineMode;
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxMaterialGeneratedValues( const PxMaterial* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, DynamicFriction, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, StaticFriction, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, Restitution, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, Damping, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, Flags, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, FrictionCombineMode, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, RestitutionCombineMode, PxMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, ConcreteTypeName, PxMaterialGeneratedValues)
struct PxMaterialGeneratedInfo
: PxBaseMaterialGeneratedInfo
{
static const char* getClassName() { return "PxMaterial"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_DynamicFriction, PxMaterial, PxReal, PxReal > DynamicFriction;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_StaticFriction, PxMaterial, PxReal, PxReal > StaticFriction;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_Restitution, PxMaterial, PxReal, PxReal > Restitution;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_Damping, PxMaterial, PxReal, PxReal > Damping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_Flags, PxMaterial, PxMaterialFlags, PxMaterialFlags > Flags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_FrictionCombineMode, PxMaterial, PxCombineMode::Enum, PxCombineMode::Enum > FrictionCombineMode;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_RestitutionCombineMode, PxMaterial, PxCombineMode::Enum, PxCombineMode::Enum > RestitutionCombineMode;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_ConcreteTypeName, PxMaterial, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxMaterialGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxMaterial*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxBaseMaterialGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxBaseMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxBaseMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 8; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxBaseMaterialGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( DynamicFriction, inStartIndex + 0 );;
inOperator( StaticFriction, inStartIndex + 1 );;
inOperator( Restitution, inStartIndex + 2 );;
inOperator( Damping, inStartIndex + 3 );;
inOperator( Flags, inStartIndex + 4 );;
inOperator( FrictionCombineMode, inStartIndex + 5 );;
inOperator( RestitutionCombineMode, inStartIndex + 6 );;
inOperator( ConcreteTypeName, inStartIndex + 7 );;
return 8 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxMaterial>
{
PxMaterialGeneratedInfo Info;
const PxMaterialGeneratedInfo* getInfo() { return &Info; }
};
class PxFEMMaterial;
struct PxFEMMaterialGeneratedValues
: PxBaseMaterialGeneratedValues {
PxReal YoungsModulus;
PxReal Poissons;
PxReal DynamicFriction;
PX_PHYSX_CORE_API PxFEMMaterialGeneratedValues( const PxFEMMaterial* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMMaterial, YoungsModulus, PxFEMMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMMaterial, Poissons, PxFEMMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMMaterial, DynamicFriction, PxFEMMaterialGeneratedValues)
struct PxFEMMaterialGeneratedInfo
: PxBaseMaterialGeneratedInfo
{
static const char* getClassName() { return "PxFEMMaterial"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMMaterial_YoungsModulus, PxFEMMaterial, PxReal, PxReal > YoungsModulus;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMMaterial_Poissons, PxFEMMaterial, PxReal, PxReal > Poissons;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMMaterial_DynamicFriction, PxFEMMaterial, PxReal, PxReal > DynamicFriction;
PX_PHYSX_CORE_API PxFEMMaterialGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxFEMMaterial*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxBaseMaterialGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxBaseMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxBaseMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 3; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxBaseMaterialGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( YoungsModulus, inStartIndex + 0 );;
inOperator( Poissons, inStartIndex + 1 );;
inOperator( DynamicFriction, inStartIndex + 2 );;
return 3 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxFEMMaterial>
{
PxFEMMaterialGeneratedInfo Info;
const PxFEMMaterialGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxFEMSoftBodyMaterialModel__EnumConversion[] = {
{ "eCO_ROTATIONAL", static_cast<PxU32>( physx::PxFEMSoftBodyMaterialModel::eCO_ROTATIONAL ) },
{ "eNEO_HOOKEAN", static_cast<PxU32>( physx::PxFEMSoftBodyMaterialModel::eNEO_HOOKEAN ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxFEMSoftBodyMaterialModel::Enum > { PxEnumTraits() : NameConversion( g_physx__PxFEMSoftBodyMaterialModel__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxFEMSoftBodyMaterial;
struct PxFEMSoftBodyMaterialGeneratedValues
: PxFEMMaterialGeneratedValues {
PxReal Damping;
PxReal DampingScale;
PxFEMSoftBodyMaterialModel::Enum MaterialModel;
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedValues( const PxFEMSoftBodyMaterial* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, Damping, PxFEMSoftBodyMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, DampingScale, PxFEMSoftBodyMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, MaterialModel, PxFEMSoftBodyMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, ConcreteTypeName, PxFEMSoftBodyMaterialGeneratedValues)
struct PxFEMSoftBodyMaterialGeneratedInfo
: PxFEMMaterialGeneratedInfo
{
static const char* getClassName() { return "PxFEMSoftBodyMaterial"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_Damping, PxFEMSoftBodyMaterial, PxReal, PxReal > Damping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_DampingScale, PxFEMSoftBodyMaterial, PxReal, PxReal > DampingScale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_MaterialModel, PxFEMSoftBodyMaterial, PxFEMSoftBodyMaterialModel::Enum, PxFEMSoftBodyMaterialModel::Enum > MaterialModel;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_ConcreteTypeName, PxFEMSoftBodyMaterial, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxFEMSoftBodyMaterial*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxFEMMaterialGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxFEMMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxFEMMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 4; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxFEMMaterialGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Damping, inStartIndex + 0 );;
inOperator( DampingScale, inStartIndex + 1 );;
inOperator( MaterialModel, inStartIndex + 2 );;
inOperator( ConcreteTypeName, inStartIndex + 3 );;
return 4 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxFEMSoftBodyMaterial>
{
PxFEMSoftBodyMaterialGeneratedInfo Info;
const PxFEMSoftBodyMaterialGeneratedInfo* getInfo() { return &Info; }
};
class PxParticleMaterial;
struct PxParticleMaterialGeneratedValues
: PxBaseMaterialGeneratedValues {
PxReal Friction;
PxReal Damping;
PxReal Adhesion;
PxReal GravityScale;
PxReal AdhesionRadiusScale;
PX_PHYSX_CORE_API PxParticleMaterialGeneratedValues( const PxParticleMaterial* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, Friction, PxParticleMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, Damping, PxParticleMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, Adhesion, PxParticleMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, GravityScale, PxParticleMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, AdhesionRadiusScale, PxParticleMaterialGeneratedValues)
struct PxParticleMaterialGeneratedInfo
: PxBaseMaterialGeneratedInfo
{
static const char* getClassName() { return "PxParticleMaterial"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_Friction, PxParticleMaterial, PxReal, PxReal > Friction;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_Damping, PxParticleMaterial, PxReal, PxReal > Damping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_Adhesion, PxParticleMaterial, PxReal, PxReal > Adhesion;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_GravityScale, PxParticleMaterial, PxReal, PxReal > GravityScale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_AdhesionRadiusScale, PxParticleMaterial, PxReal, PxReal > AdhesionRadiusScale;
PX_PHYSX_CORE_API PxParticleMaterialGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxParticleMaterial*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxBaseMaterialGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxBaseMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxBaseMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 5; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxBaseMaterialGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Friction, inStartIndex + 0 );;
inOperator( Damping, inStartIndex + 1 );;
inOperator( Adhesion, inStartIndex + 2 );;
inOperator( GravityScale, inStartIndex + 3 );;
inOperator( AdhesionRadiusScale, inStartIndex + 4 );;
return 5 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxParticleMaterial>
{
PxParticleMaterialGeneratedInfo Info;
const PxParticleMaterialGeneratedInfo* getInfo() { return &Info; }
};
class PxPBDMaterial;
struct PxPBDMaterialGeneratedValues
: PxParticleMaterialGeneratedValues {
PxReal Viscosity;
PxReal VorticityConfinement;
PxReal SurfaceTension;
PxReal Cohesion;
PxReal Lift;
PxReal Drag;
PxReal CFLCoefficient;
PxReal ParticleFrictionScale;
PxReal ParticleAdhesionScale;
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxPBDMaterialGeneratedValues( const PxPBDMaterial* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Viscosity, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, VorticityConfinement, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, SurfaceTension, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Cohesion, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Lift, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Drag, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, CFLCoefficient, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, ParticleFrictionScale, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, ParticleAdhesionScale, PxPBDMaterialGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, ConcreteTypeName, PxPBDMaterialGeneratedValues)
struct PxPBDMaterialGeneratedInfo
: PxParticleMaterialGeneratedInfo
{
static const char* getClassName() { return "PxPBDMaterial"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Viscosity, PxPBDMaterial, PxReal, PxReal > Viscosity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_VorticityConfinement, PxPBDMaterial, PxReal, PxReal > VorticityConfinement;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_SurfaceTension, PxPBDMaterial, PxReal, PxReal > SurfaceTension;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Cohesion, PxPBDMaterial, PxReal, PxReal > Cohesion;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Lift, PxPBDMaterial, PxReal, PxReal > Lift;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Drag, PxPBDMaterial, PxReal, PxReal > Drag;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_CFLCoefficient, PxPBDMaterial, PxReal, PxReal > CFLCoefficient;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_ParticleFrictionScale, PxPBDMaterial, PxReal, PxReal > ParticleFrictionScale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_ParticleAdhesionScale, PxPBDMaterial, PxReal, PxReal > ParticleAdhesionScale;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_ConcreteTypeName, PxPBDMaterial, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxPBDMaterialGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxPBDMaterial*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxParticleMaterialGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxParticleMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxParticleMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 10; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxParticleMaterialGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Viscosity, inStartIndex + 0 );;
inOperator( VorticityConfinement, inStartIndex + 1 );;
inOperator( SurfaceTension, inStartIndex + 2 );;
inOperator( Cohesion, inStartIndex + 3 );;
inOperator( Lift, inStartIndex + 4 );;
inOperator( Drag, inStartIndex + 5 );;
inOperator( CFLCoefficient, inStartIndex + 6 );;
inOperator( ParticleFrictionScale, inStartIndex + 7 );;
inOperator( ParticleAdhesionScale, inStartIndex + 8 );;
inOperator( ConcreteTypeName, inStartIndex + 9 );;
return 10 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxPBDMaterial>
{
PxPBDMaterialGeneratedInfo Info;
const PxPBDMaterialGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxActorType__EnumConversion[] = {
{ "eRIGID_STATIC", static_cast<PxU32>( physx::PxActorType::eRIGID_STATIC ) },
{ "eRIGID_DYNAMIC", static_cast<PxU32>( physx::PxActorType::eRIGID_DYNAMIC ) },
{ "eARTICULATION_LINK", static_cast<PxU32>( physx::PxActorType::eARTICULATION_LINK ) },
{ "eSOFTBODY", static_cast<PxU32>( physx::PxActorType::eSOFTBODY ) },
{ "eFEMCLOTH", static_cast<PxU32>( physx::PxActorType::eFEMCLOTH ) },
{ "ePBD_PARTICLESYSTEM", static_cast<PxU32>( physx::PxActorType::ePBD_PARTICLESYSTEM ) },
{ "eFLIP_PARTICLESYSTEM", static_cast<PxU32>( physx::PxActorType::eFLIP_PARTICLESYSTEM ) },
{ "eMPM_PARTICLESYSTEM", static_cast<PxU32>( physx::PxActorType::eMPM_PARTICLESYSTEM ) },
{ "eHAIRSYSTEM", static_cast<PxU32>( physx::PxActorType::eHAIRSYSTEM ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxActorType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxActorFlag__EnumConversion[] = {
{ "eVISUALIZATION", static_cast<PxU32>( physx::PxActorFlag::eVISUALIZATION ) },
{ "eDISABLE_GRAVITY", static_cast<PxU32>( physx::PxActorFlag::eDISABLE_GRAVITY ) },
{ "eSEND_SLEEP_NOTIFIES", static_cast<PxU32>( physx::PxActorFlag::eSEND_SLEEP_NOTIFIES ) },
{ "eDISABLE_SIMULATION", static_cast<PxU32>( physx::PxActorFlag::eDISABLE_SIMULATION ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxActorFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxActor;
struct PxActorGeneratedValues
{
PxScene * Scene;
const char * Name;
PxActorFlags ActorFlags;
PxDominanceGroup DominanceGroup;
PxClientID OwnerClient;
PxAggregate * Aggregate;
void * UserData;
PX_PHYSX_CORE_API PxActorGeneratedValues( const PxActor* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, Scene, PxActorGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, Name, PxActorGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, ActorFlags, PxActorGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, DominanceGroup, PxActorGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, OwnerClient, PxActorGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, Aggregate, PxActorGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, UserData, PxActorGeneratedValues)
struct PxActorGeneratedInfo
{
static const char* getClassName() { return "PxActor"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_Scene, PxActor, PxScene * > Scene;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_Name, PxActor, const char *, const char * > Name;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_ActorFlags, PxActor, PxActorFlags, PxActorFlags > ActorFlags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_DominanceGroup, PxActor, PxDominanceGroup, PxDominanceGroup > DominanceGroup;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_OwnerClient, PxActor, PxClientID, PxClientID > OwnerClient;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_Aggregate, PxActor, PxAggregate * > Aggregate;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_UserData, PxActor, void *, void * > UserData;
PX_PHYSX_CORE_API PxActorGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxActor*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 7; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Scene, inStartIndex + 0 );;
inOperator( Name, inStartIndex + 1 );;
inOperator( ActorFlags, inStartIndex + 2 );;
inOperator( DominanceGroup, inStartIndex + 3 );;
inOperator( OwnerClient, inStartIndex + 4 );;
inOperator( Aggregate, inStartIndex + 5 );;
inOperator( UserData, inStartIndex + 6 );;
return 7 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxActor>
{
PxActorGeneratedInfo Info;
const PxActorGeneratedInfo* getInfo() { return &Info; }
};
class PxRigidActor;
struct PxRigidActorGeneratedValues
: PxActorGeneratedValues {
PxTransform GlobalPose;
PX_PHYSX_CORE_API PxRigidActorGeneratedValues( const PxRigidActor* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidActor, GlobalPose, PxRigidActorGeneratedValues)
struct PxRigidActorGeneratedInfo
: PxActorGeneratedInfo
{
static const char* getClassName() { return "PxRigidActor"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidActor_GlobalPose, PxRigidActor, const PxTransform &, PxTransform > GlobalPose;
PxRigidActorShapeCollection Shapes;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidActor_Constraints, PxRigidActor, PxConstraint * > Constraints;
PX_PHYSX_CORE_API PxRigidActorGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRigidActor*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxActorGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxActorGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxActorGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 3; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxActorGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( GlobalPose, inStartIndex + 0 );;
inOperator( Shapes, inStartIndex + 1 );;
inOperator( Constraints, inStartIndex + 2 );;
return 3 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRigidActor>
{
PxRigidActorGeneratedInfo Info;
const PxRigidActorGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxForceMode__EnumConversion[] = {
{ "eFORCE", static_cast<PxU32>( physx::PxForceMode::eFORCE ) },
{ "eIMPULSE", static_cast<PxU32>( physx::PxForceMode::eIMPULSE ) },
{ "eVELOCITY_CHANGE", static_cast<PxU32>( physx::PxForceMode::eVELOCITY_CHANGE ) },
{ "eACCELERATION", static_cast<PxU32>( physx::PxForceMode::eACCELERATION ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxForceMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxForceMode__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxRigidBodyFlag__EnumConversion[] = {
{ "eKINEMATIC", static_cast<PxU32>( physx::PxRigidBodyFlag::eKINEMATIC ) },
{ "eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES", static_cast<PxU32>( physx::PxRigidBodyFlag::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES ) },
{ "eENABLE_CCD", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_CCD ) },
{ "eENABLE_CCD_FRICTION", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_CCD_FRICTION ) },
{ "eENABLE_SPECULATIVE_CCD", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_SPECULATIVE_CCD ) },
{ "eENABLE_POSE_INTEGRATION_PREVIEW", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW ) },
{ "eENABLE_CCD_MAX_CONTACT_IMPULSE", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_CCD_MAX_CONTACT_IMPULSE ) },
{ "eRETAIN_ACCELERATIONS", static_cast<PxU32>( physx::PxRigidBodyFlag::eRETAIN_ACCELERATIONS ) },
{ "eFORCE_KINE_KINE_NOTIFICATIONS", static_cast<PxU32>( physx::PxRigidBodyFlag::eFORCE_KINE_KINE_NOTIFICATIONS ) },
{ "eFORCE_STATIC_KINE_NOTIFICATIONS", static_cast<PxU32>( physx::PxRigidBodyFlag::eFORCE_STATIC_KINE_NOTIFICATIONS ) },
{ "eENABLE_GYROSCOPIC_FORCES", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_GYROSCOPIC_FORCES ) },
{ "eRESERVED", static_cast<PxU32>( physx::PxRigidBodyFlag::eRESERVED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxRigidBodyFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxRigidBodyFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxRigidBody;
struct PxRigidBodyGeneratedValues
: PxRigidActorGeneratedValues {
PxTransform CMassLocalPose;
PxReal Mass;
PxReal InvMass;
PxVec3 MassSpaceInertiaTensor;
PxVec3 MassSpaceInvInertiaTensor;
PxReal LinearDamping;
PxReal AngularDamping;
PxReal MaxLinearVelocity;
PxReal MaxAngularVelocity;
PxRigidBodyFlags RigidBodyFlags;
PxReal MinCCDAdvanceCoefficient;
PxReal MaxDepenetrationVelocity;
PxReal MaxContactImpulse;
PxReal ContactSlopCoefficient;
PX_PHYSX_CORE_API PxRigidBodyGeneratedValues( const PxRigidBody* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, CMassLocalPose, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, Mass, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, InvMass, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MassSpaceInertiaTensor, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MassSpaceInvInertiaTensor, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, LinearDamping, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, AngularDamping, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxLinearVelocity, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxAngularVelocity, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, RigidBodyFlags, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MinCCDAdvanceCoefficient, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxDepenetrationVelocity, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxContactImpulse, PxRigidBodyGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, ContactSlopCoefficient, PxRigidBodyGeneratedValues)
struct PxRigidBodyGeneratedInfo
: PxRigidActorGeneratedInfo
{
static const char* getClassName() { return "PxRigidBody"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_CMassLocalPose, PxRigidBody, const PxTransform &, PxTransform > CMassLocalPose;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_Mass, PxRigidBody, PxReal, PxReal > Mass;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_InvMass, PxRigidBody, PxReal > InvMass;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MassSpaceInertiaTensor, PxRigidBody, const PxVec3 &, PxVec3 > MassSpaceInertiaTensor;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MassSpaceInvInertiaTensor, PxRigidBody, PxVec3 > MassSpaceInvInertiaTensor;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_LinearDamping, PxRigidBody, PxReal, PxReal > LinearDamping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_AngularDamping, PxRigidBody, PxReal, PxReal > AngularDamping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxLinearVelocity, PxRigidBody, PxReal, PxReal > MaxLinearVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxAngularVelocity, PxRigidBody, PxReal, PxReal > MaxAngularVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_RigidBodyFlags, PxRigidBody, PxRigidBodyFlags, PxRigidBodyFlags > RigidBodyFlags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MinCCDAdvanceCoefficient, PxRigidBody, PxReal, PxReal > MinCCDAdvanceCoefficient;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxDepenetrationVelocity, PxRigidBody, PxReal, PxReal > MaxDepenetrationVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxContactImpulse, PxRigidBody, PxReal, PxReal > MaxContactImpulse;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_ContactSlopCoefficient, PxRigidBody, PxReal, PxReal > ContactSlopCoefficient;
PX_PHYSX_CORE_API PxRigidBodyGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRigidBody*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxRigidActorGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxRigidActorGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxRigidActorGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 14; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxRigidActorGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( CMassLocalPose, inStartIndex + 0 );;
inOperator( Mass, inStartIndex + 1 );;
inOperator( InvMass, inStartIndex + 2 );;
inOperator( MassSpaceInertiaTensor, inStartIndex + 3 );;
inOperator( MassSpaceInvInertiaTensor, inStartIndex + 4 );;
inOperator( LinearDamping, inStartIndex + 5 );;
inOperator( AngularDamping, inStartIndex + 6 );;
inOperator( MaxLinearVelocity, inStartIndex + 7 );;
inOperator( MaxAngularVelocity, inStartIndex + 8 );;
inOperator( RigidBodyFlags, inStartIndex + 9 );;
inOperator( MinCCDAdvanceCoefficient, inStartIndex + 10 );;
inOperator( MaxDepenetrationVelocity, inStartIndex + 11 );;
inOperator( MaxContactImpulse, inStartIndex + 12 );;
inOperator( ContactSlopCoefficient, inStartIndex + 13 );;
return 14 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRigidBody>
{
PxRigidBodyGeneratedInfo Info;
const PxRigidBodyGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxRigidDynamicLockFlag__EnumConversion[] = {
{ "eLOCK_LINEAR_X", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_LINEAR_X ) },
{ "eLOCK_LINEAR_Y", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_LINEAR_Y ) },
{ "eLOCK_LINEAR_Z", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_LINEAR_Z ) },
{ "eLOCK_ANGULAR_X", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_ANGULAR_X ) },
{ "eLOCK_ANGULAR_Y", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_ANGULAR_Y ) },
{ "eLOCK_ANGULAR_Z", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_ANGULAR_Z ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxRigidDynamicLockFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxRigidDynamicLockFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxRigidDynamic;
struct PxRigidDynamicGeneratedValues
: PxRigidBodyGeneratedValues {
_Bool IsSleeping;
PxReal SleepThreshold;
PxReal StabilizationThreshold;
PxRigidDynamicLockFlags RigidDynamicLockFlags;
PxVec3 LinearVelocity;
PxVec3 AngularVelocity;
PxReal WakeCounter;
PxU32 SolverIterationCounts[2];
PxReal ContactReportThreshold;
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxRigidDynamicGeneratedValues( const PxRigidDynamic* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, IsSleeping, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, SleepThreshold, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, StabilizationThreshold, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, RigidDynamicLockFlags, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, LinearVelocity, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, AngularVelocity, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, WakeCounter, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, SolverIterationCounts, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, ContactReportThreshold, PxRigidDynamicGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, ConcreteTypeName, PxRigidDynamicGeneratedValues)
struct PxRigidDynamicGeneratedInfo
: PxRigidBodyGeneratedInfo
{
static const char* getClassName() { return "PxRigidDynamic"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_IsSleeping, PxRigidDynamic, _Bool > IsSleeping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_SleepThreshold, PxRigidDynamic, PxReal, PxReal > SleepThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_StabilizationThreshold, PxRigidDynamic, PxReal, PxReal > StabilizationThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_RigidDynamicLockFlags, PxRigidDynamic, PxRigidDynamicLockFlags, PxRigidDynamicLockFlags > RigidDynamicLockFlags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_LinearVelocity, PxRigidDynamic, const PxVec3 &, PxVec3 > LinearVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_AngularVelocity, PxRigidDynamic, const PxVec3 &, PxVec3 > AngularVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_WakeCounter, PxRigidDynamic, PxReal, PxReal > WakeCounter;
PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_SolverIterationCounts, PxRigidDynamic, PxU32 > SolverIterationCounts;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_ContactReportThreshold, PxRigidDynamic, PxReal, PxReal > ContactReportThreshold;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_ConcreteTypeName, PxRigidDynamic, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxRigidDynamicGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRigidDynamic*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxRigidBodyGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxRigidBodyGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxRigidBodyGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 10; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxRigidBodyGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( IsSleeping, inStartIndex + 0 );;
inOperator( SleepThreshold, inStartIndex + 1 );;
inOperator( StabilizationThreshold, inStartIndex + 2 );;
inOperator( RigidDynamicLockFlags, inStartIndex + 3 );;
inOperator( LinearVelocity, inStartIndex + 4 );;
inOperator( AngularVelocity, inStartIndex + 5 );;
inOperator( WakeCounter, inStartIndex + 6 );;
inOperator( SolverIterationCounts, inStartIndex + 7 );;
inOperator( ContactReportThreshold, inStartIndex + 8 );;
inOperator( ConcreteTypeName, inStartIndex + 9 );;
return 10 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRigidDynamic>
{
PxRigidDynamicGeneratedInfo Info;
const PxRigidDynamicGeneratedInfo* getInfo() { return &Info; }
};
class PxRigidStatic;
struct PxRigidStaticGeneratedValues
: PxRigidActorGeneratedValues {
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxRigidStaticGeneratedValues( const PxRigidStatic* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidStatic, ConcreteTypeName, PxRigidStaticGeneratedValues)
struct PxRigidStaticGeneratedInfo
: PxRigidActorGeneratedInfo
{
static const char* getClassName() { return "PxRigidStatic"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidStatic_ConcreteTypeName, PxRigidStatic, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxRigidStaticGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxRigidStatic*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxRigidActorGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxRigidActorGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxRigidActorGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxRigidActorGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( ConcreteTypeName, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxRigidStatic>
{
PxRigidStaticGeneratedInfo Info;
const PxRigidStaticGeneratedInfo* getInfo() { return &Info; }
};
class PxArticulationLink;
struct PxArticulationLinkGeneratedValues
: PxRigidBodyGeneratedValues {
PxArticulationJointReducedCoordinate * InboundJoint;
PxU32 InboundJointDof;
PxU32 LinkIndex;
PxReal CfmScale;
PxVec3 LinearVelocity;
PxVec3 AngularVelocity;
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxArticulationLinkGeneratedValues( const PxArticulationLink* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, InboundJoint, PxArticulationLinkGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, InboundJointDof, PxArticulationLinkGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, LinkIndex, PxArticulationLinkGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, CfmScale, PxArticulationLinkGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, LinearVelocity, PxArticulationLinkGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, AngularVelocity, PxArticulationLinkGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, ConcreteTypeName, PxArticulationLinkGeneratedValues)
struct PxArticulationLinkGeneratedInfo
: PxRigidBodyGeneratedInfo
{
static const char* getClassName() { return "PxArticulationLink"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_InboundJoint, PxArticulationLink, PxArticulationJointReducedCoordinate * > InboundJoint;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_InboundJointDof, PxArticulationLink, PxU32 > InboundJointDof;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_LinkIndex, PxArticulationLink, PxU32 > LinkIndex;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_Children, PxArticulationLink, PxArticulationLink * > Children;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_CfmScale, PxArticulationLink, const PxReal, PxReal > CfmScale;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_LinearVelocity, PxArticulationLink, PxVec3 > LinearVelocity;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_AngularVelocity, PxArticulationLink, PxVec3 > AngularVelocity;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_ConcreteTypeName, PxArticulationLink, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxArticulationLinkGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxArticulationLink*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxRigidBodyGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxRigidBodyGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxRigidBodyGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 8; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxRigidBodyGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( InboundJoint, inStartIndex + 0 );;
inOperator( InboundJointDof, inStartIndex + 1 );;
inOperator( LinkIndex, inStartIndex + 2 );;
inOperator( Children, inStartIndex + 3 );;
inOperator( CfmScale, inStartIndex + 4 );;
inOperator( LinearVelocity, inStartIndex + 5 );;
inOperator( AngularVelocity, inStartIndex + 6 );;
inOperator( ConcreteTypeName, inStartIndex + 7 );;
return 8 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxArticulationLink>
{
PxArticulationLinkGeneratedInfo Info;
const PxArticulationLinkGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxArticulationJointType__EnumConversion[] = {
{ "eFIX", static_cast<PxU32>( physx::PxArticulationJointType::eFIX ) },
{ "ePRISMATIC", static_cast<PxU32>( physx::PxArticulationJointType::ePRISMATIC ) },
{ "eREVOLUTE", static_cast<PxU32>( physx::PxArticulationJointType::eREVOLUTE ) },
{ "eREVOLUTE_UNWRAPPED", static_cast<PxU32>( physx::PxArticulationJointType::eREVOLUTE_UNWRAPPED ) },
{ "eSPHERICAL", static_cast<PxU32>( physx::PxArticulationJointType::eSPHERICAL ) },
{ "eUNDEFINED", static_cast<PxU32>( physx::PxArticulationJointType::eUNDEFINED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationJointType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationJointType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxArticulationAxis__EnumConversion[] = {
{ "eTWIST", static_cast<PxU32>( physx::PxArticulationAxis::eTWIST ) },
{ "eSWING1", static_cast<PxU32>( physx::PxArticulationAxis::eSWING1 ) },
{ "eSWING2", static_cast<PxU32>( physx::PxArticulationAxis::eSWING2 ) },
{ "eX", static_cast<PxU32>( physx::PxArticulationAxis::eX ) },
{ "eY", static_cast<PxU32>( physx::PxArticulationAxis::eY ) },
{ "eZ", static_cast<PxU32>( physx::PxArticulationAxis::eZ ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationAxis::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationAxis__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxArticulationMotion__EnumConversion[] = {
{ "eLOCKED", static_cast<PxU32>( physx::PxArticulationMotion::eLOCKED ) },
{ "eLIMITED", static_cast<PxU32>( physx::PxArticulationMotion::eLIMITED ) },
{ "eFREE", static_cast<PxU32>( physx::PxArticulationMotion::eFREE ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationMotion::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationMotion__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxArticulationJointReducedCoordinate;
struct PxArticulationJointReducedCoordinateGeneratedValues
{
PxTransform ParentPose;
PxTransform ChildPose;
PxArticulationJointType::Enum JointType;
PxArticulationMotion::Enum Motion[physx::PxArticulationAxis::eCOUNT];
PxArticulationLimit LimitParams[physx::PxArticulationAxis::eCOUNT];
PxArticulationDrive DriveParams[physx::PxArticulationAxis::eCOUNT];
PxReal Armature[physx::PxArticulationAxis::eCOUNT];
PxReal FrictionCoefficient;
PxReal MaxJointVelocity;
PxReal JointPosition[physx::PxArticulationAxis::eCOUNT];
PxReal JointVelocity[physx::PxArticulationAxis::eCOUNT];
const char * ConcreteTypeName;
void * UserData;
PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedValues( const PxArticulationJointReducedCoordinate* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, ParentPose, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, ChildPose, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, JointType, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, Motion, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, LimitParams, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, DriveParams, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, Armature, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, FrictionCoefficient, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, MaxJointVelocity, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, JointPosition, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, JointVelocity, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, ConcreteTypeName, PxArticulationJointReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, UserData, PxArticulationJointReducedCoordinateGeneratedValues)
struct PxArticulationJointReducedCoordinateGeneratedInfo
{
static const char* getClassName() { return "PxArticulationJointReducedCoordinate"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_ParentPose, PxArticulationJointReducedCoordinate, const PxTransform &, PxTransform > ParentPose;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_ChildPose, PxArticulationJointReducedCoordinate, const PxTransform &, PxTransform > ChildPose;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_JointType, PxArticulationJointReducedCoordinate, PxArticulationJointType::Enum, PxArticulationJointType::Enum > JointType;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_Motion, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxArticulationMotion::Enum > Motion;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_LimitParams, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxArticulationLimit > LimitParams;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_DriveParams, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxArticulationDrive > DriveParams;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_Armature, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxReal > Armature;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_FrictionCoefficient, PxArticulationJointReducedCoordinate, const PxReal, PxReal > FrictionCoefficient;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_MaxJointVelocity, PxArticulationJointReducedCoordinate, const PxReal, PxReal > MaxJointVelocity;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_JointPosition, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxReal > JointPosition;
PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_JointVelocity, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxReal > JointVelocity;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_ConcreteTypeName, PxArticulationJointReducedCoordinate, const char * > ConcreteTypeName;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_UserData, PxArticulationJointReducedCoordinate, void *, void * > UserData;
PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxArticulationJointReducedCoordinate*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 13; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( ParentPose, inStartIndex + 0 );;
inOperator( ChildPose, inStartIndex + 1 );;
inOperator( JointType, inStartIndex + 2 );;
inOperator( Motion, inStartIndex + 3 );;
inOperator( LimitParams, inStartIndex + 4 );;
inOperator( DriveParams, inStartIndex + 5 );;
inOperator( Armature, inStartIndex + 6 );;
inOperator( FrictionCoefficient, inStartIndex + 7 );;
inOperator( MaxJointVelocity, inStartIndex + 8 );;
inOperator( JointPosition, inStartIndex + 9 );;
inOperator( JointVelocity, inStartIndex + 10 );;
inOperator( ConcreteTypeName, inStartIndex + 11 );;
inOperator( UserData, inStartIndex + 12 );;
return 13 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxArticulationJointReducedCoordinate>
{
PxArticulationJointReducedCoordinateGeneratedInfo Info;
const PxArticulationJointReducedCoordinateGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxArticulationFlag__EnumConversion[] = {
{ "eFIX_BASE", static_cast<PxU32>( physx::PxArticulationFlag::eFIX_BASE ) },
{ "eDRIVE_LIMITS_ARE_FORCES", static_cast<PxU32>( physx::PxArticulationFlag::eDRIVE_LIMITS_ARE_FORCES ) },
{ "eDISABLE_SELF_COLLISION", static_cast<PxU32>( physx::PxArticulationFlag::eDISABLE_SELF_COLLISION ) },
{ "eCOMPUTE_JOINT_FORCES", static_cast<PxU32>( physx::PxArticulationFlag::eCOMPUTE_JOINT_FORCES ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxArticulationCacheFlag__EnumConversion[] = {
{ "eVELOCITY", static_cast<PxU32>( physx::PxArticulationCacheFlag::eVELOCITY ) },
{ "eACCELERATION", static_cast<PxU32>( physx::PxArticulationCacheFlag::eACCELERATION ) },
{ "ePOSITION", static_cast<PxU32>( physx::PxArticulationCacheFlag::ePOSITION ) },
{ "eFORCE", static_cast<PxU32>( physx::PxArticulationCacheFlag::eFORCE ) },
{ "eLINK_VELOCITY", static_cast<PxU32>( physx::PxArticulationCacheFlag::eLINK_VELOCITY ) },
{ "eLINK_ACCELERATION", static_cast<PxU32>( physx::PxArticulationCacheFlag::eLINK_ACCELERATION ) },
{ "eROOT_TRANSFORM", static_cast<PxU32>( physx::PxArticulationCacheFlag::eROOT_TRANSFORM ) },
{ "eROOT_VELOCITIES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eROOT_VELOCITIES ) },
{ "eSENSOR_FORCES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eSENSOR_FORCES ) },
{ "eJOINT_SOLVER_FORCES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eJOINT_SOLVER_FORCES ) },
{ "eLINK_INCOMING_JOINT_FORCE", static_cast<PxU32>( physx::PxArticulationCacheFlag::eLINK_INCOMING_JOINT_FORCE ) },
{ "eJOINT_TARGET_POSITIONS", static_cast<PxU32>( physx::PxArticulationCacheFlag::eJOINT_TARGET_POSITIONS ) },
{ "eJOINT_TARGET_VELOCITIES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eJOINT_TARGET_VELOCITIES ) },
{ "eALL", static_cast<PxU32>( physx::PxArticulationCacheFlag::eALL ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationCacheFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationCacheFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxArticulationReducedCoordinate;
struct PxArticulationReducedCoordinateGeneratedValues
{
PxScene * Scene;
PxU32 SolverIterationCounts[2];
_Bool IsSleeping;
PxReal SleepThreshold;
PxReal StabilizationThreshold;
PxReal WakeCounter;
PxReal MaxCOMLinearVelocity;
PxReal MaxCOMAngularVelocity;
const char * Name;
PxAggregate * Aggregate;
PxArticulationFlags ArticulationFlags;
PxTransform RootGlobalPose;
PxVec3 RootLinearVelocity;
PxVec3 RootAngularVelocity;
void * UserData;
PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedValues( const PxArticulationReducedCoordinate* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, Scene, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, SolverIterationCounts, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, IsSleeping, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, SleepThreshold, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, StabilizationThreshold, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, WakeCounter, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, MaxCOMLinearVelocity, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, MaxCOMAngularVelocity, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, Name, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, Aggregate, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, ArticulationFlags, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, RootGlobalPose, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, RootLinearVelocity, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, RootAngularVelocity, PxArticulationReducedCoordinateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, UserData, PxArticulationReducedCoordinateGeneratedValues)
struct PxArticulationReducedCoordinateGeneratedInfo
{
static const char* getClassName() { return "PxArticulationReducedCoordinate"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_Scene, PxArticulationReducedCoordinate, PxScene * > Scene;
PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_SolverIterationCounts, PxArticulationReducedCoordinate, PxU32 > SolverIterationCounts;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_IsSleeping, PxArticulationReducedCoordinate, _Bool > IsSleeping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_SleepThreshold, PxArticulationReducedCoordinate, PxReal, PxReal > SleepThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_StabilizationThreshold, PxArticulationReducedCoordinate, PxReal, PxReal > StabilizationThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_WakeCounter, PxArticulationReducedCoordinate, PxReal, PxReal > WakeCounter;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_MaxCOMLinearVelocity, PxArticulationReducedCoordinate, const PxReal, PxReal > MaxCOMLinearVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_MaxCOMAngularVelocity, PxArticulationReducedCoordinate, const PxReal, PxReal > MaxCOMAngularVelocity;
PxArticulationLinkCollectionProp Links;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_Name, PxArticulationReducedCoordinate, const char *, const char * > Name;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_Aggregate, PxArticulationReducedCoordinate, PxAggregate * > Aggregate;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_ArticulationFlags, PxArticulationReducedCoordinate, PxArticulationFlags, PxArticulationFlags > ArticulationFlags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_RootGlobalPose, PxArticulationReducedCoordinate, const PxTransform &, PxTransform > RootGlobalPose;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_RootLinearVelocity, PxArticulationReducedCoordinate, const PxVec3 &, PxVec3 > RootLinearVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_RootAngularVelocity, PxArticulationReducedCoordinate, const PxVec3 &, PxVec3 > RootAngularVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_UserData, PxArticulationReducedCoordinate, void *, void * > UserData;
PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxArticulationReducedCoordinate*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 16; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Scene, inStartIndex + 0 );;
inOperator( SolverIterationCounts, inStartIndex + 1 );;
inOperator( IsSleeping, inStartIndex + 2 );;
inOperator( SleepThreshold, inStartIndex + 3 );;
inOperator( StabilizationThreshold, inStartIndex + 4 );;
inOperator( WakeCounter, inStartIndex + 5 );;
inOperator( MaxCOMLinearVelocity, inStartIndex + 6 );;
inOperator( MaxCOMAngularVelocity, inStartIndex + 7 );;
inOperator( Links, inStartIndex + 8 );;
inOperator( Name, inStartIndex + 9 );;
inOperator( Aggregate, inStartIndex + 10 );;
inOperator( ArticulationFlags, inStartIndex + 11 );;
inOperator( RootGlobalPose, inStartIndex + 12 );;
inOperator( RootLinearVelocity, inStartIndex + 13 );;
inOperator( RootAngularVelocity, inStartIndex + 14 );;
inOperator( UserData, inStartIndex + 15 );;
return 16 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxArticulationReducedCoordinate>
{
PxArticulationReducedCoordinateGeneratedInfo Info;
const PxArticulationReducedCoordinateGeneratedInfo* getInfo() { return &Info; }
};
class PxAggregate;
struct PxAggregateGeneratedValues
{
PxU32 MaxNbActors;
PxU32 MaxNbShapes;
_Bool SelfCollision;
const char * ConcreteTypeName;
void * UserData;
PX_PHYSX_CORE_API PxAggregateGeneratedValues( const PxAggregate* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, MaxNbActors, PxAggregateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, MaxNbShapes, PxAggregateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, SelfCollision, PxAggregateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, ConcreteTypeName, PxAggregateGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, UserData, PxAggregateGeneratedValues)
struct PxAggregateGeneratedInfo
{
static const char* getClassName() { return "PxAggregate"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_MaxNbActors, PxAggregate, PxU32 > MaxNbActors;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_MaxNbShapes, PxAggregate, PxU32 > MaxNbShapes;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_Actors, PxAggregate, PxActor * > Actors;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_SelfCollision, PxAggregate, _Bool > SelfCollision;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_ConcreteTypeName, PxAggregate, const char * > ConcreteTypeName;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_UserData, PxAggregate, void *, void * > UserData;
PX_PHYSX_CORE_API PxAggregateGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxAggregate*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 6; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( MaxNbActors, inStartIndex + 0 );;
inOperator( MaxNbShapes, inStartIndex + 1 );;
inOperator( Actors, inStartIndex + 2 );;
inOperator( SelfCollision, inStartIndex + 3 );;
inOperator( ConcreteTypeName, inStartIndex + 4 );;
inOperator( UserData, inStartIndex + 5 );;
return 6 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxAggregate>
{
PxAggregateGeneratedInfo Info;
const PxAggregateGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxConstraintFlag__EnumConversion[] = {
{ "eBROKEN", static_cast<PxU32>( physx::PxConstraintFlag::eBROKEN ) },
{ "eCOLLISION_ENABLED", static_cast<PxU32>( physx::PxConstraintFlag::eCOLLISION_ENABLED ) },
{ "eVISUALIZATION", static_cast<PxU32>( physx::PxConstraintFlag::eVISUALIZATION ) },
{ "eDRIVE_LIMITS_ARE_FORCES", static_cast<PxU32>( physx::PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES ) },
{ "eIMPROVED_SLERP", static_cast<PxU32>( physx::PxConstraintFlag::eIMPROVED_SLERP ) },
{ "eDISABLE_PREPROCESSING", static_cast<PxU32>( physx::PxConstraintFlag::eDISABLE_PREPROCESSING ) },
{ "eENABLE_EXTENDED_LIMITS", static_cast<PxU32>( physx::PxConstraintFlag::eENABLE_EXTENDED_LIMITS ) },
{ "eGPU_COMPATIBLE", static_cast<PxU32>( physx::PxConstraintFlag::eGPU_COMPATIBLE ) },
{ "eALWAYS_UPDATE", static_cast<PxU32>( physx::PxConstraintFlag::eALWAYS_UPDATE ) },
{ "eDISABLE_CONSTRAINT", static_cast<PxU32>( physx::PxConstraintFlag::eDISABLE_CONSTRAINT ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxConstraintFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxConstraintFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxConstraint;
struct PxConstraintGeneratedValues
{
PxScene * Scene;
PxRigidActor * Actors[2];
PxConstraintFlags Flags;
_Bool IsValid;
PxReal BreakForce[2];
PxReal MinResponseThreshold;
const char * ConcreteTypeName;
void * UserData;
PX_PHYSX_CORE_API PxConstraintGeneratedValues( const PxConstraint* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, Scene, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, Actors, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, Flags, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, IsValid, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, BreakForce, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, MinResponseThreshold, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, ConcreteTypeName, PxConstraintGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, UserData, PxConstraintGeneratedValues)
struct PxConstraintGeneratedInfo
{
static const char* getClassName() { return "PxConstraint"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_Scene, PxConstraint, PxScene * > Scene;
PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_Actors, PxConstraint, PxRigidActor * > Actors;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_Flags, PxConstraint, PxConstraintFlags, PxConstraintFlags > Flags;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_IsValid, PxConstraint, _Bool > IsValid;
PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_BreakForce, PxConstraint, PxReal > BreakForce;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_MinResponseThreshold, PxConstraint, PxReal, PxReal > MinResponseThreshold;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_ConcreteTypeName, PxConstraint, const char * > ConcreteTypeName;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_UserData, PxConstraint, void *, void * > UserData;
PX_PHYSX_CORE_API PxConstraintGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxConstraint*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 8; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Scene, inStartIndex + 0 );;
inOperator( Actors, inStartIndex + 1 );;
inOperator( Flags, inStartIndex + 2 );;
inOperator( IsValid, inStartIndex + 3 );;
inOperator( BreakForce, inStartIndex + 4 );;
inOperator( MinResponseThreshold, inStartIndex + 5 );;
inOperator( ConcreteTypeName, inStartIndex + 6 );;
inOperator( UserData, inStartIndex + 7 );;
return 8 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxConstraint>
{
PxConstraintGeneratedInfo Info;
const PxConstraintGeneratedInfo* getInfo() { return &Info; }
};
class PxShape;
struct PxShapeGeneratedValues
: PxRefCountedGeneratedValues {
PxTransform LocalPose;
PxFilterData SimulationFilterData;
PxFilterData QueryFilterData;
PxReal ContactOffset;
PxReal RestOffset;
PxReal DensityForFluid;
PxReal TorsionalPatchRadius;
PxReal MinTorsionalPatchRadius;
PxU32 InternalShapeIndex;
PxShapeFlags Flags;
_Bool IsExclusive;
const char * Name;
const char * ConcreteTypeName;
void * UserData;
PxGeometryHolder Geom;
PX_PHYSX_CORE_API PxShapeGeneratedValues( const PxShape* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, LocalPose, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, SimulationFilterData, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, QueryFilterData, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, ContactOffset, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, RestOffset, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, DensityForFluid, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, TorsionalPatchRadius, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, MinTorsionalPatchRadius, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, InternalShapeIndex, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, Flags, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, IsExclusive, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, Name, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, ConcreteTypeName, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, UserData, PxShapeGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, Geom, PxShapeGeneratedValues)
struct PxShapeGeneratedInfo
: PxRefCountedGeneratedInfo
{
static const char* getClassName() { return "PxShape"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_LocalPose, PxShape, const PxTransform &, PxTransform > LocalPose;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_SimulationFilterData, PxShape, const PxFilterData &, PxFilterData > SimulationFilterData;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_QueryFilterData, PxShape, const PxFilterData &, PxFilterData > QueryFilterData;
PxShapeMaterialsProperty Materials;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_ContactOffset, PxShape, PxReal, PxReal > ContactOffset;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_RestOffset, PxShape, PxReal, PxReal > RestOffset;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_DensityForFluid, PxShape, PxReal, PxReal > DensityForFluid;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_TorsionalPatchRadius, PxShape, PxReal, PxReal > TorsionalPatchRadius;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_MinTorsionalPatchRadius, PxShape, PxReal, PxReal > MinTorsionalPatchRadius;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_InternalShapeIndex, PxShape, PxU32 > InternalShapeIndex;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_Flags, PxShape, PxShapeFlags, PxShapeFlags > Flags;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_IsExclusive, PxShape, _Bool > IsExclusive;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_Name, PxShape, const char *, const char * > Name;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_ConcreteTypeName, PxShape, const char * > ConcreteTypeName;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_UserData, PxShape, void *, void * > UserData;
PxShapeGeomProperty Geom;
PX_PHYSX_CORE_API PxShapeGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxShape*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxRefCountedGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxRefCountedGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxRefCountedGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 16; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxRefCountedGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( LocalPose, inStartIndex + 0 );;
inOperator( SimulationFilterData, inStartIndex + 1 );;
inOperator( QueryFilterData, inStartIndex + 2 );;
inOperator( Materials, inStartIndex + 3 );;
inOperator( ContactOffset, inStartIndex + 4 );;
inOperator( RestOffset, inStartIndex + 5 );;
inOperator( DensityForFluid, inStartIndex + 6 );;
inOperator( TorsionalPatchRadius, inStartIndex + 7 );;
inOperator( MinTorsionalPatchRadius, inStartIndex + 8 );;
inOperator( InternalShapeIndex, inStartIndex + 9 );;
inOperator( Flags, inStartIndex + 10 );;
inOperator( IsExclusive, inStartIndex + 11 );;
inOperator( Name, inStartIndex + 12 );;
inOperator( ConcreteTypeName, inStartIndex + 13 );;
inOperator( UserData, inStartIndex + 14 );;
inOperator( Geom, inStartIndex + 15 );;
return 16 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxShape>
{
PxShapeGeneratedInfo Info;
const PxShapeGeneratedInfo* getInfo() { return &Info; }
};
class PxPruningStructure;
struct PxPruningStructureGeneratedValues
{
const void * StaticMergeData;
const void * DynamicMergeData;
const char * ConcreteTypeName;
PX_PHYSX_CORE_API PxPruningStructureGeneratedValues( const PxPruningStructure* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPruningStructure, StaticMergeData, PxPruningStructureGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPruningStructure, DynamicMergeData, PxPruningStructureGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPruningStructure, ConcreteTypeName, PxPruningStructureGeneratedValues)
struct PxPruningStructureGeneratedInfo
{
static const char* getClassName() { return "PxPruningStructure"; }
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_RigidActors, PxPruningStructure, PxRigidActor * > RigidActors;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_StaticMergeData, PxPruningStructure, const void * > StaticMergeData;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_DynamicMergeData, PxPruningStructure, const void * > DynamicMergeData;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_ConcreteTypeName, PxPruningStructure, const char * > ConcreteTypeName;
PX_PHYSX_CORE_API PxPruningStructureGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxPruningStructure*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 4; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( RigidActors, inStartIndex + 0 );;
inOperator( StaticMergeData, inStartIndex + 1 );;
inOperator( DynamicMergeData, inStartIndex + 2 );;
inOperator( ConcreteTypeName, inStartIndex + 3 );;
return 4 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxPruningStructure>
{
PxPruningStructureGeneratedInfo Info;
const PxPruningStructureGeneratedInfo* getInfo() { return &Info; }
};
class PxTolerancesScale;
struct PxTolerancesScaleGeneratedValues
{
_Bool IsValid;
PxReal Length;
PxReal Speed;
PX_PHYSX_CORE_API PxTolerancesScaleGeneratedValues( const PxTolerancesScale* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTolerancesScale, IsValid, PxTolerancesScaleGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTolerancesScale, Length, PxTolerancesScaleGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTolerancesScale, Speed, PxTolerancesScaleGeneratedValues)
struct PxTolerancesScaleGeneratedInfo
{
static const char* getClassName() { return "PxTolerancesScale"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxTolerancesScale_IsValid, PxTolerancesScale, _Bool > IsValid;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTolerancesScale_Length, PxTolerancesScale, PxReal, PxReal > Length;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTolerancesScale_Speed, PxTolerancesScale, PxReal, PxReal > Speed;
PX_PHYSX_CORE_API PxTolerancesScaleGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxTolerancesScale*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 3; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( IsValid, inStartIndex + 0 );;
inOperator( Length, inStartIndex + 1 );;
inOperator( Speed, inStartIndex + 2 );;
return 3 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxTolerancesScale>
{
PxTolerancesScaleGeneratedInfo Info;
const PxTolerancesScaleGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxGeometryType__EnumConversion[] = {
{ "eSPHERE", static_cast<PxU32>( physx::PxGeometryType::eSPHERE ) },
{ "ePLANE", static_cast<PxU32>( physx::PxGeometryType::ePLANE ) },
{ "eCAPSULE", static_cast<PxU32>( physx::PxGeometryType::eCAPSULE ) },
{ "eBOX", static_cast<PxU32>( physx::PxGeometryType::eBOX ) },
{ "eCONVEXMESH", static_cast<PxU32>( physx::PxGeometryType::eCONVEXMESH ) },
{ "ePARTICLESYSTEM", static_cast<PxU32>( physx::PxGeometryType::ePARTICLESYSTEM ) },
{ "eTETRAHEDRONMESH", static_cast<PxU32>( physx::PxGeometryType::eTETRAHEDRONMESH ) },
{ "eTRIANGLEMESH", static_cast<PxU32>( physx::PxGeometryType::eTRIANGLEMESH ) },
{ "eHEIGHTFIELD", static_cast<PxU32>( physx::PxGeometryType::eHEIGHTFIELD ) },
{ "eHAIRSYSTEM", static_cast<PxU32>( physx::PxGeometryType::eHAIRSYSTEM ) },
{ "eCUSTOM", static_cast<PxU32>( physx::PxGeometryType::eCUSTOM ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxGeometryType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxGeometryType__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxGeometry;
struct PxGeometryGeneratedValues
{
PX_PHYSX_CORE_API PxGeometryGeneratedValues( const PxGeometry* inSource );
};
struct PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxGeometry"; }
PX_PHYSX_CORE_API PxGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 0; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return 0 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxGeometry>
{
PxGeometryGeneratedInfo Info;
const PxGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxBoxGeometry;
struct PxBoxGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxVec3 HalfExtents;
PX_PHYSX_CORE_API PxBoxGeometryGeneratedValues( const PxBoxGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBoxGeometry, HalfExtents, PxBoxGeometryGeneratedValues)
struct PxBoxGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxBoxGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBoxGeometry_HalfExtents, PxBoxGeometry, PxVec3, PxVec3 > HalfExtents;
PX_PHYSX_CORE_API PxBoxGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxBoxGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( HalfExtents, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxBoxGeometry>
{
PxBoxGeometryGeneratedInfo Info;
const PxBoxGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxCapsuleGeometry;
struct PxCapsuleGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxReal Radius;
PxReal HalfHeight;
PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedValues( const PxCapsuleGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxCapsuleGeometry, Radius, PxCapsuleGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxCapsuleGeometry, HalfHeight, PxCapsuleGeometryGeneratedValues)
struct PxCapsuleGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxCapsuleGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxCapsuleGeometry_Radius, PxCapsuleGeometry, PxReal, PxReal > Radius;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxCapsuleGeometry_HalfHeight, PxCapsuleGeometry, PxReal, PxReal > HalfHeight;
PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxCapsuleGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Radius, inStartIndex + 0 );;
inOperator( HalfHeight, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxCapsuleGeometry>
{
PxCapsuleGeometryGeneratedInfo Info;
const PxCapsuleGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxMeshScale;
struct PxMeshScaleGeneratedValues
{
PxVec3 Scale;
PxQuat Rotation;
PX_PHYSX_CORE_API PxMeshScaleGeneratedValues( const PxMeshScale* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMeshScale, Scale, PxMeshScaleGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMeshScale, Rotation, PxMeshScaleGeneratedValues)
struct PxMeshScaleGeneratedInfo
{
static const char* getClassName() { return "PxMeshScale"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMeshScale_Scale, PxMeshScale, PxVec3, PxVec3 > Scale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMeshScale_Rotation, PxMeshScale, PxQuat, PxQuat > Rotation;
PX_PHYSX_CORE_API PxMeshScaleGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxMeshScale*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Scale, inStartIndex + 0 );;
inOperator( Rotation, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxMeshScale>
{
PxMeshScaleGeneratedInfo Info;
const PxMeshScaleGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxConvexMeshGeometryFlag__EnumConversion[] = {
{ "eTIGHT_BOUNDS", static_cast<PxU32>( physx::PxConvexMeshGeometryFlag::eTIGHT_BOUNDS ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxConvexMeshGeometryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxConvexMeshGeometryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxConvexMeshGeometry;
struct PxConvexMeshGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxMeshScale Scale;
PxConvexMesh * ConvexMesh;
PxConvexMeshGeometryFlags MeshFlags;
PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedValues( const PxConvexMeshGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConvexMeshGeometry, Scale, PxConvexMeshGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConvexMeshGeometry, ConvexMesh, PxConvexMeshGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConvexMeshGeometry, MeshFlags, PxConvexMeshGeometryGeneratedValues)
struct PxConvexMeshGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxConvexMeshGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConvexMeshGeometry_Scale, PxConvexMeshGeometry, PxMeshScale, PxMeshScale > Scale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConvexMeshGeometry_ConvexMesh, PxConvexMeshGeometry, PxConvexMesh *, PxConvexMesh * > ConvexMesh;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConvexMeshGeometry_MeshFlags, PxConvexMeshGeometry, PxConvexMeshGeometryFlags, PxConvexMeshGeometryFlags > MeshFlags;
PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxConvexMeshGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 3; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Scale, inStartIndex + 0 );;
inOperator( ConvexMesh, inStartIndex + 1 );;
inOperator( MeshFlags, inStartIndex + 2 );;
return 3 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxConvexMeshGeometry>
{
PxConvexMeshGeometryGeneratedInfo Info;
const PxConvexMeshGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxSphereGeometry;
struct PxSphereGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxReal Radius;
PX_PHYSX_CORE_API PxSphereGeometryGeneratedValues( const PxSphereGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphereGeometry, Radius, PxSphereGeometryGeneratedValues)
struct PxSphereGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxSphereGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphereGeometry_Radius, PxSphereGeometry, PxReal, PxReal > Radius;
PX_PHYSX_CORE_API PxSphereGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSphereGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Radius, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSphereGeometry>
{
PxSphereGeometryGeneratedInfo Info;
const PxSphereGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxPlaneGeometry;
struct PxPlaneGeometryGeneratedValues
: PxGeometryGeneratedValues {
PX_PHYSX_CORE_API PxPlaneGeometryGeneratedValues( const PxPlaneGeometry* inSource );
};
struct PxPlaneGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxPlaneGeometry"; }
PX_PHYSX_CORE_API PxPlaneGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxPlaneGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 0; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return 0 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxPlaneGeometry>
{
PxPlaneGeometryGeneratedInfo Info;
const PxPlaneGeometryGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxMeshGeometryFlag__EnumConversion[] = {
{ "eTIGHT_BOUNDS", static_cast<PxU32>( physx::PxMeshGeometryFlag::eTIGHT_BOUNDS ) },
{ "eDOUBLE_SIDED", static_cast<PxU32>( physx::PxMeshGeometryFlag::eDOUBLE_SIDED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxMeshGeometryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxMeshGeometryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxTriangleMeshGeometry;
struct PxTriangleMeshGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxMeshScale Scale;
PxMeshGeometryFlags MeshFlags;
PxTriangleMesh * TriangleMesh;
PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedValues( const PxTriangleMeshGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTriangleMeshGeometry, Scale, PxTriangleMeshGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTriangleMeshGeometry, MeshFlags, PxTriangleMeshGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTriangleMeshGeometry, TriangleMesh, PxTriangleMeshGeometryGeneratedValues)
struct PxTriangleMeshGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxTriangleMeshGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTriangleMeshGeometry_Scale, PxTriangleMeshGeometry, PxMeshScale, PxMeshScale > Scale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTriangleMeshGeometry_MeshFlags, PxTriangleMeshGeometry, PxMeshGeometryFlags, PxMeshGeometryFlags > MeshFlags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTriangleMeshGeometry_TriangleMesh, PxTriangleMeshGeometry, PxTriangleMesh *, PxTriangleMesh * > TriangleMesh;
PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxTriangleMeshGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 3; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Scale, inStartIndex + 0 );;
inOperator( MeshFlags, inStartIndex + 1 );;
inOperator( TriangleMesh, inStartIndex + 2 );;
return 3 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxTriangleMeshGeometry>
{
PxTriangleMeshGeometryGeneratedInfo Info;
const PxTriangleMeshGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxHeightFieldGeometry;
struct PxHeightFieldGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxHeightField * HeightField;
PxReal HeightScale;
PxReal RowScale;
PxReal ColumnScale;
PxMeshGeometryFlags HeightFieldFlags;
PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedValues( const PxHeightFieldGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, HeightField, PxHeightFieldGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, HeightScale, PxHeightFieldGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, RowScale, PxHeightFieldGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, ColumnScale, PxHeightFieldGeometryGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, HeightFieldFlags, PxHeightFieldGeometryGeneratedValues)
struct PxHeightFieldGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxHeightFieldGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_HeightField, PxHeightFieldGeometry, PxHeightField *, PxHeightField * > HeightField;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_HeightScale, PxHeightFieldGeometry, PxReal, PxReal > HeightScale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_RowScale, PxHeightFieldGeometry, PxReal, PxReal > RowScale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_ColumnScale, PxHeightFieldGeometry, PxReal, PxReal > ColumnScale;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_HeightFieldFlags, PxHeightFieldGeometry, PxMeshGeometryFlags, PxMeshGeometryFlags > HeightFieldFlags;
PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxHeightFieldGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 5; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( HeightField, inStartIndex + 0 );;
inOperator( HeightScale, inStartIndex + 1 );;
inOperator( RowScale, inStartIndex + 2 );;
inOperator( ColumnScale, inStartIndex + 3 );;
inOperator( HeightFieldFlags, inStartIndex + 4 );;
return 5 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxHeightFieldGeometry>
{
PxHeightFieldGeometryGeneratedInfo Info;
const PxHeightFieldGeometryGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxSceneQueryUpdateMode__EnumConversion[] = {
{ "eBUILD_ENABLED_COMMIT_ENABLED", static_cast<PxU32>( physx::PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED ) },
{ "eBUILD_ENABLED_COMMIT_DISABLED", static_cast<PxU32>( physx::PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_DISABLED ) },
{ "eBUILD_DISABLED_COMMIT_DISABLED", static_cast<PxU32>( physx::PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxSceneQueryUpdateMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSceneQueryUpdateMode__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxHitFlag__EnumConversion[] = {
{ "ePOSITION", static_cast<PxU32>( physx::PxHitFlag::ePOSITION ) },
{ "eNORMAL", static_cast<PxU32>( physx::PxHitFlag::eNORMAL ) },
{ "eUV", static_cast<PxU32>( physx::PxHitFlag::eUV ) },
{ "eASSUME_NO_INITIAL_OVERLAP", static_cast<PxU32>( physx::PxHitFlag::eASSUME_NO_INITIAL_OVERLAP ) },
{ "eANY_HIT", static_cast<PxU32>( physx::PxHitFlag::eANY_HIT ) },
{ "eMESH_MULTIPLE", static_cast<PxU32>( physx::PxHitFlag::eMESH_MULTIPLE ) },
{ "eMESH_ANY", static_cast<PxU32>( physx::PxHitFlag::eMESH_ANY ) },
{ "eMESH_BOTH_SIDES", static_cast<PxU32>( physx::PxHitFlag::eMESH_BOTH_SIDES ) },
{ "ePRECISE_SWEEP", static_cast<PxU32>( physx::PxHitFlag::ePRECISE_SWEEP ) },
{ "eMTD", static_cast<PxU32>( physx::PxHitFlag::eMTD ) },
{ "eFACE_INDEX", static_cast<PxU32>( physx::PxHitFlag::eFACE_INDEX ) },
{ "eDEFAULT", static_cast<PxU32>( physx::PxHitFlag::eDEFAULT ) },
{ "eMODIFIABLE_FLAGS", static_cast<PxU32>( physx::PxHitFlag::eMODIFIABLE_FLAGS ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxHitFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxHitFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxGeometryQueryFlag__EnumConversion[] = {
{ "eSIMD_GUARD", static_cast<PxU32>( physx::PxGeometryQueryFlag::eSIMD_GUARD ) },
{ "eDEFAULT", static_cast<PxU32>( physx::PxGeometryQueryFlag::eDEFAULT ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxGeometryQueryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxGeometryQueryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxSceneQuerySystemBase;
struct PxSceneQuerySystemBaseGeneratedValues
{
PxU32 DynamicTreeRebuildRateHint;
PxSceneQueryUpdateMode::Enum UpdateMode;
PxU32 StaticTimestamp;
PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedValues( const PxSceneQuerySystemBase* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQuerySystemBase, DynamicTreeRebuildRateHint, PxSceneQuerySystemBaseGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQuerySystemBase, UpdateMode, PxSceneQuerySystemBaseGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQuerySystemBase, StaticTimestamp, PxSceneQuerySystemBaseGeneratedValues)
struct PxSceneQuerySystemBaseGeneratedInfo
{
static const char* getClassName() { return "PxSceneQuerySystemBase"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQuerySystemBase_DynamicTreeRebuildRateHint, PxSceneQuerySystemBase, PxU32, PxU32 > DynamicTreeRebuildRateHint;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQuerySystemBase_UpdateMode, PxSceneQuerySystemBase, PxSceneQueryUpdateMode::Enum, PxSceneQueryUpdateMode::Enum > UpdateMode;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQuerySystemBase_StaticTimestamp, PxSceneQuerySystemBase, PxU32 > StaticTimestamp;
PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSceneQuerySystemBase*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 3; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( DynamicTreeRebuildRateHint, inStartIndex + 0 );;
inOperator( UpdateMode, inStartIndex + 1 );;
inOperator( StaticTimestamp, inStartIndex + 2 );;
return 3 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSceneQuerySystemBase>
{
PxSceneQuerySystemBaseGeneratedInfo Info;
const PxSceneQuerySystemBaseGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxPruningStructureType__EnumConversion[] = {
{ "eNONE", static_cast<PxU32>( physx::PxPruningStructureType::eNONE ) },
{ "eDYNAMIC_AABB_TREE", static_cast<PxU32>( physx::PxPruningStructureType::eDYNAMIC_AABB_TREE ) },
{ "eSTATIC_AABB_TREE", static_cast<PxU32>( physx::PxPruningStructureType::eSTATIC_AABB_TREE ) },
{ "eLAST", static_cast<PxU32>( physx::PxPruningStructureType::eLAST ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxPruningStructureType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxPruningStructureType__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxSceneSQSystem;
struct PxSceneSQSystemGeneratedValues
: PxSceneQuerySystemBaseGeneratedValues {
PxSceneQueryUpdateMode::Enum SceneQueryUpdateMode;
PxU32 SceneQueryStaticTimestamp;
PxPruningStructureType::Enum StaticStructure;
PxPruningStructureType::Enum DynamicStructure;
PX_PHYSX_CORE_API PxSceneSQSystemGeneratedValues( const PxSceneSQSystem* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, SceneQueryUpdateMode, PxSceneSQSystemGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, SceneQueryStaticTimestamp, PxSceneSQSystemGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, StaticStructure, PxSceneSQSystemGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, DynamicStructure, PxSceneSQSystemGeneratedValues)
struct PxSceneSQSystemGeneratedInfo
: PxSceneQuerySystemBaseGeneratedInfo
{
static const char* getClassName() { return "PxSceneSQSystem"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_SceneQueryUpdateMode, PxSceneSQSystem, PxSceneQueryUpdateMode::Enum, PxSceneQueryUpdateMode::Enum > SceneQueryUpdateMode;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_SceneQueryStaticTimestamp, PxSceneSQSystem, PxU32 > SceneQueryStaticTimestamp;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_StaticStructure, PxSceneSQSystem, PxPruningStructureType::Enum > StaticStructure;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_DynamicStructure, PxSceneSQSystem, PxPruningStructureType::Enum > DynamicStructure;
PX_PHYSX_CORE_API PxSceneSQSystemGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSceneSQSystem*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxSceneQuerySystemBaseGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxSceneQuerySystemBaseGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxSceneQuerySystemBaseGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 4; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxSceneQuerySystemBaseGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( SceneQueryUpdateMode, inStartIndex + 0 );;
inOperator( SceneQueryStaticTimestamp, inStartIndex + 1 );;
inOperator( StaticStructure, inStartIndex + 2 );;
inOperator( DynamicStructure, inStartIndex + 3 );;
return 4 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSceneSQSystem>
{
PxSceneSQSystemGeneratedInfo Info;
const PxSceneSQSystemGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxSceneFlag__EnumConversion[] = {
{ "eENABLE_ACTIVE_ACTORS", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_ACTIVE_ACTORS ) },
{ "eENABLE_CCD", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_CCD ) },
{ "eDISABLE_CCD_RESWEEP", static_cast<PxU32>( physx::PxSceneFlag::eDISABLE_CCD_RESWEEP ) },
{ "eENABLE_PCM", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_PCM ) },
{ "eDISABLE_CONTACT_REPORT_BUFFER_RESIZE", static_cast<PxU32>( physx::PxSceneFlag::eDISABLE_CONTACT_REPORT_BUFFER_RESIZE ) },
{ "eDISABLE_CONTACT_CACHE", static_cast<PxU32>( physx::PxSceneFlag::eDISABLE_CONTACT_CACHE ) },
{ "eREQUIRE_RW_LOCK", static_cast<PxU32>( physx::PxSceneFlag::eREQUIRE_RW_LOCK ) },
{ "eENABLE_STABILIZATION", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_STABILIZATION ) },
{ "eENABLE_AVERAGE_POINT", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_AVERAGE_POINT ) },
{ "eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS", static_cast<PxU32>( physx::PxSceneFlag::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS ) },
{ "eENABLE_GPU_DYNAMICS", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_GPU_DYNAMICS ) },
{ "eENABLE_ENHANCED_DETERMINISM", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_ENHANCED_DETERMINISM ) },
{ "eENABLE_FRICTION_EVERY_ITERATION", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_FRICTION_EVERY_ITERATION ) },
{ "eENABLE_DIRECT_GPU_API", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_DIRECT_GPU_API ) },
{ "eMUTABLE_FLAGS", static_cast<PxU32>( physx::PxSceneFlag::eMUTABLE_FLAGS ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxSceneFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSceneFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxActorTypeFlag__EnumConversion[] = {
{ "eRIGID_STATIC", static_cast<PxU32>( physx::PxActorTypeFlag::eRIGID_STATIC ) },
{ "eRIGID_DYNAMIC", static_cast<PxU32>( physx::PxActorTypeFlag::eRIGID_DYNAMIC ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxActorTypeFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorTypeFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxParticleSolverType__EnumConversion[] = {
{ "ePBD", static_cast<PxU32>( physx::PxParticleSolverType::ePBD ) },
{ "eFLIP", static_cast<PxU32>( physx::PxParticleSolverType::eFLIP ) },
{ "eMPM", static_cast<PxU32>( physx::PxParticleSolverType::eMPM ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxParticleSolverType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxParticleSolverType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxPairFilteringMode__EnumConversion[] = {
{ "eKEEP", static_cast<PxU32>( physx::PxPairFilteringMode::eKEEP ) },
{ "eSUPPRESS", static_cast<PxU32>( physx::PxPairFilteringMode::eSUPPRESS ) },
{ "eKILL", static_cast<PxU32>( physx::PxPairFilteringMode::eKILL ) },
{ "eDEFAULT", static_cast<PxU32>( physx::PxPairFilteringMode::eDEFAULT ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxPairFilteringMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxPairFilteringMode__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxFrictionType__EnumConversion[] = {
{ "ePATCH", static_cast<PxU32>( physx::PxFrictionType::ePATCH ) },
{ "eONE_DIRECTIONAL", static_cast<PxU32>( physx::PxFrictionType::eONE_DIRECTIONAL ) },
{ "eTWO_DIRECTIONAL", static_cast<PxU32>( physx::PxFrictionType::eTWO_DIRECTIONAL ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxFrictionType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxFrictionType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxSolverType__EnumConversion[] = {
{ "ePGS", static_cast<PxU32>( physx::PxSolverType::ePGS ) },
{ "eTGS", static_cast<PxU32>( physx::PxSolverType::eTGS ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxSolverType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSolverType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxVisualizationParameter__EnumConversion[] = {
{ "eSCALE", static_cast<PxU32>( physx::PxVisualizationParameter::eSCALE ) },
{ "eWORLD_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eWORLD_AXES ) },
{ "eBODY_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_AXES ) },
{ "eBODY_MASS_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_MASS_AXES ) },
{ "eBODY_LIN_VELOCITY", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_LIN_VELOCITY ) },
{ "eBODY_ANG_VELOCITY", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_ANG_VELOCITY ) },
{ "eCONTACT_POINT", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_POINT ) },
{ "eCONTACT_NORMAL", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_NORMAL ) },
{ "eCONTACT_ERROR", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_ERROR ) },
{ "eCONTACT_FORCE", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_FORCE ) },
{ "eACTOR_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eACTOR_AXES ) },
{ "eCOLLISION_AABBS", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_AABBS ) },
{ "eCOLLISION_SHAPES", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_SHAPES ) },
{ "eCOLLISION_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_AXES ) },
{ "eCOLLISION_COMPOUNDS", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_COMPOUNDS ) },
{ "eCOLLISION_FNORMALS", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_FNORMALS ) },
{ "eCOLLISION_EDGES", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_EDGES ) },
{ "eCOLLISION_STATIC", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_STATIC ) },
{ "eCOLLISION_DYNAMIC", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_DYNAMIC ) },
{ "eJOINT_LOCAL_FRAMES", static_cast<PxU32>( physx::PxVisualizationParameter::eJOINT_LOCAL_FRAMES ) },
{ "eJOINT_LIMITS", static_cast<PxU32>( physx::PxVisualizationParameter::eJOINT_LIMITS ) },
{ "eCULL_BOX", static_cast<PxU32>( physx::PxVisualizationParameter::eCULL_BOX ) },
{ "eMBP_REGIONS", static_cast<PxU32>( physx::PxVisualizationParameter::eMBP_REGIONS ) },
{ "eSIMULATION_MESH", static_cast<PxU32>( physx::PxVisualizationParameter::eSIMULATION_MESH ) },
{ "eSDF", static_cast<PxU32>( physx::PxVisualizationParameter::eSDF ) },
{ "eNUM_VALUES", static_cast<PxU32>( physx::PxVisualizationParameter::eNUM_VALUES ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxVisualizationParameter::Enum > { PxEnumTraits() : NameConversion( g_physx__PxVisualizationParameter__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxBroadPhaseType__EnumConversion[] = {
{ "eSAP", static_cast<PxU32>( physx::PxBroadPhaseType::eSAP ) },
{ "eMBP", static_cast<PxU32>( physx::PxBroadPhaseType::eMBP ) },
{ "eABP", static_cast<PxU32>( physx::PxBroadPhaseType::eABP ) },
{ "ePABP", static_cast<PxU32>( physx::PxBroadPhaseType::ePABP ) },
{ "eGPU", static_cast<PxU32>( physx::PxBroadPhaseType::eGPU ) },
{ "eLAST", static_cast<PxU32>( physx::PxBroadPhaseType::eLAST ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxBroadPhaseType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxBroadPhaseType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxArticulationGpuDataType__EnumConversion[] = {
{ "eJOINT_POSITION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_POSITION ) },
{ "eJOINT_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_VELOCITY ) },
{ "eJOINT_ACCELERATION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_ACCELERATION ) },
{ "eJOINT_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_FORCE ) },
{ "eJOINT_SOLVER_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_SOLVER_FORCE ) },
{ "eJOINT_TARGET_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_TARGET_VELOCITY ) },
{ "eJOINT_TARGET_POSITION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_TARGET_POSITION ) },
{ "eSENSOR_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eSENSOR_FORCE ) },
{ "eROOT_TRANSFORM", static_cast<PxU32>( physx::PxArticulationGpuDataType::eROOT_TRANSFORM ) },
{ "eROOT_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eROOT_VELOCITY ) },
{ "eLINK_TRANSFORM", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_TRANSFORM ) },
{ "eLINK_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_VELOCITY ) },
{ "eLINK_ACCELERATION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_ACCELERATION ) },
{ "eLINK_INCOMING_JOINT_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_INCOMING_JOINT_FORCE ) },
{ "eLINK_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_FORCE ) },
{ "eLINK_TORQUE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_TORQUE ) },
{ "eFIXED_TENDON", static_cast<PxU32>( physx::PxArticulationGpuDataType::eFIXED_TENDON ) },
{ "eFIXED_TENDON_JOINT", static_cast<PxU32>( physx::PxArticulationGpuDataType::eFIXED_TENDON_JOINT ) },
{ "eSPATIAL_TENDON", static_cast<PxU32>( physx::PxArticulationGpuDataType::eSPATIAL_TENDON ) },
{ "eSPATIAL_TENDON_ATTACHMENT", static_cast<PxU32>( physx::PxArticulationGpuDataType::eSPATIAL_TENDON_ATTACHMENT ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationGpuDataType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationGpuDataType__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxSoftBodyGpuDataFlag__EnumConversion[] = {
{ "eTET_INDICES", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_INDICES ) },
{ "eTET_REST_POSES", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_REST_POSES ) },
{ "eTET_ROTATIONS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_ROTATIONS ) },
{ "eTET_POSITION_INV_MASS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_POSITION_INV_MASS ) },
{ "eSIM_TET_INDICES", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_TET_INDICES ) },
{ "eSIM_TET_ROTATIONS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_TET_ROTATIONS ) },
{ "eSIM_VELOCITY_INV_MASS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_VELOCITY_INV_MASS ) },
{ "eSIM_POSITION_INV_MASS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_POSITION_INV_MASS ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxSoftBodyGpuDataFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSoftBodyGpuDataFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxActorCacheFlag__EnumConversion[] = {
{ "eACTOR_DATA", static_cast<PxU32>( physx::PxActorCacheFlag::eACTOR_DATA ) },
{ "eFORCE", static_cast<PxU32>( physx::PxActorCacheFlag::eFORCE ) },
{ "eTORQUE", static_cast<PxU32>( physx::PxActorCacheFlag::eTORQUE ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxActorCacheFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorCacheFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxScene;
struct PxSceneGeneratedValues
: PxSceneSQSystemGeneratedValues {
PxSceneFlags Flags;
PxSceneLimits Limits;
PxU32 Timestamp;
const char * Name;
PxCpuDispatcher * CpuDispatcher;
PxCudaContextManager * CudaContextManager;
PxSimulationEventCallback * SimulationEventCallback;
PxContactModifyCallback * ContactModifyCallback;
PxCCDContactModifyCallback * CCDContactModifyCallback;
PxBroadPhaseCallback * BroadPhaseCallback;
PxU32 FilterShaderDataSize;
PxSimulationFilterShader FilterShader;
PxSimulationFilterCallback * FilterCallback;
PxPairFilteringMode::Enum KinematicKinematicFilteringMode;
PxPairFilteringMode::Enum StaticKinematicFilteringMode;
PxVec3 Gravity;
PxReal BounceThresholdVelocity;
PxU32 CCDMaxPasses;
PxReal CCDMaxSeparation;
PxReal CCDThreshold;
PxReal MaxBiasCoefficient;
PxReal FrictionOffsetThreshold;
PxReal FrictionCorrelationDistance;
PxFrictionType::Enum FrictionType;
PxSolverType::Enum SolverType;
PxBounds3 VisualizationCullingBox;
PxBroadPhaseType::Enum BroadPhaseType;
PxTaskManager * TaskManager;
PxU32 MaxNbContactDataBlocksUsed;
PxU32 ContactReportStreamBufferSize;
PxU32 SolverBatchSize;
PxU32 SolverArticulationBatchSize;
PxReal WakeCounterResetValue;
PxgDynamicsMemoryConfig GpuDynamicsConfig;
void * UserData;
PxSimulationStatistics SimulationStatistics;
PX_PHYSX_CORE_API PxSceneGeneratedValues( const PxScene* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Flags, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Limits, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Timestamp, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Name, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CpuDispatcher, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CudaContextManager, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SimulationEventCallback, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, ContactModifyCallback, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDContactModifyCallback, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, BroadPhaseCallback, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FilterShaderDataSize, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FilterShader, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FilterCallback, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, KinematicKinematicFilteringMode, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, StaticKinematicFilteringMode, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Gravity, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, BounceThresholdVelocity, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDMaxPasses, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDMaxSeparation, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDThreshold, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, MaxBiasCoefficient, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FrictionOffsetThreshold, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FrictionCorrelationDistance, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FrictionType, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SolverType, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, VisualizationCullingBox, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, BroadPhaseType, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, TaskManager, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, MaxNbContactDataBlocksUsed, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, ContactReportStreamBufferSize, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SolverBatchSize, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SolverArticulationBatchSize, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, WakeCounterResetValue, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, GpuDynamicsConfig, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, UserData, PxSceneGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SimulationStatistics, PxSceneGeneratedValues)
struct PxSceneGeneratedInfo
: PxSceneSQSystemGeneratedInfo
{
static const char* getClassName() { return "PxScene"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Flags, PxScene, PxSceneFlags > Flags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Limits, PxScene, const PxSceneLimits &, PxSceneLimits > Limits;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Timestamp, PxScene, PxU32 > Timestamp;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Name, PxScene, const char *, const char * > Name;
PxReadOnlyFilteredCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Actors, PxScene, PxActor *, PxActorTypeFlags > Actors;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SoftBodies, PxScene, PxSoftBody * > SoftBodies;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Articulations, PxScene, PxArticulationReducedCoordinate * > Articulations;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Constraints, PxScene, PxConstraint * > Constraints;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Aggregates, PxScene, PxAggregate * > Aggregates;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CpuDispatcher, PxScene, PxCpuDispatcher * > CpuDispatcher;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CudaContextManager, PxScene, PxCudaContextManager * > CudaContextManager;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SimulationEventCallback, PxScene, PxSimulationEventCallback *, PxSimulationEventCallback * > SimulationEventCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_ContactModifyCallback, PxScene, PxContactModifyCallback *, PxContactModifyCallback * > ContactModifyCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDContactModifyCallback, PxScene, PxCCDContactModifyCallback *, PxCCDContactModifyCallback * > CCDContactModifyCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BroadPhaseCallback, PxScene, PxBroadPhaseCallback *, PxBroadPhaseCallback * > BroadPhaseCallback;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FilterShaderDataSize, PxScene, PxU32 > FilterShaderDataSize;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FilterShader, PxScene, PxSimulationFilterShader > FilterShader;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FilterCallback, PxScene, PxSimulationFilterCallback * > FilterCallback;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_KinematicKinematicFilteringMode, PxScene, PxPairFilteringMode::Enum > KinematicKinematicFilteringMode;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_StaticKinematicFilteringMode, PxScene, PxPairFilteringMode::Enum > StaticKinematicFilteringMode;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Gravity, PxScene, const PxVec3 &, PxVec3 > Gravity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BounceThresholdVelocity, PxScene, const PxReal, PxReal > BounceThresholdVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDMaxPasses, PxScene, PxU32, PxU32 > CCDMaxPasses;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDMaxSeparation, PxScene, const PxReal, PxReal > CCDMaxSeparation;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDThreshold, PxScene, const PxReal, PxReal > CCDThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_MaxBiasCoefficient, PxScene, const PxReal, PxReal > MaxBiasCoefficient;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FrictionOffsetThreshold, PxScene, const PxReal, PxReal > FrictionOffsetThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FrictionCorrelationDistance, PxScene, const PxReal, PxReal > FrictionCorrelationDistance;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FrictionType, PxScene, PxFrictionType::Enum > FrictionType;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SolverType, PxScene, PxSolverType::Enum > SolverType;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_VisualizationCullingBox, PxScene, const PxBounds3 &, PxBounds3 > VisualizationCullingBox;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BroadPhaseType, PxScene, PxBroadPhaseType::Enum > BroadPhaseType;
PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BroadPhaseRegions, PxScene, PxBroadPhaseRegionInfo > BroadPhaseRegions;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_TaskManager, PxScene, PxTaskManager * > TaskManager;
PxWriteOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_NbContactDataBlocks, PxScene, PxU32 > NbContactDataBlocks;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_MaxNbContactDataBlocksUsed, PxScene, PxU32 > MaxNbContactDataBlocksUsed;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_ContactReportStreamBufferSize, PxScene, PxU32 > ContactReportStreamBufferSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SolverBatchSize, PxScene, PxU32, PxU32 > SolverBatchSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SolverArticulationBatchSize, PxScene, PxU32, PxU32 > SolverArticulationBatchSize;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_WakeCounterResetValue, PxScene, PxReal > WakeCounterResetValue;
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_GpuDynamicsConfig, PxScene, PxgDynamicsMemoryConfig > GpuDynamicsConfig;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_UserData, PxScene, void *, void * > UserData;
SimulationStatisticsProperty SimulationStatistics;
PX_PHYSX_CORE_API PxSceneGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxScene*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxSceneSQSystemGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxSceneSQSystemGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxSceneSQSystemGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 43; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxSceneSQSystemGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Flags, inStartIndex + 0 );;
inOperator( Limits, inStartIndex + 1 );;
inOperator( Timestamp, inStartIndex + 2 );;
inOperator( Name, inStartIndex + 3 );;
inOperator( Actors, inStartIndex + 4 );;
inOperator( SoftBodies, inStartIndex + 5 );;
inOperator( Articulations, inStartIndex + 6 );;
inOperator( Constraints, inStartIndex + 7 );;
inOperator( Aggregates, inStartIndex + 8 );;
inOperator( CpuDispatcher, inStartIndex + 9 );;
inOperator( CudaContextManager, inStartIndex + 10 );;
inOperator( SimulationEventCallback, inStartIndex + 11 );;
inOperator( ContactModifyCallback, inStartIndex + 12 );;
inOperator( CCDContactModifyCallback, inStartIndex + 13 );;
inOperator( BroadPhaseCallback, inStartIndex + 14 );;
inOperator( FilterShaderDataSize, inStartIndex + 15 );;
inOperator( FilterShader, inStartIndex + 16 );;
inOperator( FilterCallback, inStartIndex + 17 );;
inOperator( KinematicKinematicFilteringMode, inStartIndex + 18 );;
inOperator( StaticKinematicFilteringMode, inStartIndex + 19 );;
inOperator( Gravity, inStartIndex + 20 );;
inOperator( BounceThresholdVelocity, inStartIndex + 21 );;
inOperator( CCDMaxPasses, inStartIndex + 22 );;
inOperator( CCDMaxSeparation, inStartIndex + 23 );;
inOperator( CCDThreshold, inStartIndex + 24 );;
inOperator( MaxBiasCoefficient, inStartIndex + 25 );;
inOperator( FrictionOffsetThreshold, inStartIndex + 26 );;
inOperator( FrictionCorrelationDistance, inStartIndex + 27 );;
inOperator( FrictionType, inStartIndex + 28 );;
inOperator( SolverType, inStartIndex + 29 );;
inOperator( VisualizationCullingBox, inStartIndex + 30 );;
inOperator( BroadPhaseType, inStartIndex + 31 );;
inOperator( BroadPhaseRegions, inStartIndex + 32 );;
inOperator( TaskManager, inStartIndex + 33 );;
inOperator( NbContactDataBlocks, inStartIndex + 34 );;
inOperator( MaxNbContactDataBlocksUsed, inStartIndex + 35 );;
inOperator( ContactReportStreamBufferSize, inStartIndex + 36 );;
inOperator( SolverBatchSize, inStartIndex + 37 );;
inOperator( SolverArticulationBatchSize, inStartIndex + 38 );;
inOperator( WakeCounterResetValue, inStartIndex + 39 );;
inOperator( GpuDynamicsConfig, inStartIndex + 40 );;
inOperator( UserData, inStartIndex + 41 );;
inOperator( SimulationStatistics, inStartIndex + 42 );;
return 43 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxScene>
{
PxSceneGeneratedInfo Info;
const PxSceneGeneratedInfo* getInfo() { return &Info; }
};
class PxTetrahedronMeshGeometry;
struct PxTetrahedronMeshGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxTetrahedronMesh * TetrahedronMesh;
PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedValues( const PxTetrahedronMeshGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTetrahedronMeshGeometry, TetrahedronMesh, PxTetrahedronMeshGeometryGeneratedValues)
struct PxTetrahedronMeshGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxTetrahedronMeshGeometry"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTetrahedronMeshGeometry_TetrahedronMesh, PxTetrahedronMeshGeometry, PxTetrahedronMesh *, PxTetrahedronMesh * > TetrahedronMesh;
PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxTetrahedronMeshGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( TetrahedronMesh, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxTetrahedronMeshGeometry>
{
PxTetrahedronMeshGeometryGeneratedInfo Info;
const PxTetrahedronMeshGeometryGeneratedInfo* getInfo() { return &Info; }
};
class PxCustomGeometry;
struct PxCustomGeometryGeneratedValues
: PxGeometryGeneratedValues {
PxU32 CustomType;
PX_PHYSX_CORE_API PxCustomGeometryGeneratedValues( const PxCustomGeometry* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxCustomGeometry, CustomType, PxCustomGeometryGeneratedValues)
struct PxCustomGeometryGeneratedInfo
: PxGeometryGeneratedInfo
{
static const char* getClassName() { return "PxCustomGeometry"; }
PxCustomGeometryCustomTypeProperty CustomType;
PX_PHYSX_CORE_API PxCustomGeometryGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxCustomGeometry*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 1; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxGeometryGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( CustomType, inStartIndex + 0 );;
return 1 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxCustomGeometry>
{
PxCustomGeometryGeneratedInfo Info;
const PxCustomGeometryGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxHeightFieldFormat__EnumConversion[] = {
{ "eS16_TM", static_cast<PxU32>( physx::PxHeightFieldFormat::eS16_TM ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxHeightFieldFormat::Enum > { PxEnumTraits() : NameConversion( g_physx__PxHeightFieldFormat__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxHeightFieldFlag__EnumConversion[] = {
{ "eNO_BOUNDARY_EDGES", static_cast<PxU32>( physx::PxHeightFieldFlag::eNO_BOUNDARY_EDGES ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxHeightFieldFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxHeightFieldFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxHeightFieldDesc;
struct PxHeightFieldDescGeneratedValues
{
PxU32 NbRows;
PxU32 NbColumns;
PxHeightFieldFormat::Enum Format;
PxStridedData Samples;
PxReal ConvexEdgeThreshold;
PxHeightFieldFlags Flags;
PX_PHYSX_CORE_API PxHeightFieldDescGeneratedValues( const PxHeightFieldDesc* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, NbRows, PxHeightFieldDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, NbColumns, PxHeightFieldDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, Format, PxHeightFieldDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, Samples, PxHeightFieldDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, ConvexEdgeThreshold, PxHeightFieldDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, Flags, PxHeightFieldDescGeneratedValues)
struct PxHeightFieldDescGeneratedInfo
{
static const char* getClassName() { return "PxHeightFieldDesc"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_NbRows, PxHeightFieldDesc, PxU32, PxU32 > NbRows;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_NbColumns, PxHeightFieldDesc, PxU32, PxU32 > NbColumns;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_Format, PxHeightFieldDesc, PxHeightFieldFormat::Enum, PxHeightFieldFormat::Enum > Format;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_Samples, PxHeightFieldDesc, PxStridedData, PxStridedData > Samples;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_ConvexEdgeThreshold, PxHeightFieldDesc, PxReal, PxReal > ConvexEdgeThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_Flags, PxHeightFieldDesc, PxHeightFieldFlags, PxHeightFieldFlags > Flags;
PX_PHYSX_CORE_API PxHeightFieldDescGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxHeightFieldDesc*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 6; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( NbRows, inStartIndex + 0 );;
inOperator( NbColumns, inStartIndex + 1 );;
inOperator( Format, inStartIndex + 2 );;
inOperator( Samples, inStartIndex + 3 );;
inOperator( ConvexEdgeThreshold, inStartIndex + 4 );;
inOperator( Flags, inStartIndex + 5 );;
return 6 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxHeightFieldDesc>
{
PxHeightFieldDescGeneratedInfo Info;
const PxHeightFieldDescGeneratedInfo* getInfo() { return &Info; }
};
struct PxArticulationLimit;
struct PxArticulationLimitGeneratedValues
{
PxReal Low;
PxReal High;
PX_PHYSX_CORE_API PxArticulationLimitGeneratedValues( const PxArticulationLimit* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLimit, Low, PxArticulationLimitGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLimit, High, PxArticulationLimitGeneratedValues)
struct PxArticulationLimitGeneratedInfo
{
static const char* getClassName() { return "PxArticulationLimit"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLimit_Low, PxArticulationLimit, PxReal, PxReal > Low;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLimit_High, PxArticulationLimit, PxReal, PxReal > High;
PX_PHYSX_CORE_API PxArticulationLimitGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxArticulationLimit*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 2; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Low, inStartIndex + 0 );;
inOperator( High, inStartIndex + 1 );;
return 2 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxArticulationLimit>
{
PxArticulationLimitGeneratedInfo Info;
const PxArticulationLimitGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxArticulationDriveType__EnumConversion[] = {
{ "eFORCE", static_cast<PxU32>( physx::PxArticulationDriveType::eFORCE ) },
{ "eACCELERATION", static_cast<PxU32>( physx::PxArticulationDriveType::eACCELERATION ) },
{ "eTARGET", static_cast<PxU32>( physx::PxArticulationDriveType::eTARGET ) },
{ "eVELOCITY", static_cast<PxU32>( physx::PxArticulationDriveType::eVELOCITY ) },
{ "eNONE", static_cast<PxU32>( physx::PxArticulationDriveType::eNONE ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxArticulationDriveType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationDriveType__EnumConversion ) {} const PxU32ToName* NameConversion; };
struct PxArticulationDrive;
struct PxArticulationDriveGeneratedValues
{
PxReal Stiffness;
PxReal Damping;
PxReal MaxForce;
PxArticulationDriveType::Enum DriveType;
PX_PHYSX_CORE_API PxArticulationDriveGeneratedValues( const PxArticulationDrive* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, Stiffness, PxArticulationDriveGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, Damping, PxArticulationDriveGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, MaxForce, PxArticulationDriveGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, DriveType, PxArticulationDriveGeneratedValues)
struct PxArticulationDriveGeneratedInfo
{
static const char* getClassName() { return "PxArticulationDrive"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_Stiffness, PxArticulationDrive, PxReal, PxReal > Stiffness;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_Damping, PxArticulationDrive, PxReal, PxReal > Damping;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_MaxForce, PxArticulationDrive, PxReal, PxReal > MaxForce;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_DriveType, PxArticulationDrive, PxArticulationDriveType::Enum, PxArticulationDriveType::Enum > DriveType;
PX_PHYSX_CORE_API PxArticulationDriveGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxArticulationDrive*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 4; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( Stiffness, inStartIndex + 0 );;
inOperator( Damping, inStartIndex + 1 );;
inOperator( MaxForce, inStartIndex + 2 );;
inOperator( DriveType, inStartIndex + 3 );;
return 4 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxArticulationDrive>
{
PxArticulationDriveGeneratedInfo Info;
const PxArticulationDriveGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxDynamicTreeSecondaryPruner__EnumConversion[] = {
{ "eNONE", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eNONE ) },
{ "eBUCKET", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eBUCKET ) },
{ "eINCREMENTAL", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eINCREMENTAL ) },
{ "eBVH", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eBVH ) },
{ "eLAST", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eLAST ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxDynamicTreeSecondaryPruner::Enum > { PxEnumTraits() : NameConversion( g_physx__PxDynamicTreeSecondaryPruner__EnumConversion ) {} const PxU32ToName* NameConversion; };
static PxU32ToName g_physx__PxBVHBuildStrategy__EnumConversion[] = {
{ "eFAST", static_cast<PxU32>( physx::PxBVHBuildStrategy::eFAST ) },
{ "eDEFAULT", static_cast<PxU32>( physx::PxBVHBuildStrategy::eDEFAULT ) },
{ "eSAH", static_cast<PxU32>( physx::PxBVHBuildStrategy::eSAH ) },
{ "eLAST", static_cast<PxU32>( physx::PxBVHBuildStrategy::eLAST ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxBVHBuildStrategy::Enum > { PxEnumTraits() : NameConversion( g_physx__PxBVHBuildStrategy__EnumConversion ) {} const PxU32ToName* NameConversion; };
class PxSceneQueryDesc;
struct PxSceneQueryDescGeneratedValues
{
_Bool IsValid;
PxPruningStructureType::Enum StaticStructure;
PxPruningStructureType::Enum DynamicStructure;
PxU32 DynamicTreeRebuildRateHint;
PxDynamicTreeSecondaryPruner::Enum DynamicTreeSecondaryPruner;
PxBVHBuildStrategy::Enum StaticBVHBuildStrategy;
PxBVHBuildStrategy::Enum DynamicBVHBuildStrategy;
PxU32 StaticNbObjectsPerNode;
PxU32 DynamicNbObjectsPerNode;
PxSceneQueryUpdateMode::Enum SceneQueryUpdateMode;
PX_PHYSX_CORE_API PxSceneQueryDescGeneratedValues( const PxSceneQueryDesc* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, IsValid, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, StaticStructure, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicStructure, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicTreeRebuildRateHint, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicTreeSecondaryPruner, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, StaticBVHBuildStrategy, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicBVHBuildStrategy, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, StaticNbObjectsPerNode, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicNbObjectsPerNode, PxSceneQueryDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, SceneQueryUpdateMode, PxSceneQueryDescGeneratedValues)
struct PxSceneQueryDescGeneratedInfo
{
static const char* getClassName() { return "PxSceneQueryDesc"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_IsValid, PxSceneQueryDesc, _Bool > IsValid;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_StaticStructure, PxSceneQueryDesc, PxPruningStructureType::Enum, PxPruningStructureType::Enum > StaticStructure;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicStructure, PxSceneQueryDesc, PxPruningStructureType::Enum, PxPruningStructureType::Enum > DynamicStructure;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicTreeRebuildRateHint, PxSceneQueryDesc, PxU32, PxU32 > DynamicTreeRebuildRateHint;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicTreeSecondaryPruner, PxSceneQueryDesc, PxDynamicTreeSecondaryPruner::Enum, PxDynamicTreeSecondaryPruner::Enum > DynamicTreeSecondaryPruner;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_StaticBVHBuildStrategy, PxSceneQueryDesc, PxBVHBuildStrategy::Enum, PxBVHBuildStrategy::Enum > StaticBVHBuildStrategy;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicBVHBuildStrategy, PxSceneQueryDesc, PxBVHBuildStrategy::Enum, PxBVHBuildStrategy::Enum > DynamicBVHBuildStrategy;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_StaticNbObjectsPerNode, PxSceneQueryDesc, PxU32, PxU32 > StaticNbObjectsPerNode;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicNbObjectsPerNode, PxSceneQueryDesc, PxU32, PxU32 > DynamicNbObjectsPerNode;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_SceneQueryUpdateMode, PxSceneQueryDesc, PxSceneQueryUpdateMode::Enum, PxSceneQueryUpdateMode::Enum > SceneQueryUpdateMode;
PX_PHYSX_CORE_API PxSceneQueryDescGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSceneQueryDesc*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 10; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( IsValid, inStartIndex + 0 );;
inOperator( StaticStructure, inStartIndex + 1 );;
inOperator( DynamicStructure, inStartIndex + 2 );;
inOperator( DynamicTreeRebuildRateHint, inStartIndex + 3 );;
inOperator( DynamicTreeSecondaryPruner, inStartIndex + 4 );;
inOperator( StaticBVHBuildStrategy, inStartIndex + 5 );;
inOperator( DynamicBVHBuildStrategy, inStartIndex + 6 );;
inOperator( StaticNbObjectsPerNode, inStartIndex + 7 );;
inOperator( DynamicNbObjectsPerNode, inStartIndex + 8 );;
inOperator( SceneQueryUpdateMode, inStartIndex + 9 );;
return 10 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSceneQueryDesc>
{
PxSceneQueryDescGeneratedInfo Info;
const PxSceneQueryDescGeneratedInfo* getInfo() { return &Info; }
};
class PxSceneDesc;
struct PxSceneDescGeneratedValues
: PxSceneQueryDescGeneratedValues {
PxVec3 Gravity;
PxSimulationEventCallback * SimulationEventCallback;
PxContactModifyCallback * ContactModifyCallback;
PxCCDContactModifyCallback * CcdContactModifyCallback;
const void * FilterShaderData;
PxU32 FilterShaderDataSize;
PxSimulationFilterShader FilterShader;
PxSimulationFilterCallback * FilterCallback;
PxPairFilteringMode::Enum KineKineFilteringMode;
PxPairFilteringMode::Enum StaticKineFilteringMode;
PxBroadPhaseType::Enum BroadPhaseType;
PxBroadPhaseCallback * BroadPhaseCallback;
PxSceneLimits Limits;
PxFrictionType::Enum FrictionType;
PxSolverType::Enum SolverType;
PxReal BounceThresholdVelocity;
PxReal FrictionOffsetThreshold;
PxReal FrictionCorrelationDistance;
PxSceneFlags Flags;
PxCpuDispatcher * CpuDispatcher;
PxCudaContextManager * CudaContextManager;
void * UserData;
PxU32 SolverBatchSize;
PxU32 SolverArticulationBatchSize;
PxU32 NbContactDataBlocks;
PxU32 MaxNbContactDataBlocks;
PxReal MaxBiasCoefficient;
PxU32 ContactReportStreamBufferSize;
PxU32 CcdMaxPasses;
PxReal CcdThreshold;
PxReal CcdMaxSeparation;
PxReal WakeCounterResetValue;
PxBounds3 SanityBounds;
PxgDynamicsMemoryConfig GpuDynamicsConfig;
PxU32 GpuMaxNumPartitions;
PxU32 GpuMaxNumStaticPartitions;
PxU32 GpuComputeVersion;
PxU32 ContactPairSlabSize;
PX_PHYSX_CORE_API PxSceneDescGeneratedValues( const PxSceneDesc* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, Gravity, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SimulationEventCallback, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, ContactModifyCallback, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdContactModifyCallback, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterShaderData, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterShaderDataSize, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterShader, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterCallback, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, KineKineFilteringMode, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, StaticKineFilteringMode, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, BroadPhaseType, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, BroadPhaseCallback, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, Limits, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FrictionType, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SolverType, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, BounceThresholdVelocity, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FrictionOffsetThreshold, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FrictionCorrelationDistance, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, Flags, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CpuDispatcher, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CudaContextManager, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, UserData, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SolverBatchSize, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SolverArticulationBatchSize, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, NbContactDataBlocks, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, MaxNbContactDataBlocks, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, MaxBiasCoefficient, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, ContactReportStreamBufferSize, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdMaxPasses, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdThreshold, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdMaxSeparation, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, WakeCounterResetValue, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SanityBounds, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuDynamicsConfig, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuMaxNumPartitions, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuMaxNumStaticPartitions, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuComputeVersion, PxSceneDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, ContactPairSlabSize, PxSceneDescGeneratedValues)
struct PxSceneDescGeneratedInfo
: PxSceneQueryDescGeneratedInfo
{
static const char* getClassName() { return "PxSceneDesc"; }
PxWriteOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ToDefault, PxSceneDesc, const PxTolerancesScale & > ToDefault;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_Gravity, PxSceneDesc, PxVec3, PxVec3 > Gravity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SimulationEventCallback, PxSceneDesc, PxSimulationEventCallback *, PxSimulationEventCallback * > SimulationEventCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ContactModifyCallback, PxSceneDesc, PxContactModifyCallback *, PxContactModifyCallback * > ContactModifyCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdContactModifyCallback, PxSceneDesc, PxCCDContactModifyCallback *, PxCCDContactModifyCallback * > CcdContactModifyCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterShaderData, PxSceneDesc, const void *, const void * > FilterShaderData;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterShaderDataSize, PxSceneDesc, PxU32, PxU32 > FilterShaderDataSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterShader, PxSceneDesc, PxSimulationFilterShader, PxSimulationFilterShader > FilterShader;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterCallback, PxSceneDesc, PxSimulationFilterCallback *, PxSimulationFilterCallback * > FilterCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_KineKineFilteringMode, PxSceneDesc, PxPairFilteringMode::Enum, PxPairFilteringMode::Enum > KineKineFilteringMode;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_StaticKineFilteringMode, PxSceneDesc, PxPairFilteringMode::Enum, PxPairFilteringMode::Enum > StaticKineFilteringMode;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_BroadPhaseType, PxSceneDesc, PxBroadPhaseType::Enum, PxBroadPhaseType::Enum > BroadPhaseType;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_BroadPhaseCallback, PxSceneDesc, PxBroadPhaseCallback *, PxBroadPhaseCallback * > BroadPhaseCallback;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_Limits, PxSceneDesc, PxSceneLimits, PxSceneLimits > Limits;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FrictionType, PxSceneDesc, PxFrictionType::Enum, PxFrictionType::Enum > FrictionType;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SolverType, PxSceneDesc, PxSolverType::Enum, PxSolverType::Enum > SolverType;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_BounceThresholdVelocity, PxSceneDesc, PxReal, PxReal > BounceThresholdVelocity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FrictionOffsetThreshold, PxSceneDesc, PxReal, PxReal > FrictionOffsetThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FrictionCorrelationDistance, PxSceneDesc, PxReal, PxReal > FrictionCorrelationDistance;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_Flags, PxSceneDesc, PxSceneFlags, PxSceneFlags > Flags;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CpuDispatcher, PxSceneDesc, PxCpuDispatcher *, PxCpuDispatcher * > CpuDispatcher;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CudaContextManager, PxSceneDesc, PxCudaContextManager *, PxCudaContextManager * > CudaContextManager;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_UserData, PxSceneDesc, void *, void * > UserData;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SolverBatchSize, PxSceneDesc, PxU32, PxU32 > SolverBatchSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SolverArticulationBatchSize, PxSceneDesc, PxU32, PxU32 > SolverArticulationBatchSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_NbContactDataBlocks, PxSceneDesc, PxU32, PxU32 > NbContactDataBlocks;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_MaxNbContactDataBlocks, PxSceneDesc, PxU32, PxU32 > MaxNbContactDataBlocks;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_MaxBiasCoefficient, PxSceneDesc, PxReal, PxReal > MaxBiasCoefficient;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ContactReportStreamBufferSize, PxSceneDesc, PxU32, PxU32 > ContactReportStreamBufferSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdMaxPasses, PxSceneDesc, PxU32, PxU32 > CcdMaxPasses;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdThreshold, PxSceneDesc, PxReal, PxReal > CcdThreshold;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdMaxSeparation, PxSceneDesc, PxReal, PxReal > CcdMaxSeparation;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_WakeCounterResetValue, PxSceneDesc, PxReal, PxReal > WakeCounterResetValue;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SanityBounds, PxSceneDesc, PxBounds3, PxBounds3 > SanityBounds;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuDynamicsConfig, PxSceneDesc, PxgDynamicsMemoryConfig, PxgDynamicsMemoryConfig > GpuDynamicsConfig;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuMaxNumPartitions, PxSceneDesc, PxU32, PxU32 > GpuMaxNumPartitions;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuMaxNumStaticPartitions, PxSceneDesc, PxU32, PxU32 > GpuMaxNumStaticPartitions;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuComputeVersion, PxSceneDesc, PxU32, PxU32 > GpuComputeVersion;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ContactPairSlabSize, PxSceneDesc, PxU32, PxU32 > ContactPairSlabSize;
PX_PHYSX_CORE_API PxSceneDescGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSceneDesc*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
inOperator( *static_cast<PxSceneQueryDescGeneratedInfo*>( this ) );
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inStartIndex = PxSceneQueryDescGeneratedInfo::visitBaseProperties( inOperator, inStartIndex );
inStartIndex = PxSceneQueryDescGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex );
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 39; }
static PxU32 totalPropertyCount() { return instancePropertyCount()
+ PxSceneQueryDescGeneratedInfo::totalPropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( ToDefault, inStartIndex + 0 );;
inOperator( Gravity, inStartIndex + 1 );;
inOperator( SimulationEventCallback, inStartIndex + 2 );;
inOperator( ContactModifyCallback, inStartIndex + 3 );;
inOperator( CcdContactModifyCallback, inStartIndex + 4 );;
inOperator( FilterShaderData, inStartIndex + 5 );;
inOperator( FilterShaderDataSize, inStartIndex + 6 );;
inOperator( FilterShader, inStartIndex + 7 );;
inOperator( FilterCallback, inStartIndex + 8 );;
inOperator( KineKineFilteringMode, inStartIndex + 9 );;
inOperator( StaticKineFilteringMode, inStartIndex + 10 );;
inOperator( BroadPhaseType, inStartIndex + 11 );;
inOperator( BroadPhaseCallback, inStartIndex + 12 );;
inOperator( Limits, inStartIndex + 13 );;
inOperator( FrictionType, inStartIndex + 14 );;
inOperator( SolverType, inStartIndex + 15 );;
inOperator( BounceThresholdVelocity, inStartIndex + 16 );;
inOperator( FrictionOffsetThreshold, inStartIndex + 17 );;
inOperator( FrictionCorrelationDistance, inStartIndex + 18 );;
inOperator( Flags, inStartIndex + 19 );;
inOperator( CpuDispatcher, inStartIndex + 20 );;
inOperator( CudaContextManager, inStartIndex + 21 );;
inOperator( UserData, inStartIndex + 22 );;
inOperator( SolverBatchSize, inStartIndex + 23 );;
inOperator( SolverArticulationBatchSize, inStartIndex + 24 );;
inOperator( NbContactDataBlocks, inStartIndex + 25 );;
inOperator( MaxNbContactDataBlocks, inStartIndex + 26 );;
inOperator( MaxBiasCoefficient, inStartIndex + 27 );;
inOperator( ContactReportStreamBufferSize, inStartIndex + 28 );;
inOperator( CcdMaxPasses, inStartIndex + 29 );;
inOperator( CcdThreshold, inStartIndex + 30 );;
inOperator( CcdMaxSeparation, inStartIndex + 31 );;
inOperator( WakeCounterResetValue, inStartIndex + 32 );;
inOperator( SanityBounds, inStartIndex + 33 );;
inOperator( GpuDynamicsConfig, inStartIndex + 34 );;
inOperator( GpuMaxNumPartitions, inStartIndex + 35 );;
inOperator( GpuMaxNumStaticPartitions, inStartIndex + 36 );;
inOperator( GpuComputeVersion, inStartIndex + 37 );;
inOperator( ContactPairSlabSize, inStartIndex + 38 );;
return 39 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSceneDesc>
{
PxSceneDescGeneratedInfo Info;
const PxSceneDescGeneratedInfo* getInfo() { return &Info; }
};
class PxBroadPhaseDesc;
struct PxBroadPhaseDescGeneratedValues
{
_Bool IsValid;
PxBroadPhaseType::Enum MType;
PxU64 MContextID;
PxCudaContextManager * MContextManager;
PxU32 MFoundLostPairsCapacity;
_Bool MDiscardStaticVsKinematic;
_Bool MDiscardKinematicVsKinematic;
PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedValues( const PxBroadPhaseDesc* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, IsValid, PxBroadPhaseDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MType, PxBroadPhaseDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MContextID, PxBroadPhaseDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MContextManager, PxBroadPhaseDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MFoundLostPairsCapacity, PxBroadPhaseDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MDiscardStaticVsKinematic, PxBroadPhaseDescGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MDiscardKinematicVsKinematic, PxBroadPhaseDescGeneratedValues)
struct PxBroadPhaseDescGeneratedInfo
{
static const char* getClassName() { return "PxBroadPhaseDesc"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_IsValid, PxBroadPhaseDesc, _Bool > IsValid;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MType, PxBroadPhaseDesc, PxBroadPhaseType::Enum, PxBroadPhaseType::Enum > MType;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MContextID, PxBroadPhaseDesc, PxU64, PxU64 > MContextID;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MContextManager, PxBroadPhaseDesc, PxCudaContextManager *, PxCudaContextManager * > MContextManager;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MFoundLostPairsCapacity, PxBroadPhaseDesc, PxU32, PxU32 > MFoundLostPairsCapacity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MDiscardStaticVsKinematic, PxBroadPhaseDesc, _Bool, _Bool > MDiscardStaticVsKinematic;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MDiscardKinematicVsKinematic, PxBroadPhaseDesc, _Bool, _Bool > MDiscardKinematicVsKinematic;
PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxBroadPhaseDesc*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 7; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( IsValid, inStartIndex + 0 );;
inOperator( MType, inStartIndex + 1 );;
inOperator( MContextID, inStartIndex + 2 );;
inOperator( MContextManager, inStartIndex + 3 );;
inOperator( MFoundLostPairsCapacity, inStartIndex + 4 );;
inOperator( MDiscardStaticVsKinematic, inStartIndex + 5 );;
inOperator( MDiscardKinematicVsKinematic, inStartIndex + 6 );;
return 7 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxBroadPhaseDesc>
{
PxBroadPhaseDescGeneratedInfo Info;
const PxBroadPhaseDescGeneratedInfo* getInfo() { return &Info; }
};
class PxSceneLimits;
struct PxSceneLimitsGeneratedValues
{
PxU32 MaxNbActors;
PxU32 MaxNbBodies;
PxU32 MaxNbStaticShapes;
PxU32 MaxNbDynamicShapes;
PxU32 MaxNbAggregates;
PxU32 MaxNbConstraints;
PxU32 MaxNbRegions;
PxU32 MaxNbBroadPhaseOverlaps;
PX_PHYSX_CORE_API PxSceneLimitsGeneratedValues( const PxSceneLimits* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbActors, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbBodies, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbStaticShapes, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbDynamicShapes, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbAggregates, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbConstraints, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbRegions, PxSceneLimitsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbBroadPhaseOverlaps, PxSceneLimitsGeneratedValues)
struct PxSceneLimitsGeneratedInfo
{
static const char* getClassName() { return "PxSceneLimits"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbActors, PxSceneLimits, PxU32, PxU32 > MaxNbActors;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbBodies, PxSceneLimits, PxU32, PxU32 > MaxNbBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbStaticShapes, PxSceneLimits, PxU32, PxU32 > MaxNbStaticShapes;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbDynamicShapes, PxSceneLimits, PxU32, PxU32 > MaxNbDynamicShapes;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbAggregates, PxSceneLimits, PxU32, PxU32 > MaxNbAggregates;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbConstraints, PxSceneLimits, PxU32, PxU32 > MaxNbConstraints;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbRegions, PxSceneLimits, PxU32, PxU32 > MaxNbRegions;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbBroadPhaseOverlaps, PxSceneLimits, PxU32, PxU32 > MaxNbBroadPhaseOverlaps;
PX_PHYSX_CORE_API PxSceneLimitsGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSceneLimits*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 8; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( MaxNbActors, inStartIndex + 0 );;
inOperator( MaxNbBodies, inStartIndex + 1 );;
inOperator( MaxNbStaticShapes, inStartIndex + 2 );;
inOperator( MaxNbDynamicShapes, inStartIndex + 3 );;
inOperator( MaxNbAggregates, inStartIndex + 4 );;
inOperator( MaxNbConstraints, inStartIndex + 5 );;
inOperator( MaxNbRegions, inStartIndex + 6 );;
inOperator( MaxNbBroadPhaseOverlaps, inStartIndex + 7 );;
return 8 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSceneLimits>
{
PxSceneLimitsGeneratedInfo Info;
const PxSceneLimitsGeneratedInfo* getInfo() { return &Info; }
};
struct PxgDynamicsMemoryConfig;
struct PxgDynamicsMemoryConfigGeneratedValues
{
_Bool IsValid;
PxU32 TempBufferCapacity;
PxU32 MaxRigidContactCount;
PxU32 MaxRigidPatchCount;
PxU32 HeapCapacity;
PxU32 FoundLostPairsCapacity;
PxU32 FoundLostAggregatePairsCapacity;
PxU32 TotalAggregatePairsCapacity;
PxU32 MaxSoftBodyContacts;
PxU32 MaxFemClothContacts;
PxU32 MaxParticleContacts;
PxU32 CollisionStackSize;
PxU32 MaxHairContacts;
PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedValues( const PxgDynamicsMemoryConfig* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, IsValid, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, TempBufferCapacity, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxRigidContactCount, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxRigidPatchCount, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, HeapCapacity, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, FoundLostPairsCapacity, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, FoundLostAggregatePairsCapacity, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, TotalAggregatePairsCapacity, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxSoftBodyContacts, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxFemClothContacts, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxParticleContacts, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, CollisionStackSize, PxgDynamicsMemoryConfigGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxHairContacts, PxgDynamicsMemoryConfigGeneratedValues)
struct PxgDynamicsMemoryConfigGeneratedInfo
{
static const char* getClassName() { return "PxgDynamicsMemoryConfig"; }
PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_IsValid, PxgDynamicsMemoryConfig, _Bool > IsValid;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_TempBufferCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > TempBufferCapacity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxRigidContactCount, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxRigidContactCount;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxRigidPatchCount, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxRigidPatchCount;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_HeapCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > HeapCapacity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_FoundLostPairsCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > FoundLostPairsCapacity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_FoundLostAggregatePairsCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > FoundLostAggregatePairsCapacity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_TotalAggregatePairsCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > TotalAggregatePairsCapacity;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxSoftBodyContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxSoftBodyContacts;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxFemClothContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxFemClothContacts;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxParticleContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxParticleContacts;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_CollisionStackSize, PxgDynamicsMemoryConfig, PxU32, PxU32 > CollisionStackSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxHairContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxHairContacts;
PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxgDynamicsMemoryConfig*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 13; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( IsValid, inStartIndex + 0 );;
inOperator( TempBufferCapacity, inStartIndex + 1 );;
inOperator( MaxRigidContactCount, inStartIndex + 2 );;
inOperator( MaxRigidPatchCount, inStartIndex + 3 );;
inOperator( HeapCapacity, inStartIndex + 4 );;
inOperator( FoundLostPairsCapacity, inStartIndex + 5 );;
inOperator( FoundLostAggregatePairsCapacity, inStartIndex + 6 );;
inOperator( TotalAggregatePairsCapacity, inStartIndex + 7 );;
inOperator( MaxSoftBodyContacts, inStartIndex + 8 );;
inOperator( MaxFemClothContacts, inStartIndex + 9 );;
inOperator( MaxParticleContacts, inStartIndex + 10 );;
inOperator( CollisionStackSize, inStartIndex + 11 );;
inOperator( MaxHairContacts, inStartIndex + 12 );;
return 13 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxgDynamicsMemoryConfig>
{
PxgDynamicsMemoryConfigGeneratedInfo Info;
const PxgDynamicsMemoryConfigGeneratedInfo* getInfo() { return &Info; }
};
static PxU32ToName g_physx__PxSimulationStatistics__RbPairStatsTypeConversion[] = {
{ "eDISCRETE_CONTACT_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eDISCRETE_CONTACT_PAIRS ) },
{ "eCCD_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eCCD_PAIRS ) },
{ "eMODIFIED_CONTACT_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eMODIFIED_CONTACT_PAIRS ) },
{ "eTRIGGER_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eTRIGGER_PAIRS ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits< physx::PxSimulationStatistics::RbPairStatsType > { PxEnumTraits() : NameConversion( g_physx__PxSimulationStatistics__RbPairStatsTypeConversion ) {} const PxU32ToName* NameConversion; };
class PxSimulationStatistics;
struct PxSimulationStatisticsGeneratedValues
{
PxU32 NbActiveConstraints;
PxU32 NbActiveDynamicBodies;
PxU32 NbActiveKinematicBodies;
PxU32 NbStaticBodies;
PxU32 NbDynamicBodies;
PxU32 NbKinematicBodies;
PxU32 NbAggregates;
PxU32 NbArticulations;
PxU32 NbAxisSolverConstraints;
PxU32 CompressedContactSize;
PxU32 RequiredContactConstraintMemory;
PxU32 PeakConstraintMemory;
PxU32 NbDiscreteContactPairsTotal;
PxU32 NbDiscreteContactPairsWithCacheHits;
PxU32 NbDiscreteContactPairsWithContacts;
PxU32 NbNewPairs;
PxU32 NbLostPairs;
PxU32 NbNewTouches;
PxU32 NbLostTouches;
PxU32 NbPartitions;
PxU64 GpuMemParticles;
PxU64 GpuMemSoftBodies;
PxU64 GpuMemFEMCloths;
PxU64 GpuMemHairSystems;
PxU64 GpuMemHeap;
PxU64 GpuMemHeapBroadPhase;
PxU64 GpuMemHeapNarrowPhase;
PxU64 GpuMemHeapSolver;
PxU64 GpuMemHeapArticulation;
PxU64 GpuMemHeapSimulation;
PxU64 GpuMemHeapSimulationArticulation;
PxU64 GpuMemHeapSimulationParticles;
PxU64 GpuMemHeapSimulationSoftBody;
PxU64 GpuMemHeapSimulationFEMCloth;
PxU64 GpuMemHeapSimulationHairSystem;
PxU64 GpuMemHeapParticles;
PxU64 GpuMemHeapSoftBodies;
PxU64 GpuMemHeapFEMCloths;
PxU64 GpuMemHeapHairSystems;
PxU64 GpuMemHeapOther;
PxU32 NbBroadPhaseAdds;
PxU32 NbBroadPhaseRemoves;
PxU32 NbDiscreteContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
PxU32 NbModifiedContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
PxU32 NbCCDPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
PxU32 NbTriggerPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT];
PxU32 NbShapes[PxGeometryType::eGEOMETRY_COUNT];
PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedValues( const PxSimulationStatistics* inSource );
};
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbActiveConstraints, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbActiveDynamicBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbActiveKinematicBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbStaticBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDynamicBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbKinematicBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbAggregates, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbArticulations, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbAxisSolverConstraints, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, CompressedContactSize, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, RequiredContactConstraintMemory, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, PeakConstraintMemory, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairsTotal, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairsWithCacheHits, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairsWithContacts, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbNewPairs, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbLostPairs, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbNewTouches, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbLostTouches, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbPartitions, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemParticles, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemSoftBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemFEMCloths, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHairSystems, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeap, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapBroadPhase, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapNarrowPhase, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSolver, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapArticulation, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulation, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationArticulation, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationParticles, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationSoftBody, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationFEMCloth, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationHairSystem, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapParticles, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSoftBodies, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapFEMCloths, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapHairSystems, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapOther, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbBroadPhaseAdds, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbBroadPhaseRemoves, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairs, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbModifiedContactPairs, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbCCDPairs, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbTriggerPairs, PxSimulationStatisticsGeneratedValues)
DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbShapes, PxSimulationStatisticsGeneratedValues)
struct PxSimulationStatisticsGeneratedInfo
{
static const char* getClassName() { return "PxSimulationStatistics"; }
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbActiveConstraints, PxSimulationStatistics, PxU32, PxU32 > NbActiveConstraints;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbActiveDynamicBodies, PxSimulationStatistics, PxU32, PxU32 > NbActiveDynamicBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbActiveKinematicBodies, PxSimulationStatistics, PxU32, PxU32 > NbActiveKinematicBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbStaticBodies, PxSimulationStatistics, PxU32, PxU32 > NbStaticBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDynamicBodies, PxSimulationStatistics, PxU32, PxU32 > NbDynamicBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbKinematicBodies, PxSimulationStatistics, PxU32, PxU32 > NbKinematicBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbAggregates, PxSimulationStatistics, PxU32, PxU32 > NbAggregates;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbArticulations, PxSimulationStatistics, PxU32, PxU32 > NbArticulations;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbAxisSolverConstraints, PxSimulationStatistics, PxU32, PxU32 > NbAxisSolverConstraints;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_CompressedContactSize, PxSimulationStatistics, PxU32, PxU32 > CompressedContactSize;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_RequiredContactConstraintMemory, PxSimulationStatistics, PxU32, PxU32 > RequiredContactConstraintMemory;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_PeakConstraintMemory, PxSimulationStatistics, PxU32, PxU32 > PeakConstraintMemory;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDiscreteContactPairsTotal, PxSimulationStatistics, PxU32, PxU32 > NbDiscreteContactPairsTotal;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDiscreteContactPairsWithCacheHits, PxSimulationStatistics, PxU32, PxU32 > NbDiscreteContactPairsWithCacheHits;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDiscreteContactPairsWithContacts, PxSimulationStatistics, PxU32, PxU32 > NbDiscreteContactPairsWithContacts;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbNewPairs, PxSimulationStatistics, PxU32, PxU32 > NbNewPairs;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbLostPairs, PxSimulationStatistics, PxU32, PxU32 > NbLostPairs;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbNewTouches, PxSimulationStatistics, PxU32, PxU32 > NbNewTouches;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbLostTouches, PxSimulationStatistics, PxU32, PxU32 > NbLostTouches;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbPartitions, PxSimulationStatistics, PxU32, PxU32 > NbPartitions;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemParticles, PxSimulationStatistics, PxU64, PxU64 > GpuMemParticles;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemSoftBodies, PxSimulationStatistics, PxU64, PxU64 > GpuMemSoftBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemFEMCloths, PxSimulationStatistics, PxU64, PxU64 > GpuMemFEMCloths;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHairSystems, PxSimulationStatistics, PxU64, PxU64 > GpuMemHairSystems;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeap, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeap;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapBroadPhase, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapBroadPhase;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapNarrowPhase, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapNarrowPhase;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSolver, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSolver;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapArticulation, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapArticulation;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulation, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulation;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationArticulation, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationArticulation;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationParticles, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationParticles;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationSoftBody, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationSoftBody;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationFEMCloth, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationFEMCloth;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationHairSystem, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationHairSystem;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapParticles, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapParticles;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSoftBodies, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSoftBodies;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapFEMCloths, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapFEMCloths;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapHairSystems, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapHairSystems;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapOther, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapOther;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbBroadPhaseAdds, PxSimulationStatistics, PxU32, PxU32 > NbBroadPhaseAdds;
PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbBroadPhaseRemoves, PxSimulationStatistics, PxU32, PxU32 > NbBroadPhaseRemoves;
NbDiscreteContactPairsProperty NbDiscreteContactPairs;
NbModifiedContactPairsProperty NbModifiedContactPairs;
NbCCDPairsProperty NbCCDPairs;
NbTriggerPairsProperty NbTriggerPairs;
NbShapesProperty NbShapes;
PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedInfo();
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator inOperator ) const
{
return inOperator( reinterpret_cast<PxSimulationStatistics*>(NULL) );
}
template<typename TOperator>
void visitBases( TOperator inOperator )
{
PX_UNUSED(inOperator);
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
return inStartIndex;
}
static PxU32 instancePropertyCount() { return 47; }
static PxU32 totalPropertyCount() { return instancePropertyCount(); }
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const
{
PX_UNUSED(inOperator);
PX_UNUSED(inStartIndex);
inOperator( NbActiveConstraints, inStartIndex + 0 );;
inOperator( NbActiveDynamicBodies, inStartIndex + 1 );;
inOperator( NbActiveKinematicBodies, inStartIndex + 2 );;
inOperator( NbStaticBodies, inStartIndex + 3 );;
inOperator( NbDynamicBodies, inStartIndex + 4 );;
inOperator( NbKinematicBodies, inStartIndex + 5 );;
inOperator( NbAggregates, inStartIndex + 6 );;
inOperator( NbArticulations, inStartIndex + 7 );;
inOperator( NbAxisSolverConstraints, inStartIndex + 8 );;
inOperator( CompressedContactSize, inStartIndex + 9 );;
inOperator( RequiredContactConstraintMemory, inStartIndex + 10 );;
inOperator( PeakConstraintMemory, inStartIndex + 11 );;
inOperator( NbDiscreteContactPairsTotal, inStartIndex + 12 );;
inOperator( NbDiscreteContactPairsWithCacheHits, inStartIndex + 13 );;
inOperator( NbDiscreteContactPairsWithContacts, inStartIndex + 14 );;
inOperator( NbNewPairs, inStartIndex + 15 );;
inOperator( NbLostPairs, inStartIndex + 16 );;
inOperator( NbNewTouches, inStartIndex + 17 );;
inOperator( NbLostTouches, inStartIndex + 18 );;
inOperator( NbPartitions, inStartIndex + 19 );;
inOperator( GpuMemParticles, inStartIndex + 20 );;
inOperator( GpuMemSoftBodies, inStartIndex + 21 );;
inOperator( GpuMemFEMCloths, inStartIndex + 22 );;
inOperator( GpuMemHairSystems, inStartIndex + 23 );;
inOperator( GpuMemHeap, inStartIndex + 24 );;
inOperator( GpuMemHeapBroadPhase, inStartIndex + 25 );;
inOperator( GpuMemHeapNarrowPhase, inStartIndex + 26 );;
inOperator( GpuMemHeapSolver, inStartIndex + 27 );;
inOperator( GpuMemHeapArticulation, inStartIndex + 28 );;
inOperator( GpuMemHeapSimulation, inStartIndex + 29 );;
inOperator( GpuMemHeapSimulationArticulation, inStartIndex + 30 );;
inOperator( GpuMemHeapSimulationParticles, inStartIndex + 31 );;
inOperator( GpuMemHeapSimulationSoftBody, inStartIndex + 32 );;
inOperator( GpuMemHeapSimulationFEMCloth, inStartIndex + 33 );;
inOperator( GpuMemHeapSimulationHairSystem, inStartIndex + 34 );;
inOperator( GpuMemHeapParticles, inStartIndex + 35 );;
inOperator( GpuMemHeapSoftBodies, inStartIndex + 36 );;
inOperator( GpuMemHeapFEMCloths, inStartIndex + 37 );;
inOperator( GpuMemHeapHairSystems, inStartIndex + 38 );;
inOperator( GpuMemHeapOther, inStartIndex + 39 );;
inOperator( NbBroadPhaseAdds, inStartIndex + 40 );;
inOperator( NbBroadPhaseRemoves, inStartIndex + 41 );;
inOperator( NbDiscreteContactPairs, inStartIndex + 42 );;
inOperator( NbModifiedContactPairs, inStartIndex + 43 );;
inOperator( NbCCDPairs, inStartIndex + 44 );;
inOperator( NbTriggerPairs, inStartIndex + 45 );;
inOperator( NbShapes, inStartIndex + 46 );;
return 47 + inStartIndex;
}
};
template<> struct PxClassInfoTraits<PxSimulationStatistics>
{
PxSimulationStatisticsGeneratedInfo Info;
const PxSimulationStatisticsGeneratedInfo* getInfo() { return &Info; }
};
#undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
#undef PX_PROPERTY_INFO_NAME
| 213,625 | C | 53.902596 | 218 | 0.791092 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/RepXMetaDataPropertyVisitor.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_REPX_META_DATA_PROPERTY_VISITOR_H
#define PX_REPX_META_DATA_PROPERTY_VISITOR_H
#include "PvdMetaDataPropertyVisitor.h"
namespace physx {
template<PxU32 TKey, typename TObjectType,typename TSetPropType, typename TPropertyType>
struct PxRepXPropertyAccessor : public Vd::ValueStructOffsetRecord
{
typedef PxPropertyInfo<TKey,TObjectType,TSetPropType,TPropertyType> TPropertyInfoType;
typedef TPropertyType prop_type;
const TPropertyInfoType mProperty;
PxRepXPropertyAccessor( const TPropertyInfoType& inProp )
: mProperty( inProp )
{
}
prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); }
void set( TObjectType* inObj, prop_type val ) const { return mProperty.set( inObj, val ); }
private:
PxRepXPropertyAccessor& operator=(const PxRepXPropertyAccessor&);
};
template<typename TSetPropType, typename TPropertyType>
struct PxRepXPropertyAccessor<PxPropertyInfoName::PxRigidDynamic_WakeCounter, PxRigidDynamic, TSetPropType, TPropertyType> : public Vd::ValueStructOffsetRecord
{
typedef PxPropertyInfo<PxPropertyInfoName::PxRigidDynamic_WakeCounter,PxRigidDynamic,TSetPropType,TPropertyType> TPropertyInfoType;
typedef TPropertyType prop_type;
const TPropertyInfoType mProperty;
PxRepXPropertyAccessor( const TPropertyInfoType& inProp )
: mProperty( inProp )
{
}
prop_type get( const PxRigidDynamic* inObj ) const { return mProperty.get( inObj ); }
void set( PxRigidDynamic* inObj, prop_type val ) const
{
PX_UNUSED(val);
PxRigidBodyFlags flags = inObj->getRigidBodyFlags();
if( !(flags & PxRigidBodyFlag::eKINEMATIC) )
return mProperty.set( inObj, val );
}
private:
PxRepXPropertyAccessor& operator=(const PxRepXPropertyAccessor&);
};
typedef PxReadOnlyPropertyInfo<PxPropertyInfoName::PxArticulationLink_InboundJoint, PxArticulationLink, PxArticulationJointReducedCoordinate *> TIncomingJointPropType;
//RepX cares about fewer property types than PVD does,
//but I want to reuse the accessor architecture as it
//greatly simplifies clients dealing with complex datatypes
template<typename TOperatorType>
struct RepXPropertyFilter
{
RepXPropertyFilter<TOperatorType> &operator=(const RepXPropertyFilter<TOperatorType> &);
Vd::PvdPropertyFilter<TOperatorType> mFilter;
RepXPropertyFilter( TOperatorType op ) : mFilter( op ) {}
RepXPropertyFilter( const RepXPropertyFilter<TOperatorType>& other ) : mFilter( other.mFilter ) {}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} //repx ignores read only and write only properties
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxWriteOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {}
template<PxU32 TKey, typename TObjType, typename TCollectionType>
void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType>&, PxU32 ) {}
template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType>
void operator()( const PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType >&, PxU32 ) {}
//forward these properties verbatim.
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 idx )
{
mFilter( inProp, idx );
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void operator()( const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType,TPropertyType >& inProp, PxU32 idx )
{
mFilter( inProp, idx );
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
void operator()( const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 idx)
{
mFilter( inProp, idx);
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType>
void operator()( const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx )
{
mFilter( inProp, idx );
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType>
void operator()( const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx )
{
mFilter( inProp, idx );
}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 idx )
{
mFilter( inProp, idx );
}
template<PxU32 TKey, typename TObjType, typename TPropertyType>
void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 count )
{
mFilter( inProp, count );
}
template<PxU32 TKey, typename TObjType, typename TSetPropType, typename TPropertyType>
void operator()( const PxPropertyInfo<TKey,TObjType,TSetPropType,TPropertyType>& prop, PxU32 )
{
PxRepXPropertyAccessor< TKey, TObjType, TSetPropType, TPropertyType > theAccessor( prop );
mFilter.mOperator.pushName( prop.mName );
mFilter.template handleAccessor<TKey>( theAccessor );
mFilter.mOperator.popName();
}
void operator()(const PxRigidActorGlobalPosePropertyInfo& inProp, PxU32)
{
mFilter.mOperator.pushName(inProp.mName);
mFilter.mOperator.handleRigidActorGlobalPose(inProp);
mFilter.mOperator.popName();
}
void operator()( const PxRigidActorShapeCollection& inProp, PxU32 )
{
mFilter.mOperator.pushName( "Shapes" );
mFilter.mOperator.handleShapes( inProp );
mFilter.mOperator.popName();
}
void operator()( const PxArticulationLinkCollectionProp& inProp, PxU32 )
{
mFilter.mOperator.pushName( "Links" );
mFilter.mOperator.handleArticulationLinks( inProp );
mFilter.mOperator.popName();
}
void operator()( const PxShapeMaterialsProperty& inProp, PxU32 )
{
mFilter.mOperator.pushName( "Materials" );
mFilter.mOperator.handleShapeMaterials( inProp );
mFilter.mOperator.popName();
}
void operator()( const TIncomingJointPropType& inProp, PxU32 )
{
mFilter.mOperator.handleIncomingJoint( inProp );
}
void operator()( const PxShapeGeomProperty& inProp, PxU32 )
{
mFilter.mOperator.handleGeomProperty( inProp );
}
#define DEFINE_REPX_PROPERTY_NOP(datatype) \
template<PxU32 TKey, typename TObjType, typename TSetPropType> \
void operator()( const PxPropertyInfo<TKey,TObjType,TSetPropType,datatype>&, PxU32 ){}
DEFINE_REPX_PROPERTY_NOP( const void* )
DEFINE_REPX_PROPERTY_NOP( void* )
DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterCallback * )
DEFINE_REPX_PROPERTY_NOP( physx::PxTaskManager * )
DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterShader * )
DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterShader)
DEFINE_REPX_PROPERTY_NOP( PxContactModifyCallback * )
DEFINE_REPX_PROPERTY_NOP( PxCCDContactModifyCallback * )
DEFINE_REPX_PROPERTY_NOP( PxSimulationEventCallback * )
DEFINE_REPX_PROPERTY_NOP( physx::PxCudaContextManager* )
DEFINE_REPX_PROPERTY_NOP( physx::PxCpuDispatcher * )
DEFINE_REPX_PROPERTY_NOP( PxRigidActor )
DEFINE_REPX_PROPERTY_NOP( const PxRigidActor )
DEFINE_REPX_PROPERTY_NOP( PxRigidActor& )
DEFINE_REPX_PROPERTY_NOP( const PxRigidActor& )
DEFINE_REPX_PROPERTY_NOP( PxScene* )
DEFINE_REPX_PROPERTY_NOP( PxAggregate * )
DEFINE_REPX_PROPERTY_NOP( PxArticulationReducedCoordinate& )
DEFINE_REPX_PROPERTY_NOP( const PxArticulationLink * )
DEFINE_REPX_PROPERTY_NOP( const PxRigidDynamic * )
DEFINE_REPX_PROPERTY_NOP( const PxRigidStatic * )
DEFINE_REPX_PROPERTY_NOP( PxStridedData ) //These are handled in a custom fasion.
};
}
#endif
| 9,616 | C | 42.713636 | 168 | 0.761543 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxMetaDataObjects.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_METADATAOBJECTS_H
#define PX_METADATAOBJECTS_H
#include "foundation/PxMemory.h"
#include "foundation/PxPhysicsVersion.h"
// include the base headers instead of the PxPhysicsAPI.h
//Geometry Library
#include "geometry/PxBoxGeometry.h"
#include "geometry/PxCapsuleGeometry.h"
#include "geometry/PxConvexMesh.h"
#include "geometry/PxConvexMeshGeometry.h"
#include "geometry/PxGeometry.h"
#include "geometry/PxGeometryHelpers.h"
#include "geometry/PxGeometryQuery.h"
#include "geometry/PxHeightField.h"
#include "geometry/PxHeightFieldDesc.h"
#include "geometry/PxHeightFieldFlag.h"
#include "geometry/PxHeightFieldGeometry.h"
#include "geometry/PxHeightFieldSample.h"
#include "geometry/PxMeshQuery.h"
#include "geometry/PxMeshScale.h"
#include "geometry/PxPlaneGeometry.h"
#include "geometry/PxSimpleTriangleMesh.h"
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxTriangle.h"
#include "geometry/PxTriangleMesh.h"
#include "geometry/PxTriangleMeshGeometry.h"
#include "geometry/PxTetrahedron.h"
#include "geometry/PxTetrahedronMesh.h"
#include "geometry/PxTetrahedronMeshGeometry.h"
// PhysX Core SDK
#include "PxActor.h"
#include "PxAggregate.h"
#include "PxArticulationReducedCoordinate.h"
#include "PxArticulationJointReducedCoordinate.h"
#include "PxArticulationLink.h"
#include "PxClient.h"
#include "PxConstraint.h"
#include "PxConstraintDesc.h"
#include "PxContact.h"
#include "PxContactModifyCallback.h"
#include "PxDeletionListener.h"
#include "PxFiltering.h"
#include "PxForceMode.h"
#include "PxLockedData.h"
#include "PxMaterial.h"
#include "PxFEMSoftBodyMaterial.h"
#include "PxFEMClothMaterial.h"
#include "PxPBDMaterial.h"
#include "PxFLIPMaterial.h"
#include "PxMPMMaterial.h"
#include "PxPhysics.h"
#include "PxPhysXConfig.h"
#include "PxQueryFiltering.h"
#include "PxQueryReport.h"
#include "PxRigidActor.h"
#include "PxRigidBody.h"
#include "PxRigidDynamic.h"
#include "PxRigidStatic.h"
#include "PxScene.h"
#include "PxSceneDesc.h"
#include "PxSceneLock.h"
#include "PxShape.h"
#include "PxSimulationEventCallback.h"
#include "PxSimulationStatistics.h"
#include "PxVisualizationParameter.h"
#include "PxPruningStructure.h"
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
/** \addtogroup physics
@{
*/
namespace physx
{
class PxArticulationLink;
class PxArticulationJointReducedCoordinate;
struct PxPropertyInfoName
{
enum Enum
{
Unnamed = 0,
#include "PxAutoGeneratedMetaDataObjectNames.h"
LastPxPropertyInfoName
};
};
struct PxU32ToName
{
const char* mName;
PxU32 mValue;
};
struct PxPropertyInfoBase
{
const char* mName;
PxU32 mKey;
PxPropertyInfoBase( const char* n, PxU32 inKey )
: mName( n )
, mKey( inKey )
{
}
};
template<PxU32 TKey>
struct PxPropertyInfoParameterizedBase : public PxPropertyInfoBase
{
PxPropertyInfoParameterizedBase( const char* inName )
: PxPropertyInfoBase( inName, TKey ) {}
};
template<PxU32 TKey, typename TObjType, typename TPropertyType>
struct PxReadOnlyPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef TPropertyType (*TGetterType)( const TObjType* );
TGetterType mGetter;
PxReadOnlyPropertyInfo( const char* inName, TGetterType inGetter )
: PxPropertyInfoParameterizedBase<TKey>( inName )
, mGetter( inGetter ) {}
TPropertyType get( const TObjType* inObj ) const { return mGetter( inObj ); }
};
template<PxU32 TKey, typename TObjType, typename TPropertyType>
struct PxWriteOnlyPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef void(*TSetterType)( TObjType*, TPropertyType inArg );
TSetterType mSetter;
PxWriteOnlyPropertyInfo( const char* inName, TSetterType inSetter )
: PxPropertyInfoParameterizedBase<TKey>( inName )
, mSetter( inSetter ) {}
void set( TObjType* inObj, TPropertyType inArg ) const { mSetter( inObj, inArg ); }
};
//Define the property types on the auto-generated objects.
template<PxU32 TKey, typename TObjType, typename TSetPropType, typename TGetPropType>
struct PxPropertyInfo : public PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType>
{
typedef typename PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType>::TGetterType TGetterType;
typedef void(*TSetterType)( TObjType*, TSetPropType inArg );
TSetterType mSetter;
PxPropertyInfo( const char* inName, TSetterType inSetter, TGetterType inGetter )
: PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType>( inName, inGetter )
, mSetter( inSetter ) {}
void set( TObjType* inObj, TSetPropType inArg ) const { mSetter( inObj, inArg ); }
};
template<PxU32 TKey, typename TObjType, typename TPropertyType>
struct PxRangePropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef void (*TSetterType)( TObjType*,TPropertyType,TPropertyType);
typedef void (*TGetterType)( const TObjType*,TPropertyType&,TPropertyType&);
const char* mArg0Name;
const char* mArg1Name;
TSetterType mSetter;
TGetterType mGetter;
PxRangePropertyInfo( const char* name, const char* arg0Name, const char* arg1Name
, TSetterType setter, TGetterType getter )
: PxPropertyInfoParameterizedBase<TKey>( name )
, mArg0Name( arg0Name )
, mArg1Name( arg1Name )
, mSetter( setter )
, mGetter( getter )
{
}
void set( TObjType* inObj, TPropertyType arg0, TPropertyType arg1 ) const { mSetter( inObj, arg0, arg1 ); }
void get( const TObjType* inObj, TPropertyType& arg0, TPropertyType& arg1 ) const { mGetter( inObj, arg0, arg1 ); }
};
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
struct PxIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef void (*TSetterType)( TObjType*, TIndexType, TPropertyType );
typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndexType );
TSetterType mSetter;
TGetterType mGetter;
PxIndexedPropertyInfo( const char* name, TSetterType setter, TGetterType getter )
: PxPropertyInfoParameterizedBase<TKey>( name )
, mSetter( setter )
, mGetter( getter )
{
}
void set( TObjType* inObj, TIndexType inIndex, TPropertyType arg ) const { mSetter( inObj, inIndex, arg ); }
TPropertyType get( const TObjType* inObj, TIndexType inIndex ) const { return mGetter( inObj, inIndex ); }
};
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
struct PxExtendedIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef PxU32 (*TNbObjectsMember)( const TObjType* );
typedef void (*TSetterType)( TObjType*, TIndexType, TPropertyType );
typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndexType );
TSetterType mSetter;
TGetterType mGetter;
PxU32 mCount;
TNbObjectsMember mNbObjectsMember;
PxExtendedIndexedPropertyInfo( const char* name, TGetterType getter, TNbObjectsMember inNb, TSetterType setter)
: PxPropertyInfoParameterizedBase<TKey>( name )
, mSetter( setter )
, mGetter( getter )
, mNbObjectsMember( inNb )
{
}
PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); }
void set( TObjType* inObj, TIndexType inIndex, TPropertyType arg ) const { mSetter( inObj, inIndex, arg ); }
TPropertyType get( const TObjType* inObj, TIndexType inIndex ) const { return mGetter( inObj, inIndex ); }
};
template<PxU32 TKey, typename TObjType, typename TIndex1Type, typename TIndex2Type, typename TPropertyType>
struct PxDualIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef void (*TSetterType)( TObjType*, TIndex1Type, TIndex2Type, TPropertyType );
typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndex1Type, TIndex2Type );
TSetterType mSetter;
TGetterType mGetter;
PxDualIndexedPropertyInfo( const char* name, TSetterType setter, TGetterType getter )
: PxPropertyInfoParameterizedBase<TKey>( name )
, mSetter( setter )
, mGetter( getter )
{
}
void set( TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2, TPropertyType arg ) const { mSetter( inObj, inIdx1, inIdx2, arg ); }
TPropertyType get( const TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2 ) const { return mGetter( inObj, inIdx1, inIdx2 ); }
};
template<PxU32 TKey, typename TObjType, typename TIndex1Type, typename TIndex2Type, typename TPropertyType>
struct PxExtendedDualIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef void (*TSetterType)( TObjType*, TIndex1Type, TIndex2Type, TPropertyType );
typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndex1Type, TIndex2Type );
TSetterType mSetter;
TGetterType mGetter;
PxU32 mId0Count;
PxU32 mId1Count;
PxExtendedDualIndexedPropertyInfo( const char* name, TSetterType setter, TGetterType getter, PxU32 id0Count, PxU32 id1Count )
: PxPropertyInfoParameterizedBase<TKey>( name )
, mSetter( setter )
, mGetter( getter )
, mId0Count( id0Count )
, mId1Count( id1Count )
{
}
void set( TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2, TPropertyType arg ) const { mSetter( inObj, inIdx1, inIdx2, arg ); }
TPropertyType get( const TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2 ) const { return mGetter( inObj, inIdx1, inIdx2 ); }
};
template<PxU32 TKey, typename TObjType, typename TCollectionType>
struct PxBufferCollectionPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef PxU32 (*TNbObjectsMember)( const TObjType* );
typedef PxU32 (*TGetObjectsMember)( const TObjType*, TCollectionType*, PxU32 );
typedef void (*TSetObjectsMember)( TObjType*, TCollectionType*, PxU32 );
TGetObjectsMember mGetObjectsMember;
TNbObjectsMember mNbObjectsMember;
TSetObjectsMember mSetObjectsMember;
PxBufferCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TSetObjectsMember inSet )
: PxPropertyInfoParameterizedBase<TKey>( inName )
, mGetObjectsMember( inGetter )
, mNbObjectsMember( inNb )
, mSetObjectsMember( inSet )
{
}
PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); }
PxU32 get( const TObjType* inObj, TCollectionType* inBuffer, PxU32 inNumItems ) const { return mGetObjectsMember( inObj, inBuffer, inNumItems ); }
void set( TObjType* inObj, TCollectionType* inBuffer, PxU32 inNumItems ) const { mSetObjectsMember( inObj, inBuffer, inNumItems); }
};
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType>
struct PxFixedSizeLookupTablePropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef PxU32 (*TNbObjectsMember)( const TObjType* );
typedef PxReal (*TGetXMember)( const TObjType*, PxU32 );
typedef PxReal (*TGetYMember)( const TObjType*, PxU32 );
typedef void (*TAddPairMember)( TObjType*, PxReal, PxReal );
typedef void (*TClearMember)( TObjType* );
TGetXMember mGetXMember;
TGetYMember mGetYMember;
TNbObjectsMember mNbObjectsMember;
TAddPairMember mAddPairMember;
TClearMember mClearMember;
PxFixedSizeLookupTablePropertyInfo( const char* inName, TGetXMember inGetterX, TGetYMember inGetterY, TNbObjectsMember inNb, TAddPairMember inAddPair, TClearMember inClear )
: PxPropertyInfoParameterizedBase<TKey>( inName )
, mGetXMember( inGetterX )
, mGetYMember( inGetterY )
, mNbObjectsMember( inNb )
, mAddPairMember( inAddPair )
, mClearMember( inClear )
{
}
PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); }
PxReal getX( const TObjType* inObj, const PxU32 index ) const { return mGetXMember( inObj, index ); }
PxReal getY( const TObjType* inObj, const PxU32 index ) const { return mGetYMember( inObj, index ); }
void addPair( TObjType* inObj, const PxReal x, const PxReal y ) { mAddPairMember( inObj, x, y ); }
void clear( TObjType* inObj ) { mClearMember( inObj ); }
};
template<PxU32 TKey, typename TObjType, typename TCollectionType>
struct PxReadOnlyCollectionPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef PxU32 (*TNbObjectsMember)( const TObjType* );
typedef PxU32 (*TGetObjectsMember)( const TObjType*, TCollectionType*, PxU32 );
TGetObjectsMember mGetObjectsMember;
TNbObjectsMember mNbObjectsMember;
PxReadOnlyCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb )
: PxPropertyInfoParameterizedBase<TKey>( inName )
, mGetObjectsMember( inGetter )
, mNbObjectsMember( inNb )
{
}
PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); }
PxU32 get( const TObjType* inObj, TCollectionType* inBuffer, PxU32 inBufSize ) const { return mGetObjectsMember( inObj, inBuffer, inBufSize); }
};
template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType>
struct PxReadOnlyFilteredCollectionPropertyInfo : public PxPropertyInfoParameterizedBase<TKey>
{
typedef PxU32 (*TNbObjectsMember)( const TObjType*, TFilterType );
typedef PxU32 (*TGetObjectsMember)( const TObjType*, TFilterType, TCollectionType*, PxU32 );
TGetObjectsMember mGetObjectsMember;
TNbObjectsMember mNbObjectsMember;
PxReadOnlyFilteredCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb )
: PxPropertyInfoParameterizedBase<TKey>( inName )
, mGetObjectsMember( inGetter )
, mNbObjectsMember( inNb )
{
}
PxU32 size( const TObjType* inObj, TFilterType inFilter ) const { return mNbObjectsMember( inObj, inFilter ); }
PxU32 get( const TObjType* inObj, TFilterType inFilter, TCollectionType* inBuffer, PxU32 inBufSize ) const { return mGetObjectsMember( inObj, inFilter, inBuffer, inBufSize); }
};
template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TCreateArg>
struct PxFactoryCollectionPropertyInfo : public PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >
{
typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TGetObjectsMember TGetObjectsMember;
typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TNbObjectsMember TNbObjectsMember;
typedef TCollectionType (*TCreateMember)( TObjType*, TCreateArg );
TCreateMember mCreateMember;
PxFactoryCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TCreateMember inMember )
: PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >( inName, inGetter, inNb )
, mCreateMember( inMember )
{
}
TCollectionType create( TObjType* inObj, TCreateArg inArg ) const { return mCreateMember( inObj, inArg ); }
};
template<PxU32 TKey, typename TObjType, typename TCollectionType>
struct PxCollectionPropertyInfo : public PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >
{
typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TGetObjectsMember TGetObjectsMember;
typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TNbObjectsMember TNbObjectsMember;
typedef void (*TAddMember)(TObjType*, TCollectionType&);
typedef void (*TRemoveMember)(TObjType*, TCollectionType&);
TAddMember mAddMember;
TRemoveMember mRemoveMember;
PxCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TAddMember inMember, TRemoveMember inRemoveMember )
: PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >( inName, inGetter, inNb )
, mAddMember( inMember )
, mRemoveMember( inRemoveMember )
{
}
void add( TObjType* inObj, TCollectionType& inArg ) const { mAddMember(inObj, inArg ); }
void remove( TObjType* inObj, TCollectionType& inArg ) const { mRemoveMember( inObj, inArg ); }
};
template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType>
struct PxFilteredCollectionPropertyInfo : public PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType>
{
typedef typename PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TCollectionType, TFilterType >::TGetObjectsMember TGetObjectsMember;
typedef typename PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TCollectionType, TFilterType >::TNbObjectsMember TNbObjectsMember;
typedef void (*TAddMember)(TObjType*, TCollectionType&);
typedef void (*TRemoveMember)(TObjType*, TCollectionType&);
TAddMember mAddMember;
TRemoveMember mRemoveMember;
PxFilteredCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TAddMember inMember, TRemoveMember inRemoveMember )
: PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType>( inName, inGetter, inNb )
, mAddMember( inMember )
, mRemoveMember( inRemoveMember )
{
}
void add( TObjType* inObj, TCollectionType& inArg ) const { mAddMember(inObj, inArg ); }
void remove( TObjType* inObj, TCollectionType& inArg ) const { mRemoveMember( inObj, inArg ); }
};
//create a default info class for when we can't match
//the type correctly.
struct PxUnknownClassInfo
{
static const char* getClassName() { return "__unknown_class"; }
template<typename TReturnType, typename TOperator>
TReturnType visitType( TOperator )
{
return TReturnType();
}
template<typename TOperator>
void visitBases( TOperator )
{
}
template<typename TOperator>
PxU32 visitBaseProperties( TOperator, PxU32 inStartIndex = 0 ) const
{
return inStartIndex;
}
template<typename TOperator>
PxU32 visitInstanceProperties( TOperator, PxU32 inStartIndex = 0 ) const
{
return inStartIndex;
}
};
template<typename TDataType>
struct PxClassInfoTraits
{
PxUnknownClassInfo Info;
static bool getInfo() { return false;}
};
//move the bool typedef to the global namespace.
typedef bool _Bool;
template<PxU32 TPropertyName>
struct PxPropertyToValueStructMemberMap
{
bool Offset;
};
#define DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( type, prop, valueStruct ) \
template<> struct PxPropertyToValueStructMemberMap< PxPropertyInfoName::type##_##prop > \
{ \
PxU32 Offset; \
PxPropertyToValueStructMemberMap< PxPropertyInfoName::type##_##prop >() : Offset( PX_OFFSET_OF_RT( valueStruct, prop ) ) {} \
template<typename TOperator> void visitProp( TOperator inOperator, valueStruct& inStruct ) { inOperator( inStruct.prop ); } \
};
struct PxShapeGeomPropertyHelper
{
PX_PHYSX_CORE_API PxGeometryType::Enum getGeometryType(const PxShape* inShape) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxBoxGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxSphereGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxCapsuleGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxPlaneGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxConvexMeshGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxTetrahedronMeshGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxParticleSystemGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxTriangleMeshGeometry& geometry) const;
PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxHeightFieldGeometry& geometry) const;
};
struct PxShapeGeomProperty : public PxWriteOnlyPropertyInfo< PxPropertyInfoName::PxShape_Geom, PxShape, const PxGeometry & >
, public PxShapeGeomPropertyHelper
{
static void setPxShape_Geom( PxShape* inObj, const PxGeometry& inArg){ inObj->setGeometry( inArg ); }
static PxGeometryHolder getPxShape_Geom( const PxShape* inObj ) { return PxGeometryHolder(inObj->getGeometry()); }
typedef PxWriteOnlyPropertyInfo< PxPropertyInfoName::PxShape_Geom, PxShape, const PxGeometry & >::TSetterType TSetterType;
typedef PxGeometryHolder (*TGetterType)( const PxShape* inObj );
PxShapeGeomProperty( const char* inName="Geometry", TSetterType inSetter=setPxShape_Geom, TGetterType=getPxShape_Geom )
: PxWriteOnlyPropertyInfo< PxPropertyInfoName::PxShape_Geom, PxShape, const PxGeometry & >( inName, inSetter )
{
}
};
struct PxShapeMaterialsPropertyHelper
{
PX_PHYSX_CORE_API void setMaterials(PxShape* inShape, PxMaterial*const* materials, PxU16 materialCount) const;
};
struct PxShapeMaterialsProperty : public PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial*>
, public PxShapeMaterialsPropertyHelper
{
typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial* >::TGetObjectsMember TGetObjectsMember;
typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial* >::TNbObjectsMember TNbObjectsMember;
PxShapeMaterialsProperty( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb )
: PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial*>( inName, inGetter, inNb )
{
}
};
typedef PxPropertyInfo<PxPropertyInfoName::PxRigidActor_GlobalPose, PxRigidActor, const PxTransform &, PxTransform > PxRigidActorGlobalPosePropertyInfo;
struct PxRigidActorShapeCollectionHelper
{
PX_PHYSX_CORE_API PxShape* createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial& material, PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) const;
PX_PHYSX_CORE_API PxShape* createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial *const* materials, PxU16 materialCount, PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) const;
};
struct PxRigidActorShapeCollection : public PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape*>
, public PxRigidActorShapeCollectionHelper
{
typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape* >::TGetObjectsMember TGetObjectsMember;
typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape* >::TNbObjectsMember TNbObjectsMember;
PxRigidActorShapeCollection( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb )
: PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape*>( inName, inGetter, inNb )
{
}
};
struct PxArticulationReducedCoordinateLinkCollectionPropHelper
{
PX_PHYSX_CORE_API PxArticulationLink* createLink(PxArticulationReducedCoordinate* inArticulation, PxArticulationLink* parent, const PxTransform& pose) const;
};
struct PxArticulationLinkCollectionProp : public PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationReducedCoordinate_Links, PxArticulationReducedCoordinate, PxArticulationLink*>
, public PxArticulationReducedCoordinateLinkCollectionPropHelper
{
PxArticulationLinkCollectionProp( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb )
: PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationReducedCoordinate_Links, PxArticulationReducedCoordinate, PxArticulationLink*>( inName, inGetter, inNb )
{
}
};
template<typename TDataType>
struct PxEnumTraits { PxEnumTraits() : NameConversion( false ) {} bool NameConversion; };
struct NbShapesProperty : public PxIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbShapes, PxSimulationStatistics, PxGeometryType::Enum, PxU32>
{
PX_PHYSX_CORE_API NbShapesProperty();
};
struct NbDiscreteContactPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbDiscreteContactPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32>
{
PX_PHYSX_CORE_API NbDiscreteContactPairsProperty();
};
struct NbModifiedContactPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbModifiedContactPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32>
{
PX_PHYSX_CORE_API NbModifiedContactPairsProperty();
};
struct NbCCDPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbCCDPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32>
{
PX_PHYSX_CORE_API NbCCDPairsProperty();
};
struct NbTriggerPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbTriggerPairs
, PxSimulationStatistics
, PxGeometryType::Enum
, PxGeometryType::Enum
, PxU32>
{
PX_PHYSX_CORE_API NbTriggerPairsProperty();
};
struct SimulationStatisticsProperty : public PxReadOnlyPropertyInfo<PxPropertyInfoName::PxScene_SimulationStatistics, PxScene, PxSimulationStatistics>
{
PX_PHYSX_CORE_API SimulationStatisticsProperty();
};
struct PxCustomGeometryCustomTypeProperty : public PxReadOnlyPropertyInfo<PxPropertyInfoName::PxCustomGeometry_CustomType, PxCustomGeometry, PxU32>
{
PX_PHYSX_CORE_API PxCustomGeometryCustomTypeProperty();
};
struct PxMetaDataPlane
{
PxVec3 normal;
PxReal distance;
PxMetaDataPlane( PxVec3 n = PxVec3( 0, 0, 0 ), PxReal d = 0 )
: normal( n )
, distance( d )
{
}
};
#include "PxAutoGeneratedMetaDataObjects.h"
#undef DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP
static PxU32ToName g_physx__PxQueryFlag__EnumConversion[] = {
{ "eSTATIC", static_cast<PxU32>( PxQueryFlag::eSTATIC ) },
{ "eDYNAMIC", static_cast<PxU32>( PxQueryFlag::eDYNAMIC ) },
{ "ePREFILTER", static_cast<PxU32>( PxQueryFlag::ePREFILTER ) },
{ "ePOSTFILTER", static_cast<PxU32>( PxQueryFlag::ePOSTFILTER ) },
{ NULL, 0 }
};
template<> struct PxEnumTraits<PxQueryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxQueryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; };
template<typename TObjType, typename TOperator>
inline PxU32 visitAllProperties( TOperator inOperator )
{
PxU32 thePropCount = PxClassInfoTraits<TObjType>().Info.visitBaseProperties( inOperator );
return PxClassInfoTraits<TObjType>().Info.visitInstanceProperties( inOperator, thePropCount );
}
template<typename TObjType, typename TOperator>
inline void visitInstanceProperties( TOperator inOperator )
{
PxClassInfoTraits<TObjType>().Info.visitInstanceProperties( inOperator, 0 );
}
}
#if PX_LINUX && PX_CLANG
#pragma clang diagnostic pop
#endif
/** @} */
#endif
| 28,256 | C | 40.311403 | 270 | 0.778843 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxMetaDataCompare.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_METADATACOMPARE_H
#define PX_METADATACOMPARE_H
#include "PxMetaDataObjects.h"
#include "foundation/PxInlineArray.h"
//Implement a basic equality comparison system based on the meta data system.
//if you implement a particular areequal specialized to exactly your type
//before including this file it will be called in preference to the completely
//generic one shown here.
//If you don't care about the failure prop name you are welcome to pass in 'null',
template<typename TBaseObjType>
bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName );
//We don't have the ability right now to handle these types.
inline bool areEqual( const PxAggregate&, const PxAggregate& ) { return true; }
inline bool areEqual( const PxSimulationFilterShader&, const PxSimulationFilterShader& ) { return true; }
inline bool areEqual( const PxSimulationFilterCallback&, const PxSimulationFilterCallback& ) { return true; }
inline bool areEqual( const PxConvexMesh&, const PxConvexMesh& ) { return true; }
inline bool areEqual( const PxTriangleMesh&, const PxTriangleMesh& ) { return true; }
inline bool areEqual( const PxTetrahedronMesh&, const PxTetrahedronMesh&) { return true; }
inline bool areEqual( const PxParticleSystemGeometry&, const PxParticleSystemGeometry&) { return true; }
inline bool areEqual( const PxBVH33TriangleMesh&, const PxBVH33TriangleMesh& ) { return true; }
inline bool areEqual( const PxBVH34TriangleMesh&, const PxBVH34TriangleMesh& ) { return true; }
inline bool areEqual( const PxHeightField&, const PxHeightField& ) { return true; }
inline bool areEqual( const void* inLhs, const void* inRhs ) { return inLhs == inRhs; }
inline bool areEqual( void* inLhs, void* inRhs ) { return inLhs == inRhs; }
//Operators are copied, so this object needs to point
//to the important data rather than reference or own it.
template<typename TBaseObjType>
struct EqualityOp
{
bool* mVal;
const TBaseObjType* mLhs;
const TBaseObjType* mRhs;
const char** mFailurePropName;
EqualityOp( bool& inVal, const TBaseObjType& inLhs, const TBaseObjType& inRhs, const char*& inFailurePropName )
: mVal( &inVal )
, mLhs( &inLhs )
, mRhs( &inRhs )
, mFailurePropName( &inFailurePropName )
{
}
bool hasFailed() { return *mVal == false; }
//Ensure failure propagates the result a ways.
void update( bool inResult, const char* inName )
{
*mVal = *mVal && inResult;
if ( hasFailed() )
*mFailurePropName = inName;
}
//ignore any properties pointering back to the scene.
template<PxU32 TKey, typename TObjType>
void operator()( const PxReadOnlyPropertyInfo<TKey, TObjType, PxScene*> & inProp, PxU32 ) {}
template<PxU32 TKey, typename TObjType>
void operator()( const PxReadOnlyPropertyInfo<TKey, TObjType, const PxScene*> & inProp, PxU32 ) {}
//ignore any properties pointering back to the impl.
template<PxU32 TKey, typename TObjType>
void operator()(const PxReadOnlyPropertyInfo<TKey, TObjType, void*> & inProp, PxU32) {}
template<PxU32 TKey, typename TObjType>
void operator()(const PxReadOnlyPropertyInfo<TKey, TObjType, const void*> & inProp, PxU32) {}
//ignore all of these properties because they just point back to the 'this' object and cause
//a stack overflow.
//Children is unnecessary and articulation points back to the source.
void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationLink_Children, PxArticulationLink, PxArticulationLink* >& inProp, PxU32 ) {}
void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Constraints, PxRigidActor, PxConstraint* >& inProp, PxU32 ){}
void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxAggregate_Actors, PxAggregate, PxActor* >& inProp, PxU32 ) {}
template<PxU32 TKey, typename TObjType, typename TGetPropType>
void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TGetPropType> & inProp, PxU32 )
{
}
template<PxU32 TKey, typename TObjType, typename TGetPropType>
void operator()( const PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType> & inProp, PxU32 )
{
if ( hasFailed() )
return;
TGetPropType lhs( inProp.get( mLhs ) );
TGetPropType rhs( inProp.get( mRhs ) );
update( areEqual( lhs, rhs, NULL ), inProp.mName );
}
template<PxU32 TKey, typename TObjType, typename TPropType>
void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropType> & inProp, PxU32 )
{
if ( hasFailed() )
return;
TPropType lhsl, lhsr, rhsl, rhsr;
inProp.get( mLhs, lhsl, lhsr );
inProp.get( mRhs, rhsl, rhsr );
update( areEqual( lhsl, rhsl, NULL ), inProp.mName );
update( areEqual( lhsr, rhsr, NULL ), inProp.mName );
}
//Indexed properties where we don't know the range of index types are ignored
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropType>
void compareIndex( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropType> &, bool ) {}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropType>
void compareIndex( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropType> &inProp, const PxU32ToName* inNames )
{
for ( const PxU32ToName* theName = inNames;
theName->mName != NULL && !hasFailed();
++theName )
{
TIndexType theIndex( static_cast<TIndexType>( theName->mValue ) );
update( areEqual( inProp.get( mLhs, theIndex ), inProp.get( mRhs, theIndex ), NULL ), inProp.mName );
}
}
template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropType>
void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropType> & inProp, PxU32 )
{
if ( hasFailed() )
return;
compareIndex( inProp, PxEnumTraits<TIndexType>().NameConversion );
}
template<PxU32 TKey, typename TObjType, typename TCollectionType>
void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType> & inProp, PxU32 )
{
if ( hasFailed() )
return;
physx::PxInlineArray<TCollectionType, 20> lhsArray;
physx::PxInlineArray<TCollectionType, 20> rhsArray;
PxU32 size = inProp.size( mLhs );
if ( size != inProp.size( mRhs ) )
update( false, inProp.mName );
else
{
lhsArray.resize( size );
rhsArray.resize( size );
inProp.get( mLhs, lhsArray.begin(), size );
inProp.get( mRhs, rhsArray.begin(), size );
for ( PxU32 idx =0; idx < size && !hasFailed(); ++idx )
update( areEqual( lhsArray[idx], rhsArray[idx], NULL ), inProp.mName );
}
}
//Filtered collections where we can't know the range of filter values are ignored.
template<PxU32 TKey, typename TObjType, typename TFilterType, typename TCollectionType>
void compare( const PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TFilterType, TCollectionType >&, bool ) {}
template<PxU32 TKey, typename TObjType, typename TFilterType, typename TCollectionType>
void compare( const PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TFilterType, TCollectionType >& inProp, const PxU32ToName* inNames )
{
//Exaustively compare all items.
physx::PxInlineArray<TCollectionType*, 20> lhsArray;
physx::PxInlineArray<TCollectionType*, 20> rhsArray;
for ( const PxU32ToName* theName = inNames;
theName->mName != NULL && !hasFailed();
++theName )
{
TFilterType theFilter( static_cast<TFilterType>( theName->mValue ) );
PxU32 size = inProp.size( mLhs, theFilter );
if ( size != inProp.size( mRhs, theFilter ) )
update( false, inProp.mName );
else
{
lhsArray.resize( size );
rhsArray.resize( size );
inProp.get( mLhs, theFilter, lhsArray.begin(), size );
inProp.get( mRhs, theFilter, rhsArray.begin(), size );
for ( PxU32 idx =0; idx < size && !hasFailed(); ++idx )
update( areEqual( lhsArray[idx], rhsArray[idx], NULL ), inProp.mName );
}
}
}
template<PxU32 TKey, typename TObjType, typename TFilterType, typename TCollectionType>
void operator()( const PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TFilterType, TCollectionType >& inProp, PxU32 )
{
if ( hasFailed() ) return;
compare( inProp, PxEnumTraits<TFilterType>().NameConversion );
}
template<typename TGeometryType, typename TPropertyType>
void compareGeometry( const TPropertyType& inProp )
{
TGeometryType lhs;
TGeometryType rhs;
bool lsuc = inProp.getGeometry( mLhs, lhs );
bool rsuc = inProp.getGeometry( mRhs, rhs );
if ( !( lsuc && rsuc ) )
update( false, inProp.mName );
else
update( areEqual( lhs, rhs, NULL ), inProp.mName );
}
void operator()( const PxShapeGeomProperty& inProp, PxU32 )
{
if ( hasFailed() )
return;
PxGeometryType::Enum lhsType( inProp.getGeometryType( mLhs ) );
PxGeometryType::Enum rhsType( inProp.getGeometryType( mRhs ) );
if ( lhsType != rhsType )
update( false, inProp.mName );
else
{
switch( lhsType )
{
case PxGeometryType::eSPHERE: compareGeometry<PxSphereGeometry>(inProp); break;
case PxGeometryType::ePLANE: compareGeometry<PxPlaneGeometry>(inProp); break;
case PxGeometryType::eCAPSULE: compareGeometry<PxCapsuleGeometry>(inProp); break;
case PxGeometryType::eBOX: compareGeometry<PxBoxGeometry>(inProp); break;
case PxGeometryType::eCONVEXMESH: compareGeometry<PxConvexMeshGeometry>(inProp); break;
case PxGeometryType::eTETRAHEDRONMESH: compareGeometry<PxTetrahedronMeshGeometry>(inProp); break;
case PxGeometryType::ePARTICLESYSTEM: compareGeometry<PxParticleSystemGeometry>(inProp); break;
case PxGeometryType::eTRIANGLEMESH: compareGeometry<PxTriangleMeshGeometry>(inProp); break;
case PxGeometryType::eHEIGHTFIELD: compareGeometry<PxHeightFieldGeometry>(inProp); break;
default: PX_ASSERT( false ); break;
}
}
}
};
inline bool areEqual( const char* lhs, const char* rhs, const char**, const PxUnknownClassInfo& )
{
if ( lhs && rhs ) return Pxstrcmp( lhs, rhs ) == 0;
if ( lhs || rhs ) return false;
return true;
}
inline bool areEqual( PxReal inLhs, PxReal inRhs )
{
return PxAbs( inLhs - inRhs ) < 1e-5f;
}
inline bool areEqual( PxVec3& lhs, PxVec3& rhs )
{
return areEqual( lhs.x, rhs.x )
&& areEqual( lhs.y, rhs.y )
&& areEqual( lhs.z, rhs.z );
}
inline bool areEqual( const PxVec3& lhs, const PxVec3& rhs )
{
return areEqual( lhs.x, rhs.x )
&& areEqual( lhs.y, rhs.y )
&& areEqual( lhs.z, rhs.z );
}
inline bool areEqual( const PxVec4& lhs, const PxVec4& rhs )
{
return areEqual( lhs.x, rhs.x )
&& areEqual( lhs.y, rhs.y )
&& areEqual( lhs.z, rhs.z )
&& areEqual( lhs.w, rhs.w );
}
inline bool areEqual( const PxQuat& lhs, const PxQuat& rhs )
{
return areEqual( lhs.x, rhs.x )
&& areEqual( lhs.y, rhs.y )
&& areEqual( lhs.z, rhs.z )
&& areEqual( lhs.w, rhs.w );
}
inline bool areEqual( const PxTransform& lhs, const PxTransform& rhs )
{
return areEqual(lhs.p, rhs.p) && areEqual(lhs.q, rhs.q);
}
inline bool areEqual( const PxBounds3& inLhs, const PxBounds3& inRhs )
{
return areEqual(inLhs.minimum,inRhs.minimum)
&& areEqual(inLhs.maximum,inRhs.maximum);
}
inline bool areEqual( const PxMetaDataPlane& lhs, const PxMetaDataPlane& rhs )
{
return areEqual( lhs.normal.x, rhs.normal.x )
&& areEqual( lhs.normal.y, rhs.normal.y )
&& areEqual( lhs.normal.z, rhs.normal.z )
&& areEqual( lhs.distance, rhs.distance );
}
template<typename TBaseObjType>
inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs )
{
return lhs == rhs;
}
//If we don't know the class type, we must result in == operator
template<typename TBaseObjType>
inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char**, const PxUnknownClassInfo& )
{
return areEqual( lhs, rhs );
}
//If we don't know the class type, we must result in == operator
template<typename TBaseObjType, typename TTraitsType>
inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName, const TTraitsType& )
{
const char* theFailureName = NULL;
bool result = true;
static int i = 0;
++i;
visitAllProperties<TBaseObjType>( EqualityOp<TBaseObjType>( result, lhs, rhs, theFailureName ) );
if ( outFailurePropName != NULL && theFailureName )
*outFailurePropName = theFailureName;
return result;
}
template<typename TBaseObjType>
inline bool areEqualPointerCheck( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName, int )
{
return areEqual( lhs, rhs, outFailurePropName, PxClassInfoTraits<TBaseObjType>().Info );
}
inline bool areEqualPointerCheck( const void* lhs, const void* rhs, const char**, bool )
{
return lhs == rhs;
}
inline bool areEqualPointerCheck( const char* lhs, const char* rhs, const char** outFailurePropName, bool )
{
bool bRet = true;
if ( lhs && rhs ) bRet = Pxstrcmp( lhs, rhs ) == 0;
else if ( lhs || rhs ) bRet = false;
return bRet;
}
inline bool areEqualPointerCheck( void* lhs, void* rhs, const char**, bool )
{
return lhs == rhs;
}
template<typename TBaseObjType>
inline bool areEqualPointerCheck( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName, bool )
{
if ( lhs && rhs )
return areEqual( *lhs, *rhs, outFailurePropName );
if ( lhs || rhs )
return false;
return true;
}
template < typename Tp >
struct is_pointer { static const int val = 0; };
template < typename Tp >
struct is_pointer<Tp*> { static const bool val = true; };
template<typename TBaseObjType>
inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName )
{
return areEqualPointerCheck( lhs, rhs, outFailurePropName, is_pointer<TBaseObjType>::val );
}
#endif | 15,297 | C | 37.631313 | 167 | 0.732562 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PvdMetaDataDefineProperties.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PVD_META_DATA_DEFINE_PROPERTIES_H
#define PVD_META_DATA_DEFINE_PROPERTIES_H
#if PX_SUPPORT_PVD
#include "common/PxCoreUtilityTypes.h"
#include "PvdMetaDataPropertyVisitor.h"
#include "PxPvdDataStreamHelpers.h"
#include "PxPvdDataStream.h"
namespace physx
{
namespace Vd
{
using namespace physx::pvdsdk;
template<typename TPropType>
struct PropertyDefinitionOp
{
void defineProperty( PvdPropertyDefinitionHelper& mHelper, NamespacedName mClassKey )
{
mHelper.createProperty( mClassKey, "", getPvdNamespacedNameForType<TPropType>(), PropertyType::Scalar );
}
};
template<>
struct PropertyDefinitionOp<const char*>
{
void defineProperty( PvdPropertyDefinitionHelper& mHelper, NamespacedName mClassKey )
{
mHelper.createProperty( mClassKey, "", getPvdNamespacedNameForType<StringHandle>(), PropertyType::Scalar );
}
};
#define DEFINE_PROPERTY_DEFINITION_OP_NOP( type ) \
template<> struct PropertyDefinitionOp<type> { void defineProperty( PvdPropertyDefinitionHelper&, NamespacedName ){} };
//NOP out these two types.
DEFINE_PROPERTY_DEFINITION_OP_NOP( PxStridedData )
DEFINE_PROPERTY_DEFINITION_OP_NOP( PxBoundedData )
#define DEFINE_PROPERTY_DEFINITION_OBJECT_REF( type ) \
template<> struct PropertyDefinitionOp<type> { \
void defineProperty( PvdPropertyDefinitionHelper& mHelper, NamespacedName mClassKey) \
{ \
mHelper.createProperty( mClassKey, "", getPvdNamespacedNameForType<ObjectRef>(), PropertyType::Scalar ); \
} \
};
DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxTetrahedronMesh* )
DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxTriangleMesh* )
DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxBVH33TriangleMesh* )
DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxBVH34TriangleMesh* )
DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxConvexMesh* )
DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxHeightField* )
struct PvdClassInfoDefine
{
PvdPropertyDefinitionHelper& mHelper;
NamespacedName mClassKey;
PvdClassInfoDefine( PvdPropertyDefinitionHelper& info, NamespacedName inClassName )
: mHelper( info )
, mClassKey( inClassName ) { }
PvdClassInfoDefine( const PvdClassInfoDefine& other )
: mHelper( other.mHelper )
, mClassKey( other.mClassKey )
{
}
void defineProperty( NamespacedName inDtype, const char* semantic = "", PropertyType::Enum inPType = PropertyType::Scalar )
{
mHelper.createProperty( mClassKey, semantic, inDtype, inPType );
}
void pushName( const char* inName )
{
mHelper.pushName( inName );
}
void pushBracketedName( const char* inName)
{
mHelper.pushBracketedName( inName );
}
void popName()
{
mHelper.popName();
}
inline void defineNameValueDefs( const PxU32ToName* theConversions )
{
while( theConversions->mName != NULL )
{
mHelper.addNamedValue( theConversions->mName, theConversions->mValue );
++theConversions;
}
}
template<typename TAccessorType>
void simpleProperty( PxU32, TAccessorType& /*inProp */)
{
typedef typename TAccessorType::prop_type TPropertyType;
PropertyDefinitionOp<TPropertyType>().defineProperty( mHelper, mClassKey );
}
template<typename TAccessorType, typename TInfoType>
void extendedIndexedProperty( PxU32* key, const TAccessorType& inProp, TInfoType& )
{
simpleProperty(*key, inProp);
}
template<typename TDataType>
static NamespacedName getNameForEnumType()
{
size_t s = sizeof( TDataType );
switch(s)
{
case 1: return getPvdNamespacedNameForType<PxU8>();
case 2: return getPvdNamespacedNameForType<PxU16>();
case 4: return getPvdNamespacedNameForType<PxU32>();
default: return getPvdNamespacedNameForType<PxU64>();
}
}
template<typename TAccessorType>
void enumProperty( PxU32 /*key*/, TAccessorType& /*inProp*/, const PxU32ToName* inConversions )
{
typedef typename TAccessorType::prop_type TPropType;
defineNameValueDefs( inConversions );
defineProperty( getNameForEnumType<TPropType>(), "Enumeration Value" );
}
template<typename TAccessorType>
void flagsProperty( PxU32 /*key*/, const TAccessorType& /*inAccessor*/, const PxU32ToName* inConversions )
{
typedef typename TAccessorType::prop_type TPropType;
defineNameValueDefs( inConversions );
defineProperty( getNameForEnumType<TPropType>(), "Bitflag" );
}
template<typename TAccessorType, typename TInfoType>
void complexProperty( PxU32* key, const TAccessorType& inAccessor, TInfoType& inInfo )
{
PxU32 theOffset = inAccessor.mOffset;
inInfo.visitBaseProperties( makePvdPropertyFilter( *this, key, &theOffset ) );
inInfo.visitInstanceProperties( makePvdPropertyFilter( *this, key, &theOffset ) );
}
template<typename TAccessorType, typename TInfoType>
void bufferCollectionProperty( PxU32* key, const TAccessorType& inAccessor, TInfoType& inInfo )
{
complexProperty(key, inAccessor, inInfo);
}
template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag>
void handleBuffer( const PxBufferPropertyInfo<TKey, TObjectType, const PxArray< TPropertyType >&, TEnableFlag>& inProp )
{
mHelper.pushName( inProp.mName );
defineProperty( getPvdNamespacedNameForType<TPropertyType>(), "", PropertyType::Array );
mHelper.popName();
}
template<PxU32 TKey, typename TObjectType, typename TCollectionType>
void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TCollectionType>& inProp )
{
mHelper.pushName( inProp.mName );
defineProperty( getPvdNamespacedNameForType<TCollectionType>(), "", PropertyType::Array );
mHelper.popName();
}
template<PxU32 TKey, typename TObjectType, typename TEnumType>
void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TEnumType>& inProp, const PxU32ToName* inConversions )
{
mHelper.pushName( inProp.mName );
defineNameValueDefs( inConversions );
defineProperty( getNameForEnumType<TEnumType>(), "Enumeration Value", PropertyType::Array );
mHelper.popName();
}
private:
PvdClassInfoDefine& operator=(const PvdClassInfoDefine&);
};
template<typename TPropType>
struct SimplePropertyValueStructOp
{
void addPropertyMessageArg( PvdPropertyDefinitionHelper& mHelper, PxU32 inOffset )
{
mHelper.addPropertyMessageArg<TPropType>( inOffset );
}
};
#define DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_OP_NOP( type ) \
template<> struct SimplePropertyValueStructOp<type> { void addPropertyMessageArg( PvdPropertyDefinitionHelper&, PxU32 ){}};
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_OP_NOP( PxStridedData )
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_OP_NOP( PxBoundedData )
#define DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( type ) \
template<> struct SimplePropertyValueStructOp<type> { \
void addPropertyMessageArg( PvdPropertyDefinitionHelper& mHelper, PxU32 inOffset ) \
{ \
mHelper.addPropertyMessageArg<VoidPtr>( inOffset ); \
} \
};
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxTetrahedronMesh* )
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxTriangleMesh* )
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxBVH33TriangleMesh* )
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxBVH34TriangleMesh* )
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxConvexMesh* )
DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxHeightField* )
struct PvdClassInfoValueStructDefine
{
private:
PvdClassInfoValueStructDefine& operator=(const PvdClassInfoValueStructDefine&);
public:
PvdPropertyDefinitionHelper& mHelper;
PvdClassInfoValueStructDefine( PvdPropertyDefinitionHelper& info )
: mHelper( info )
{ }
PvdClassInfoValueStructDefine( const PvdClassInfoValueStructDefine& other )
: mHelper( other.mHelper )
{
}
void defineValueStructOffset( const ValueStructOffsetRecord& inProp, PxU32 inPropSize )
{
if( inProp.mHasValidOffset )
{
switch( inPropSize )
{
case 8: mHelper.addPropertyMessageArg<PxU64>( inProp.mOffset ); break;
case 4: mHelper.addPropertyMessageArg<PxU32>( inProp.mOffset ); break;
case 2: mHelper.addPropertyMessageArg<PxU16>( inProp.mOffset ); break;
default:
PX_ASSERT(1 == inPropSize);
mHelper.addPropertyMessageArg<PxU8>( inProp.mOffset ); break;
}
}
}
void pushName( const char* inName )
{
mHelper.pushName( inName );
}
void pushBracketedName( const char* inName)
{
mHelper.pushBracketedName( inName );
}
void popName()
{
mHelper.popName();
}
template<typename TAccessorType, typename TInfoType>
void bufferCollectionProperty( PxU32* /*key*/, const TAccessorType& /*inAccessor*/, TInfoType& /*inInfo*/ )
{
//complexProperty(key, inAccessor, inInfo);
}
template<typename TAccessorType>
void simpleProperty( PxU32 /*key*/, TAccessorType& inProp )
{
typedef typename TAccessorType::prop_type TPropertyType;
if ( inProp.mHasValidOffset )
{
SimplePropertyValueStructOp<TPropertyType>().addPropertyMessageArg( mHelper, inProp.mOffset );
}
}
template<typename TAccessorType>
void enumProperty( PxU32 /*key*/, TAccessorType& inAccessor, const PxU32ToName* /*inConversions */)
{
typedef typename TAccessorType::prop_type TPropType;
defineValueStructOffset( inAccessor, sizeof( TPropType ) );
}
template<typename TAccessorType>
void flagsProperty( PxU32 /*key*/, const TAccessorType& inAccessor, const PxU32ToName* /*inConversions */)
{
typedef typename TAccessorType::prop_type TPropType;
defineValueStructOffset( inAccessor, sizeof( TPropType ) );
}
template<typename TAccessorType, typename TInfoType>
void complexProperty( PxU32* key, const TAccessorType& inAccessor, TInfoType& inInfo )
{
PxU32 theOffset = inAccessor.mOffset;
inInfo.visitBaseProperties( makePvdPropertyFilter( *this, key, &theOffset ) );
inInfo.visitInstanceProperties( makePvdPropertyFilter( *this, key, &theOffset ) );
}
template<PxU32 TKey, typename TObjectType, typename TCollectionType>
void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TCollectionType>& /*prop*/ )
{
}
template<PxU32 TKey, typename TObjectType, typename TEnumType>
void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TEnumType>& /*prop*/, const PxU32ToName* /*inConversions */)
{
}
template<PxU32 TKey, typename TObjectType, typename TInfoType>
void handleCollection( const PxBufferCollectionPropertyInfo<TKey, TObjectType, TInfoType>& /*prop*/, const TInfoType& /*inInfo */)
{
}
};
}
}
#endif
#endif
| 12,100 | C | 33.280453 | 142 | 0.759256 |
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PvdMetaDataExtensions.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_META_DATA_EXTENSIONS_H
#define PX_META_DATA_EXTENSIONS_H
#include "PxMetaDataObjects.h"
#if PX_SUPPORT_PVD
#include "PxPvdObjectModelBaseTypes.h"
namespace physx { namespace pvdsdk {
template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxMetaDataPlane>() { return getPvdNamespacedNameForType<PxVec4>(); }
template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxRigidActor*>() { return getPvdNamespacedNameForType<VoidPtr>(); }
}}
#endif
namespace physx
{
namespace Vd
{
//Additional properties that exist only in pvd land.
struct PxPvdOnlyProperties
{
enum Enum
{
FirstProp = PxPropertyInfoName::LastPxPropertyInfoName,
PxScene_Frame,
PxScene_Contacts,
PxScene_SimulateElapsedTime,
#define DEFINE_ENUM_RANGE( stem, count ) \
stem##Begin, \
stem##End = stem##Begin + count
//I can't easily add up the number of required property entries, but it is large due to the below
//geometry count squared properties. Thus I punt and allocate way more than I need right now.
DEFINE_ENUM_RANGE( PxScene_SimulationStatistics, 1000 ),
DEFINE_ENUM_RANGE( PxSceneDesc_Limits, PxPropertyInfoName::PxSceneLimits_PropertiesStop - PxPropertyInfoName::PxSceneLimits_PropertiesStart ),
DEFINE_ENUM_RANGE( PxSimulationStatistics_NumShapes, PxGeometryType::eGEOMETRY_COUNT ),
DEFINE_ENUM_RANGE( PxSimulationStatistics_NumDiscreteContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
DEFINE_ENUM_RANGE( PxSimulationStatistics_NumModifiedContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
DEFINE_ENUM_RANGE( PxSimulationStatistics_NumSweptIntegrationPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
DEFINE_ENUM_RANGE( PxSimulationStatistics_NumTriggerPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ),
DEFINE_ENUM_RANGE( PxRigidDynamic_SolverIterationCounts, 2 ),
DEFINE_ENUM_RANGE( PxArticulation_SolverIterationCounts, 2 ),
DEFINE_ENUM_RANGE( PxArticulationJoint_SwingLimit, 2 ),
DEFINE_ENUM_RANGE( PxArticulationJoint_TwistLimit, 2 ),
DEFINE_ENUM_RANGE( PxConvexMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ),
DEFINE_ENUM_RANGE( PxTriangleMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ),
LastPxPvdOnlyProperty
};
};
template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag>
struct PxBufferPropertyInfo : PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType >
{
typedef PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType > TBaseType;
typedef typename TBaseType::TGetterType TGetterType;
PxBufferPropertyInfo( const char* inName, TGetterType inGetter )
: TBaseType( inName, inGetter )
{
}
bool isEnabled( PxU32 inFlags ) const { return (inFlags & TEnableFlag) > 0; }
};
#define DECLARE_BUFFER_PROPERTY( objectType, baseType, propType, propName, fieldName, flagName ) \
typedef PxBufferPropertyInfo< PxPvdOnlyProperties::baseType##_##propName, objectType, propType, flagName > T##objectType##propName##Base; \
inline propType get##propName( const objectType* inData ) { return inData->fieldName; } \
struct baseType##propName##Property : T##objectType##propName##Base \
{ \
baseType##propName##Property() : T##objectType##propName##Base( #propName, get##propName ){} \
};
template<PxU32 PropertyKey, typename TEnumType >
struct IndexerToNameMap
{
PxEnumTraits<TEnumType> Converter;
};
struct ValueStructOffsetRecord
{
mutable bool mHasValidOffset;
mutable PxU32 mOffset;
ValueStructOffsetRecord() : mHasValidOffset( false ), mOffset( 0 ) {}
void setupValueStructOffset( PxU32 inValue ) const
{
mHasValidOffset = true;
mOffset = inValue;
}
};
template<PxU32 TKey, typename TObjectType, typename TPropertyType>
struct PxPvdReadOnlyPropertyAccessor : public ValueStructOffsetRecord
{
typedef PxReadOnlyPropertyInfo<TKey,TObjectType,TPropertyType> TPropertyInfoType;
typedef TPropertyType prop_type;
const TPropertyInfoType mProperty;
PxPvdReadOnlyPropertyAccessor( const TPropertyInfoType& inProp )
: mProperty( inProp )
{
}
prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); }
private:
PxPvdReadOnlyPropertyAccessor& operator=(const PxPvdReadOnlyPropertyAccessor&);
};
template<PxU32 TKey, typename TObjectType, typename TPropertyType>
struct PxBufferCollectionPropertyAccessor : public ValueStructOffsetRecord
{
typedef PxBufferCollectionPropertyInfo< TKey, TObjectType, TPropertyType > TPropertyInfoType;
typedef TPropertyType prop_type;
const TPropertyInfoType& mProperty;
const char* mName;
PxBufferCollectionPropertyAccessor( const TPropertyInfoType& inProp, const char* inName )
: mProperty( inProp )
, mName( inName )
{
}
const char* name() const { return mName; }
PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
PxU32 get( const TObjectType* inObj, prop_type* buffer, PxU32 inNumItems) const { return mProperty.get( inObj, buffer, inNumItems); }
void set( TObjectType* inObj, prop_type* inBuffer, PxU32 inNumItems ) const { mProperty.set( inObj, inBuffer, inNumItems ); }
};
template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
struct PxPvdIndexedPropertyAccessor : public ValueStructOffsetRecord
{
typedef PxIndexedPropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType;
typedef TPropertyType prop_type;
TIndexType mIndex;
const TPropertyInfoType& mProperty;
PxPvdIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex )
: mIndex( static_cast<TIndexType>( inIndex ) )
, mProperty( inProp )
{
}
prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIndex ); }
void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIndex, val ); }
void operator = (PxPvdIndexedPropertyAccessor&) {}
};
template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
struct PxPvdExtendedIndexedPropertyAccessor : public ValueStructOffsetRecord
{
typedef PxExtendedIndexedPropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType;
typedef TPropertyType prop_type;
TIndexType mIndex;
const TPropertyInfoType& mProperty;
PxPvdExtendedIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex )
: mIndex( static_cast<TIndexType>( inIndex ) )
, mProperty( inProp )
{
}
PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
prop_type get( const TObjectType* inObj, TIndexType index ) const { return mProperty.get( inObj, index ); }
void set( TObjectType* inObj, TIndexType index, prop_type val ) const { mProperty.set( inObj, index, val ); }
void operator = (PxPvdExtendedIndexedPropertyAccessor&) {}
};
template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType>
struct PxPvdFixedSizeLookupTablePropertyAccessor : public ValueStructOffsetRecord
{
typedef PxFixedSizeLookupTablePropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType;
typedef TPropertyType prop_type;
TIndexType mIndex;
const TPropertyInfoType& mProperty;
PxPvdFixedSizeLookupTablePropertyAccessor( const TPropertyInfoType& inProp, const PxU32 inIndex3 )
: mIndex( static_cast<TIndexType>( inIndex3 ) )
, mProperty( inProp )
{
}
PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); }
prop_type getX( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getX( inObj, index ); }
prop_type getY( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getY( inObj, index ); }
void addPair( TObjectType* inObj, const PxReal x, const PxReal y ) { const_cast<TPropertyInfoType&>(mProperty).addPair( inObj, x, y ); }
void clear( TObjectType* inObj ) { const_cast<TPropertyInfoType&>(mProperty).clear( inObj ); }
void operator = (PxPvdFixedSizeLookupTablePropertyAccessor&) {}
};
template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType>
struct PxPvdDualIndexedPropertyAccessor : public ValueStructOffsetRecord
{
typedef PxDualIndexedPropertyInfo< TKey, TObjectType, TIdx0Type, TIdx1Type, TPropertyType > TPropertyInfoType;
typedef TPropertyType prop_type;
TIdx0Type mIdx0;
TIdx1Type mIdx1;
const TPropertyInfoType& mProperty;
PxPvdDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 )
: mIdx0( static_cast<TIdx0Type>( idx0 ) )
, mIdx1( static_cast<TIdx1Type>( idx1 ) )
, mProperty( inProp )
{
}
prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); }
void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); }
private:
PxPvdDualIndexedPropertyAccessor& operator = (const PxPvdDualIndexedPropertyAccessor&);
};
template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType>
struct PxPvdExtendedDualIndexedPropertyAccessor : public ValueStructOffsetRecord
{
typedef PxExtendedDualIndexedPropertyInfo< TKey, TObjectType, TIdx0Type, TIdx1Type, TPropertyType > TPropertyInfoType;
typedef TPropertyType prop_type;
TIdx0Type mIdx0;
TIdx1Type mIdx1;
const TPropertyInfoType& mProperty;
PxPvdExtendedDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 )
: mIdx0( static_cast<TIdx0Type>( idx0 ) )
, mIdx1( static_cast<TIdx1Type>( idx1 ) )
, mProperty( inProp )
{
}
prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); }
void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); }
private:
PxPvdExtendedDualIndexedPropertyAccessor& operator = (const PxPvdExtendedDualIndexedPropertyAccessor&);
};
template<PxU32 TKey, typename TObjType, typename TPropertyType>
struct PxPvdRangePropertyAccessor : public ValueStructOffsetRecord
{
typedef PxRangePropertyInfo<TKey, TObjType, TPropertyType> TPropertyInfoType;
typedef TPropertyType prop_type;
bool mFirstValue;
const TPropertyInfoType& mProperty;
PxPvdRangePropertyAccessor( const TPropertyInfoType& inProp, bool inFirstValue )
: mFirstValue( inFirstValue )
, mProperty( inProp )
{
}
prop_type get( const TObjType* inObj ) const {
prop_type first,second;
mProperty.get( inObj, first, second );
return mFirstValue ? first : second;
}
void set( TObjType* inObj, prop_type val ) const
{
prop_type first,second;
mProperty.get( inObj, first, second );
if ( mFirstValue ) mProperty.set( inObj, val, second );
else mProperty.set( inObj, first, val );
}
void operator = (PxPvdRangePropertyAccessor&) {}
};
template<typename TDataType>
struct IsFlagsType
{
bool FlagData;
};
template<typename TEnumType, typename TStorageType>
struct IsFlagsType<PxFlags<TEnumType, TStorageType> >
{
const PxU32ToName* FlagData;
IsFlagsType<PxFlags<TEnumType, TStorageType> > () : FlagData( PxEnumTraits<TEnumType>().NameConversion ) {}
};
template<typename TDataType>
struct PvdClassForType
{
bool Unknown;
};
}
}
#endif
| 13,059 | C | 40.069182 | 150 | 0.773643 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelMetaData.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#include "PxPvdObjectModelInternalTypes.h"
#include "PxPvdObjectModelMetaData.h"
#include "PxPvdInternalByteStreams.h"
#include "PxPvdMarshalling.h"
using namespace physx;
using namespace pvdsdk;
namespace
{
struct PropDescImpl : public PropertyDescription, public PxUserAllocated
{
PxArray<NamedValue> mValueNames;
PropDescImpl(const PropertyDescription& inBase, StringTable& table)
: PropertyDescription(inBase), mValueNames("NamedValue")
{
mName = table.registerStr(mName);
}
PropDescImpl() : mValueNames("NamedValue")
{
}
template <typename TSerializer>
void serialize(TSerializer& serializer)
{
serializer.streamify(mOwnerClassName);
serializer.streamify(mOwnerClassId);
serializer.streamify(mSemantic);
serializer.streamify(mDatatype);
serializer.streamify(mDatatypeName);
serializer.streamify(mPropertyType);
serializer.streamify(mPropertyId);
serializer.streamify(m32BitOffset);
serializer.streamify(m64BitOffset);
serializer.streamify(mValueNames);
serializer.streamify(mName);
}
};
struct ClassDescImpl : public ClassDescription, public PxUserAllocated
{
PxArray<PropDescImpl*> mPropImps;
PxArray<PtrOffset> m32OffsetArray;
PxArray<PtrOffset> m64OffsetArray;
ClassDescImpl(const ClassDescription& inBase)
: ClassDescription(inBase)
, mPropImps("PropDescImpl*")
, m32OffsetArray("ClassDescImpl::m32OffsetArray")
, m64OffsetArray("ClassDescImpl::m64OffsetArray")
{
PVD_FOREACH(idx, get32BitSizeInfo().mPtrOffsets.size())
m32OffsetArray.pushBack(get32BitSizeInfo().mPtrOffsets[idx]);
PVD_FOREACH(idx, get64BitSizeInfo().mPtrOffsets.size())
m64OffsetArray.pushBack(get64BitSizeInfo().mPtrOffsets[idx]);
}
ClassDescImpl()
: mPropImps("PropDescImpl*")
, m32OffsetArray("ClassDescImpl::m32OffsetArray")
, m64OffsetArray("ClassDescImpl::m64OffsetArray")
{
}
PropDescImpl* findProperty(String name)
{
PVD_FOREACH(idx, mPropImps.size())
{
if(safeStrEq(mPropImps[idx]->mName, name))
return mPropImps[idx];
}
return NULL;
}
void addProperty(PropDescImpl* prop)
{
mPropImps.pushBack(prop);
}
void addPtrOffset(PtrOffsetType::Enum type, uint32_t offset32, uint32_t offset64)
{
m32OffsetArray.pushBack(PtrOffset(type, offset32));
m64OffsetArray.pushBack(PtrOffset(type, offset64));
get32BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m32OffsetArray.begin(), m32OffsetArray.end());
get64BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m64OffsetArray.begin(), m64OffsetArray.end());
}
template <typename TSerializer>
void serialize(TSerializer& serializer)
{
serializer.streamify(mName);
serializer.streamify(mClassId);
serializer.streamify(mBaseClass);
serializer.streamify(mPackedUniformWidth);
serializer.streamify(mPackedClassType);
serializer.streamify(mLocked);
serializer.streamify(mRequiresDestruction);
serializer.streamify(get32BitSize());
serializer.streamify(get32BitSizeInfo().mDataByteSize);
serializer.streamify(get32BitSizeInfo().mAlignment);
serializer.streamify(get64BitSize());
serializer.streamify(get64BitSizeInfo().mDataByteSize);
serializer.streamify(get64BitSizeInfo().mAlignment);
serializer.streamifyLinks(mPropImps);
serializer.streamify(m32OffsetArray);
serializer.streamify(m64OffsetArray);
get32BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m32OffsetArray.begin(), m32OffsetArray.end());
get64BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m64OffsetArray.begin(), m64OffsetArray.end());
}
};
class StringTableImpl : public StringTable, public PxUserAllocated
{
PxHashMap<const char*, char*> mStrings;
uint32_t mNextStrHandle;
PxHashMap<uint32_t, char*> mHandleToStr;
PxHashMap<const char*, uint32_t> mStrToHandle;
public:
StringTableImpl()
: mStrings("StringTableImpl::mStrings")
, mNextStrHandle(1)
, mHandleToStr("StringTableImpl::mHandleToStr")
, mStrToHandle("StringTableImpl::mStrToHandle")
{
}
uint32_t nextHandleValue()
{
return mNextStrHandle++;
}
virtual ~StringTableImpl()
{
for(PxHashMap<const char*, char*>::Iterator iter = mStrings.getIterator(); !iter.done(); ++iter)
PX_FREE(iter->second);
mStrings.clear();
}
virtual uint32_t getNbStrs()
{
return mStrings.size();
}
virtual uint32_t getStrs(const char** outStrs, uint32_t bufLen, uint32_t startIdx = 0)
{
startIdx = PxMin(getNbStrs(), startIdx);
uint32_t numStrs(PxMin(getNbStrs() - startIdx, bufLen));
PxHashMap<const char*, char*>::Iterator iter(mStrings.getIterator());
for(uint32_t idx = 0; idx < startIdx; ++idx, ++iter)
;
for(uint32_t idx = 0; idx < numStrs && !iter.done(); ++idx, ++iter)
outStrs[idx] = iter->second;
return numStrs;
}
void addStringHandle(char* str, uint32_t hdl)
{
mHandleToStr.insert(hdl, str);
mStrToHandle.insert(str, hdl);
}
uint32_t addStringHandle(char* str)
{
uint32_t theNewHandle = nextHandleValue();
addStringHandle(str, theNewHandle);
return theNewHandle;
}
const char* doRegisterStr(const char* str, bool& outAdded)
{
PX_ASSERT(isMeaningful(str));
const PxHashMap<const char*, char*>::Entry* entry(mStrings.find(str));
if(entry == NULL)
{
outAdded = true;
char* retval(copyStr(str));
mStrings.insert(retval, retval);
return retval;
}
return entry->second;
}
virtual const char* registerStr(const char* str, bool& outAdded)
{
outAdded = false;
if(isMeaningful(str) == false)
return "";
const char* retval = doRegisterStr(str, outAdded);
if(outAdded)
addStringHandle(const_cast<char*>(retval));
return retval;
}
NamespacedName registerName(const NamespacedName& nm)
{
return NamespacedName(registerStr(nm.mNamespace), registerStr(nm.mName));
}
const char* registerStr(const char* str)
{
bool ignored;
return registerStr(str, ignored);
}
virtual StringHandle strToHandle(const char* str)
{
if(isMeaningful(str) == false)
return 0;
const PxHashMap<const char*, uint32_t>::Entry* entry(mStrToHandle.find(str));
if(entry)
return entry->second;
bool added = false;
const char* registeredStr = doRegisterStr(str, added);
uint32_t theNewHandle = addStringHandle(const_cast<char*>(registeredStr));
PX_ASSERT(mStrToHandle.find(str));
PX_ASSERT(added);
return theNewHandle;
}
virtual const char* handleToStr(uint32_t hdl)
{
if(hdl == 0)
return "";
const PxHashMap<uint32_t, char*>::Entry* entry(mHandleToStr.find(hdl));
if(entry)
return entry->second;
// unregistered handle...
return "";
}
void write(PvdOutputStream& stream)
{
uint32_t numStrs = static_cast<uint32_t>(mHandleToStr.size());
stream << numStrs;
stream << mNextStrHandle;
for(PxHashMap<uint32_t, char*>::Iterator iter = mHandleToStr.getIterator(); !iter.done(); ++iter)
{
stream << iter->first;
uint32_t len = static_cast<uint32_t>(strlen(iter->second) + 1);
stream << len;
stream.write(reinterpret_cast<uint8_t*>(iter->second), len);
}
}
template <typename TReader>
void read(TReader& stream)
{
mHandleToStr.clear();
mStrToHandle.clear();
uint32_t numStrs;
stream >> numStrs;
stream >> mNextStrHandle;
PxArray<uint8_t> readBuffer("StringTable::read::readBuffer");
uint32_t bufSize = 0;
for(uint32_t idx = 0; idx < numStrs; ++idx)
{
uint32_t handleValue;
uint32_t bufLen;
stream >> handleValue;
stream >> bufLen;
if(bufSize < bufLen)
readBuffer.resize(bufLen);
bufSize = PxMax(bufSize, bufLen);
stream.read(readBuffer.begin(), bufLen);
bool ignored;
const char* newStr = doRegisterStr(reinterpret_cast<const char*>(readBuffer.begin()), ignored);
addStringHandle(const_cast<char*>(newStr), handleValue);
}
}
virtual void release()
{
PVD_DELETE(this);
}
private:
StringTableImpl& operator=(const StringTableImpl&);
};
struct NamespacedNameHasher
{
uint32_t operator()(const NamespacedName& nm)
{
return PxHash<const char*>()(nm.mNamespace) ^ PxHash<const char*>()(nm.mName);
}
bool equal(const NamespacedName& lhs, const NamespacedName& rhs)
{
return safeStrEq(lhs.mNamespace, rhs.mNamespace) && safeStrEq(lhs.mName, rhs.mName);
}
};
struct ClassPropertyName
{
NamespacedName mName;
String mPropName;
ClassPropertyName(const NamespacedName& name = NamespacedName(), String propName = "")
: mName(name), mPropName(propName)
{
}
};
struct ClassPropertyNameHasher
{
uint32_t operator()(const ClassPropertyName& nm)
{
return NamespacedNameHasher()(nm.mName) ^ PxHash<const char*>()(nm.mPropName);
}
bool equal(const ClassPropertyName& lhs, const ClassPropertyName& rhs)
{
return NamespacedNameHasher().equal(lhs.mName, rhs.mName) && safeStrEq(lhs.mPropName, rhs.mPropName);
}
};
struct PropertyMessageEntryImpl : public PropertyMessageEntry
{
PropertyMessageEntryImpl(const PropertyMessageEntry& data) : PropertyMessageEntry(data)
{
}
PropertyMessageEntryImpl()
{
}
template <typename TSerializerType>
void serialize(TSerializerType& serializer)
{
serializer.streamify(mDatatypeName);
serializer.streamify(mDatatypeId);
serializer.streamify(mMessageOffset);
serializer.streamify(mByteSize);
serializer.streamify(mDestByteSize);
serializer.streamify(mProperty);
}
};
struct PropertyMessageDescriptionImpl : public PropertyMessageDescription, public PxUserAllocated
{
PxArray<PropertyMessageEntryImpl> mEntryImpls;
PxArray<PropertyMessageEntry> mEntries;
PxArray<uint32_t> mStringOffsetArray;
PropertyMessageDescriptionImpl(const PropertyMessageDescription& data)
: PropertyMessageDescription(data)
, mEntryImpls("PropertyMessageDescriptionImpl::mEntryImpls")
, mEntries("PropertyMessageDescriptionImpl::mEntries")
, mStringOffsetArray("PropertyMessageDescriptionImpl::mStringOffsets")
{
}
PropertyMessageDescriptionImpl()
: mEntryImpls("PropertyMessageDescriptionImpl::mEntryImpls")
, mEntries("PropertyMessageDescriptionImpl::mEntries")
, mStringOffsetArray("PropertyMessageDescriptionImpl::mStringOffsets")
{
}
~PropertyMessageDescriptionImpl()
{
}
void addEntry(const PropertyMessageEntryImpl& entry)
{
mEntryImpls.pushBack(entry);
mEntries.pushBack(entry);
mProperties = DataRef<PropertyMessageEntry>(mEntries.begin(), mEntries.end());
}
template <typename TSerializerType>
void serialize(TSerializerType& serializer)
{
serializer.streamify(mClassName);
serializer.streamify(mClassId); // No other class has this id, it is DB-unique
serializer.streamify(mMessageName);
serializer.streamify(mMessageId);
serializer.streamify(mMessageByteSize);
serializer.streamify(mEntryImpls);
serializer.streamify(mStringOffsetArray);
if(mEntries.size() != mEntryImpls.size())
{
mEntries.clear();
uint32_t numEntries = static_cast<uint32_t>(mEntryImpls.size());
for(uint32_t idx = 0; idx < numEntries; ++idx)
mEntries.pushBack(mEntryImpls[idx]);
}
mProperties = DataRef<PropertyMessageEntry>(mEntries.begin(), mEntries.end());
mStringOffsets = DataRef<uint32_t>(mStringOffsetArray.begin(), mStringOffsetArray.end());
}
private:
PropertyMessageDescriptionImpl& operator=(const PropertyMessageDescriptionImpl&);
};
struct PvdObjectModelMetaDataImpl : public PvdObjectModelMetaData, public PxUserAllocated
{
typedef PxHashMap<NamespacedName, ClassDescImpl*, NamespacedNameHasher> TNameToClassMap;
typedef PxHashMap<ClassPropertyName, PropDescImpl*, ClassPropertyNameHasher> TNameToPropMap;
typedef PxHashMap<NamespacedName, PropertyMessageDescriptionImpl*, NamespacedNameHasher> TNameToPropertyMessageMap;
TNameToClassMap mNameToClasses;
TNameToPropMap mNameToProperties;
PxArray<ClassDescImpl*> mClasses;
PxArray<PropDescImpl*> mProperties;
StringTableImpl* mStringTable;
TNameToPropertyMessageMap mPropertyMessageMap;
PxArray<PropertyMessageDescriptionImpl*> mPropertyMessages;
int32_t mNextClassId;
uint32_t mRefCount;
PvdObjectModelMetaDataImpl()
: mNameToClasses("NamespacedName->ClassDescImpl*")
, mNameToProperties("ClassPropertyName->PropDescImpl*")
, mClasses("ClassDescImpl*")
, mProperties("PropDescImpl*")
, mStringTable(PVD_NEW(StringTableImpl)())
, mPropertyMessageMap("PropertyMessageMap")
, mPropertyMessages("PvdObjectModelMetaDataImpl::mPropertyMessages")
, mNextClassId(1)
, mRefCount(0)
{
}
private:
PvdObjectModelMetaDataImpl& operator=(const PvdObjectModelMetaDataImpl&);
public:
int32_t nextClassId()
{
return mNextClassId++;
}
void initialize()
{
// Create the default classes.
{
ClassDescImpl& aryData = getOrCreateClassImpl(getPvdNamespacedNameForType<ArrayData>(),
DataTypeToPvdTypeMap<ArrayData>::BaseTypeEnum);
aryData.get32BitSize() = sizeof(ArrayData);
aryData.get32BitSizeInfo().mAlignment = sizeof(void*);
aryData.get64BitSize() = sizeof(ArrayData);
aryData.get64BitSizeInfo().mAlignment = sizeof(void*);
aryData.mLocked = true;
}
#define CREATE_BASIC_PVD_CLASS(type) \
{ \
ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<type>(), getPvdTypeForType<type>()); \
cls.get32BitSize() = sizeof(type); \
cls.get32BitSizeInfo().mAlignment = sizeof(type); \
cls.get64BitSize() = sizeof(type); \
cls.get64BitSizeInfo().mAlignment = sizeof(type); \
cls.mLocked = true; \
cls.mPackedUniformWidth = sizeof(type); \
cls.mPackedClassType = getPvdTypeForType<type>(); \
}
CREATE_BASIC_PVD_CLASS(int8_t)
CREATE_BASIC_PVD_CLASS(uint8_t)
CREATE_BASIC_PVD_CLASS(bool)
CREATE_BASIC_PVD_CLASS(int16_t)
CREATE_BASIC_PVD_CLASS(uint16_t)
CREATE_BASIC_PVD_CLASS(int32_t)
CREATE_BASIC_PVD_CLASS(uint32_t)
// CREATE_BASIC_PVD_CLASS(uint32_t)
CREATE_BASIC_PVD_CLASS(int64_t)
CREATE_BASIC_PVD_CLASS(uint64_t)
CREATE_BASIC_PVD_CLASS(float)
CREATE_BASIC_PVD_CLASS(double)
#undef CREATE_BASIC_PVD_CLASS
#define CREATE_PTR_TYPE_PVD_CLASS(type, ptrType) \
{ \
ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<type>(), getPvdTypeForType<type>()); \
cls.get32BitSize() = 4; \
cls.get32BitSizeInfo().mAlignment = 4; \
cls.get64BitSize() = 8; \
cls.get64BitSizeInfo().mAlignment = 8; \
cls.mLocked = true; \
cls.addPtrOffset(PtrOffsetType::ptrType, 0, 0); \
}
CREATE_PTR_TYPE_PVD_CLASS(String, StringOffset)
CREATE_PTR_TYPE_PVD_CLASS(VoidPtr, VoidPtrOffset)
CREATE_PTR_TYPE_PVD_CLASS(StringHandle, StringOffset)
CREATE_PTR_TYPE_PVD_CLASS(ObjectRef, VoidPtrOffset)
#undef CREATE_64BIT_ADJUST_PVD_CLASS
int32_t fltClassType = getPvdTypeForType<float>();
int32_t u32ClassType = getPvdTypeForType<uint32_t>();
int32_t v3ClassType = getPvdTypeForType<PxVec3>();
int32_t v4ClassType = getPvdTypeForType<PxVec4>();
int32_t qtClassType = getPvdTypeForType<PxQuat>();
{
ClassDescImpl& cls =
getOrCreateClassImpl(getPvdNamespacedNameForType<PvdColor>(), getPvdTypeForType<PvdColor>());
createProperty(cls.mClassId, "r", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar);
createProperty(cls.mClassId, "g", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar);
createProperty(cls.mClassId, "b", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar);
createProperty(cls.mClassId, "a", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 1);
PX_ASSERT(cls.get32BitSize() == 4);
PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 1);
PX_ASSERT(cls.get64BitSize() == 4);
PX_ASSERT(cls.mPackedUniformWidth == 1);
PX_ASSERT(cls.mPackedClassType == getPvdTypeForType<uint8_t>());
cls.mLocked = true;
}
{
ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxVec2>(), getPvdTypeForType<PxVec2>());
createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 8);
PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get64BitSize() == 8);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxVec3>(), getPvdTypeForType<PxVec3>());
createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "z", "", fltClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 12);
PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get64BitSize() == 12);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxVec4>(), getPvdTypeForType<PxVec4>());
createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "z", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "w", "", fltClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 16);
PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get64BitSize() == 16);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxQuat>(), getPvdTypeForType<PxQuat>());
createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "z", "", fltClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "w", "", fltClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 16);
PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get64BitSize() == 16);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls =
getOrCreateClassImpl(getPvdNamespacedNameForType<PxBounds3>(), getPvdTypeForType<PxBounds3>());
createProperty(cls.mClassId, "minimum", "", v3ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "maximum", "", v3ClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 24);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls =
getOrCreateClassImpl(getPvdNamespacedNameForType<PxTransform>(), getPvdTypeForType<PxTransform>());
createProperty(cls.mClassId, "q", "", qtClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "p", "", v3ClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 28);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls =
getOrCreateClassImpl(getPvdNamespacedNameForType<PxMat33>(), getPvdTypeForType<PxMat33>());
createProperty(cls.mClassId, "column0", "", v3ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "column1", "", v3ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "column2", "", v3ClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 36);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls =
getOrCreateClassImpl(getPvdNamespacedNameForType<PxMat44>(), getPvdTypeForType<PxMat44>());
createProperty(cls.mClassId, "column0", "", v4ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "column1", "", v4ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "column2", "", v4ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "column3", "", v4ClassType, PropertyType::Scalar);
PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4);
PX_ASSERT(cls.get32BitSize() == 64);
PX_ASSERT(cls.mPackedUniformWidth == 4);
PX_ASSERT(cls.mPackedClassType == fltClassType);
cls.mLocked = true;
}
{
ClassDescImpl& cls =
getOrCreateClassImpl(getPvdNamespacedNameForType<U32Array4>(), getPvdTypeForType<U32Array4>());
createProperty(cls.mClassId, "d0", "", u32ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "d1", "", u32ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "d2", "", u32ClassType, PropertyType::Scalar);
createProperty(cls.mClassId, "d3", "", u32ClassType, PropertyType::Scalar);
cls.mLocked = true;
}
}
virtual ~PvdObjectModelMetaDataImpl()
{
mStringTable->release();
PVD_FOREACH(idx, mClasses.size())
{
if(mClasses[idx] != NULL)
PVD_DELETE(mClasses[idx]);
}
mClasses.clear();
PVD_FOREACH(idx, mProperties.size()) PVD_DELETE(mProperties[idx]);
mProperties.clear();
PVD_FOREACH(idx, mPropertyMessages.size()) PVD_DELETE(mPropertyMessages[idx]);
mPropertyMessages.clear();
}
ClassDescImpl& getOrCreateClassImpl(const NamespacedName& nm, int32_t idx)
{
ClassDescImpl* impl(getClassImpl(idx));
if(impl)
return *impl;
NamespacedName safeName(mStringTable->registerStr(nm.mNamespace), mStringTable->registerStr(nm.mName));
while(idx >= int32_t(mClasses.size()))
mClasses.pushBack(NULL);
mClasses[uint32_t(idx)] = PVD_NEW(ClassDescImpl)(ClassDescription(safeName, idx));
mNameToClasses.insert(nm, mClasses[uint32_t(idx)]);
mNextClassId = PxMax(mNextClassId, idx + 1);
return *mClasses[uint32_t(idx)];
}
ClassDescImpl& getOrCreateClassImpl(const NamespacedName& nm)
{
ClassDescImpl* retval = findClassImpl(nm);
if(retval)
return *retval;
return getOrCreateClassImpl(nm, nextClassId());
}
virtual ClassDescription getOrCreateClass(const NamespacedName& nm)
{
return getOrCreateClassImpl(nm);
}
// get or create parent, lock parent. deriveFrom getOrCreatechild.
virtual bool deriveClass(const NamespacedName& parent, const NamespacedName& child)
{
ClassDescImpl& p(getOrCreateClassImpl(parent));
ClassDescImpl& c(getOrCreateClassImpl(child));
if(c.mBaseClass >= 0)
{
PX_ASSERT(c.mBaseClass == p.mClassId);
return false;
}
p.mLocked = true;
c.mBaseClass = p.mClassId;
c.get32BitSizeInfo() = p.get32BitSizeInfo();
c.get64BitSizeInfo() = p.get64BitSizeInfo();
c.mPackedClassType = p.mPackedClassType;
c.mPackedUniformWidth = p.mPackedUniformWidth;
c.mRequiresDestruction = p.mRequiresDestruction;
c.m32OffsetArray = p.m32OffsetArray;
c.m64OffsetArray = p.m64OffsetArray;
// Add all the parent propertes to this class in the global name map.
for(ClassDescImpl* parent0 = &p; parent0 != NULL; parent0 = getClassImpl(parent0->mBaseClass))
{
PVD_FOREACH(idx, parent0->mPropImps.size())
mNameToProperties.insert(ClassPropertyName(c.mName, parent0->mPropImps[idx]->mName), parent0->mPropImps[idx]);
if(parent0->mBaseClass < 0)
break;
}
return true;
}
ClassDescImpl* findClassImpl(const NamespacedName& nm) const
{
const TNameToClassMap::Entry* entry(mNameToClasses.find(nm));
if(entry)
return entry->second;
return NULL;
}
virtual Option<ClassDescription> findClass(const NamespacedName& nm) const
{
ClassDescImpl* retval = findClassImpl(nm);
if(retval)
return *retval;
return Option<ClassDescription>();
}
ClassDescImpl* getClassImpl(int32_t classId) const
{
if(classId < 0)
return NULL;
uint32_t idx = uint32_t(classId);
if(idx < mClasses.size())
return mClasses[idx];
return NULL;
}
virtual Option<ClassDescription> getClass(int32_t classId) const
{
ClassDescImpl* impl(getClassImpl(classId));
if(impl)
return *impl;
return None();
}
virtual ClassDescription* getClassPtr(int32_t classId) const
{
return getClassImpl(classId);
}
virtual Option<ClassDescription> getParentClass(int32_t classId) const
{
ClassDescImpl* impl(getClassImpl(classId));
if(impl == NULL)
return None();
return getClass(impl->mBaseClass);
}
virtual void lockClass(int32_t classId)
{
ClassDescImpl* impl(getClassImpl(classId));
PX_ASSERT(impl);
if(impl)
impl->mLocked = true;
}
virtual uint32_t getNbClasses() const
{
uint32_t total = 0;
PVD_FOREACH(idx, mClasses.size()) if(mClasses[idx])++ total;
return total;
}
virtual uint32_t getClasses(ClassDescription* outClasses, uint32_t requestCount, uint32_t startIndex = 0) const
{
uint32_t classCount(getNbClasses());
startIndex = PxMin(classCount, startIndex);
uint32_t retAmount = PxMin(requestCount, classCount - startIndex);
uint32_t idx = 0;
while(startIndex)
{
if(mClasses[idx] != NULL)
--startIndex;
++idx;
}
uint32_t inserted = 0;
uint32_t classesSize = static_cast<uint32_t>(mClasses.size());
while(inserted < retAmount && idx < classesSize)
{
if(mClasses[idx] != NULL)
{
outClasses[inserted] = *mClasses[idx];
++inserted;
}
++idx;
}
return inserted;
}
uint32_t updateByteSizeAndGetPropertyAlignment(ClassDescriptionSizeInfo& dest, const ClassDescriptionSizeInfo& src)
{
uint32_t alignment = src.mAlignment;
dest.mAlignment = PxMax(dest.mAlignment, alignment);
uint32_t offset = align(dest.mDataByteSize, alignment);
dest.mDataByteSize = offset + src.mByteSize;
dest.mByteSize = align(dest.mDataByteSize, dest.mAlignment);
return offset;
}
void transferPtrOffsets(ClassDescriptionSizeInfo& destInfo, PxArray<PtrOffset>& destArray,
const PxArray<PtrOffset>& src, uint32_t offset)
{
PVD_FOREACH(idx, src.size())
destArray.pushBack(PtrOffset(src[idx].mOffsetType, src[idx].mOffset + offset));
destInfo.mPtrOffsets = DataRef<PtrOffset>(destArray.begin(), destArray.end());
}
virtual Option<PropertyDescription> createProperty(int32_t classId, String name, String semantic, int32_t datatype,
PropertyType::Enum propertyType)
{
ClassDescImpl* cls(getClassImpl(classId));
PX_ASSERT(cls);
if(!cls)
return None();
if(cls->mLocked)
{
PX_ASSERT(false);
return None();
}
PropDescImpl* impl(cls->findProperty(name));
// duplicate property definition
if(impl)
{
PX_ASSERT(false);
return None();
}
if(datatype == getPvdTypeForType<String>())
{
PX_ASSERT(false);
return None();
}
// The datatype for this property has not been declared.
ClassDescImpl* propDType(getClassImpl(datatype));
PX_ASSERT(propDType);
if(!propDType)
return None();
NamespacedName propClsName(propDType->mName);
int32_t propPackedWidth = propDType->mPackedUniformWidth;
int32_t propPackedType = propDType->mPackedClassType;
// The implications of properties being complex types aren't major
//*until* you start trying to undue a property event that set values
// of those complex types. Then things just get too complex.
if(propDType->mRequiresDestruction)
{
PX_ASSERT(false);
return None();
}
bool requiresDestruction = propDType->mRequiresDestruction || cls->mRequiresDestruction;
if(propertyType == PropertyType::Array)
{
int32_t tempId = DataTypeToPvdTypeMap<ArrayData>::BaseTypeEnum;
propDType = getClassImpl(tempId);
PX_ASSERT(propDType);
if(!propDType)
return None();
requiresDestruction = true;
}
uint32_t offset32 = updateByteSizeAndGetPropertyAlignment(cls->get32BitSizeInfo(), propDType->get32BitSizeInfo());
uint32_t offset64 = updateByteSizeAndGetPropertyAlignment(cls->get64BitSizeInfo(), propDType->get64BitSizeInfo());
transferPtrOffsets(cls->get32BitSizeInfo(), cls->m32OffsetArray, propDType->m32OffsetArray, offset32);
transferPtrOffsets(cls->get64BitSizeInfo(), cls->m64OffsetArray, propDType->m64OffsetArray, offset64);
propDType->mLocked = true; // Can't add members to the property type.
cls->mRequiresDestruction = requiresDestruction;
int32_t propId = int32_t(mProperties.size());
PropertyDescription newDesc(cls->mName, cls->mClassId, name, semantic, datatype, propClsName, propertyType,
propId, offset32, offset64);
mProperties.pushBack(PVD_NEW(PropDescImpl)(newDesc, *mStringTable));
mNameToProperties.insert(ClassPropertyName(cls->mName, mProperties.back()->mName), mProperties.back());
cls->addProperty(mProperties.back());
bool firstProp = cls->mPropImps.size() == 1;
if(firstProp)
{
cls->mPackedUniformWidth = propPackedWidth;
cls->mPackedClassType = propPackedType;
}
else
{
bool packed = (propPackedWidth > 0) && (cls->get32BitSizeInfo().mDataByteSize % propPackedWidth) == 0;
if(cls->mPackedClassType >= 0) // maybe uncheck packed class type
{
if(propPackedType < 0 || cls->mPackedClassType != propPackedType
// Object refs require conversion from stream to db id
||
datatype == getPvdTypeForType<ObjectRef>()
// Strings also require conversion from stream to db id.
||
datatype == getPvdTypeForType<StringHandle>() || packed == false)
cls->mPackedClassType = -1;
}
if(cls->mPackedUniformWidth >= 0) // maybe uncheck packed class width
{
if(propPackedWidth < 0 || cls->mPackedUniformWidth != propPackedWidth
// object refs, because they require special treatment during parsing,
// cannot be packed
||
datatype == getPvdTypeForType<ObjectRef>()
// Likewise, string handles are special because the data needs to be sent *after*
// the
||
datatype == getPvdTypeForType<StringHandle>() || packed == false)
cls->mPackedUniformWidth = -1; // invalid packed width.
}
}
return *mProperties.back();
}
PropDescImpl* findPropImpl(const NamespacedName& clsName, String prop) const
{
const TNameToPropMap::Entry* entry = mNameToProperties.find(ClassPropertyName(clsName, prop));
if(entry)
return entry->second;
return NULL;
}
virtual Option<PropertyDescription> findProperty(const NamespacedName& cls, String propName) const
{
PropDescImpl* prop(findPropImpl(cls, propName));
if(prop)
return *prop;
return None();
}
virtual Option<PropertyDescription> findProperty(int32_t clsId, String propName) const
{
ClassDescImpl* cls(getClassImpl(clsId));
PX_ASSERT(cls);
if(!cls)
return None();
PropDescImpl* prop(findPropImpl(cls->mName, propName));
if(prop)
return *prop;
return None();
}
PropDescImpl* getPropertyImpl(int32_t propId) const
{
PX_ASSERT(propId >= 0);
if(propId < 0)
return NULL;
uint32_t val = uint32_t(propId);
if(val >= mProperties.size())
{
PX_ASSERT(false);
return NULL;
}
return mProperties[val];
}
virtual Option<PropertyDescription> getProperty(int32_t propId) const
{
PropDescImpl* impl(getPropertyImpl(propId));
if(impl)
return *impl;
return None();
}
virtual void setNamedPropertyValues(DataRef<NamedValue> values, int32_t propId)
{
PropDescImpl* impl(getPropertyImpl(propId));
if(impl)
{
impl->mValueNames.resize(values.size());
PVD_FOREACH(idx, values.size()) impl->mValueNames[idx] = values[idx];
}
}
virtual DataRef<NamedValue> getNamedPropertyValues(int32_t propId) const
{
PropDescImpl* impl(getPropertyImpl(propId));
if(impl)
{
return toDataRef(impl->mValueNames);
}
return DataRef<NamedValue>();
}
virtual uint32_t getNbProperties(int32_t classId) const
{
uint32_t retval = 0;
for(ClassDescImpl* impl(getClassImpl(classId)); impl; impl = getClassImpl(impl->mBaseClass))
{
retval += impl->mPropImps.size();
if(impl->mBaseClass < 0)
break;
}
return retval;
}
// Properties need to be returned in base class order, so this requires a recursive function.
uint32_t getPropertiesImpl(int32_t classId, PropertyDescription*& outBuffer, uint32_t& numItems,
uint32_t& startIdx) const
{
ClassDescImpl* impl = getClassImpl(classId);
if(impl)
{
uint32_t retval = 0;
if(impl->mBaseClass >= 0)
retval = getPropertiesImpl(impl->mBaseClass, outBuffer, numItems, startIdx);
uint32_t localStart = PxMin(impl->mPropImps.size(), startIdx);
uint32_t localNumItems = PxMin(numItems, impl->mPropImps.size() - localStart);
PVD_FOREACH(idx, localNumItems)
{
outBuffer[idx] = *impl->mPropImps[localStart + idx];
}
startIdx -= localStart;
numItems -= localNumItems;
outBuffer += localNumItems;
return retval + localNumItems;
}
return 0;
}
virtual uint32_t getProperties(int32_t classId, PropertyDescription* outBuffer, uint32_t numItems,
uint32_t startIdx) const
{
return getPropertiesImpl(classId, outBuffer, numItems, startIdx);
}
virtual MarshalQueryResult checkMarshalling(int32_t srcClsId, int32_t dstClsId) const
{
Option<ClassDescription> propTypeOpt(getClass(dstClsId));
if(propTypeOpt.hasValue() == false)
{
PX_ASSERT(false);
return MarshalQueryResult();
}
const ClassDescription& propType(propTypeOpt);
Option<ClassDescription> incomingTypeOpt(getClass(srcClsId));
if(incomingTypeOpt.hasValue() == false)
{
PX_ASSERT(false);
return MarshalQueryResult();
}
const ClassDescription& incomingType(incomingTypeOpt);
// Can only marshal simple things at this point in time.
bool needsMarshalling = false;
bool canMarshal = false;
TSingleMarshaller single = NULL;
TBlockMarshaller block = NULL;
if(incomingType.mClassId != propType.mClassId)
{
// Check that marshalling is even possible.
if((incomingType.mPackedUniformWidth >= 0 && propType.mPackedUniformWidth >= 0) == false)
{
PX_ASSERT(false);
return MarshalQueryResult();
}
int32_t srcType = incomingType.mPackedClassType;
int32_t dstType = propType.mPackedClassType;
int32_t srcWidth = incomingType.mPackedUniformWidth;
int32_t dstWidth = propType.mPackedUniformWidth;
canMarshal = getMarshalOperators(single, block, srcType, dstType);
if(srcWidth == dstWidth)
needsMarshalling = canMarshal; // If the types are the same width, we assume we can convert between some
// of them seamlessly (uint16_t, int16_t)
else
{
needsMarshalling = true;
// If we can't marshall and we have to then we can't set the property value.
// This indicates that the src and dest are different properties and we don't
// know how to convert between them.
if(!canMarshal)
{
PX_ASSERT(false);
return MarshalQueryResult();
}
}
}
return MarshalQueryResult(srcClsId, dstClsId, canMarshal, needsMarshalling, block);
}
PropertyMessageDescriptionImpl* findPropertyMessageImpl(const NamespacedName& messageName) const
{
const TNameToPropertyMessageMap::Entry* entry = mPropertyMessageMap.find(messageName);
if(entry)
return entry->second;
return NULL;
}
PropertyMessageDescriptionImpl* getPropertyMessageImpl(int32_t msg) const
{
int32_t msgCount = int32_t(mPropertyMessages.size());
if(msg >= 0 && msg < msgCount)
return mPropertyMessages[uint32_t(msg)];
return NULL;
}
virtual Option<PropertyMessageDescription> createPropertyMessage(const NamespacedName& clsName,
const NamespacedName& messageName,
DataRef<PropertyMessageArg> entries,
uint32_t messageSize)
{
PropertyMessageDescriptionImpl* existing(findPropertyMessageImpl(messageName));
if(existing)
{
PX_ASSERT(false);
return None();
}
ClassDescImpl* cls = findClassImpl(clsName);
PX_ASSERT(cls);
if(!cls)
return None();
int32_t msgId = int32_t(mPropertyMessages.size());
PropertyMessageDescriptionImpl* newMessage = PVD_NEW(PropertyMessageDescriptionImpl)(
PropertyMessageDescription(mStringTable->registerName(clsName), cls->mClassId,
mStringTable->registerName(messageName), msgId, messageSize));
uint32_t calculatedSize = 0;
PVD_FOREACH(idx, entries.size())
{
PropertyMessageArg entry(entries[idx]);
ClassDescImpl* dtypeCls = findClassImpl(entry.mDatatypeName);
if(dtypeCls == NULL)
{
PX_ASSERT(false);
goto DestroyNewMessage;
}
ClassDescriptionSizeInfo dtypeInfo(dtypeCls->get32BitSizeInfo());
uint32_t incomingSize = dtypeInfo.mByteSize;
if(entry.mByteSize < incomingSize)
{
PX_ASSERT(false);
goto DestroyNewMessage;
}
calculatedSize = PxMax(calculatedSize, entry.mMessageOffset + entry.mByteSize);
if(calculatedSize > messageSize)
{
PX_ASSERT(false);
goto DestroyNewMessage;
}
Option<PropertyDescription> propName(findProperty(cls->mClassId, entry.mPropertyName));
if(propName.hasValue() == false)
{
PX_ASSERT(false);
goto DestroyNewMessage;
}
Option<ClassDescription> propCls(getClass(propName.getValue().mDatatype));
if(propCls.hasValue() == false)
{
PX_ASSERT(false);
goto DestroyNewMessage;
}
PropertyMessageEntryImpl newEntry(PropertyMessageEntry(
propName, dtypeCls->mName, dtypeCls->mClassId, entry.mMessageOffset, incomingSize, dtypeInfo.mByteSize));
newMessage->addEntry(newEntry);
if(newEntry.mDatatypeId == getPvdTypeForType<String>())
newMessage->mStringOffsetArray.pushBack(entry.mMessageOffset);
// property messages cannot be marshalled at this time.
if(newEntry.mDatatypeId != getPvdTypeForType<String>() && newEntry.mDatatypeId != getPvdTypeForType<VoidPtr>())
{
MarshalQueryResult marshalInfo = checkMarshalling(newEntry.mDatatypeId, newEntry.mProperty.mDatatype);
if(marshalInfo.needsMarshalling)
{
PX_ASSERT(false);
goto DestroyNewMessage;
}
}
}
if(newMessage)
{
newMessage->mStringOffsets =
DataRef<uint32_t>(newMessage->mStringOffsetArray.begin(), newMessage->mStringOffsetArray.end());
mPropertyMessages.pushBack(newMessage);
mPropertyMessageMap.insert(messageName, newMessage);
return *newMessage;
}
DestroyNewMessage:
if(newMessage)
PVD_DELETE(newMessage);
return None();
}
virtual Option<PropertyMessageDescription> findPropertyMessage(const NamespacedName& msgName) const
{
PropertyMessageDescriptionImpl* desc(findPropertyMessageImpl(msgName));
if(desc)
return *desc;
return None();
}
virtual Option<PropertyMessageDescription> getPropertyMessage(int32_t msgId) const
{
PropertyMessageDescriptionImpl* desc(getPropertyMessageImpl(msgId));
if(desc)
return *desc;
return None();
}
virtual uint32_t getNbPropertyMessages() const
{
return mPropertyMessages.size();
}
virtual uint32_t getPropertyMessages(PropertyMessageDescription* msgBuf, uint32_t bufLen, uint32_t startIdx = 0) const
{
startIdx = PxMin(startIdx, getNbPropertyMessages());
bufLen = PxMin(bufLen, getNbPropertyMessages() - startIdx);
PVD_FOREACH(idx, bufLen) msgBuf[idx] = *mPropertyMessages[idx + startIdx];
return bufLen;
}
struct MetaDataWriter
{
const PvdObjectModelMetaDataImpl& mMetaData;
PvdOutputStream& mStream;
MetaDataWriter(const PvdObjectModelMetaDataImpl& meta, PvdOutputStream& stream)
: mMetaData(meta), mStream(stream)
{
}
void streamify(NamespacedName& type)
{
mStream << mMetaData.mStringTable->strToHandle(type.mNamespace);
mStream << mMetaData.mStringTable->strToHandle(type.mName);
}
void streamify(String& type)
{
mStream << mMetaData.mStringTable->strToHandle(type);
}
void streamify(int32_t& type)
{
mStream << type;
}
void streamify(uint32_t& type)
{
mStream << type;
}
void streamify(uint8_t type)
{
mStream << type;
}
void streamify(bool type)
{
streamify( uint8_t(type));
}
void streamify(PropertyType::Enum type)
{
uint32_t val = static_cast<uint32_t>(type);
mStream << val;
}
void streamify(NamedValue& type)
{
streamify(type.mValue);
streamify(type.mName);
}
void streamifyLinks(PropDescImpl* prop)
{
streamify(prop->mPropertyId);
}
void streamify(PropertyDescription& prop)
{
streamify(prop.mPropertyId);
}
void streamify(PropertyMessageEntryImpl& prop)
{
prop.serialize(*this);
}
void streamify(PtrOffset& off)
{
uint32_t type = off.mOffsetType;
mStream << type;
mStream << off.mOffset;
}
template <typename TDataType>
void streamify(TDataType* type)
{
int32_t existMarker = type ? 1 : 0;
mStream << existMarker;
if(type)
type->serialize(*this);
}
template <typename TArrayType>
void streamify(const PxArray<TArrayType>& type)
{
mStream << static_cast<uint32_t>(type.size());
PVD_FOREACH(idx, type.size()) streamify(const_cast<TArrayType&>(type[idx]));
}
template <typename TArrayType>
void streamifyLinks(const PxArray<TArrayType>& type)
{
mStream << static_cast<uint32_t>(type.size());
PVD_FOREACH(idx, type.size()) streamifyLinks(const_cast<TArrayType&>(type[idx]));
}
private:
MetaDataWriter& operator=(const MetaDataWriter&);
};
template <typename TStreamType>
struct MetaDataReader
{
PvdObjectModelMetaDataImpl& mMetaData;
TStreamType& mStream;
MetaDataReader(PvdObjectModelMetaDataImpl& meta, TStreamType& stream) : mMetaData(meta), mStream(stream)
{
}
void streamify(NamespacedName& type)
{
streamify(type.mNamespace);
streamify(type.mName);
}
void streamify(String& type)
{
uint32_t handle;
mStream >> handle;
type = mMetaData.mStringTable->handleToStr(handle);
}
void streamify(int32_t& type)
{
mStream >> type;
}
void streamify(uint32_t& type)
{
mStream >> type;
}
void streamify(bool& type)
{
uint8_t data;
mStream >> data;
type = data ? true : false;
}
void streamify(PropertyType::Enum& type)
{
uint32_t val;
mStream >> val;
type = static_cast<PropertyType::Enum>(val);
}
void streamify(NamedValue& type)
{
streamify(type.mValue);
streamify(type.mName);
}
void streamify(PropertyMessageEntryImpl& type)
{
type.serialize(*this);
}
void streamify(PtrOffset& off)
{
uint32_t type;
mStream >> type;
mStream >> off.mOffset;
off.mOffsetType = static_cast<PtrOffsetType::Enum>(type);
}
void streamifyLinks(PropDescImpl*& prop)
{
int32_t propId;
streamify(propId);
prop = mMetaData.getPropertyImpl(propId);
}
void streamify(PropertyDescription& prop)
{
streamify(prop.mPropertyId);
prop = mMetaData.getProperty(prop.mPropertyId);
}
template <typename TDataType>
void streamify(TDataType*& type)
{
uint32_t existMarker;
mStream >> existMarker;
if(existMarker)
{
TDataType* newType = PVD_NEW(TDataType)();
newType->serialize(*this);
type = newType;
}
else
type = NULL;
}
template <typename TArrayType>
void streamify(PxArray<TArrayType>& type)
{
uint32_t typeSize;
mStream >> typeSize;
type.resize(typeSize);
PVD_FOREACH(idx, type.size()) streamify(type[idx]);
}
template <typename TArrayType>
void streamifyLinks(PxArray<TArrayType>& type)
{
uint32_t typeSize;
mStream >> typeSize;
type.resize(typeSize);
PVD_FOREACH(idx, type.size()) streamifyLinks(type[idx]);
}
private:
MetaDataReader& operator=(const MetaDataReader&);
};
virtual void write(PvdOutputStream& stream) const
{
stream << getCurrentPvdObjectModelVersion();
stream << mNextClassId;
mStringTable->write(stream);
MetaDataWriter writer(*this, stream);
writer.streamify(mProperties);
writer.streamify(mClasses);
writer.streamify(mPropertyMessages);
}
template <typename TReaderType>
void read(TReaderType& stream)
{
uint32_t version;
stream >> version;
stream >> mNextClassId;
mStringTable->read(stream);
MetaDataReader<TReaderType> reader(*this, stream);
reader.streamify(mProperties);
reader.streamify(mClasses);
reader.streamify(mPropertyMessages);
mNameToClasses.clear();
mNameToProperties.clear();
mPropertyMessageMap.clear();
PVD_FOREACH(i, mClasses.size())
{
ClassDescImpl* cls(mClasses[i]);
if(cls == NULL)
continue;
mNameToClasses.insert(cls->mName, mClasses[i]);
uint32_t propCount = getNbProperties(cls->mClassId);
PropertyDescription descs[16];
uint32_t offset = 0;
for(uint32_t idx = 0; idx < propCount; idx = offset)
{
uint32_t numProps = getProperties(cls->mClassId, descs, 16, offset);
offset += numProps;
for(uint32_t propIdx = 0; propIdx < numProps; ++propIdx)
{
PropDescImpl* prop = getPropertyImpl(descs[propIdx].mPropertyId);
if(prop)
mNameToProperties.insert(ClassPropertyName(cls->mName, prop->mName), prop);
}
}
}
PVD_FOREACH(idx, mPropertyMessages.size())
mPropertyMessageMap.insert(mPropertyMessages[idx]->mMessageName, mPropertyMessages[idx]);
}
virtual StringTable& getStringTable() const
{
return *mStringTable;
}
virtual void addRef()
{
++mRefCount;
}
virtual void release()
{
if(mRefCount)
--mRefCount;
if(!mRefCount)
PVD_DELETE(this);
}
};
}
uint32_t PvdObjectModelMetaData::getCurrentPvdObjectModelVersion()
{
return 1;
}
PvdObjectModelMetaData& PvdObjectModelMetaData::create()
{
PvdObjectModelMetaDataImpl& retval(*PVD_NEW(PvdObjectModelMetaDataImpl)());
retval.initialize();
return retval;
}
PvdObjectModelMetaData& PvdObjectModelMetaData::create(PvdInputStream& stream)
{
PvdObjectModelMetaDataImpl& retval(*PVD_NEW(PvdObjectModelMetaDataImpl)());
retval.read(stream);
return retval;
}
StringTable& StringTable::create()
{
return *PVD_NEW(StringTableImpl)();
}
| 48,987 | C++ | 31.61518 | 120 | 0.697001 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileContextProviderImpl.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_CONTEXT_PROVIDER_IMPL_H
#define PX_PROFILE_CONTEXT_PROVIDER_IMPL_H
#include "PxProfileContextProvider.h"
#include "foundation/PxThread.h"
namespace physx { namespace profile {
struct PxDefaultContextProvider
{
PxProfileEventExecutionContext getExecutionContext()
{
PxThread::Id theId( PxThread::getId() );
return PxProfileEventExecutionContext( static_cast<uint32_t>( theId ), static_cast<uint8_t>( PxThreadPriority::eNORMAL ), 0 );
}
uint32_t getThreadId()
{
return static_cast<uint32_t>( PxThread::getId() );
}
};
} }
#endif
| 2,146 | C | 39.509433 | 129 | 0.756757 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventNames.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_EVENT_NAMES_H
#define PX_PROFILE_EVENT_NAMES_H
#include "PxProfileEventId.h"
namespace physx { namespace profile {
/**
\brief Mapping from event id to name.
*/
struct PxProfileEventName
{
const char* name;
PxProfileEventId eventId;
/**
\brief Default constructor.
\param inName Profile event name.
\param inId Profile event id.
*/
PxProfileEventName( const char* inName, PxProfileEventId inId ) : name( inName ), eventId( inId ) {}
};
/**
\brief Aggregator of event id -> name mappings
*/
struct PxProfileNames
{
/**
\brief Default constructor that doesn't point to any names.
\param inEventCount Number of provided events.
\param inSubsystems Event names array.
*/
PxProfileNames( uint32_t inEventCount = 0, const PxProfileEventName* inSubsystems = NULL )
: eventCount( inEventCount )
, events( inSubsystems )
{
}
uint32_t eventCount;
const PxProfileEventName* events;
};
/**
\brief Provides a mapping from event ID -> name.
*/
class PxProfileNameProvider
{
public:
/**
\brief Returns profile event names.
\return Profile event names.
*/
virtual PxProfileNames getProfileNames() const = 0;
protected:
virtual ~PxProfileNameProvider(){}
PxProfileNameProvider& operator=(const PxProfileNameProvider&) { return *this; }
};
} }
#endif
| 2,914 | C | 31.388889 | 102 | 0.736788 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileDataParsing.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_DATA_PARSING_H
#define PX_PROFILE_DATA_PARSING_H
#include "foundation/Px.h"
namespace physx { namespace profile {
//Converts datatypes without using type punning.
struct BlockParserDataConverter
{
union
{
uint8_t mU8[8];
uint16_t mU16[4];
uint32_t mU32[2];
uint64_t mU64[1];
int8_t mI8[8];
int16_t mI16[4];
int32_t mI32[2];
int64_t mI64[1];
float mF32[2];
double mF64[1];
};
template<typename TDataType> inline TDataType convert() { PX_ASSERT( false ); return TDataType(); }
template<typename TDataType>
inline void convert( const TDataType& ) {}
};
template<> inline uint8_t BlockParserDataConverter::convert<uint8_t>() { return mU8[0]; }
template<> inline uint16_t BlockParserDataConverter::convert<uint16_t>() { return mU16[0]; }
template<> inline uint32_t BlockParserDataConverter::convert<uint32_t>() { return mU32[0]; }
template<> inline uint64_t BlockParserDataConverter::convert<uint64_t>() { return mU64[0]; }
template<> inline int8_t BlockParserDataConverter::convert<int8_t>() { return mI8[0]; }
template<> inline int16_t BlockParserDataConverter::convert<int16_t>() { return mI16[0]; }
template<> inline int32_t BlockParserDataConverter::convert<int32_t>() { return mI32[0]; }
template<> inline int64_t BlockParserDataConverter::convert<int64_t>() { return mI64[0]; }
template<> inline float BlockParserDataConverter::convert<float>() { return mF32[0]; }
template<> inline double BlockParserDataConverter::convert<double>() { return mF64[0]; }
template<> inline void BlockParserDataConverter::convert<uint8_t>( const uint8_t& inData ) { mU8[0] = inData; }
template<> inline void BlockParserDataConverter::convert<uint16_t>( const uint16_t& inData ) { mU16[0] = inData; }
template<> inline void BlockParserDataConverter::convert<uint32_t>( const uint32_t& inData ) { mU32[0] = inData; }
template<> inline void BlockParserDataConverter::convert<uint64_t>( const uint64_t& inData ) { mU64[0] = inData; }
template<> inline void BlockParserDataConverter::convert<int8_t>( const int8_t& inData ) { mI8[0] = inData; }
template<> inline void BlockParserDataConverter::convert<int16_t>( const int16_t& inData ) { mI16[0] = inData; }
template<> inline void BlockParserDataConverter::convert<int32_t>( const int32_t& inData ) { mI32[0] = inData; }
template<> inline void BlockParserDataConverter::convert<int64_t>( const int64_t& inData ) { mI64[0] = inData; }
template<> inline void BlockParserDataConverter::convert<float>( const float& inData ) { mF32[0] = inData; }
template<> inline void BlockParserDataConverter::convert<double>( const double& inData ) { mF64[0] = inData; }
//Handles various details around parsing blocks of uint8_t data.
struct BlockParseFunctions
{
template<uint8_t ByteCount>
static inline void swapBytes( uint8_t* inData )
{
for ( uint32_t idx = 0; idx < ByteCount/2; ++idx )
{
uint32_t endIdx = ByteCount-idx-1;
uint8_t theTemp = inData[idx];
inData[idx] = inData[endIdx];
inData[endIdx] = theTemp;
}
}
static inline bool checkLength( const uint8_t* inStart, const uint8_t* inStop, uint32_t inLength )
{
return static_cast<uint32_t>(inStop - inStart) >= inLength;
}
//warning work-around
template<typename T>
static inline T val(T v) {return v;}
template<bool DoSwapBytes, typename TDataType>
static inline bool parse( const uint8_t*& inStart, const uint8_t* inStop, TDataType& outData )
{
if ( checkLength( inStart, inStop, sizeof( TDataType ) ) )
{
BlockParserDataConverter theConverter;
for ( uint32_t idx =0; idx < sizeof( TDataType ); ++idx )
theConverter.mU8[idx] = inStart[idx];
if ( val(DoSwapBytes))
swapBytes<sizeof(TDataType)>( theConverter.mU8 );
outData = theConverter.convert<TDataType>();
inStart += sizeof( TDataType );
return true;
}
return false;
}
template<bool DoSwapBytes, typename TDataType>
static inline bool parseBlock( const uint8_t*& inStart, const uint8_t* inStop, TDataType* outData, uint32_t inNumItems )
{
uint32_t desired = sizeof(TDataType)*inNumItems;
if ( checkLength( inStart, inStop, desired ) )
{
if ( val(DoSwapBytes) )
{
for ( uint32_t item = 0; item < inNumItems; ++item )
{
BlockParserDataConverter theConverter;
for ( uint32_t idx =0; idx < sizeof( TDataType ); ++idx )
theConverter.mU8[idx] = inStart[idx];
swapBytes<sizeof(TDataType)>( theConverter.mU8 );
outData[item] = theConverter.convert<TDataType>();
inStart += sizeof(TDataType);
}
}
else
{
uint8_t* target = reinterpret_cast<uint8_t*>(outData);
memmove( target, inStart, desired );
inStart += desired;
}
return true;
}
return false;
}
//In-place byte swapping block
template<bool DoSwapBytes, typename TDataType>
static inline bool parseBlock( uint8_t*& inStart, const uint8_t* inStop, uint32_t inNumItems )
{
uint32_t desired = sizeof(TDataType)*inNumItems;
if ( checkLength( inStart, inStop, desired ) )
{
if ( val(DoSwapBytes) )
{
for ( uint32_t item = 0; item < inNumItems; ++item, inStart += sizeof( TDataType ) )
swapBytes<sizeof(TDataType)>( inStart ); //In-place swap.
}
else
inStart += sizeof( TDataType ) * inNumItems;
return true;
}
return false;
}
};
//Wraps the begin/end keeping track of them.
template<bool DoSwapBytes>
struct BlockParser
{
const uint8_t* mBegin;
const uint8_t* mEnd;
BlockParser( const uint8_t* inBegin=NULL, const uint8_t* inEnd=NULL )
: mBegin( inBegin )
, mEnd( inEnd )
{
}
inline bool hasMoreData() const { return mBegin != mEnd; }
inline bool checkLength( uint32_t inLength ) { return BlockParseFunctions::checkLength( mBegin, mEnd, inLength ); }
template<typename TDataType>
inline bool read( TDataType& outDatatype ) { return BlockParseFunctions::parse<DoSwapBytes>( mBegin, mEnd, outDatatype ); }
template<typename TDataType>
inline bool readBlock( TDataType* outDataPtr, uint32_t inNumItems ) { return BlockParseFunctions::parseBlock<DoSwapBytes>( mBegin, mEnd, outDataPtr, inNumItems ); }
template<typename TDataType>
inline bool readBlock( uint32_t inNumItems )
{
uint8_t* theTempPtr = const_cast<uint8_t*>(mBegin);
bool retval = BlockParseFunctions::parseBlock<DoSwapBytes, TDataType>( theTempPtr, mEnd, inNumItems );
mBegin = theTempPtr;
return retval;
}
uint32_t amountLeft() const { return static_cast<uint32_t>( mEnd - mBegin ); }
};
//Reads the data without checking for error conditions
template<typename TDataType, typename TBlockParserType>
inline TDataType blockParserRead( TBlockParserType& inType )
{
TDataType retval;
inType.read( retval );
return retval;
}
}}
#endif
| 8,528 | C | 38.123853 | 166 | 0.707903 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventBuffer.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_EVENT_BUFFER_H
#define PX_PROFILE_EVENT_BUFFER_H
#include "PxProfileEvents.h"
#include "PxProfileEventSerialization.h"
#include "PxProfileDataBuffer.h"
#include "PxProfileContextProvider.h"
#include "foundation/PxTime.h"
namespace physx { namespace profile {
/**
* An event buffer maintains an in-memory buffer of events. When this buffer is full
* it sends to buffer to all handlers registered and resets the buffer.
*
* It is parameterized in four ways. The first is a context provider that provides
* both thread id and context id.
*
* The second is the mutex (which may be null) and a scoped locking mechanism. Thus the buffer
* may be used in a multithreaded context but clients of the buffer don't pay for this if they
* don't intend to use it this way.
*
* Finally the buffer may use an event filtering mechanism. This mechanism needs one function,
* namely isEventEnabled( uint8_t subsystem, uint8_t eventId ).
*
* All of these systems can be parameterized at compile time leading to an event buffer
* that should be as fast as possible given the constraints.
*
* Buffers may be chained together as this buffer has a handleBufferFlush method that
* will grab the mutex and add the data to this event buffer.
*
* Overall, lets look at the PhysX SDK an how all the pieces fit together.
* The SDK should have a mutex-protected event buffer where actual devs or users of PhysX
* can register handlers. This buffer has slow but correct implementations of the
* context provider interface.
*
* The SDK object should also have a concrete event filter which was used in the
* construction of the event buffer and which it exposes through opaque interfaces.
*
* The SDK should protect its event buffer and its event filter from multithreaded
* access and thus this provides the safest and slowest way to log events and to
* enable/disable events.
*
* Each scene should also have a concrete event filter. This filter is updated from
* the SDK event filter (in a mutex protected way) every frame. Thus scenes can change
* their event filtering on a frame-by-frame basis. It means that tasks running
* under the scene don't need a mutex when accessing the filter.
*
* Furthermore the scene should have an event buffer that always sets the context id
* on each event to the scene. This allows PVD and other systems to correlate events
* to scenes. Scenes should provide access only to a relative event sending system
* that looks up thread id upon each event but uses the scene id.
*
* The SDK's event buffer should be setup as an EventBufferClient for each scene's
* event buffer. Thus the SDK should expose an EventBufferClient interface that
* any client can use.
*
* For extremely *extremely* performance sensitive areas we should create a specialized
* per-scene, per-thread event buffer that is set on the task for these occasions. This buffer
* uses a trivial event context setup with the scene's context id and the thread id. It should
* share the scene's concrete event filter and it should have absolutely no locking. It should
* empty into the scene's event buffer which in some cases should empty into the SDK's event buffer
* which when full will push events all the way out of the system. The task should *always* flush
* the event buffer (if it has one) when it is finished; nothing else will work reliably.
*
* If the per-scene,per-thread event buffer is correctly parameterized and fully defined adding
* a new event should be an inline operation requiring no mutex grabs in the common case. I don't
* believe you can get faster event production than this; the events are as small as possible (all
* relative events) and they are all produced inline resulting in one 4 byte header and one
* 8 byte timestamp per event. Reducing the memory pressure in this way reduces the communication
* overhead, the mutex grabs, basically everything that makes profiling expensive at the cost
* of a per-scene,per-thread event buffer (which could easily be reduced to a per-thread event
* buffer.
*/
template<typename TContextProvider,
typename TMutex,
typename TScopedLock,
typename TEventFilter>
class EventBuffer : public DataBuffer<TMutex, TScopedLock>
{
public:
typedef DataBuffer<TMutex, TScopedLock> TBaseType;
typedef TContextProvider TContextProviderType;
typedef TEventFilter TEventFilterType;
typedef typename TBaseType::TMutexType TMutexType;
typedef typename TBaseType::TScopedLockType TScopedLockType;
typedef typename TBaseType::TU8AllocatorType TU8AllocatorType;
typedef typename TBaseType::TMemoryBufferType TMemoryBufferType;
typedef typename TBaseType::TBufferClientArray TBufferClientArray;
private:
EventContextInformation mEventContextInformation;
uint64_t mLastTimestamp;
TContextProvider mContextProvider;
TEventFilterType mEventFilter;
public:
EventBuffer(PxAllocatorCallback* inFoundation
, uint32_t inBufferFullAmount
, const TContextProvider& inProvider
, TMutexType* inBufferMutex
, const TEventFilterType& inEventFilter )
: TBaseType( inFoundation, inBufferFullAmount, inBufferMutex, "struct physx::profile::ProfileEvent" )
, mLastTimestamp( 0 )
, mContextProvider( inProvider )
, mEventFilter( inEventFilter )
{
memset(&mEventContextInformation,0,sizeof(EventContextInformation));
}
TContextProvider& getContextProvider() { return mContextProvider; }
PX_FORCE_INLINE void startEvent(uint16_t inId, uint32_t threadId, uint64_t contextId, uint8_t cpuId, uint8_t threadPriority, uint64_t inTimestamp)
{
TScopedLockType lock(TBaseType::mBufferMutex);
if ( mEventFilter.isEventEnabled( inId ) )
{
StartEvent theEvent;
theEvent.init( threadId, contextId, cpuId, threadPriority, inTimestamp );
doAddProfileEvent( inId, theEvent );
}
}
PX_FORCE_INLINE void startEvent(uint16_t inId, uint64_t contextId)
{
PxProfileEventExecutionContext ctx( mContextProvider.getExecutionContext() );
startEvent( inId, ctx.mThreadId, contextId, ctx.mCpuId, static_cast<uint8_t>(ctx.mThreadPriority), PxTime::getCurrentCounterValue() );
}
PX_FORCE_INLINE void startEvent(uint16_t inId, uint64_t contextId, uint32_t threadId)
{
startEvent( inId, threadId, contextId, 0, 0, PxTime::getCurrentCounterValue() );
}
PX_FORCE_INLINE void stopEvent(uint16_t inId, uint32_t threadId, uint64_t contextId, uint8_t cpuId, uint8_t threadPriority, uint64_t inTimestamp)
{
TScopedLockType lock(TBaseType::mBufferMutex);
if ( mEventFilter.isEventEnabled( inId ) )
{
StopEvent theEvent;
theEvent.init( threadId, contextId, cpuId, threadPriority, inTimestamp );
doAddProfileEvent( inId, theEvent );
}
}
PX_FORCE_INLINE void stopEvent(uint16_t inId, uint64_t contextId)
{
PxProfileEventExecutionContext ctx( mContextProvider.getExecutionContext() );
stopEvent( inId, ctx.mThreadId, contextId, ctx.mCpuId, static_cast<uint8_t>(ctx.mThreadPriority), PxTime::getCurrentCounterValue() );
}
PX_FORCE_INLINE void stopEvent(uint16_t inId, uint64_t contextId, uint32_t threadId)
{
stopEvent( inId, threadId, contextId, 0, 0, PxTime::getCurrentCounterValue() );
}
inline void eventValue( uint16_t inId, uint64_t contextId, int64_t inValue )
{
eventValue( inId, mContextProvider.getThreadId(), contextId, inValue );
}
inline void eventValue( uint16_t inId, uint32_t threadId, uint64_t contextId, int64_t inValue )
{
TScopedLockType lock( TBaseType::mBufferMutex );
EventValue theEvent;
theEvent.init( inValue, contextId, threadId );
EventHeader theHeader( static_cast<uint8_t>( getEventType<EventValue>() ), inId );
//set the header relative timestamp;
EventValue& theType( theEvent );
theType.setupHeader( theHeader );
sendEvent( theHeader, theType );
}
void flushProfileEvents()
{
TBaseType::flushEvents();
}
void release()
{
PX_PROFILE_DELETE( TBaseType::mWrapper.mUserFoundation, this );
}
protected:
//Clears the cache meaning event compression
//starts over again.
//only called when the buffer mutex is held
void clearCachedData()
{
mEventContextInformation.setToDefault();
mLastTimestamp = 0;
}
template<typename TProfileEventType>
PX_FORCE_INLINE void doAddProfileEvent(uint16_t eventId, const TProfileEventType& inType)
{
TScopedLockType lock(TBaseType::mBufferMutex);
if (mEventContextInformation == inType.mContextInformation)
doAddEvent(static_cast<uint8_t>(inType.getRelativeEventType()), eventId, inType.getRelativeEvent());
else
{
mEventContextInformation = inType.mContextInformation;
doAddEvent( static_cast<uint8_t>( getEventType<TProfileEventType>() ), eventId, inType );
}
}
template<typename TDataType>
PX_FORCE_INLINE void doAddEvent(uint8_t inEventType, uint16_t eventId, const TDataType& inType)
{
EventHeader theHeader( inEventType, eventId );
//set the header relative timestamp;
TDataType& theType( const_cast<TDataType&>( inType ) );
uint64_t currentTs = inType.getTimestamp();
theType.setupHeader(theHeader, mLastTimestamp);
mLastTimestamp = currentTs;
sendEvent( theHeader, theType );
}
template<typename TDataType>
PX_FORCE_INLINE void sendEvent( EventHeader& inHeader, TDataType& inType )
{
uint32_t sizeToWrite = sizeof(inHeader) + inType.getEventSize(inHeader);
PX_UNUSED(sizeToWrite);
uint32_t writtenSize = inHeader.streamify( TBaseType::mSerializer );
writtenSize += inType.streamify(TBaseType::mSerializer, inHeader);
PX_ASSERT(writtenSize == sizeToWrite);
if ( TBaseType::mDataArray.size() >= TBaseType::mBufferFullAmount )
flushProfileEvents();
}
};
}}
#endif
| 11,552 | C | 42.269663 | 148 | 0.750779 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileScopedEvent.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_SCOPED_EVENT_H
#define PX_PROFILE_SCOPED_EVENT_H
#include "PxProfileEventId.h"
#include "PxProfileCompileTimeEventFilter.h"
namespace physx { namespace profile {
/**
\brief Template version of startEvent, called directly on provided profile buffer.
\param inBuffer Profile event buffer.
\param inId Profile event id.
\param inContext Profile event context.
*/
template<bool TEnabled, typename TBufferType>
inline void startEvent( TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext )
{
if ( TEnabled && inBuffer ) inBuffer->startEvent( inId, inContext );
}
/**
\brief Template version of stopEvent, called directly on provided profile buffer.
\param inBuffer Profile event buffer.
\param inId Profile event id.
\param inContext Profile event context.
*/
template<bool TEnabled, typename TBufferType>
inline void stopEvent( TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext )
{
if ( TEnabled && inBuffer ) inBuffer->stopEvent( inId, inContext );
}
/**
\brief Template version of startEvent, called directly on provided profile buffer.
\param inEnabled If profile event is enabled.
\param inBuffer Profile event buffer.
\param inId Profile event id.
\param inContext Profile event context.
*/
template<typename TBufferType>
inline void startEvent( bool inEnabled, TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext )
{
if ( inEnabled && inBuffer ) inBuffer->startEvent( inId, inContext );
}
/**
\brief Template version of stopEvent, called directly on provided profile buffer.
\param inEnabled If profile event is enabled.
\param inBuffer Profile event buffer.
\param inId Profile event id.
\param inContext Profile event context.
*/
template<typename TBufferType>
inline void stopEvent( bool inEnabled, TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext )
{
if ( inEnabled && inBuffer ) inBuffer->stopEvent( inId, inContext );
}
/**
\brief Template version of eventValue, called directly on provided profile buffer.
\param inEnabled If profile event is enabled.
\param inBuffer Profile event buffer.
\param inId Profile event id.
\param inContext Profile event context.
\param inValue Event value.
*/
template<typename TBufferType>
inline void eventValue( bool inEnabled, TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext, int64_t inValue )
{
if ( inEnabled && inBuffer ) inBuffer->eventValue( inId, inContext, inValue );
}
}}
#endif
| 4,102 | C | 36.99074 | 131 | 0.762311 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdImpl.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PVD_IMPL_H
#define PX_PVD_IMPL_H
#include "foundation/PxProfiler.h"
#include "foundation/PxAllocator.h"
#include "PsPvd.h"
#include "foundation/PxArray.h"
#include "foundation/PxMutex.h"
#include "PxPvdCommStreamTypes.h"
#include "PxPvdFoundation.h"
#include "PxPvdObjectModelMetaData.h"
#include "PxPvdObjectRegistrar.h"
namespace physx
{
namespace profile
{
class PxProfileZoneManager;
}
namespace pvdsdk
{
class PvdMemClient;
class PvdProfileZoneClient;
struct MetaDataProvider : public PvdOMMetaDataProvider, public PxUserAllocated
{
typedef PxMutex::ScopedLock TScopedLockType;
typedef PxHashMap<const void*, int32_t> TInstTypeMap;
PvdObjectModelMetaData& mMetaData;
PxMutex mMutex;
uint32_t mRefCount;
TInstTypeMap mTypeMap;
MetaDataProvider()
: mMetaData(PvdObjectModelMetaData::create()), mRefCount(0), mTypeMap("MetaDataProvider::mTypeMap")
{
mMetaData.addRef();
}
virtual ~MetaDataProvider()
{
mMetaData.release();
}
virtual void addRef()
{
TScopedLockType locker(mMutex);
++mRefCount;
}
virtual void release()
{
{
TScopedLockType locker(mMutex);
if(mRefCount)
--mRefCount;
}
if(!mRefCount)
PVD_DELETE(this);
}
virtual PvdObjectModelMetaData& lock()
{
mMutex.lock();
return mMetaData;
}
virtual void unlock()
{
mMutex.unlock();
}
virtual bool createInstance(const NamespacedName& clsName, const void* instance)
{
TScopedLockType locker(mMutex);
Option<ClassDescription> cls(mMetaData.findClass(clsName));
if(cls.hasValue() == false)
return false;
int32_t instType = cls->mClassId;
mTypeMap.insert(instance, instType);
return true;
}
virtual bool isInstanceValid(const void* instance)
{
TScopedLockType locker(mMutex);
ClassDescription classDesc;
bool retval = mTypeMap.find(instance) != NULL;
#if PX_DEBUG
if(retval)
classDesc = mMetaData.getClass(mTypeMap.find(instance)->second);
#endif
return retval;
}
virtual void destroyInstance(const void* instance)
{
{
TScopedLockType locker(mMutex);
mTypeMap.erase(instance);
}
}
virtual int32_t getInstanceClassType(const void* instance)
{
TScopedLockType locker(mMutex);
const TInstTypeMap::Entry* entry = mTypeMap.find(instance);
if(entry)
return entry->second;
return -1;
}
private:
MetaDataProvider& operator=(const MetaDataProvider&);
MetaDataProvider(const MetaDataProvider&);
};
//////////////////////////////////////////////////////////////////////////
/*!
PvdImpl is the realization of PxPvd.
It implements the interface methods and provides richer functionality for advanced users or internal clients (such as
PhysX or APEX), including handler notification for clients.
*/
//////////////////////////////////////////////////////////////////////////
class PvdImpl : public PsPvd, public PxUserAllocated
{
PX_NOCOPY(PvdImpl)
typedef PxMutex::ScopedLock TScopedLockType;
typedef void (PvdImpl::*TAllocationHandler)(size_t size, const char* typeName, const char* filename, int line,
void* allocatedMemory);
typedef void (PvdImpl::*TDeallocationHandler)(void* allocatedMemory);
public:
PvdImpl();
virtual ~PvdImpl();
void release();
bool connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags);
void disconnect();
bool isConnected(bool useCachedStatus = true);
void flush();
PxPvdTransport* getTransport();
PxPvdInstrumentationFlags getInstrumentationFlags();
void addClient(PvdClient* client);
void removeClient(PvdClient* client);
PvdOMMetaDataProvider& getMetaDataProvider();
bool registerObject(const void* inItem);
bool unRegisterObject(const void* inItem);
//AllocationListener
void onAllocation(size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory);
void onDeallocation(void* addr);
uint64_t getNextStreamId();
static bool initialize();
static PvdImpl* getInstance();
// Profiling
virtual void* zoneStart(const char* eventName, bool detached, uint64_t contextId);
virtual void zoneEnd(void* profilerData, const char *eventName, bool detached, uint64_t contextId);
private:
void sendTransportInitialization();
PxPvdTransport* mPvdTransport;
physx::PxArray<PvdClient*> mPvdClients;
MetaDataProvider* mSharedMetaProvider; // shared between clients
ObjectRegistrar mObjectRegistrar;
PvdMemClient* mMemClient;
PxPvdInstrumentationFlags mFlags;
bool mIsConnected;
bool mGPUProfilingWasConnected;
bool mIsNVTXSupportEnabled;
uint32_t mNVTXContext;
uint64_t mNextStreamId;
physx::profile::PxProfileZoneManager*mProfileZoneManager;
PvdProfileZoneClient* mProfileClient;
physx::profile::PxProfileZone* mProfileZone;
static PvdImpl* sInstance;
static uint32_t sRefCount;
};
} // namespace pvdsdk
}
#endif
| 6,567 | C | 28.452915 | 117 | 0.730775 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventSender.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_EVENT_SENDER_H
#define PX_PROFILE_EVENT_SENDER_H
#include "foundation/Px.h"
namespace physx { namespace profile {
/**
\brief Tagging interface to indicate an object that is capable of flushing a profile
event stream at a certain point.
*/
class PxProfileEventFlusher
{
protected:
virtual ~PxProfileEventFlusher(){}
public:
/**
\brief Flush profile events. Sends the profile event buffer to hooked clients.
*/
virtual void flushProfileEvents() = 0;
};
/**
\brief Sends the full events where the caller must provide the context and thread id.
*/
class PxProfileEventSender
{
protected:
virtual ~PxProfileEventSender(){}
public:
/**
\brief Use this as a thread id for events that start on one thread and end on another
*/
static const uint32_t CrossThreadId = 99999789;
/**
\brief Send a start profile event, optionally with a context. Events are sorted by thread
and context in the client side.
\param inId Profile event id.
\param contextId Context id.
*/
virtual void startEvent( uint16_t inId, uint64_t contextId) = 0;
/**
\brief Send a stop profile event, optionally with a context. Events are sorted by thread
and context in the client side.
\param inId Profile event id.
\param contextId Context id.
*/
virtual void stopEvent( uint16_t inId, uint64_t contextId) = 0;
/**
\brief Send a start profile event, optionally with a context. Events are sorted by thread
and context in the client side.
\param inId Profile event id.
\param contextId Context id.
\param threadId Thread id.
*/
virtual void startEvent( uint16_t inId, uint64_t contextId, uint32_t threadId) = 0;
/**
\brief Send a stop profile event, optionally with a context. Events are sorted by thread
and context in the client side.
\param inId Profile event id.
\param contextId Context id.
\param threadId Thread id.
*/
virtual void stopEvent( uint16_t inId, uint64_t contextId, uint32_t threadId ) = 0;
virtual void atEvent(uint16_t inId, uint64_t contextId, uint32_t threadId, uint64_t start, uint64_t stop) = 0;
/**
\brief Set an specific events value. This is different than the profiling value
for the event; it is a value recorded and kept around without a timestamp associated
with it. This value is displayed when the event itself is processed.
\param inId Profile event id.
\param contextId Context id.
\param inValue Value to set for the event.
*/
virtual void eventValue( uint16_t inId, uint64_t contextId, int64_t inValue ) = 0;
};
} }
#endif
| 4,134 | C | 35.919643 | 112 | 0.740687 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileMemory.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_MEMORY_H
#define PX_PROFILE_MEMORY_H
#include "PxProfileEventBufferClientManager.h"
#include "PxProfileEventSender.h"
#include "foundation/PxBroadcast.h"
namespace physx { namespace profile {
/**
\brief Record events so a late-connecting client knows about
all outstanding allocations
*/
class PxProfileMemoryEventRecorder : public PxAllocationListener
{
protected:
virtual ~PxProfileMemoryEventRecorder(){}
public:
/**
\brief Set the allocation listener
\param inListener Allocation listener.
*/
virtual void setListener(PxAllocationListener* inListener) = 0;
/**
\brief Release the instance.
*/
virtual void release() = 0;
};
/**
\brief Stores memory events into the memory buffer.
*/
class PxProfileMemoryEventBuffer
: public PxAllocationListener //add a new event to the buffer
, public PxProfileEventBufferClientManager //add clients to handle the serialized memory events
, public PxProfileEventFlusher //flush the buffer
{
protected:
virtual ~PxProfileMemoryEventBuffer(){}
public:
/**
\brief Release the instance.
*/
virtual void release() = 0;
/**
\brief Create a non-mutex-protected event buffer.
\param inAllocator Allocation callback.
\param inBufferSize Internal buffer size.
*/
static PxProfileMemoryEventBuffer& createMemoryEventBuffer(PxAllocatorCallback& inAllocator, uint32_t inBufferSize = 0x1000);
};
} } // namespace physx
#endif
| 3,151 | C | 33.637362 | 127 | 0.757537 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventId.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_EVENT_ID_H
#define PX_PROFILE_EVENT_ID_H
#include "foundation/Px.h"
namespace physx { namespace profile {
/**
\brief A event id structure. Optionally includes information about
if the event was enabled at compile time.
*/
struct PxProfileEventId
{
uint16_t eventId;
mutable bool compileTimeEnabled;
/**
\brief Profile event id constructor.
\param inId Profile event id.
\param inCompileTimeEnabled Compile time enabled.
*/
PxProfileEventId( uint16_t inId = 0, bool inCompileTimeEnabled = true )
: eventId( inId )
, compileTimeEnabled( inCompileTimeEnabled )
{
}
operator uint16_t () const { return eventId; }
bool operator==( const PxProfileEventId& inOther ) const
{
return eventId == inOther.eventId;
}
};
} }
#endif
| 2,357 | C | 35.276923 | 74 | 0.747985 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileMemoryEventBuffer.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_MEMORY_EVENT_BUFFER_H
#define PX_PROFILE_MEMORY_EVENT_BUFFER_H
#include "PxProfileDataBuffer.h"
#include "PxProfileMemoryEvents.h"
#include "PxProfileMemory.h"
#include "PxProfileScopedMutexLock.h"
#include "PxProfileAllocatorWrapper.h"
#include "PxProfileEventMutex.h"
#include "foundation/PxHash.h"
#include "foundation/PxHashMap.h"
#include "foundation/PxUserAllocated.h"
namespace physx { namespace profile {
template<typename TMutex,
typename TScopedLock>
class MemoryEventBuffer : public DataBuffer<TMutex, TScopedLock>
{
public:
typedef DataBuffer<TMutex, TScopedLock> TBaseType;
typedef typename TBaseType::TMutexType TMutexType;
typedef typename TBaseType::TScopedLockType TScopedLockType;
typedef typename TBaseType::TU8AllocatorType TU8AllocatorType;
typedef typename TBaseType::TMemoryBufferType TMemoryBufferType;
typedef typename TBaseType::TBufferClientArray TBufferClientArray;
typedef PxHashMap<const char*, uint32_t, PxHash<const char*>, TU8AllocatorType> TCharPtrToHandleMap;
protected:
TCharPtrToHandleMap mStringTable;
public:
MemoryEventBuffer( PxAllocatorCallback& cback
, uint32_t inBufferFullAmount
, TMutexType* inBufferMutex )
: TBaseType( &cback, inBufferFullAmount, inBufferMutex, "struct physx::profile::MemoryEvent" )
, mStringTable( TU8AllocatorType( TBaseType::getWrapper(), "MemoryEventStringBuffer" ) )
{
}
uint32_t getHandle( const char* inData )
{
if ( inData == NULL ) inData = "";
const typename TCharPtrToHandleMap::Entry* result( mStringTable.find( inData ) );
if ( result )
return result->second;
uint32_t hdl = mStringTable.size() + 1;
mStringTable.insert( inData, hdl );
StringTableEvent theEvent;
theEvent.init( inData, hdl );
sendEvent( theEvent );
return hdl;
}
void onAllocation( size_t inSize, const char* inType, const char* inFile, uint32_t inLine, uint64_t addr )
{
if ( addr == 0 )
return;
uint32_t typeHdl( getHandle( inType ) );
uint32_t fileHdl( getHandle( inFile ) );
AllocationEvent theEvent;
theEvent.init( inSize, typeHdl, fileHdl, inLine, addr );
sendEvent( theEvent );
}
void onDeallocation( uint64_t addr )
{
if ( addr == 0 )
return;
DeallocationEvent theEvent;
theEvent.init( addr );
sendEvent( theEvent );
}
void flushProfileEvents()
{
TBaseType::flushEvents();
}
protected:
template<typename TDataType>
void sendEvent( TDataType inType )
{
MemoryEventHeader theHeader( getMemoryEventType<TDataType>() );
inType.setup( theHeader );
theHeader.streamify( TBaseType::mSerializer );
inType.streamify( TBaseType::mSerializer, theHeader );
if ( TBaseType::mDataArray.size() >= TBaseType::mBufferFullAmount )
flushProfileEvents();
}
};
class PxProfileMemoryEventBufferImpl : public PxUserAllocated
, public PxProfileMemoryEventBuffer
{
typedef MemoryEventBuffer<PxProfileEventMutex, NullLock> TMemoryBufferType;
TMemoryBufferType mBuffer;
public:
PxProfileMemoryEventBufferImpl( PxAllocatorCallback& alloc, uint32_t inBufferFullAmount )
: mBuffer( alloc, inBufferFullAmount, NULL )
{
}
virtual void onAllocation( size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory )
{
mBuffer.onAllocation( size, typeName, filename, uint32_t(line), static_cast<uint64_t>(reinterpret_cast<size_t>(allocatedMemory)) );
}
virtual void onDeallocation( void* allocatedMemory )
{
mBuffer.onDeallocation(static_cast<uint64_t>(reinterpret_cast<size_t>(allocatedMemory)) );
}
virtual void addClient( PxProfileEventBufferClient& inClient ) { mBuffer.addClient( inClient ); }
virtual void removeClient( PxProfileEventBufferClient& inClient ) { mBuffer.removeClient( inClient ); }
virtual bool hasClients() const { return mBuffer.hasClients(); }
virtual void flushProfileEvents() { mBuffer.flushProfileEvents(); }
virtual void release(){ PX_PROFILE_DELETE( mBuffer.getWrapper().getAllocator(), this ); }
};
}}
#endif
| 5,746 | C | 35.605095 | 134 | 0.748869 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdUserRenderer.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#include "PxPvdUserRenderImpl.h"
#include "PxPvdInternalByteStreams.h"
#include "PxPvdBits.h"
#include <stdarg.h>
using namespace physx;
using namespace physx::pvdsdk;
namespace
{
template <typename TStreamType>
struct RenderWriter : public RenderSerializer
{
TStreamType& mStream;
RenderWriter(TStreamType& stream) : mStream(stream)
{
}
template <typename TDataType>
void write(const TDataType* val, uint32_t count)
{
uint32_t numBytes = count * sizeof(TDataType);
mStream.write(reinterpret_cast<const uint8_t*>(val), numBytes);
}
template <typename TDataType>
void write(const TDataType& val)
{
write(&val, 1);
}
template <typename TDataType>
void writeRef(DataRef<TDataType>& val)
{
uint32_t amount = val.size();
write(amount);
if(amount)
write(val.begin(), amount);
}
virtual void streamify(uint64_t& val)
{
write(val);
}
virtual void streamify(uint32_t& val)
{
write(val);
}
virtual void streamify(float& val)
{
write(val);
}
virtual void streamify(uint8_t& val)
{
write(val);
}
virtual void streamify(DataRef<uint8_t>& val)
{
writeRef(val);
}
virtual void streamify(PxDebugText& val)
{
write(val.color);
write(val.position);
write(val.size);
uint32_t amount = static_cast<uint32_t>(strlen(val.string)) + 1;
write(amount);
if(amount)
write(val.string, amount);
}
virtual void streamify(DataRef<PxDebugPoint>& val)
{
writeRef(val);
}
virtual void streamify(DataRef<PxDebugLine>& val)
{
writeRef(val);
}
virtual void streamify(DataRef<PxDebugTriangle>& val)
{
writeRef(val);
}
virtual uint32_t hasData()
{
return false;
}
virtual bool isGood()
{
return true;
}
private:
RenderWriter& operator=(const RenderWriter&);
};
struct UserRenderer : public PvdUserRenderer
{
ForwardingMemoryBuffer mBuffer;
uint32_t mBufferCapacity;
RendererEventClient* mClient;
UserRenderer(uint32_t bufferFullAmount)
: mBuffer("UserRenderBuffer"), mBufferCapacity(bufferFullAmount), mClient(NULL)
{
}
virtual ~UserRenderer()
{
}
virtual void release()
{
PVD_DELETE(this);
}
template <typename TEventType>
void handleEvent(TEventType evt)
{
RenderWriter<ForwardingMemoryBuffer> _writer(mBuffer);
RenderSerializer& writer(_writer);
PvdUserRenderTypes::Enum evtType(getPvdRenderTypeFromType<TEventType>());
writer.streamify(evtType);
evt.serialize(writer);
if(mBuffer.size() >= mBufferCapacity)
flushRenderEvents();
}
virtual void setInstanceId(const void* iid)
{
handleEvent(SetInstanceIdRenderEvent(PVD_POINTER_TO_U64(iid)));
}
// Draw these points associated with this instance
virtual void drawPoints(const PxDebugPoint* points, uint32_t count)
{
handleEvent(PointsRenderEvent(points, count));
}
// Draw these lines associated with this instance
virtual void drawLines(const PxDebugLine* lines, uint32_t count)
{
handleEvent(LinesRenderEvent(lines, count));
}
// Draw these triangles associated with this instance
virtual void drawTriangles(const PxDebugTriangle* triangles, uint32_t count)
{
handleEvent(TrianglesRenderEvent(triangles, count));
}
virtual void drawText(const PxDebugText& text)
{
handleEvent(TextRenderEvent(text));
}
virtual void drawRenderbuffer(const PxDebugPoint* pointData, uint32_t pointCount, const PxDebugLine* lineData,
uint32_t lineCount, const PxDebugTriangle* triangleData, uint32_t triangleCount)
{
handleEvent(DebugRenderEvent(pointData, pointCount, lineData, lineCount, triangleData, triangleCount));
}
// Constraint visualization routines
virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) PX_OVERRIDE
{
handleEvent(JointFramesRenderEvent(parent, child));
}
virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, float value) PX_OVERRIDE
{
handleEvent(LinearLimitRenderEvent(t0, t1, value, true));
}
virtual void visualizeAngularLimit(const PxTransform& t0, float lower, float upper) PX_OVERRIDE
{
handleEvent(AngularLimitRenderEvent(t0, lower, upper, true));
}
virtual void visualizeLimitCone(const PxTransform& t, float tanQSwingY, float tanQSwingZ) PX_OVERRIDE
{
handleEvent(LimitConeRenderEvent(t, tanQSwingY, tanQSwingZ, true));
}
virtual void visualizeDoubleCone(const PxTransform& t, float angle) PX_OVERRIDE
{
handleEvent(DoubleConeRenderEvent(t, angle, true));
}
// Clear the immedate buffer.
virtual void flushRenderEvents()
{
if(mClient)
mClient->handleBufferFlush(mBuffer.begin(), mBuffer.size());
mBuffer.clear();
}
virtual void setClient(RendererEventClient* client)
{
mClient = client;
}
private:
UserRenderer& operator=(const UserRenderer&);
};
template <bool swapBytes>
struct RenderReader : public RenderSerializer
{
MemPvdInputStream mStream;
ForwardingMemoryBuffer& mBuffer;
RenderReader(ForwardingMemoryBuffer& buf) : mBuffer(buf)
{
}
void setData(DataRef<const uint8_t> data)
{
mStream.setup(const_cast<uint8_t*>(data.begin()), const_cast<uint8_t*>(data.end()));
}
virtual void streamify(uint32_t& val)
{
mStream >> val;
}
virtual void streamify(uint64_t& val)
{
mStream >> val;
}
virtual void streamify(float& val)
{
mStream >> val;
}
virtual void streamify(uint8_t& val)
{
mStream >> val;
}
template <typename TDataType>
void readRef(DataRef<TDataType>& val)
{
uint32_t count;
mStream >> count;
uint32_t numBytes = sizeof(TDataType) * count;
TDataType* dataPtr = reinterpret_cast<TDataType*>(mBuffer.growBuf(numBytes));
mStream.read(reinterpret_cast<uint8_t*>(dataPtr), numBytes);
val = DataRef<TDataType>(dataPtr, count);
}
virtual void streamify(DataRef<PxDebugPoint>& val)
{
readRef(val);
}
virtual void streamify(DataRef<PxDebugLine>& val)
{
readRef(val);
}
virtual void streamify(DataRef<PxDebugTriangle>& val)
{
readRef(val);
}
virtual void streamify(PxDebugText& val)
{
mStream >> val.color;
mStream >> val.position;
mStream >> val.size;
uint32_t len = 0;
mStream >> len;
uint8_t* dataPtr = mBuffer.growBuf(len);
mStream.read(dataPtr, len);
val.string = reinterpret_cast<const char*>(dataPtr);
}
virtual void streamify(DataRef<uint8_t>& val)
{
readRef(val);
}
virtual bool isGood()
{
return mStream.isGood();
}
virtual uint32_t hasData()
{
return uint32_t(mStream.size() > 0);
}
private:
RenderReader& operator=(const RenderReader&);
};
template <>
struct RenderReader<true> : public RenderSerializer
{
MemPvdInputStream mStream;
ForwardingMemoryBuffer& mBuffer;
RenderReader(ForwardingMemoryBuffer& buf) : mBuffer(buf)
{
}
void setData(DataRef<const uint8_t> data)
{
mStream.setup(const_cast<uint8_t*>(data.begin()), const_cast<uint8_t*>(data.end()));
}
template <typename TDataType>
void read(TDataType& val)
{
mStream >> val;
swapBytes(val);
}
virtual void streamify(uint64_t& val)
{
read(val);
}
virtual void streamify(uint32_t& val)
{
read(val);
}
virtual void streamify(float& val)
{
read(val);
}
virtual void streamify(uint8_t& val)
{
read(val);
}
template <typename TDataType>
void readRef(DataRef<TDataType>& val)
{
uint32_t count;
mStream >> count;
swapBytes(count);
uint32_t numBytes = sizeof(TDataType) * count;
TDataType* dataPtr = reinterpret_cast<TDataType*>(mBuffer.growBuf(numBytes));
PVD_FOREACH(idx, count)
RenderSerializerMap<TDataType>().serialize(*this, dataPtr[idx]);
val = DataRef<TDataType>(dataPtr, count);
}
virtual void streamify(DataRef<PxDebugPoint>& val)
{
readRef(val);
}
virtual void streamify(DataRef<PxDebugLine>& val)
{
readRef(val);
}
virtual void streamify(DataRef<PxDebugTriangle>& val)
{
readRef(val);
}
virtual void streamify(PxDebugText& val)
{
mStream >> val.color;
mStream >> val.position;
mStream >> val.size;
uint32_t len = 0;
mStream >> len;
uint8_t* dataPtr = mBuffer.growBuf(len);
mStream.read(dataPtr, len);
val.string = reinterpret_cast<const char*>(dataPtr);
}
virtual void streamify(DataRef<uint8_t>& val)
{
readRef(val);
}
virtual bool isGood()
{
return mStream.isGood();
}
virtual uint32_t hasData()
{
return uint32_t(mStream.size() > 0);
}
private:
RenderReader& operator=(const RenderReader&);
};
}
PvdUserRenderer* PvdUserRenderer::create(uint32_t bufferSize)
{
return PVD_NEW(UserRenderer)(bufferSize);
}
| 9,923 | C++ | 23.503704 | 111 | 0.727401 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDefaultSocketTransport.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxPvdDefaultSocketTransport.h"
namespace physx
{
namespace pvdsdk
{
PvdDefaultSocketTransport::PvdDefaultSocketTransport(const char* host, int port, unsigned int timeoutInMilliseconds)
: mHost(host), mPort(uint16_t(port)), mTimeout(timeoutInMilliseconds), mConnected(false), mWrittenData(0)
{
}
PvdDefaultSocketTransport::~PvdDefaultSocketTransport()
{
}
bool PvdDefaultSocketTransport::connect()
{
if(mConnected)
return true;
if(mSocket.connect(mHost, mPort, mTimeout))
{
mSocket.setBlocking(true);
mConnected = true;
}
return mConnected;
}
void PvdDefaultSocketTransport::disconnect()
{
mSocket.flush();
mSocket.disconnect();
mConnected = false;
}
bool PvdDefaultSocketTransport::isConnected()
{
return mSocket.isConnected();
}
bool PvdDefaultSocketTransport::write(const uint8_t* inBytes, uint32_t inLength)
{
if(mConnected)
{
if(inLength == 0)
return true;
uint32_t amountWritten = 0;
uint32_t totalWritten = 0;
do
{
// Sockets don't have to write as much as requested, so we need
// to wrap this call in a do/while loop.
// If they don't write any bytes then we consider them disconnected.
amountWritten = mSocket.write(inBytes, inLength);
inLength -= amountWritten;
inBytes += amountWritten;
totalWritten += amountWritten;
} while(inLength && amountWritten);
if(amountWritten == 0)
return false;
mWrittenData += totalWritten;
return true;
}
else
return false;
}
PxPvdTransport& PvdDefaultSocketTransport::lock()
{
mMutex.lock();
return *this;
}
void PvdDefaultSocketTransport::unlock()
{
mMutex.unlock();
}
void PvdDefaultSocketTransport::flush()
{
mSocket.flush();
}
uint64_t PvdDefaultSocketTransport::getWrittenDataSize()
{
return mWrittenData;
}
void PvdDefaultSocketTransport::release()
{
PX_DELETE_THIS;
}
} // namespace pvdsdk
PxPvdTransport* PxDefaultPvdSocketTransportCreate(const char* host, int port, unsigned int timeoutInMilliseconds)
{
return PX_NEW(pvdsdk::PvdDefaultSocketTransport)(host, port, timeoutInMilliseconds);
}
} // namespace physx
| 3,762 | C++ | 27.082089 | 116 | 0.754918 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDefaultFileTransport.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxPvdDefaultFileTransport.h"
namespace physx
{
namespace pvdsdk
{
PvdDefaultFileTransport::PvdDefaultFileTransport(const char* name) : mConnected(false), mWrittenData(0), mLocked(false)
{
mFileBuffer = PX_NEW(PsFileBuffer)(name, PxFileBuf::OPEN_WRITE_ONLY);
}
PvdDefaultFileTransport::~PvdDefaultFileTransport()
{
}
bool PvdDefaultFileTransport::connect()
{
PX_ASSERT(mFileBuffer);
mConnected = mFileBuffer->isOpen();
return mConnected;
}
void PvdDefaultFileTransport::disconnect()
{
mConnected = false;
}
bool PvdDefaultFileTransport::isConnected()
{
return mConnected;
}
bool PvdDefaultFileTransport::write(const uint8_t* inBytes, uint32_t inLength)
{
PX_ASSERT(mLocked);
PX_ASSERT(mFileBuffer);
if (mConnected)
{
uint32_t len = mFileBuffer->write(inBytes, inLength);
mWrittenData += len;
return len == inLength;
}
else
return false;
}
PxPvdTransport& PvdDefaultFileTransport::lock()
{
mMutex.lock();
PX_ASSERT(!mLocked);
mLocked = true;
return *this;
}
void PvdDefaultFileTransport::unlock()
{
PX_ASSERT(mLocked);
mLocked = false;
mMutex.unlock();
}
void PvdDefaultFileTransport::flush()
{
}
uint64_t PvdDefaultFileTransport::getWrittenDataSize()
{
return mWrittenData;
}
void PvdDefaultFileTransport::release()
{
if (mFileBuffer)
{
mFileBuffer->close();
delete mFileBuffer;
}
mFileBuffer = NULL;
PX_DELETE_THIS;
}
class NullFileTransport : public physx::PxPvdTransport, public physx::PxUserAllocated
{
PX_NOCOPY(NullFileTransport)
public:
NullFileTransport();
virtual ~NullFileTransport();
virtual bool connect();
virtual void disconnect();
virtual bool isConnected();
virtual bool write(const uint8_t* inBytes, uint32_t inLength);
virtual PxPvdTransport& lock();
virtual void unlock();
virtual void flush();
virtual uint64_t getWrittenDataSize();
virtual void release();
private:
bool mConnected;
uint64_t mWrittenData;
physx::PxMutex mMutex;
bool mLocked; // for debug, remove it when finished
};
NullFileTransport::NullFileTransport() : mConnected(false), mWrittenData(0), mLocked(false)
{
}
NullFileTransport::~NullFileTransport()
{
}
bool NullFileTransport::connect()
{
mConnected = true;
return true;
}
void NullFileTransport::disconnect()
{
mConnected = false;
}
bool NullFileTransport::isConnected()
{
return mConnected;
}
bool NullFileTransport::write(const uint8_t* /*inBytes*/, uint32_t inLength)
{
PX_ASSERT(mLocked);
if(mConnected)
{
uint32_t len = inLength;
mWrittenData += len;
return len == inLength;
}
else
return false;
}
PxPvdTransport& NullFileTransport::lock()
{
mMutex.lock();
PX_ASSERT(!mLocked);
mLocked = true;
return *this;
}
void NullFileTransport::unlock()
{
PX_ASSERT(mLocked);
mLocked = false;
mMutex.unlock();
}
void NullFileTransport::flush()
{
}
uint64_t NullFileTransport::getWrittenDataSize()
{
return mWrittenData;
}
void NullFileTransport::release()
{
PX_DELETE_THIS;
}
} // namespace pvdsdk
PxPvdTransport* PxDefaultPvdFileTransportCreate(const char* name)
{
if(name)
return PX_NEW(pvdsdk::PvdDefaultFileTransport)(name);
else
return PX_NEW(pvdsdk::NullFileTransport)();
}
} // namespace physx
| 4,866 | C++ | 21.325688 | 119 | 0.748048 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEvents.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_EVENTS_H
#define PX_PROFILE_EVENTS_H
#include "foundation/PxMath.h"
#include "foundation/PxAssert.h"
#include "PxProfileEventId.h"
#define PX_PROFILE_UNION_1(a) physx::profile::TUnion<a, physx::profile::Empty>
#define PX_PROFILE_UNION_2(a,b) physx::profile::TUnion<a, PX_PROFILE_UNION_1(b)>
#define PX_PROFILE_UNION_3(a,b,c) physx::profile::TUnion<a, PX_PROFILE_UNION_2(b,c)>
#define PX_PROFILE_UNION_4(a,b,c,d) physx::profile::TUnion<a, PX_PROFILE_UNION_3(b,c,d)>
#define PX_PROFILE_UNION_5(a,b,c,d,e) physx::profile::TUnion<a, PX_PROFILE_UNION_4(b,c,d,e)>
#define PX_PROFILE_UNION_6(a,b,c,d,e,f) physx::profile::TUnion<a, PX_PROFILE_UNION_5(b,c,d,e,f)>
#define PX_PROFILE_UNION_7(a,b,c,d,e,f,g) physx::profile::TUnion<a, PX_PROFILE_UNION_6(b,c,d,e,f,g)>
#define PX_PROFILE_UNION_8(a,b,c,d,e,f,g,h) physx::profile::TUnion<a, PX_PROFILE_UNION_7(b,c,d,e,f,g,h)>
#define PX_PROFILE_UNION_9(a,b,c,d,e,f,g,h,i) physx::profile::TUnion<a, PX_PROFILE_UNION_8(b,c,d,e,f,g,h,i)>
namespace physx { namespace profile {
struct Empty {};
template <typename T> struct Type2Type {};
template <typename U, typename V>
union TUnion
{
typedef U Head;
typedef V Tail;
Head head;
Tail tail;
template <typename TDataType>
void init(const TDataType& inData)
{
toType(Type2Type<TDataType>()).init(inData);
}
template <typename TDataType>
PX_FORCE_INLINE TDataType& toType(const Type2Type<TDataType>& outData) { return tail.toType(outData); }
PX_FORCE_INLINE Head& toType(const Type2Type<Head>&) { return head; }
template <typename TDataType>
PX_FORCE_INLINE const TDataType& toType(const Type2Type<TDataType>& outData) const { return tail.toType(outData); }
PX_FORCE_INLINE const Head& toType(const Type2Type<Head>&) const { return head; }
};
struct EventTypes
{
enum Enum
{
Unknown = 0,
StartEvent,
StopEvent,
RelativeStartEvent, //reuses context,id from the earlier event.
RelativeStopEvent, //reuses context,id from the earlier event.
EventValue,
CUDAProfileBuffer //obsolete, placeholder to skip data from PhysX SDKs < 3.4
};
};
struct EventStreamCompressionFlags
{
enum Enum
{
U8 = 0,
U16 = 1,
U32 = 2,
U64 = 3,
CompressionMask = 3
};
};
#if PX_APPLE_FAMILY
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#endif
//Find the smallest value that will represent the incoming value without loss.
//We can enlarge the current compression value, but we can't make is smaller.
//In this way, we can use this function to find the smallest compression setting
//that will work for a set of values.
inline EventStreamCompressionFlags::Enum findCompressionValue( uint64_t inValue, EventStreamCompressionFlags::Enum inCurrentCompressionValue = EventStreamCompressionFlags::U8 )
{
PX_ASSERT_WITH_MESSAGE( (inCurrentCompressionValue >= EventStreamCompressionFlags::U8) &&
(inCurrentCompressionValue <= EventStreamCompressionFlags::U64),
"Invalid inCurrentCompressionValue in profile::findCompressionValue");
//Fallthrough is intentional
switch( inCurrentCompressionValue )
{
case EventStreamCompressionFlags::U8:
if ( inValue <= UINT8_MAX )
return EventStreamCompressionFlags::U8;
case EventStreamCompressionFlags::U16:
if ( inValue <= UINT16_MAX )
return EventStreamCompressionFlags::U16;
case EventStreamCompressionFlags::U32:
if ( inValue <= UINT32_MAX )
return EventStreamCompressionFlags::U32;
case EventStreamCompressionFlags::U64:
break;
}
return EventStreamCompressionFlags::U64;
}
//Find the smallest value that will represent the incoming value without loss.
//We can enlarge the current compression value, but we can't make is smaller.
//In this way, we can use this function to find the smallest compression setting
//that will work for a set of values.
inline EventStreamCompressionFlags::Enum findCompressionValue( uint32_t inValue, EventStreamCompressionFlags::Enum inCurrentCompressionValue = EventStreamCompressionFlags::U8 )
{
PX_ASSERT_WITH_MESSAGE( (inCurrentCompressionValue >= EventStreamCompressionFlags::U8) &&
(inCurrentCompressionValue <= EventStreamCompressionFlags::U64),
"Invalid inCurrentCompressionValue in profile::findCompressionValue");
//Fallthrough is intentional
switch( inCurrentCompressionValue )
{
case EventStreamCompressionFlags::U8:
if ( inValue <= UINT8_MAX )
return EventStreamCompressionFlags::U8;
case EventStreamCompressionFlags::U16:
if ( inValue <= UINT16_MAX )
return EventStreamCompressionFlags::U16;
case EventStreamCompressionFlags::U32:
case EventStreamCompressionFlags::U64:
break;
}
return EventStreamCompressionFlags::U32;
}
#if PX_APPLE_FAMILY
#pragma clang diagnostic pop
#endif
//Event header is 32 bytes and precedes all events.
struct EventHeader
{
uint8_t mEventType; //Used to parse the correct event out of the stream
uint8_t mStreamOptions; //Timestamp compression, etc.
uint16_t mEventId; //16 bit per-event-system event id
EventHeader( uint8_t type = 0, uint16_t id = 0 )
: mEventType( type )
, mStreamOptions( uint8_t(-1) )
, mEventId( id )
{
}
EventHeader( EventTypes::Enum type, uint16_t id )
: mEventType( static_cast<uint8_t>( type ) )
, mStreamOptions( uint8_t(-1) )
, mEventId( id )
{
}
EventStreamCompressionFlags::Enum getTimestampCompressionFlags() const
{
return static_cast<EventStreamCompressionFlags::Enum> ( mStreamOptions & EventStreamCompressionFlags::CompressionMask );
}
uint64_t compressTimestamp( uint64_t inLastTimestamp, uint64_t inCurrentTimestamp )
{
mStreamOptions = EventStreamCompressionFlags::U64;
uint64_t retval = inCurrentTimestamp;
if ( inLastTimestamp )
{
retval = inCurrentTimestamp - inLastTimestamp;
EventStreamCompressionFlags::Enum compressionValue = findCompressionValue( retval );
mStreamOptions = static_cast<uint8_t>( compressionValue );
if ( compressionValue == EventStreamCompressionFlags::U64 )
retval = inCurrentTimestamp; //just send the timestamp as is.
}
return retval;
}
uint64_t uncompressTimestamp( uint64_t inLastTimestamp, uint64_t inCurrentTimestamp ) const
{
if ( getTimestampCompressionFlags() != EventStreamCompressionFlags::U64 )
return inLastTimestamp + inCurrentTimestamp;
return inCurrentTimestamp;
}
void setContextIdCompressionFlags( uint64_t inContextId )
{
uint8_t options = static_cast<uint8_t>( findCompressionValue( inContextId ) );
mStreamOptions = uint8_t(mStreamOptions | options << 2);
}
EventStreamCompressionFlags::Enum getContextIdCompressionFlags() const
{
return static_cast< EventStreamCompressionFlags::Enum >( ( mStreamOptions >> 2 ) & EventStreamCompressionFlags::CompressionMask );
}
bool operator==( const EventHeader& inOther ) const
{
return mEventType == inOther.mEventType
&& mStreamOptions == inOther.mStreamOptions
&& mEventId == inOther.mEventId;
}
template<typename TStreamType>
inline uint32_t streamify( TStreamType& inStream )
{
uint32_t writtenSize = inStream.streamify( "EventType", mEventType );
writtenSize += inStream.streamify("StreamOptions", mStreamOptions); //Timestamp compression, etc.
writtenSize += inStream.streamify("EventId", mEventId); //16 bit per-event-system event id
return writtenSize;
}
};
//Declaration of type level getEventType function that maps enumeration event types to datatypes
template<typename TDataType>
inline EventTypes::Enum getEventType() { PX_ASSERT( false ); return EventTypes::Unknown; }
//Relative profile event means this event is sharing the context and thread id
//with the event before it.
struct RelativeProfileEvent
{
uint64_t mTensOfNanoSeconds; //timestamp is in tensOfNanonseconds
void init( uint64_t inTs ) { mTensOfNanoSeconds = inTs; }
void init( const RelativeProfileEvent& inData ) { mTensOfNanoSeconds = inData.mTensOfNanoSeconds; }
bool operator==( const RelativeProfileEvent& other ) const
{
return mTensOfNanoSeconds == other.mTensOfNanoSeconds;
}
template<typename TStreamType>
uint32_t streamify( TStreamType& inStream, const EventHeader& inHeader )
{
return inStream.streamify( "TensOfNanoSeconds", mTensOfNanoSeconds, inHeader.getTimestampCompressionFlags() );
}
uint64_t getTimestamp() const { return mTensOfNanoSeconds; }
void setTimestamp( uint64_t inTs ) { mTensOfNanoSeconds = inTs; }
void setupHeader( EventHeader& inHeader, uint64_t inLastTimestamp )
{
mTensOfNanoSeconds = inHeader.compressTimestamp( inLastTimestamp, mTensOfNanoSeconds );
}
uint32_t getEventSize(const EventHeader& inHeader)
{
uint32_t size = 0;
switch (inHeader.getTimestampCompressionFlags())
{
case EventStreamCompressionFlags::U8:
size = 1;
break;
case EventStreamCompressionFlags::U16:
size = 2;
break;
case EventStreamCompressionFlags::U32:
size = 4;
break;
case EventStreamCompressionFlags::U64:
size = 8;
break;
}
return size;
}
};
//Start version of the relative event.
struct RelativeStartEvent : public RelativeProfileEvent
{
void init( uint64_t inTs = 0 ) { RelativeProfileEvent::init( inTs ); }
void init( const RelativeStartEvent& inData ) { RelativeProfileEvent::init( inData ); }
template<typename THandlerType>
void handle( THandlerType* inHdlr, uint16_t eventId, uint32_t thread, uint64_t context, uint8_t inCpuId, uint8_t threadPriority ) const
{
inHdlr->onStartEvent( PxProfileEventId( eventId ), thread, context, inCpuId, threadPriority, mTensOfNanoSeconds );
}
};
template<> inline EventTypes::Enum getEventType<RelativeStartEvent>() { return EventTypes::RelativeStartEvent; }
//Stop version of relative event.
struct RelativeStopEvent : public RelativeProfileEvent
{
void init( uint64_t inTs = 0 ) { RelativeProfileEvent::init( inTs ); }
void init( const RelativeStopEvent& inData ) { RelativeProfileEvent::init( inData ); }
template<typename THandlerType>
void handle( THandlerType* inHdlr, uint16_t eventId, uint32_t thread, uint64_t context, uint8_t inCpuId, uint8_t threadPriority ) const
{
inHdlr->onStopEvent( PxProfileEventId( eventId ), thread, context, inCpuId, threadPriority, mTensOfNanoSeconds );
}
};
template<> inline EventTypes::Enum getEventType<RelativeStopEvent>() { return EventTypes::RelativeStopEvent; }
struct EventContextInformation
{
uint64_t mContextId;
uint32_t mThreadId; //Thread this event was taken from
uint8_t mThreadPriority;
uint8_t mCpuId;
void init( uint32_t inThreadId = UINT32_MAX
, uint64_t inContextId = (uint64_t(-1))
, uint8_t inPriority = UINT8_MAX
, uint8_t inCpuId = UINT8_MAX )
{
mContextId = inContextId;
mThreadId = inThreadId;
mThreadPriority = inPriority;
mCpuId = inCpuId;
}
void init( const EventContextInformation& inData )
{
mContextId = inData.mContextId;
mThreadId = inData.mThreadId;
mThreadPriority = inData.mThreadPriority;
mCpuId = inData.mCpuId;
}
template<typename TStreamType>
uint32_t streamify( TStreamType& inStream, EventStreamCompressionFlags::Enum inContextIdFlags )
{
uint32_t writtenSize = inStream.streamify( "ThreadId", mThreadId );
writtenSize += inStream.streamify("ContextId", mContextId, inContextIdFlags);
writtenSize += inStream.streamify("ThreadPriority", mThreadPriority);
writtenSize += inStream.streamify("CpuId", mCpuId);
return writtenSize;
}
bool operator==( const EventContextInformation& other ) const
{
return mThreadId == other.mThreadId
&& mContextId == other.mContextId
&& mThreadPriority == other.mThreadPriority
&& mCpuId == other.mCpuId;
}
void setToDefault()
{
*this = EventContextInformation();
}
};
//Profile event contains all the data required to tell the profile what is going
//on.
struct ProfileEvent
{
EventContextInformation mContextInformation;
RelativeProfileEvent mTimeData; //timestamp in seconds.
void init( uint32_t inThreadId, uint64_t inContextId, uint8_t inCpuId, uint8_t inPriority, uint64_t inTs )
{
mContextInformation.init( inThreadId, inContextId, inPriority, inCpuId );
mTimeData.init( inTs );
}
void init( const ProfileEvent& inData )
{
mContextInformation.init( inData.mContextInformation );
mTimeData.init( inData.mTimeData );
}
bool operator==( const ProfileEvent& other ) const
{
return mContextInformation == other.mContextInformation
&& mTimeData == other.mTimeData;
}
template<typename TStreamType>
uint32_t streamify( TStreamType& inStream, const EventHeader& inHeader )
{
uint32_t writtenSize = mContextInformation.streamify(inStream, inHeader.getContextIdCompressionFlags());
writtenSize += mTimeData.streamify(inStream, inHeader);
return writtenSize;
}
uint32_t getEventSize(const EventHeader& inHeader)
{
uint32_t eventSize = 0;
// time is stored depending on the conpress flag mTimeData.streamify(inStream, inHeader);
switch (inHeader.getTimestampCompressionFlags())
{
case EventStreamCompressionFlags::U8:
eventSize++;
break;
case EventStreamCompressionFlags::U16:
eventSize += 2;
break;
case EventStreamCompressionFlags::U32:
eventSize += 4;
break;
case EventStreamCompressionFlags::U64:
eventSize += 8;
break;
}
// context information
// mContextInformation.streamify( inStream, inHeader.getContextIdCompressionFlags() );
eventSize += 6; // uint32_t mThreadId; uint8_t mThreadPriority; uint8_t mCpuId;
switch (inHeader.getContextIdCompressionFlags())
{
case EventStreamCompressionFlags::U8:
eventSize++;
break;
case EventStreamCompressionFlags::U16:
eventSize += 2;
break;
case EventStreamCompressionFlags::U32:
eventSize += 4;
break;
case EventStreamCompressionFlags::U64:
eventSize += 8;
break;
}
return eventSize;
}
uint64_t getTimestamp() const { return mTimeData.getTimestamp(); }
void setTimestamp( uint64_t inTs ) { mTimeData.setTimestamp( inTs ); }
void setupHeader( EventHeader& inHeader, uint64_t inLastTimestamp )
{
mTimeData.setupHeader( inHeader, inLastTimestamp );
inHeader.setContextIdCompressionFlags( mContextInformation.mContextId );
}
};
//profile start event starts the profile session.
struct StartEvent : public ProfileEvent
{
void init( uint32_t inThreadId = 0, uint64_t inContextId = 0, uint8_t inCpuId = 0, uint8_t inPriority = 0, uint64_t inTensOfNanoSeconds = 0 )
{
ProfileEvent::init( inThreadId, inContextId, inCpuId, inPriority, inTensOfNanoSeconds );
}
void init( const StartEvent& inData )
{
ProfileEvent::init( inData );
}
RelativeStartEvent getRelativeEvent() const { RelativeStartEvent theEvent; theEvent.init( mTimeData.mTensOfNanoSeconds ); return theEvent; }
EventTypes::Enum getRelativeEventType() const { return getEventType<RelativeStartEvent>(); }
};
template<> inline EventTypes::Enum getEventType<StartEvent>() { return EventTypes::StartEvent; }
//Profile stop event stops the profile session.
struct StopEvent : public ProfileEvent
{
void init( uint32_t inThreadId = 0, uint64_t inContextId = 0, uint8_t inCpuId = 0, uint8_t inPriority = 0, uint64_t inTensOfNanoSeconds = 0 )
{
ProfileEvent::init( inThreadId, inContextId, inCpuId, inPriority, inTensOfNanoSeconds );
}
void init( const StopEvent& inData )
{
ProfileEvent::init( inData );
}
RelativeStopEvent getRelativeEvent() const { RelativeStopEvent theEvent; theEvent.init( mTimeData.mTensOfNanoSeconds ); return theEvent; }
EventTypes::Enum getRelativeEventType() const { return getEventType<RelativeStopEvent>(); }
};
template<> inline EventTypes::Enum getEventType<StopEvent>() { return EventTypes::StopEvent; }
struct EventValue
{
uint64_t mValue;
uint64_t mContextId;
uint32_t mThreadId;
void init( int64_t inValue = 0, uint64_t inContextId = 0, uint32_t inThreadId = 0 )
{
mValue = static_cast<uint64_t>( inValue );
mContextId = inContextId;
mThreadId = inThreadId;
}
void init( const EventValue& inData )
{
mValue = inData.mValue;
mContextId = inData.mContextId;
mThreadId = inData.mThreadId;
}
int64_t getValue() const { return static_cast<int16_t>( mValue ); }
void setupHeader( EventHeader& inHeader )
{
mValue = inHeader.compressTimestamp( 0, mValue );
inHeader.setContextIdCompressionFlags( mContextId );
}
template<typename TStreamType>
uint32_t streamify( TStreamType& inStream, const EventHeader& inHeader )
{
uint32_t writtenSize = inStream.streamify("Value", mValue, inHeader.getTimestampCompressionFlags());
writtenSize += inStream.streamify("ContextId", mContextId, inHeader.getContextIdCompressionFlags());
writtenSize += inStream.streamify("ThreadId", mThreadId);
return writtenSize;
}
uint32_t getEventSize(const EventHeader& inHeader)
{
uint32_t eventSize = 0;
// value
switch (inHeader.getTimestampCompressionFlags())
{
case EventStreamCompressionFlags::U8:
eventSize++;
break;
case EventStreamCompressionFlags::U16:
eventSize += 2;
break;
case EventStreamCompressionFlags::U32:
eventSize += 4;
break;
case EventStreamCompressionFlags::U64:
eventSize += 8;
break;
}
// context information
switch (inHeader.getContextIdCompressionFlags())
{
case EventStreamCompressionFlags::U8:
eventSize++;
break;
case EventStreamCompressionFlags::U16:
eventSize += 2;
break;
case EventStreamCompressionFlags::U32:
eventSize += 4;
break;
case EventStreamCompressionFlags::U64:
eventSize += 8;
break;
}
eventSize += 4; // uint32_t mThreadId;
return eventSize;
}
bool operator==( const EventValue& other ) const
{
return mValue == other.mValue
&& mContextId == other.mContextId
&& mThreadId == other.mThreadId;
}
template<typename THandlerType>
void handle( THandlerType* inHdlr, uint16_t eventId ) const
{
inHdlr->onEventValue( PxProfileEventId( eventId ), mThreadId, mContextId, getValue() );
}
};
template<> inline EventTypes::Enum getEventType<EventValue>() { return EventTypes::EventValue; }
//obsolete, placeholder to skip data from PhysX SDKs < 3.4
struct CUDAProfileBuffer
{
uint64_t mTimestamp;
float mTimespan;
const uint8_t* mCudaData;
uint32_t mBufLen;
uint32_t mVersion;
template<typename TStreamType>
uint32_t streamify( TStreamType& inStream, const EventHeader& )
{
uint32_t writtenSize = inStream.streamify("Timestamp", mTimestamp);
writtenSize += inStream.streamify("Timespan", mTimespan);
writtenSize += inStream.streamify("CudaData", mCudaData, mBufLen);
writtenSize += inStream.streamify("BufLen", mBufLen);
writtenSize += inStream.streamify("Version", mVersion);
return writtenSize;
}
bool operator==( const CUDAProfileBuffer& other ) const
{
return mTimestamp == other.mTimestamp
&& mTimespan == other.mTimespan
&& mBufLen == other.mBufLen
&& memcmp( mCudaData, other.mCudaData, mBufLen ) == 0
&& mVersion == other.mVersion;
}
};
template<> inline EventTypes::Enum getEventType<CUDAProfileBuffer>() { return EventTypes::CUDAProfileBuffer; }
//Provides a generic equal operation for event data objects.
template <typename TEventData>
struct EventDataEqualOperator
{
TEventData mData;
EventDataEqualOperator( const TEventData& inD ) : mData( inD ) {}
template<typename TDataType> bool operator()( const TDataType& inRhs ) const { return mData.toType( Type2Type<TDataType>() ) == inRhs; }
bool operator()() const { return false; }
};
/**
* Generic event container that combines and even header with the generic event data type.
* Provides unsafe and typesafe access to the event data.
*/
class Event
{
public:
typedef PX_PROFILE_UNION_7(StartEvent, StopEvent, RelativeStartEvent, RelativeStopEvent, EventValue, CUDAProfileBuffer, uint8_t) EventData;
private:
EventHeader mHeader;
EventData mData;
public:
Event() {}
template <typename TDataType>
Event( EventHeader inHeader, const TDataType& inData )
: mHeader( inHeader )
{
mData.init<TDataType>(inData);
}
template<typename TDataType>
Event( uint16_t eventId, const TDataType& inData )
: mHeader( getEventType<TDataType>(), eventId )
{
mData.init<TDataType>(inData);
}
const EventHeader& getHeader() const { return mHeader; }
const EventData& getData() const { return mData; }
template<typename TDataType>
const TDataType& getValue() const { PX_ASSERT( mHeader.mEventType == getEventType<TDataType>() ); return mData.toType<TDataType>(); }
template<typename TDataType>
TDataType& getValue() { PX_ASSERT( mHeader.mEventType == getEventType<TDataType>() ); return mData.toType<TDataType>(); }
template<typename TRetVal, typename TOperator>
inline TRetVal visit( TOperator inOp ) const;
bool operator==( const Event& inOther ) const
{
if ( !(mHeader == inOther.mHeader ) ) return false;
if ( mHeader.mEventType )
return inOther.visit<bool>( EventDataEqualOperator<EventData>( mData ) );
return true;
}
};
//Combining the above union type with an event type means that an object can get the exact
//data out of the union. Using this function means that all callsites will be forced to
//deal with the newer datatypes and that the switch statement only exists in once place.
//Implements conversion from enum -> datatype
template<typename TRetVal, typename TOperator>
TRetVal visit( EventTypes::Enum inEventType, const Event::EventData& inData, TOperator inOperator )
{
switch( inEventType )
{
case EventTypes::StartEvent: return inOperator( inData.toType( Type2Type<StartEvent>() ) );
case EventTypes::StopEvent: return inOperator( inData.toType( Type2Type<StopEvent>() ) );
case EventTypes::RelativeStartEvent: return inOperator( inData.toType( Type2Type<RelativeStartEvent>() ) );
case EventTypes::RelativeStopEvent: return inOperator( inData.toType( Type2Type<RelativeStopEvent>() ) );
case EventTypes::EventValue: return inOperator( inData.toType( Type2Type<EventValue>() ) );
//obsolete, placeholder to skip data from PhysX SDKs < 3.4
case EventTypes::CUDAProfileBuffer: return inOperator( inData.toType( Type2Type<CUDAProfileBuffer>() ) );
case EventTypes::Unknown: break;
}
uint8_t type = static_cast<uint8_t>( inEventType );
return inOperator( type );
}
template<typename TRetVal, typename TOperator>
inline TRetVal Event::visit( TOperator inOp ) const
{
return physx::profile::visit<TRetVal>( static_cast<EventTypes::Enum>(mHeader.mEventType), mData, inOp );
}
} }
#endif
| 24,440 | C | 33.61898 | 177 | 0.729378 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelInternalTypes.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_OBJECT_MODEL_INTERNAL_TYPES_H
#define PX_PVD_OBJECT_MODEL_INTERNAL_TYPES_H
#include "foundation/PxMemory.h"
#include "PxPvdObjectModelBaseTypes.h"
#include "foundation/PxArray.h"
#include "PxPvdFoundation.h"
namespace physx
{
namespace pvdsdk
{
struct PvdInternalType
{
enum Enum
{
None = 0,
#define DECLARE_INTERNAL_PVD_TYPE(type) type,
#include "PxPvdObjectModelInternalTypeDefs.h"
Last
#undef DECLARE_INTERNAL_PVD_TYPE
};
};
PX_COMPILE_TIME_ASSERT(uint32_t(PvdInternalType::Last) <= uint32_t(PvdBaseType::InternalStop));
template <typename T>
struct DataTypeToPvdTypeMap
{
bool compile_error;
};
template <PvdInternalType::Enum>
struct PvdTypeToDataTypeMap
{
bool compile_error;
};
#define DECLARE_INTERNAL_PVD_TYPE(type) \
template <> \
struct DataTypeToPvdTypeMap<type> \
{ \
enum Enum \
{ \
BaseTypeEnum = PvdInternalType::type \
}; \
}; \
template <> \
struct PvdTypeToDataTypeMap<PvdInternalType::type> \
{ \
typedef type TDataType; \
}; \
template <> \
struct PvdDataTypeToNamespacedNameMap<type> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<type>() : Name("physx3_debugger_internal", #type) \
{ \
} \
};
#include "PxPvdObjectModelInternalTypeDefs.h"
#undef DECLARE_INTERNAL_PVD_TYPE
template <typename TDataType, typename TAlloc>
DataRef<TDataType> toDataRef(const PxArray<TDataType, TAlloc>& data)
{
return DataRef<TDataType>(data.begin(), data.end());
}
static inline bool safeStrEq(const DataRef<String>& lhs, const DataRef<String>& rhs)
{
uint32_t count = lhs.size();
if(count != rhs.size())
return false;
for(uint32_t idx = 0; idx < count; ++idx)
if(!safeStrEq(lhs[idx], rhs[idx]))
return false;
return true;
}
static inline char* copyStr(const char* str)
{
str = nonNull(str);
uint32_t len = static_cast<uint32_t>(strlen(str));
char* newData = reinterpret_cast<char*>(PX_ALLOC(len + 1, "string"));
PxMemCopy(newData, str, len);
newData[len] = 0;
return newData;
}
// Used for predictable bit fields.
template <typename TDataType, uint8_t TNumBits, uint8_t TOffset, typename TInputType>
struct BitMaskSetter
{
// Create a mask that masks out the orginal value shift into place
static TDataType createOffsetMask()
{
return createMask() << TOffset;
}
// Create a mask of TNumBits number of tis
static TDataType createMask()
{
return static_cast<TDataType>((1 << TNumBits) - 1);
}
void setValue(TDataType& inCurrent, TInputType inData)
{
PX_ASSERT(inData < (1 << TNumBits));
// Create a mask to remove the current value.
TDataType theMask = ~(createOffsetMask());
// Clear out current value.
inCurrent = inCurrent & theMask;
// Create the new value.
TDataType theAddition = reinterpret_cast<TDataType>(inData << TOffset);
// or it into the existing value.
inCurrent = inCurrent | theAddition;
}
TInputType getValue(TDataType inCurrent)
{
return static_cast<TInputType>((inCurrent >> TOffset) & createMask());
}
};
}
}
#endif
| 6,519 | C | 41.337662 | 120 | 0.511888 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdMemClient.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxPvdImpl.h"
#include "PxPvdMemClient.h"
namespace physx
{
namespace pvdsdk
{
PvdMemClient::PvdMemClient(PvdImpl& pvd)
: mSDKPvd(pvd)
, mPvdDataStream(NULL)
, mIsConnected(false)
, mMemEventBuffer(profile::PxProfileMemoryEventBuffer::createMemoryEventBuffer(*gPvdAllocatorCallback))
{
}
PvdMemClient::~PvdMemClient()
{
mSDKPvd.removeClient(this);
if(mMemEventBuffer.hasClients())
mPvdDataStream->destroyInstance(&mMemEventBuffer);
mMemEventBuffer.release();
}
PvdDataStream* PvdMemClient::getDataStream()
{
return mPvdDataStream;
}
bool PvdMemClient::isConnected() const
{
return mIsConnected;
}
void PvdMemClient::onPvdConnected()
{
if(mIsConnected)
return;
mIsConnected = true;
mPvdDataStream = PvdDataStream::create(&mSDKPvd);
mPvdDataStream->createInstance(&mMemEventBuffer);
mMemEventBuffer.addClient(*this);
}
void PvdMemClient::onPvdDisconnected()
{
if(!mIsConnected)
return;
mIsConnected = false;
flush();
mMemEventBuffer.removeClient(*this);
mPvdDataStream->release();
mPvdDataStream = NULL;
}
void PvdMemClient::onAllocation(size_t inSize, const char* inType, const char* inFile, int inLine, void* inAddr)
{
mMutex.lock();
mMemEventBuffer.onAllocation(inSize, inType, inFile, inLine, inAddr);
mMutex.unlock();
}
void PvdMemClient::onDeallocation(void* inAddr)
{
mMutex.lock();
mMemEventBuffer.onDeallocation(inAddr);
mMutex.unlock();
}
void PvdMemClient::flush()
{
mMutex.lock();
mMemEventBuffer.flushProfileEvents();
mMutex.unlock();
}
void PvdMemClient::handleBufferFlush(const uint8_t* inData, uint32_t inLength)
{
if(mPvdDataStream)
mPvdDataStream->setPropertyValue(&mMemEventBuffer, "events", inData, inLength);
}
void PvdMemClient::handleClientRemoved()
{
}
} // pvd
} // physx
| 3,453 | C++ | 27.783333 | 112 | 0.764263 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdMarshalling.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_MARSHALLING_H
#define PX_PVD_MARSHALLING_H
#include "foundation/PxMathIntrinsics.h"
#include "PxPvdObjectModelBaseTypes.h"
#include "PxPvdBits.h"
namespace physx
{
namespace pvdsdk
{
// Define marshalling
template <typename TSmallerType, typename TLargerType>
struct PvdMarshalling
{
bool canMarshal;
PvdMarshalling() : canMarshal(false)
{
}
};
template <typename smtype, typename lgtype>
static inline void marshalSingleT(const uint8_t* srcData, uint8_t* destData)
{
smtype incoming;
physx::intrinsics::memCopy(&incoming, srcData, sizeof(smtype));
lgtype outgoing = static_cast<lgtype>(incoming);
physx::intrinsics::memCopy(destData, &outgoing, sizeof(lgtype));
}
template <typename smtype, typename lgtype>
static inline void marshalBlockT(const uint8_t* srcData, uint8_t* destData, uint32_t numBytes)
{
for(const uint8_t* item = srcData, *end = srcData + numBytes; item < end;
item += sizeof(smtype), destData += sizeof(lgtype))
marshalSingleT<smtype, lgtype>(item, destData);
}
#define PVD_TYPE_MARSHALLER(smtype, lgtype) \
template <> \
struct PvdMarshalling<smtype, lgtype> \
{ \
uint32_t canMarshal; \
static void marshalSingle(const uint8_t* srcData, uint8_t* destData) \
{ \
marshalSingleT<smtype, lgtype>(srcData, destData); \
} \
static void marshalBlock(const uint8_t* srcData, uint8_t* destData, uint32_t numBytes) \
{ \
marshalBlockT<smtype, lgtype>(srcData, destData, numBytes); \
} \
};
// define marshalling tables.
PVD_TYPE_MARSHALLER(int8_t, int16_t)
PVD_TYPE_MARSHALLER(int8_t, uint16_t)
PVD_TYPE_MARSHALLER(int8_t, int32_t)
PVD_TYPE_MARSHALLER(int8_t, uint32_t)
PVD_TYPE_MARSHALLER(int8_t, int64_t)
PVD_TYPE_MARSHALLER(int8_t, uint64_t)
PVD_TYPE_MARSHALLER(int8_t, PvdF32)
PVD_TYPE_MARSHALLER(int8_t, PvdF64)
PVD_TYPE_MARSHALLER(uint8_t, int16_t)
PVD_TYPE_MARSHALLER(uint8_t, uint16_t)
PVD_TYPE_MARSHALLER(uint8_t, int32_t)
PVD_TYPE_MARSHALLER(uint8_t, uint32_t)
PVD_TYPE_MARSHALLER(uint8_t, int64_t)
PVD_TYPE_MARSHALLER(uint8_t, uint64_t)
PVD_TYPE_MARSHALLER(uint8_t, PvdF32)
PVD_TYPE_MARSHALLER(uint8_t, PvdF64)
PVD_TYPE_MARSHALLER(int16_t, int32_t)
PVD_TYPE_MARSHALLER(int16_t, uint32_t)
PVD_TYPE_MARSHALLER(int16_t, int64_t)
PVD_TYPE_MARSHALLER(int16_t, uint64_t)
PVD_TYPE_MARSHALLER(int16_t, PvdF32)
PVD_TYPE_MARSHALLER(int16_t, PvdF64)
PVD_TYPE_MARSHALLER(uint16_t, int32_t)
PVD_TYPE_MARSHALLER(uint16_t, uint32_t)
PVD_TYPE_MARSHALLER(uint16_t, int64_t)
PVD_TYPE_MARSHALLER(uint16_t, uint64_t)
PVD_TYPE_MARSHALLER(uint16_t, PvdF32)
PVD_TYPE_MARSHALLER(uint16_t, PvdF64)
PVD_TYPE_MARSHALLER(int32_t, int64_t)
PVD_TYPE_MARSHALLER(int32_t, uint64_t)
PVD_TYPE_MARSHALLER(int32_t, PvdF64)
PVD_TYPE_MARSHALLER(int32_t, PvdF32)
PVD_TYPE_MARSHALLER(uint32_t, int64_t)
PVD_TYPE_MARSHALLER(uint32_t, uint64_t)
PVD_TYPE_MARSHALLER(uint32_t, PvdF64)
PVD_TYPE_MARSHALLER(uint32_t, PvdF32)
PVD_TYPE_MARSHALLER(PvdF32, PvdF64)
PVD_TYPE_MARSHALLER(PvdF32, uint32_t)
PVD_TYPE_MARSHALLER(PvdF32, int32_t)
PVD_TYPE_MARSHALLER(uint64_t, PvdF64)
PVD_TYPE_MARSHALLER(int64_t, PvdF64)
PVD_TYPE_MARSHALLER(PvdF64, uint64_t)
PVD_TYPE_MARSHALLER(PvdF64, int64_t)
template <typename TMarshaller>
static inline bool getMarshalOperators(TSingleMarshaller&, TBlockMarshaller&, TMarshaller&, bool)
{
return false;
}
template <typename TMarshaller>
static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block, TMarshaller&, uint32_t)
{
single = TMarshaller::marshalSingle;
block = TMarshaller::marshalBlock;
return true;
}
template <typename smtype, typename lgtype>
static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block)
{
single = NULL;
block = NULL;
PvdMarshalling<smtype, lgtype> marshaller = PvdMarshalling<smtype, lgtype>();
return getMarshalOperators(single, block, marshaller, marshaller.canMarshal);
}
template <typename smtype>
static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block, int32_t lgtypeId)
{
switch(lgtypeId)
{
case PvdBaseType::PvdI8: // int8_t:
return getMarshalOperators<smtype, int8_t>(single, block);
case PvdBaseType::PvdU8: // uint8_t:
return getMarshalOperators<smtype, uint8_t>(single, block);
case PvdBaseType::PvdI16: // int16_t:
return getMarshalOperators<smtype, int16_t>(single, block);
case PvdBaseType::PvdU16: // uint16_t:
return getMarshalOperators<smtype, uint16_t>(single, block);
case PvdBaseType::PvdI32: // int32_t:
return getMarshalOperators<smtype, int32_t>(single, block);
case PvdBaseType::PvdU32: // uint32_t:
return getMarshalOperators<smtype, uint32_t>(single, block);
case PvdBaseType::PvdI64: // int64_t:
return getMarshalOperators<smtype, int64_t>(single, block);
case PvdBaseType::PvdU64: // uint64_t:
return getMarshalOperators<smtype, uint64_t>(single, block);
case PvdBaseType::PvdF32:
return getMarshalOperators<smtype, PvdF32>(single, block);
case PvdBaseType::PvdF64:
return getMarshalOperators<smtype, PvdF64>(single, block);
}
return false;
}
static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block, int32_t smtypeId,
int32_t lgtypeId)
{
switch(smtypeId)
{
case PvdBaseType::PvdI8: // int8_t:
return getMarshalOperators<int8_t>(single, block, lgtypeId);
case PvdBaseType::PvdU8: // uint8_t:
return getMarshalOperators<uint8_t>(single, block, lgtypeId);
case PvdBaseType::PvdI16: // int16_t:
return getMarshalOperators<int16_t>(single, block, lgtypeId);
case PvdBaseType::PvdU16: // uint16_t:
return getMarshalOperators<uint16_t>(single, block, lgtypeId);
case PvdBaseType::PvdI32: // int32_t:
return getMarshalOperators<int32_t>(single, block, lgtypeId);
case PvdBaseType::PvdU32: // uint32_t:
return getMarshalOperators<uint32_t>(single, block, lgtypeId);
case PvdBaseType::PvdI64: // int64_t:
return getMarshalOperators<int64_t>(single, block, lgtypeId);
case PvdBaseType::PvdU64: // uint64_t:
return getMarshalOperators<uint64_t>(single, block, lgtypeId);
case PvdBaseType::PvdF32:
return getMarshalOperators<PvdF32>(single, block, lgtypeId);
case PvdBaseType::PvdF64:
return getMarshalOperators<PvdF64>(single, block, lgtypeId);
}
return false;
}
}
}
#endif
| 8,876 | C | 39.167421 | 120 | 0.666629 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventSerialization.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_EVENT_SERIALIZATION_H
#define PX_PROFILE_EVENT_SERIALIZATION_H
#include "PxProfileDataParsing.h"
#include "PxProfileEvents.h"
namespace physx { namespace profile {
/**
* Array type must be a pxu8 container. Templated so that this object can write
* to different collections.
*/
template<typename TArrayType>
struct EventSerializer
{
TArrayType* mArray;
EventSerializer( TArrayType* inA ) : mArray( inA ) {}
template<typename TDataType>
uint32_t streamify( const char*, const TDataType& inType )
{
return mArray->write( inType );
}
uint32_t streamify( const char*, const char*& inType )
{
PX_ASSERT( inType != NULL );
uint32_t len( static_cast<uint32_t>( strlen( inType ) ) );
++len; //include the null terminator
uint32_t writtenSize = 0;
writtenSize = mArray->write(len);
writtenSize += mArray->write(inType, len);
return writtenSize;
}
uint32_t streamify( const char*, const uint8_t* inData, uint32_t len )
{
uint32_t writtenSize = mArray->write(len);
if ( len )
writtenSize += mArray->write(inData, len);
return writtenSize;
}
uint32_t streamify( const char* nm, const uint64_t& inType, EventStreamCompressionFlags::Enum inFlags )
{
uint32_t writtenSize = 0;
switch( inFlags )
{
case EventStreamCompressionFlags::U8:
writtenSize = streamify(nm, static_cast<uint8_t>(inType));
break;
case EventStreamCompressionFlags::U16:
writtenSize = streamify(nm, static_cast<uint16_t>(inType));
break;
case EventStreamCompressionFlags::U32:
writtenSize = streamify(nm, static_cast<uint32_t>(inType));
break;
case EventStreamCompressionFlags::U64:
writtenSize = streamify(nm, inType);
break;
}
return writtenSize;
}
uint32_t streamify( const char* nm, const uint32_t& inType, EventStreamCompressionFlags::Enum inFlags )
{
uint32_t writtenSize = 0;
switch( inFlags )
{
case EventStreamCompressionFlags::U8:
writtenSize = streamify(nm, static_cast<uint8_t>(inType));
break;
case EventStreamCompressionFlags::U16:
writtenSize = streamify(nm, static_cast<uint16_t>(inType));
break;
case EventStreamCompressionFlags::U32:
case EventStreamCompressionFlags::U64:
writtenSize = streamify(nm, inType);
break;
}
return writtenSize;
}
};
/**
* The event deserializes takes a buffer implements the streamify functions
* by setting the passed in data to the data in the buffer.
*/
template<bool TSwapBytes>
struct EventDeserializer
{
const uint8_t* mData;
uint32_t mLength;
bool mFail;
EventDeserializer( const uint8_t* inData, uint32_t inLength )
: mData( inData )
, mLength( inLength )
, mFail( false )
{
if ( mData == NULL )
mLength = 0;
}
bool val() { return TSwapBytes; }
uint32_t streamify( const char* , uint8_t& inType )
{
uint8_t* theData = reinterpret_cast<uint8_t*>( &inType ); //type punned pointer...
if ( mFail || sizeof( inType ) > mLength )
{
PX_ASSERT( false );
mFail = true;
}
else
{
for( uint32_t idx = 0; idx < sizeof( uint8_t ); ++idx, ++mData, --mLength )
theData[idx] = *mData;
}
return 0;
}
//default streamify reads things natively as bytes.
template<typename TDataType>
uint32_t streamify( const char* , TDataType& inType )
{
uint8_t* theData = reinterpret_cast<uint8_t*>( &inType ); //type punned pointer...
if ( mFail || sizeof( inType ) > mLength )
{
PX_ASSERT( false );
mFail = true;
}
else
{
for( uint32_t idx = 0; idx < sizeof( TDataType ); ++idx, ++mData, --mLength )
theData[idx] = *mData;
bool temp = val();
if ( temp )
BlockParseFunctions::swapBytes<sizeof(TDataType)>( theData );
}
return 0;
}
uint32_t streamify( const char*, const char*& inType )
{
uint32_t theLen;
streamify( "", theLen );
theLen = PxMin( theLen, mLength );
inType = reinterpret_cast<const char*>( mData );
mData += theLen;
mLength -= theLen;
return 0;
}
uint32_t streamify( const char*, const uint8_t*& inData, uint32_t& len )
{
uint32_t theLen;
streamify( "", theLen );
theLen = PxMin( theLen, mLength );
len = theLen;
inData = reinterpret_cast<const uint8_t*>( mData );
mData += theLen;
mLength -= theLen;
return 0;
}
uint32_t streamify( const char* nm, uint64_t& inType, EventStreamCompressionFlags::Enum inFlags )
{
switch( inFlags )
{
case EventStreamCompressionFlags::U8:
{
uint8_t val=0;
streamify( nm, val );
inType = val;
}
break;
case EventStreamCompressionFlags::U16:
{
uint16_t val;
streamify( nm, val );
inType = val;
}
break;
case EventStreamCompressionFlags::U32:
{
uint32_t val;
streamify( nm, val );
inType = val;
}
break;
case EventStreamCompressionFlags::U64:
streamify( nm, inType );
break;
}
return 0;
}
uint32_t streamify( const char* nm, uint32_t& inType, EventStreamCompressionFlags::Enum inFlags )
{
switch( inFlags )
{
case EventStreamCompressionFlags::U8:
{
uint8_t val=0;
streamify( nm, val );
inType = val;
}
break;
case EventStreamCompressionFlags::U16:
{
uint16_t val=0;
streamify( nm, val );
inType = val;
}
break;
case EventStreamCompressionFlags::U32:
case EventStreamCompressionFlags::U64:
streamify( nm, inType );
break;
}
return 0;
}
};
}}
#endif
| 7,248 | C | 27.206226 | 105 | 0.66984 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdImpl.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxPvdImpl.h"
#include "PxPvdMemClient.h"
#include "PxPvdProfileZoneClient.h"
#include "PxPvdProfileZone.h"
#if PX_SUPPORT_GPU_PHYSX
#include "gpu/PxGpu.h"
#endif
#if PX_NVTX
#include "nvToolsExt.h"
#endif
namespace
{
const char* gSdkName = "PhysXSDK";
}
namespace physx
{
namespace pvdsdk
{
class CmEventNameProvider : public physx::profile::PxProfileNameProvider
{
public:
physx::profile::PxProfileNames getProfileNames() const
{
physx::profile::PxProfileNames ret;
ret.eventCount = 0;
return ret;
}
};
CmEventNameProvider gProfileNameProvider;
void initializeModelTypes(PvdDataStream& stream)
{
stream.createClass<profile::PxProfileZone>();
stream.createProperty<profile::PxProfileZone, uint8_t>(
"events", PvdCommStreamEmbeddedTypes::getProfileEventStreamSemantic(), PropertyType::Array);
stream.createClass<profile::PxProfileMemoryEventBuffer>();
stream.createProperty<profile::PxProfileMemoryEventBuffer, uint8_t>(
"events", PvdCommStreamEmbeddedTypes::getMemoryEventStreamSemantic(), PropertyType::Array);
stream.createClass<PvdUserRenderer>();
stream.createProperty<PvdUserRenderer, uint8_t>(
"events", PvdCommStreamEmbeddedTypes::getRendererEventStreamSemantic(), PropertyType::Array);
}
PvdImpl* PvdImpl::sInstance = NULL;
uint32_t PvdImpl::sRefCount = 0;
PvdImpl::PvdImpl()
: mPvdTransport(NULL)
, mSharedMetaProvider(NULL)
, mMemClient(NULL)
, mIsConnected(false)
, mGPUProfilingWasConnected(false)
, mIsNVTXSupportEnabled(true)
, mNVTXContext(0)
, mNextStreamId(1)
, mProfileClient(NULL)
, mProfileZone(NULL)
{
mProfileZoneManager = &physx::profile::PxProfileZoneManager::createProfileZoneManager(PxGetBroadcastAllocator());
mProfileClient = PVD_NEW(PvdProfileZoneClient)(*this);
}
PvdImpl::~PvdImpl()
{
if((mFlags & PxPvdInstrumentationFlag::ePROFILE) )
{
PxSetProfilerCallback(NULL);
#if PX_SUPPORT_GPU_PHYSX
if (mGPUProfilingWasConnected)
{
PxSetPhysXGpuProfilerCallback(NULL);
}
#endif
}
disconnect();
if ( mProfileZoneManager )
{
mProfileZoneManager->release();
mProfileZoneManager = NULL;
}
PVD_DELETE(mProfileClient);
mProfileClient = NULL;
}
bool PvdImpl::connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags)
{
if(mIsConnected)
{
PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PxPvd::connect - recall connect! Should call disconnect before re-connect.");
return false;
}
mFlags = flags;
mPvdTransport = &transport;
mIsConnected = mPvdTransport->connect();
if(mIsConnected)
{
mSharedMetaProvider = PVD_NEW(MetaDataProvider);
sendTransportInitialization();
PvdDataStream* stream = PvdDataStream::create(this);
initializeModelTypes(*stream);
stream->release();
if(mFlags & PxPvdInstrumentationFlag::eMEMORY)
{
mMemClient = PVD_NEW(PvdMemClient)(*this);
mPvdClients.pushBack(mMemClient);
}
if((mFlags & PxPvdInstrumentationFlag::ePROFILE) && mProfileZoneManager)
{
mPvdClients.pushBack(mProfileClient);
mProfileZone = &physx::profile::PxProfileZone::createProfileZone(PxGetBroadcastAllocator(),gSdkName,gProfileNameProvider.getProfileNames());
}
for(uint32_t i = 0; i < mPvdClients.size(); i++)
mPvdClients[i]->onPvdConnected();
if (mProfileZone)
{
mProfileZoneManager->addProfileZoneHandler(*mProfileClient);
mProfileZoneManager->addProfileZone( *mProfileZone );
}
if ((mFlags & PxPvdInstrumentationFlag::ePROFILE))
{
PxSetProfilerCallback(this);
#if PX_SUPPORT_GPU_PHYSX
PxSetPhysXGpuProfilerCallback(this);
mGPUProfilingWasConnected = true;
#endif
}
}
return mIsConnected;
}
void PvdImpl::disconnect()
{
if(mProfileZone)
{
mProfileZoneManager->removeProfileZoneHandler(*mProfileClient);
mProfileZoneManager->removeProfileZone( *mProfileZone );
mProfileZone->release();
mProfileZone=NULL;
removeClient(mProfileClient);
}
if(mIsConnected)
{
for(uint32_t i = 0; i < mPvdClients.size(); i++)
mPvdClients[i]->onPvdDisconnected();
if(mMemClient)
{
removeClient(mMemClient);
PvdMemClient* tmp = mMemClient; //avoid tracking deallocation itsself
mMemClient = NULL;
PVD_DELETE(tmp);
}
mSharedMetaProvider->release();
mPvdTransport->disconnect();
mObjectRegistrar.clear();
mIsConnected = false;
}
}
void PvdImpl::flush()
{
for(uint32_t i = 0; i < mPvdClients.size(); i++)
mPvdClients[i]->flush();
if ( mProfileZone )
{
mProfileZone->flushEventIdNameMap();
mProfileZone->flushProfileEvents();
}
}
bool PvdImpl::isConnected(bool useCachedStatus)
{
if(mPvdTransport)
return useCachedStatus ? mIsConnected : mPvdTransport->isConnected();
else
return false;
}
PxPvdTransport* PvdImpl::getTransport()
{
return mPvdTransport;
}
PxPvdInstrumentationFlags PvdImpl::getInstrumentationFlags()
{
return mFlags;
}
void PvdImpl::sendTransportInitialization()
{
StreamInitialization init;
EventStreamifier<PxPvdTransport> stream(mPvdTransport->lock());
init.serialize(stream);
mPvdTransport->unlock();
}
void PvdImpl::addClient(PvdClient* client)
{
PX_ASSERT(client);
for(uint32_t i = 0; i < mPvdClients.size(); i++)
{
if(client == mPvdClients[i])
return;
}
mPvdClients.pushBack(client);
if(mIsConnected)
{
client->onPvdConnected();
}
}
void PvdImpl::removeClient(PvdClient* client)
{
for(uint32_t i = 0; i < mPvdClients.size(); i++)
{
if(client == mPvdClients[i])
{
client->onPvdDisconnected();
mPvdClients.remove(i);
}
}
}
void PvdImpl::onAllocation(size_t inSize, const char* inType, const char* inFile, int inLine, void* inAddr)
{
if(mMemClient)
mMemClient->onAllocation(inSize, inType, inFile, inLine, inAddr);
}
void PvdImpl::onDeallocation(void* inAddr)
{
if(mMemClient)
mMemClient->onDeallocation(inAddr);
}
PvdOMMetaDataProvider& PvdImpl::getMetaDataProvider()
{
return *mSharedMetaProvider;
}
bool PvdImpl::registerObject(const void* inItem)
{
return mObjectRegistrar.addItem(inItem);
}
bool PvdImpl::unRegisterObject(const void* inItem)
{
return mObjectRegistrar.decItem(inItem);
}
uint64_t PvdImpl::getNextStreamId()
{
uint64_t retval = ++mNextStreamId;
return retval;
}
bool PvdImpl::initialize()
{
if(0 == sRefCount)
{
sInstance = PVD_NEW(PvdImpl)();
}
++sRefCount;
return !!sInstance;
}
void PvdImpl::release()
{
if(sRefCount > 0)
{
if(--sRefCount)
return;
PVD_DELETE(sInstance);
sInstance = NULL;
}
}
PvdImpl* PvdImpl::getInstance()
{
return sInstance;
}
/**************************************************************************************************************************
Instrumented profiling events
***************************************************************************************************************************/
static const uint32_t CrossThreadId = 99999789;
void* PvdImpl::zoneStart(const char* eventName, bool detached, uint64_t contextId)
{
if(mProfileZone)
{
const uint16_t id = mProfileZone->getEventIdForName(eventName);
if(detached)
mProfileZone->startEvent(id, contextId, CrossThreadId);
else
mProfileZone->startEvent(id, contextId);
}
#if PX_NVTX
if(mIsNVTXSupportEnabled)
{
if(detached)
{
// TODO : Need to use the nvtxRangeStart API for cross thread events
nvtxEventAttributes_t eventAttrib;
memset(&eventAttrib, 0, sizeof(eventAttrib));
eventAttrib.version = NVTX_VERSION;
eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
eventAttrib.colorType = NVTX_COLOR_ARGB;
eventAttrib.color = 0xFF00FF00;
eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
eventAttrib.message.ascii = eventName;
nvtxMarkEx(&eventAttrib);
}
else
{
nvtxRangePush(eventName);
}
}
#endif
return NULL;
}
void PvdImpl::zoneEnd(void* /*profilerData*/, const char* eventName, bool detached, uint64_t contextId)
{
if(mProfileZone)
{
const uint16_t id = mProfileZone->getEventIdForName(eventName);
if(detached)
mProfileZone->stopEvent(id, contextId, CrossThreadId);
else
mProfileZone->stopEvent(id, contextId);
}
#if PX_NVTX
if(mIsNVTXSupportEnabled)
{
if(detached)
{
nvtxEventAttributes_t eventAttrib;
memset(&eventAttrib, 0, sizeof(eventAttrib));
eventAttrib.version = NVTX_VERSION;
eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE;
eventAttrib.colorType = NVTX_COLOR_ARGB;
eventAttrib.color = 0xFFFF0000;
eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII;
eventAttrib.message.ascii = eventName;
nvtxMarkEx(&eventAttrib);
}
else
{
nvtxRangePop();
}
}
#endif
}
} // pvd
} // physx
| 10,222 | C++ | 23.753027 | 144 | 0.7207 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDefaultFileTransport.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PVD_DEFAULT_FILE_TRANSPORT_H
#define PX_PVD_DEFAULT_FILE_TRANSPORT_H
#include "pvd/PxPvdTransport.h"
#include "foundation/PxUserAllocated.h"
#include "PsFileBuffer.h"
#include "foundation/PxMutex.h"
namespace physx
{
namespace pvdsdk
{
class PvdDefaultFileTransport : public physx::PxPvdTransport, public physx::PxUserAllocated
{
PX_NOCOPY(PvdDefaultFileTransport)
public:
PvdDefaultFileTransport(const char* name);
virtual ~PvdDefaultFileTransport();
virtual bool connect();
virtual void disconnect();
virtual bool isConnected();
virtual bool write(const uint8_t* inBytes, uint32_t inLength);
virtual PxPvdTransport& lock();
virtual void unlock();
virtual void flush();
virtual uint64_t getWrittenDataSize();
virtual void release();
private:
physx::PsFileBuffer* mFileBuffer;
bool mConnected;
uint64_t mWrittenData;
physx::PxMutex mMutex;
bool mLocked; // for debug, remove it when finished
};
} // pvdsdk
} // physx
#endif
| 2,667 | C | 33.205128 | 91 | 0.764154 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelMetaData.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_OBJECT_MODEL_METADATA_H
#define PX_PVD_OBJECT_MODEL_METADATA_H
#include "foundation/PxAssert.h"
#include "PxPvdObjectModelBaseTypes.h"
#include "PxPvdBits.h"
namespace physx
{
namespace pvdsdk
{
class PvdInputStream;
class PvdOutputStream;
struct PropertyDescription
{
NamespacedName mOwnerClassName;
int32_t mOwnerClassId;
String mName;
String mSemantic;
// The datatype this property corresponds to.
int32_t mDatatype;
// The name of the datatype
NamespacedName mDatatypeName;
// Scalar or array.
PropertyType::Enum mPropertyType;
// No other property under any class has this id, it is DB-unique.
int32_t mPropertyId;
// Offset in bytes into the object's data section where this property starts.
uint32_t m32BitOffset;
// Offset in bytes into the object's data section where this property starts.
uint32_t m64BitOffset;
PropertyDescription(const NamespacedName& clsName, int32_t classId, String name, String semantic, int32_t datatype,
const NamespacedName& datatypeName, PropertyType::Enum propType, int32_t propId,
uint32_t offset32, uint32_t offset64)
: mOwnerClassName(clsName)
, mOwnerClassId(classId)
, mName(name)
, mSemantic(semantic)
, mDatatype(datatype)
, mDatatypeName(datatypeName)
, mPropertyType(propType)
, mPropertyId(propId)
, m32BitOffset(offset32)
, m64BitOffset(offset64)
{
}
PropertyDescription()
: mOwnerClassId(-1)
, mName("")
, mSemantic("")
, mDatatype(-1)
, mPropertyType(PropertyType::Unknown)
, mPropertyId(-1)
, m32BitOffset(0)
, m64BitOffset(0)
{
}
virtual ~PropertyDescription()
{
}
};
struct PtrOffsetType
{
enum Enum
{
UnknownOffset,
VoidPtrOffset,
StringOffset
};
};
struct PtrOffset
{
PtrOffsetType::Enum mOffsetType;
uint32_t mOffset;
PtrOffset(PtrOffsetType::Enum type, uint32_t offset) : mOffsetType(type), mOffset(offset)
{
}
PtrOffset() : mOffsetType(PtrOffsetType::UnknownOffset), mOffset(0)
{
}
};
inline uint32_t align(uint32_t offset, uint32_t alignment)
{
uint32_t startOffset = offset;
uint32_t alignmentMask = ~(alignment - 1);
offset = (offset + alignment - 1) & alignmentMask;
PX_ASSERT(offset >= startOffset && (offset % alignment) == 0);
(void)startOffset;
return offset;
}
struct ClassDescriptionSizeInfo
{
// The size of the data section of this object, padded to alignment.
uint32_t mByteSize;
// The last data member goes to here.
uint32_t mDataByteSize;
// Alignment in bytes of the data section of this object.
uint32_t mAlignment;
// the offsets of string handles in the binary value of this class
DataRef<PtrOffset> mPtrOffsets;
ClassDescriptionSizeInfo() : mByteSize(0), mDataByteSize(0), mAlignment(0)
{
}
};
struct ClassDescription
{
NamespacedName mName;
// No other class has this id, it is DB-unique
int32_t mClassId;
// Only single derivation supported.
int32_t mBaseClass;
// If this class has properties that are of uniform type, then we note that.
// This means that when deserialization an array of these objects we can just use
// single function to endian convert the entire mess at once.
int32_t mPackedUniformWidth;
// If this class is composed uniformly of members of a given type
// Or all of its properties are composed uniformly of members of
// a give ntype, then this class's packed type is that type.
// PxTransform's packed type would be float.
int32_t mPackedClassType;
// 0: 32Bit 1: 64Bit
ClassDescriptionSizeInfo mSizeInfo[2];
// No further property additions allowed.
bool mLocked;
// True when this datatype has an array on it that needs to be
// separately deleted.
bool mRequiresDestruction;
ClassDescription(NamespacedName name, int32_t id)
: mName(name)
, mClassId(id)
, mBaseClass(-1)
, mPackedUniformWidth(-1)
, mPackedClassType(-1)
, mLocked(false)
, mRequiresDestruction(false)
{
}
ClassDescription()
: mClassId(-1), mBaseClass(-1), mPackedUniformWidth(-1), mPackedClassType(-1), mLocked(false), mRequiresDestruction(false)
{
}
virtual ~ClassDescription()
{
}
ClassDescriptionSizeInfo& get32BitSizeInfo()
{
return mSizeInfo[0];
}
ClassDescriptionSizeInfo& get64BitSizeInfo()
{
return mSizeInfo[1];
}
uint32_t& get32BitSize()
{
return get32BitSizeInfo().mByteSize;
}
uint32_t& get64BitSize()
{
return get64BitSizeInfo().mByteSize;
}
uint32_t get32BitSize() const
{
return mSizeInfo[0].mByteSize;
}
const ClassDescriptionSizeInfo& getNativeSizeInfo() const
{
return mSizeInfo[(sizeof(void*) >> 2) - 1];
}
uint32_t getNativeSize() const
{
return getNativeSizeInfo().mByteSize;
}
};
struct MarshalQueryResult
{
int32_t srcType;
int32_t dstType;
// If canMarshal != needsMarshalling we have a problem.
bool canMarshal;
bool needsMarshalling;
// Non null if marshalling is possible.
TBlockMarshaller marshaller;
MarshalQueryResult(int32_t _srcType = -1, int32_t _dstType = -1, bool _canMarshal = false, bool _needs = false,
TBlockMarshaller _m = NULL)
: srcType(_srcType), dstType(_dstType), canMarshal(_canMarshal), needsMarshalling(_needs), marshaller(_m)
{
}
};
struct PropertyMessageEntry
{
PropertyDescription mProperty;
NamespacedName mDatatypeName;
// datatype of the data in the message.
int32_t mDatatypeId;
// where in the message this property starts.
uint32_t mMessageOffset;
// size of this entry object
uint32_t mByteSize;
// If the chain of properties doesn't have any array properties this indicates the
uint32_t mDestByteSize;
PropertyMessageEntry(PropertyDescription propName, NamespacedName dtypeName, int32_t dtype, uint32_t messageOff,
uint32_t byteSize, uint32_t destByteSize)
: mProperty(propName)
, mDatatypeName(dtypeName)
, mDatatypeId(dtype)
, mMessageOffset(messageOff)
, mByteSize(byteSize)
, mDestByteSize(destByteSize)
{
}
PropertyMessageEntry() : mDatatypeId(-1), mMessageOffset(0), mByteSize(0), mDestByteSize(0)
{
}
};
// Create a struct that defines a subset of the properties on an object.
struct PropertyMessageDescription
{
NamespacedName mClassName;
// No other class has this id, it is DB-unique
int32_t mClassId;
NamespacedName mMessageName;
int32_t mMessageId;
DataRef<PropertyMessageEntry> mProperties;
uint32_t mMessageByteSize;
// Offsets into the property message where const char* items are.
DataRef<uint32_t> mStringOffsets;
PropertyMessageDescription(const NamespacedName& nm, int32_t clsId, const NamespacedName& msgName, int32_t msgId,
uint32_t msgSize)
: mClassName(nm), mClassId(clsId), mMessageName(msgName), mMessageId(msgId), mMessageByteSize(msgSize)
{
}
PropertyMessageDescription() : mClassId(-1), mMessageId(-1), mMessageByteSize(0)
{
}
virtual ~PropertyMessageDescription()
{
}
};
class StringTable
{
protected:
virtual ~StringTable()
{
}
public:
virtual uint32_t getNbStrs() = 0;
virtual uint32_t getStrs(const char** outStrs, uint32_t bufLen, uint32_t startIdx = 0) = 0;
virtual const char* registerStr(const char* str, bool& outAdded) = 0;
const char* registerStr(const char* str)
{
bool ignored;
return registerStr(str, ignored);
}
virtual StringHandle strToHandle(const char* str) = 0;
virtual const char* handleToStr(uint32_t hdl) = 0;
virtual void release() = 0;
static StringTable& create();
};
struct None
{
};
template <typename T>
class Option
{
T mValue;
bool mHasValue;
public:
Option(const T& val) : mValue(val), mHasValue(true)
{
}
Option(None nothing = None()) : mHasValue(false)
{
(void)nothing;
}
Option(const Option& other) : mValue(other.mValue), mHasValue(other.mHasValue)
{
}
Option& operator=(const Option& other)
{
mValue = other.mValue;
mHasValue = other.mHasValue;
return *this;
}
bool hasValue() const
{
return mHasValue;
}
const T& getValue() const
{
PX_ASSERT(hasValue());
return mValue;
}
T& getValue()
{
PX_ASSERT(hasValue());
return mValue;
}
operator const T&() const
{
return getValue();
}
operator T&()
{
return getValue();
}
T* operator->()
{
return &getValue();
}
const T* operator->() const
{
return &getValue();
}
};
/**
* Create new classes and add properties to some existing ones.
* The default classes are created already, the simple types
* along with the basic math types.
* (uint8_t, int8_t, etc )
* (PxVec3, PxQuat, PxTransform, PxMat33, PxMat34, PxMat44)
*/
class PvdObjectModelMetaData
{
protected:
virtual ~PvdObjectModelMetaData()
{
}
public:
virtual ClassDescription getOrCreateClass(const NamespacedName& nm) = 0;
// get or create parent, lock parent. deriveFrom getOrCreatechild.
virtual bool deriveClass(const NamespacedName& parent, const NamespacedName& child) = 0;
virtual Option<ClassDescription> findClass(const NamespacedName& nm) const = 0;
template <typename TDataType>
Option<ClassDescription> findClass()
{
return findClass(getPvdNamespacedNameForType<TDataType>());
}
virtual Option<ClassDescription> getClass(int32_t classId) const = 0;
virtual ClassDescription* getClassPtr(int32_t classId) const = 0;
virtual Option<ClassDescription> getParentClass(int32_t classId) const = 0;
bool isDerivedFrom(int32_t classId, int32_t parentClass) const
{
if(classId == parentClass)
return true;
ClassDescription* p = getClassPtr(getClassPtr(classId)->mBaseClass);
while(p != NULL)
{
if(p->mClassId == parentClass)
return true;
p = getClassPtr(p->mBaseClass);
}
return false;
}
virtual void lockClass(int32_t classId) = 0;
virtual uint32_t getNbClasses() const = 0;
virtual uint32_t getClasses(ClassDescription* outClasses, uint32_t requestCount, uint32_t startIndex = 0) const = 0;
// Create a nested property.
// This way you can have obj.p.x without explicity defining the class p.
virtual Option<PropertyDescription> createProperty(int32_t classId, String name, String semantic, int32_t datatype,
PropertyType::Enum propertyType = PropertyType::Scalar) = 0;
Option<PropertyDescription> createProperty(NamespacedName clsId, String name, String semantic, NamespacedName dtype,
PropertyType::Enum propertyType = PropertyType::Scalar)
{
return createProperty(findClass(clsId)->mClassId, name, semantic, findClass(dtype)->mClassId, propertyType);
}
Option<PropertyDescription> createProperty(NamespacedName clsId, String name, NamespacedName dtype,
PropertyType::Enum propertyType = PropertyType::Scalar)
{
return createProperty(findClass(clsId)->mClassId, name, "", findClass(dtype)->mClassId, propertyType);
}
Option<PropertyDescription> createProperty(int32_t clsId, String name, int32_t dtype,
PropertyType::Enum propertyType = PropertyType::Scalar)
{
return createProperty(clsId, name, "", dtype, propertyType);
}
template <typename TDataType>
Option<PropertyDescription> createProperty(int32_t clsId, String name, String semantic = "",
PropertyType::Enum propertyType = PropertyType::Scalar)
{
return createProperty(clsId, name, semantic, getPvdNamespacedNameForType<TDataType>(), propertyType);
}
virtual Option<PropertyDescription> findProperty(const NamespacedName& cls, String prop) const = 0;
virtual Option<PropertyDescription> findProperty(int32_t clsId, String prop) const = 0;
virtual Option<PropertyDescription> getProperty(int32_t propId) const = 0;
virtual void setNamedPropertyValues(DataRef<NamedValue> values, int32_t propId) = 0;
// for enumerations and flags.
virtual DataRef<NamedValue> getNamedPropertyValues(int32_t propId) const = 0;
virtual uint32_t getNbProperties(int32_t classId) const = 0;
virtual uint32_t getProperties(int32_t classId, PropertyDescription* outBuffer, uint32_t bufCount,
uint32_t startIdx = 0) const = 0;
// Does one cls id differ marshalling to another and if so return the functions to do it.
virtual MarshalQueryResult checkMarshalling(int32_t srcClsId, int32_t dstClsId) const = 0;
// messages and classes are stored in separate maps, so a property message can have the same name as a class.
virtual Option<PropertyMessageDescription> createPropertyMessage(const NamespacedName& cls,
const NamespacedName& msgName,
DataRef<PropertyMessageArg> entries,
uint32_t messageSize) = 0;
virtual Option<PropertyMessageDescription> findPropertyMessage(const NamespacedName& msgName) const = 0;
virtual Option<PropertyMessageDescription> getPropertyMessage(int32_t msgId) const = 0;
virtual uint32_t getNbPropertyMessages() const = 0;
virtual uint32_t getPropertyMessages(PropertyMessageDescription* msgBuf, uint32_t bufLen,
uint32_t startIdx = 0) const = 0;
virtual StringTable& getStringTable() const = 0;
virtual void write(PvdOutputStream& stream) const = 0;
void save(PvdOutputStream& stream) const
{
write(stream);
}
virtual void addRef() = 0;
virtual void release() = 0;
static uint32_t getCurrentPvdObjectModelVersion();
static PvdObjectModelMetaData& create();
static PvdObjectModelMetaData& create(PvdInputStream& stream);
};
}
}
#endif
| 15,021 | C | 30.165975 | 123 | 0.721656 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdByteStreams.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_BYTE_STREAMS_H
#define PX_PVD_BYTE_STREAMS_H
#include "PxPvdObjectModelBaseTypes.h"
namespace physx
{
namespace pvdsdk
{
static inline uint32_t strLen(const char* inStr)
{
uint32_t len = 0;
if(inStr)
{
while(*inStr)
{
++len;
++inStr;
}
}
return len;
}
class PvdInputStream
{
protected:
virtual ~PvdInputStream()
{
}
public:
// Return false if you can't write the number of bytes requested
// But make an absolute best effort to read the data...
virtual bool read(uint8_t* buffer, uint32_t& len) = 0;
template <typename TDataType>
bool read(TDataType* buffer, uint32_t numItems)
{
uint32_t expected = numItems;
uint32_t amountToRead = numItems * sizeof(TDataType);
read(reinterpret_cast<uint8_t*>(buffer), amountToRead);
numItems = amountToRead / sizeof(TDataType);
PX_ASSERT(numItems == expected);
return expected == numItems;
}
template <typename TDataType>
PvdInputStream& operator>>(TDataType& data)
{
uint32_t dataSize = static_cast<uint32_t>(sizeof(TDataType));
bool success = read(reinterpret_cast<uint8_t*>(&data), dataSize);
// PX_ASSERT( success );
// PX_ASSERT( dataSize == sizeof( data ) );
(void)success;
return *this;
}
};
class PvdOutputStream
{
protected:
virtual ~PvdOutputStream()
{
}
public:
// Return false if you can't write the number of bytes requested
// But make an absolute best effort to write the data...
virtual bool write(const uint8_t* buffer, uint32_t len) = 0;
virtual bool directCopy(PvdInputStream& inStream, uint32_t len) = 0;
template <typename TDataType>
bool write(const TDataType* buffer, uint32_t numItems)
{
return write(reinterpret_cast<const uint8_t*>(buffer), numItems * sizeof(TDataType));
}
template <typename TDataType>
PvdOutputStream& operator<<(const TDataType& data)
{
bool success = write(reinterpret_cast<const uint8_t*>(&data), sizeof(data));
PX_ASSERT(success);
(void)success;
return *this;
}
PvdOutputStream& operator<<(const char* inString)
{
if(inString && *inString)
{
uint32_t len(strLen(inString));
write(inString, len);
}
return *this;
}
};
}
}
#endif
| 3,709 | C | 28.212598 | 87 | 0.72742 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileZoneManagerImpl.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_ZONE_MANAGER_IMPL_H
#define PX_PROFILE_ZONE_MANAGER_IMPL_H
#include "PxProfileZoneManager.h"
#include "PxProfileScopedMutexLock.h"
#include "PxPvdProfileZone.h"
#include "PxProfileAllocatorWrapper.h"
#include "foundation/PxArray.h"
#include "foundation/PxMutex.h"
namespace physx { namespace profile {
struct NullEventNameProvider : public PxProfileNameProvider
{
virtual PxProfileNames getProfileNames() const { return PxProfileNames( 0, 0 ); }
};
class ZoneManagerImpl : public PxProfileZoneManager
{
typedef ScopedLockImpl<PxMutex> TScopedLockType;
PxProfileAllocatorWrapper mWrapper;
PxProfileArray<PxProfileZone*> mZones;
PxProfileArray<PxProfileZoneHandler*> mHandlers;
PxMutex mMutex;
ZoneManagerImpl( const ZoneManagerImpl& inOther );
ZoneManagerImpl& operator=( const ZoneManagerImpl& inOther );
public:
ZoneManagerImpl(PxAllocatorCallback* inFoundation)
: mWrapper( inFoundation )
, mZones( mWrapper )
, mHandlers( mWrapper )
{}
virtual ~ZoneManagerImpl()
{
//This assert would mean that a profile zone is outliving us.
//This will cause a crash when the profile zone is released.
PX_ASSERT( mZones.size() == 0 );
while( mZones.size() )
removeProfileZone( *mZones.back() );
}
virtual void addProfileZone( PxProfileZone& inSDK )
{
TScopedLockType lock( &mMutex );
if ( inSDK.getProfileZoneManager() != NULL )
{
if ( inSDK.getProfileZoneManager() == this )
return;
else //there must be two managers in the system somehow.
{
PX_ASSERT( false );
inSDK.getProfileZoneManager()->removeProfileZone( inSDK );
}
}
mZones.pushBack( &inSDK );
inSDK.setProfileZoneManager( this );
for ( uint32_t idx =0; idx < mHandlers.size(); ++idx )
mHandlers[idx]->onZoneAdded( inSDK );
}
virtual void removeProfileZone( PxProfileZone& inSDK )
{
TScopedLockType lock( &mMutex );
if ( inSDK.getProfileZoneManager() == NULL )
return;
else if ( inSDK.getProfileZoneManager() != this )
{
PX_ASSERT( false );
inSDK.getProfileZoneManager()->removeProfileZone( inSDK );
return;
}
inSDK.setProfileZoneManager( NULL );
for ( uint32_t idx = 0; idx < mZones.size(); ++idx )
{
if ( mZones[idx] == &inSDK )
{
for ( uint32_t handler =0; handler < mHandlers.size(); ++handler )
mHandlers[handler]->onZoneRemoved( inSDK );
mZones.replaceWithLast( idx );
}
}
}
virtual void flushProfileEvents()
{
uint32_t sdkCount = mZones.size();
for ( uint32_t idx = 0; idx < sdkCount; ++idx )
mZones[idx]->flushProfileEvents();
}
virtual void addProfileZoneHandler( PxProfileZoneHandler& inHandler )
{
TScopedLockType lock( &mMutex );
mHandlers.pushBack( &inHandler );
for ( uint32_t idx = 0; idx < mZones.size(); ++idx )
inHandler.onZoneAdded( *mZones[idx] );
}
virtual void removeProfileZoneHandler( PxProfileZoneHandler& inHandler )
{
TScopedLockType lock( &mMutex );
for( uint32_t idx = 0; idx < mZones.size(); ++idx )
inHandler.onZoneRemoved( *mZones[idx] );
for( uint32_t idx = 0; idx < mHandlers.size(); ++idx )
{
if ( mHandlers[idx] == &inHandler )
mHandlers.replaceWithLast( idx );
}
}
virtual PxProfileZone& createProfileZone( const char* inSDKName, PxProfileNameProvider* inProvider, uint32_t inEventBufferByteSize )
{
NullEventNameProvider nullProvider;
if ( inProvider == NULL )
inProvider = &nullProvider;
return createProfileZone( inSDKName, inProvider->getProfileNames(), inEventBufferByteSize );
}
virtual PxProfileZone& createProfileZone( const char* inSDKName, PxProfileNames inNames, uint32_t inEventBufferByteSize )
{
PxProfileZone& retval( PxProfileZone::createProfileZone( &mWrapper.getAllocator(), inSDKName, inNames, inEventBufferByteSize ) );
addProfileZone( retval );
return retval;
}
virtual void release()
{
PX_PROFILE_DELETE( mWrapper.getAllocator(), this );
}
};
} }
#endif
| 5,729 | C | 32.121387 | 134 | 0.713039 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdCommStreamTypes.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_COMM_STREAM_TYPES_H
#define PX_PVD_COMM_STREAM_TYPES_H
#include "foundation/PxErrorCallback.h"
#include "common/PxRenderBuffer.h"
#include "pvd/PxPvdTransport.h"
#include "PxPvdObjectModelBaseTypes.h"
#include "PxPvdCommStreamEvents.h"
#include "PxPvdDataStream.h"
#include "foundation/PxMutex.h"
namespace physx
{
namespace profile
{
class PxProfileZone;
class PxProfileMemoryEventBuffer;
}
namespace pvdsdk
{
struct PvdErrorMessage;
class PvdObjectModelMetaData;
DEFINE_PVD_TYPE_NAME_MAP(profile::PxProfileZone, "_debugger_", "PxProfileZone")
DEFINE_PVD_TYPE_NAME_MAP(profile::PxProfileMemoryEventBuffer, "_debugger_", "PxProfileMemoryEventBuffer")
DEFINE_PVD_TYPE_NAME_MAP(PvdErrorMessage, "_debugger_", "PvdErrorMessage")
// All event streams are on the 'events' property of objects of these types
static inline NamespacedName getMemoryEventTotalsClassName()
{
return NamespacedName("_debugger", "MemoryEventTotals");
}
class PvdOMMetaDataProvider
{
protected:
virtual ~PvdOMMetaDataProvider()
{
}
public:
virtual void addRef() = 0;
virtual void release() = 0;
virtual PvdObjectModelMetaData& lock() = 0;
virtual void unlock() = 0;
virtual bool createInstance(const NamespacedName& clsName, const void* instance) = 0;
virtual bool isInstanceValid(const void* instance) = 0;
virtual void destroyInstance(const void* instance) = 0;
virtual int32_t getInstanceClassType(const void* instance) = 0;
};
class PvdCommStreamEmbeddedTypes
{
public:
static const char* getProfileEventStreamSemantic()
{
return "profile event stream";
}
static const char* getMemoryEventStreamSemantic()
{
return "memory event stream";
}
static const char* getRendererEventStreamSemantic()
{
return "render event stream";
}
};
class PvdCommStreamEventBufferClient;
template <typename TStreamType>
struct EventStreamifier : public PvdEventSerializer
{
TStreamType& mBuffer;
EventStreamifier(TStreamType& buf) : mBuffer(buf)
{
}
template <typename TDataType>
void write(const TDataType& type)
{
mBuffer.write(reinterpret_cast<const uint8_t*>(&type), sizeof(TDataType));
}
template <typename TDataType>
void write(const TDataType* type, uint32_t count)
{
mBuffer.write(reinterpret_cast<const uint8_t*>(type), count * sizeof(TDataType));
}
void writeRef(DataRef<const uint8_t> data)
{
uint32_t amount = static_cast<uint32_t>(data.size());
write(amount);
write(data.begin(), amount);
}
void writeRef(DataRef<StringHandle> data)
{
uint32_t amount = static_cast<uint32_t>(data.size());
write(amount);
write(data.begin(), amount);
}
template <typename TDataType>
void writeRef(DataRef<TDataType> data)
{
uint32_t amount = static_cast<uint32_t>(data.size());
write(amount);
for(uint32_t idx = 0; idx < amount; ++idx)
{
TDataType& dtype(const_cast<TDataType&>(data[idx]));
dtype.serialize(*this);
}
}
virtual void streamify(uint16_t& val)
{
write(val);
}
virtual void streamify(uint8_t& val)
{
write(val);
}
virtual void streamify(uint32_t& val)
{
write(val);
}
virtual void streamify(float& val)
{
write(val);
}
virtual void streamify(uint64_t& val)
{
write(val);
}
virtual void streamify(PxDebugText& val)
{
write(val.color);
write(val.position);
write(val.size);
streamify(val.string);
}
virtual void streamify(String& val)
{
uint32_t len = 0;
String temp = nonNull(val);
if(*temp)
len = static_cast<uint32_t>(strlen(temp) + 1);
write(len);
write(val, len);
}
virtual void streamify(DataRef<const uint8_t>& val)
{
writeRef(val);
}
virtual void streamify(DataRef<NameHandleValue>& val)
{
writeRef(val);
}
virtual void streamify(DataRef<StreamPropMessageArg>& val)
{
writeRef(val);
}
virtual void streamify(DataRef<StringHandle>& val)
{
writeRef(val);
}
private:
EventStreamifier& operator=(const EventStreamifier&);
};
struct MeasureStream
{
uint32_t mSize;
MeasureStream() : mSize(0)
{
}
template <typename TDataType>
void write(const TDataType& val)
{
mSize += sizeof(val);
}
template <typename TDataType>
void write(const TDataType*, uint32_t count)
{
mSize += sizeof(TDataType) * count;
}
};
struct DataStreamState
{
enum Enum
{
Open,
SetPropertyValue,
PropertyMessageGroup
};
};
} // pvdsdk
} // physx
#endif
| 5,865 | C | 24.504348 | 105 | 0.73572 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDataStream.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#include "foundation/PxAssert.h"
#include "PxPvdCommStreamEventSink.h"
#include "PxPvdDataStreamHelpers.h"
#include "PxPvdObjectModelInternalTypes.h"
#include "PxPvdImpl.h"
using namespace physx;
using namespace physx::pvdsdk;
namespace
{
struct ScopedMetaData
{
PvdOMMetaDataProvider& mProvider;
PvdObjectModelMetaData& mMeta;
ScopedMetaData(PvdOMMetaDataProvider& provider) : mProvider(provider), mMeta(provider.lock())
{
}
~ScopedMetaData()
{
mProvider.unlock();
}
PvdObjectModelMetaData* operator->()
{
return &mMeta;
}
private:
ScopedMetaData& operator=(const ScopedMetaData&);
};
struct PropertyDefinitionHelper : public PvdPropertyDefinitionHelper
{
PvdDataStream* mStream;
PvdOMMetaDataProvider& mProvider;
PxArray<char> mNameBuffer;
PxArray<uint32_t> mNameStack;
PxArray<NamedValue> mNamedValues;
PxArray<PropertyMessageArg> mPropertyMessageArgs;
PropertyDefinitionHelper(PvdOMMetaDataProvider& provider)
: mStream(NULL)
, mProvider(provider)
, mNameBuffer("PropertyDefinitionHelper::mNameBuffer")
, mNameStack("PropertyDefinitionHelper::mNameStack")
, mNamedValues("PropertyDefinitionHelper::mNamedValues")
, mPropertyMessageArgs("PropertyDefinitionHelper::mPropertyMessageArgs")
{
}
void setStream(PvdDataStream* stream)
{
mStream = stream;
}
inline void appendStrToBuffer(const char* str)
{
if(str == NULL)
return;
size_t strLen = strlen(str);
size_t endBufOffset = mNameBuffer.size();
size_t resizeLen = endBufOffset;
// account for null
if(mNameBuffer.empty())
resizeLen += 1;
else
endBufOffset -= 1;
mNameBuffer.resize(static_cast<uint32_t>(resizeLen + strLen));
char* endPtr = mNameBuffer.begin() + endBufOffset;
PxMemCopy(endPtr, str, static_cast<uint32_t>(strLen));
}
virtual void pushName(const char* nm, const char* appender = ".")
{
size_t nameBufLen = mNameBuffer.size();
mNameStack.pushBack(static_cast<uint32_t>(nameBufLen));
if(mNameBuffer.empty() == false)
appendStrToBuffer(appender);
appendStrToBuffer(nm);
mNameBuffer.back() = 0;
}
virtual void pushBracketedName(const char* inName, const char* leftBracket = "[", const char* rightBracket = "]")
{
size_t nameBufLen = mNameBuffer.size();
mNameStack.pushBack(static_cast<uint32_t>(nameBufLen));
appendStrToBuffer(leftBracket);
appendStrToBuffer(inName);
appendStrToBuffer(rightBracket);
mNameBuffer.back() = 0;
}
virtual void popName()
{
if(mNameStack.empty())
return;
mNameBuffer.resize(static_cast<uint32_t>(mNameStack.back()));
mNameStack.popBack();
if(mNameBuffer.empty() == false)
mNameBuffer.back() = 0;
}
virtual const char* getTopName()
{
if(mNameBuffer.size())
return mNameBuffer.begin();
return "";
}
virtual void clearNameStack()
{
mNameBuffer.clear();
mNameStack.clear();
}
virtual void addNamedValue(const char* name, uint32_t value)
{
mNamedValues.pushBack(NamedValue(name, value));
}
virtual void clearNamedValues()
{
mNamedValues.clear();
}
virtual DataRef<NamedValue> getNamedValues()
{
return DataRef<NamedValue>(mNamedValues.begin(), mNamedValues.size());
}
virtual void createProperty(const NamespacedName& clsName, const char* inSemantic, const NamespacedName& dtypeName,
PropertyType::Enum propType)
{
mStream->createProperty(clsName, getTopName(), inSemantic, dtypeName, propType, getNamedValues());
clearNamedValues();
}
const char* registerStr(const char* str)
{
ScopedMetaData scopedProvider(mProvider);
return scopedProvider->getStringTable().registerStr(str);
}
virtual void addPropertyMessageArg(const NamespacedName& inDatatype, uint32_t inOffset, uint32_t inSize)
{
mPropertyMessageArgs.pushBack(PropertyMessageArg(registerStr(getTopName()), inDatatype, inOffset, inSize));
}
virtual void addPropertyMessage(const NamespacedName& clsName, const NamespacedName& msgName,
uint32_t inStructSizeInBytes)
{
if(mPropertyMessageArgs.empty())
{
PX_ASSERT(false);
return;
}
mStream->createPropertyMessage(
clsName, msgName, DataRef<PropertyMessageArg>(mPropertyMessageArgs.begin(), mPropertyMessageArgs.size()),
inStructSizeInBytes);
}
virtual void clearPropertyMessageArgs()
{
mPropertyMessageArgs.clear();
}
private:
PropertyDefinitionHelper& operator=(const PropertyDefinitionHelper&);
};
class PvdMemPool
{
// Link List
PxArray<uint8_t*> mMemBuffer;
uint32_t mLength;
uint32_t mBufIndex;
// 4k for one page
static const int BUFFER_LENGTH = 4096;
PX_NOCOPY(PvdMemPool)
public:
PvdMemPool(const char* bufDataName) : mMemBuffer(bufDataName), mLength(0), mBufIndex(0)
{
grow();
}
~PvdMemPool()
{
for(uint32_t i = 0; i < mMemBuffer.size(); i++)
{
PX_FREE(mMemBuffer[i]);
}
}
void grow()
{
if(mBufIndex + 1 < mMemBuffer.size())
{
mBufIndex++;
}
else
{
uint8_t* Buf = reinterpret_cast<uint8_t*>(PX_ALLOC(BUFFER_LENGTH, "PvdMemPool::mMemBuffer.buf"));
mMemBuffer.pushBack(Buf);
mBufIndex = mMemBuffer.size() - 1;
}
mLength = 0;
}
void* allocate(uint32_t length)
{
if(length > uint32_t(BUFFER_LENGTH))
return NULL;
if(length + mLength > uint32_t(BUFFER_LENGTH))
grow();
void* mem = reinterpret_cast<void*>(&mMemBuffer[mBufIndex][mLength]);
mLength += length;
return mem;
}
void clear()
{
mLength = 0;
mBufIndex = 0;
}
};
struct PvdOutStream : public PvdDataStream, public PxUserAllocated
{
PxHashMap<String, uint32_t> mStringHashMap;
PvdOMMetaDataProvider& mMetaDataProvider;
PxArray<uint8_t> mTempBuffer;
PropertyDefinitionHelper mPropertyDefinitionHelper;
DataStreamState::Enum mStreamState;
ClassDescription mSPVClass;
PropertyMessageDescription mMessageDesc;
// Set property value and SetPropertyMessage calls require
// us to write the data out to a separate buffer
// when strings are involved.
ForwardingMemoryBuffer mSPVBuffer;
uint32_t mEventCount;
uint32_t mPropertyMessageSize;
bool mConnected;
uint64_t mStreamId;
PxArray<PvdCommand*> mPvdCommandArray;
PvdMemPool mPvdCommandPool;
PxPvdTransport& mTransport;
PvdOutStream(PxPvdTransport& transport, PvdOMMetaDataProvider& provider, uint64_t streamId)
: mStringHashMap("PvdOutStream::mStringHashMap")
, mMetaDataProvider(provider)
, mTempBuffer("PvdOutStream::mTempBuffer")
, mPropertyDefinitionHelper(mMetaDataProvider)
, mStreamState(DataStreamState::Open)
, mSPVBuffer("PvdCommStreamBufferedEventSink::mSPVBuffer")
, mEventCount(0)
, mPropertyMessageSize(0)
, mConnected(true)
, mStreamId(streamId)
, mPvdCommandArray("PvdCommStreamBufferedEventSink::mPvdCommandArray")
, mPvdCommandPool("PvdCommStreamBufferedEventSink::mPvdCommandPool")
, mTransport(transport)
{
mPropertyDefinitionHelper.setStream(this);
}
virtual ~PvdOutStream()
{
}
virtual void release()
{
PVD_DELETE(this);
}
StringHandle toStream(String nm)
{
if(nm == NULL || *nm == 0)
return 0;
const PxHashMap<String, uint32_t>::Entry* entry(mStringHashMap.find(nm));
if(entry)
return entry->second;
ScopedMetaData meta(mMetaDataProvider);
StringHandle hdl = meta->getStringTable().strToHandle(nm);
nm = meta->getStringTable().handleToStr(hdl);
handlePvdEvent(StringHandleEvent(nm, hdl));
mStringHashMap.insert(nm, hdl);
return hdl;
}
StreamNamespacedName toStream(const NamespacedName& nm)
{
return StreamNamespacedName(toStream(nm.mNamespace), toStream(nm.mName));
}
bool isClassExist(const NamespacedName& nm)
{
ScopedMetaData meta(mMetaDataProvider);
return meta->findClass(nm).hasValue();
}
bool createMetaClass(const NamespacedName& nm)
{
ScopedMetaData meta(mMetaDataProvider);
meta->getOrCreateClass(nm);
return true;
}
bool deriveMetaClass(const NamespacedName& parent, const NamespacedName& child)
{
ScopedMetaData meta(mMetaDataProvider);
return meta->deriveClass(parent, child);
}
// You will notice that some functions are #pragma'd out throughout this file.
// This is because they are only called from asserts which means they aren't
// called in release. This causes warnings when building using snc which break
// the build.
#if PX_DEBUG
bool propertyExists(const NamespacedName& nm, String pname)
{
ScopedMetaData meta(mMetaDataProvider);
return meta->findProperty(nm, pname).hasValue();
}
#endif
PvdError boolToError(bool val)
{
if(val)
return PvdErrorType::Success;
return PvdErrorType::NetworkError;
}
// PvdMetaDataStream
virtual PvdError createClass(const NamespacedName& nm)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
#if PX_DEBUG
PX_ASSERT(isClassExist(nm) == false);
#endif
createMetaClass(nm);
return boolToError(handlePvdEvent(CreateClass(toStream(nm))));
}
virtual PvdError deriveClass(const NamespacedName& parent, const NamespacedName& child)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
#if PX_DEBUG
PX_ASSERT(isClassExist(parent));
PX_ASSERT(isClassExist(child));
#endif
deriveMetaClass(parent, child);
return boolToError(handlePvdEvent(DeriveClass(toStream(parent), toStream(child))));
}
template <typename TDataType>
TDataType* allocTemp(uint32_t numItems)
{
uint32_t desiredBytes = numItems * sizeof(TDataType);
if(desiredBytes > mTempBuffer.size())
mTempBuffer.resize(desiredBytes);
TDataType* retval = reinterpret_cast<TDataType*>(mTempBuffer.begin());
if(numItems)
{
PVD_FOREACH(idx, numItems) new (retval + idx) TDataType();
}
return retval;
}
#if PX_DEBUG
// Property datatypes need to be uniform.
// At this point, the data stream cannot handle properties that
// A struct with a float member and a char member would work.
// A struct with a float member and a long member would work (more efficiently).
bool isValidPropertyDatatype(const NamespacedName& dtypeName)
{
ScopedMetaData meta(mMetaDataProvider);
ClassDescription clsDesc(meta->findClass(dtypeName));
return clsDesc.mRequiresDestruction == false;
}
#endif
NamespacedName createMetaProperty(const NamespacedName& clsName, String name, String semantic,
const NamespacedName& dtypeName, PropertyType::Enum propertyType)
{
ScopedMetaData meta(mMetaDataProvider);
int32_t dtypeType = meta->findClass(dtypeName)->mClassId;
NamespacedName typeName = dtypeName;
if(dtypeType == getPvdTypeForType<String>())
{
dtypeType = getPvdTypeForType<StringHandle>();
typeName = getPvdNamespacedNameForType<StringHandle>();
}
Option<PropertyDescription> propOpt =
meta->createProperty(meta->findClass(clsName)->mClassId, name, semantic, dtypeType, propertyType);
PX_ASSERT(propOpt.hasValue());
PX_UNUSED(propOpt);
return typeName;
}
virtual PvdError createProperty(const NamespacedName& clsName, String name, String semantic,
const NamespacedName& incomingDtypeName, PropertyType::Enum propertyType,
DataRef<NamedValue> values)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
#if PX_DEBUG
PX_ASSERT(isClassExist(clsName));
PX_ASSERT(propertyExists(clsName, name) == false);
#endif
NamespacedName dtypeName(incomingDtypeName);
if(safeStrEq(dtypeName.mName, "VoidPtr"))
dtypeName.mName = "ObjectRef";
#if PX_DEBUG
PX_ASSERT(isClassExist(dtypeName));
PX_ASSERT(isValidPropertyDatatype(dtypeName));
#endif
NamespacedName typeName = createMetaProperty(clsName, name, semantic, dtypeName, propertyType);
// Can't have arrays of strings or arrays of string handles due to the difficulty
// of quickly dealing with them on the network receiving side.
if(propertyType == PropertyType::Array && safeStrEq(typeName.mName, "StringHandle"))
{
PX_ASSERT(false);
return PvdErrorType::ArgumentError;
}
uint32_t numItems = values.size();
NameHandleValue* streamValues = allocTemp<NameHandleValue>(numItems);
PVD_FOREACH(idx, numItems)
streamValues[idx] = NameHandleValue(toStream(values[idx].mName), values[idx].mValue);
CreateProperty evt(toStream(clsName), toStream(name), toStream(semantic), toStream(typeName), propertyType,
DataRef<NameHandleValue>(streamValues, numItems));
return boolToError(handlePvdEvent(evt));
}
bool createMetaPropertyMessage(const NamespacedName& cls, const NamespacedName& msgName,
DataRef<PropertyMessageArg> entries, uint32_t messageSizeInBytes)
{
ScopedMetaData meta(mMetaDataProvider);
return meta->createPropertyMessage(cls, msgName, entries, messageSizeInBytes).hasValue();
}
#if PX_DEBUG
bool messageExists(const NamespacedName& msgName)
{
ScopedMetaData meta(mMetaDataProvider);
return meta->findPropertyMessage(msgName).hasValue();
}
#endif
virtual PvdError createPropertyMessage(const NamespacedName& cls, const NamespacedName& msgName,
DataRef<PropertyMessageArg> entries, uint32_t messageSizeInBytes)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
#if PX_DEBUG
PX_ASSERT(isClassExist(cls));
PX_ASSERT(messageExists(msgName) == false);
#endif
createMetaPropertyMessage(cls, msgName, entries, messageSizeInBytes);
uint32_t numItems = entries.size();
StreamPropMessageArg* streamValues = allocTemp<StreamPropMessageArg>(numItems);
PVD_FOREACH(idx, numItems)
streamValues[idx] =
StreamPropMessageArg(toStream(entries[idx].mPropertyName), toStream(entries[idx].mDatatypeName),
entries[idx].mMessageOffset, entries[idx].mByteSize);
CreatePropertyMessage evt(toStream(cls), toStream(msgName),
DataRef<StreamPropMessageArg>(streamValues, numItems), messageSizeInBytes);
return boolToError(handlePvdEvent(evt));
}
uint64_t toStream(const void* instance)
{
return PVD_POINTER_TO_U64(instance);
}
virtual PvdError createInstance(const NamespacedName& cls, const void* instance)
{
PX_ASSERT(isInstanceValid(instance) == false);
PX_ASSERT(mStreamState == DataStreamState::Open);
bool success = mMetaDataProvider.createInstance(cls, instance);
PX_ASSERT(success);
(void)success;
return boolToError(handlePvdEvent(CreateInstance(toStream(cls), toStream(instance))));
}
virtual bool isInstanceValid(const void* instance)
{
return mMetaDataProvider.isInstanceValid(instance);
}
#if PX_DEBUG
// If the property will fit or is already completely in memory
bool checkPropertyType(const void* instance, String name, const NamespacedName& incomingType)
{
int32_t instType = mMetaDataProvider.getInstanceClassType(instance);
ScopedMetaData meta(mMetaDataProvider);
Option<PropertyDescription> prop = meta->findProperty(instType, name);
if(prop.hasValue() == false)
return false;
int32_t propType = prop->mDatatype;
int32_t incomingTypeId = meta->findClass(incomingType)->mClassId;
if(incomingTypeId != getPvdTypeForType<VoidPtr>())
{
MarshalQueryResult result = meta->checkMarshalling(incomingTypeId, propType);
bool possible = result.needsMarshalling == false || result.canMarshal;
return possible;
}
else
{
if(propType != getPvdTypeForType<ObjectRef>())
return false;
}
return true;
}
#endif
DataRef<const uint8_t> bufferPropertyValue(ClassDescriptionSizeInfo info, DataRef<const uint8_t> data)
{
uint32_t realSize = info.mByteSize;
uint32_t numItems = data.size() / realSize;
if(info.mPtrOffsets.size() != 0)
{
mSPVBuffer.clear();
PVD_FOREACH(item, numItems)
{
const uint8_t* itemPtr = data.begin() + item * realSize;
mSPVBuffer.write(itemPtr, realSize);
PVD_FOREACH(stringIdx, info.mPtrOffsets.size())
{
PtrOffset offset(info.mPtrOffsets[stringIdx]);
if(offset.mOffsetType == PtrOffsetType::VoidPtrOffset)
continue;
const char* strPtr;
physx::intrinsics::memCopy(&strPtr, itemPtr + offset.mOffset, sizeof(char*));
strPtr = nonNull(strPtr);
uint32_t len = safeStrLen(strPtr) + 1;
mSPVBuffer.write(strPtr, len);
}
}
data = DataRef<const uint8_t>(mSPVBuffer.begin(), mSPVBuffer.size());
}
return data;
}
virtual PvdError setPropertyValue(const void* instance, String name, DataRef<const uint8_t> data,
const NamespacedName& incomingTypeName)
{
PX_ASSERT(isInstanceValid(instance));
#if PX_DEBUG
PX_ASSERT(isClassExist(incomingTypeName));
#endif
PX_ASSERT(mStreamState == DataStreamState::Open);
ClassDescription clsDesc;
{
ScopedMetaData meta(mMetaDataProvider);
clsDesc = meta->findClass(incomingTypeName);
}
uint32_t realSize = clsDesc.getNativeSize();
uint32_t numItems = data.size() / realSize;
data = bufferPropertyValue(clsDesc.getNativeSizeInfo(), data);
SetPropertyValue evt(toStream(instance), toStream(name), data, toStream(incomingTypeName), numItems);
return boolToError(handlePvdEvent(evt));
}
// Else if the property is very large (contact reports) you can send it in chunks.
virtual PvdError beginSetPropertyValue(const void* instance, String name, const NamespacedName& incomingTypeName)
{
PX_ASSERT(isInstanceValid(instance));
#if PX_DEBUG
PX_ASSERT(isClassExist(incomingTypeName));
PX_ASSERT(checkPropertyType(instance, name, incomingTypeName));
#endif
PX_ASSERT(mStreamState == DataStreamState::Open);
mStreamState = DataStreamState::SetPropertyValue;
{
ScopedMetaData meta(mMetaDataProvider);
mSPVClass = meta->findClass(incomingTypeName);
}
BeginSetPropertyValue evt(toStream(instance), toStream(name), toStream(incomingTypeName));
return boolToError(handlePvdEvent(evt));
}
virtual PvdError appendPropertyValueData(DataRef<const uint8_t> data)
{
uint32_t realSize = mSPVClass.getNativeSize();
uint32_t numItems = data.size() / realSize;
data = bufferPropertyValue(mSPVClass.getNativeSizeInfo(), data);
PX_ASSERT(mStreamState == DataStreamState::SetPropertyValue);
return boolToError(handlePvdEvent(AppendPropertyValueData(data, numItems)));
}
virtual PvdError endSetPropertyValue()
{
PX_ASSERT(mStreamState == DataStreamState::SetPropertyValue);
mStreamState = DataStreamState::Open;
return boolToError(handlePvdEvent(EndSetPropertyValue()));
}
#if PX_DEBUG
bool checkPropertyMessage(const void* instance, const NamespacedName& msgName)
{
int32_t clsId = mMetaDataProvider.getInstanceClassType(instance);
ScopedMetaData meta(mMetaDataProvider);
PropertyMessageDescription desc(meta->findPropertyMessage(msgName));
bool retval = meta->isDerivedFrom(clsId, desc.mClassId);
return retval;
}
#endif
DataRef<const uint8_t> bufferPropertyMessage(const PropertyMessageDescription& desc, DataRef<const uint8_t> data)
{
if(desc.mStringOffsets.size())
{
mSPVBuffer.clear();
mSPVBuffer.write(data.begin(), data.size());
PVD_FOREACH(idx, desc.mStringOffsets.size())
{
const char* strPtr;
physx::intrinsics::memCopy(&strPtr, data.begin() + desc.mStringOffsets[idx], sizeof(char*));
strPtr = nonNull(strPtr);
uint32_t len = safeStrLen(strPtr) + 1;
mSPVBuffer.write(strPtr, len);
}
data = DataRef<const uint8_t>(mSPVBuffer.begin(), mSPVBuffer.end());
}
return data;
}
virtual PvdError setPropertyMessage(const void* instance, const NamespacedName& msgName, DataRef<const uint8_t> data)
{
ScopedMetaData meta(mMetaDataProvider);
PX_ASSERT(isInstanceValid(instance));
#if PX_DEBUG
PX_ASSERT(messageExists(msgName));
PX_ASSERT(checkPropertyMessage(instance, msgName));
#endif
PropertyMessageDescription desc(meta->findPropertyMessage(msgName));
if(data.size() < desc.mMessageByteSize)
{
PX_ASSERT(false);
return PvdErrorType::ArgumentError;
}
data = bufferPropertyMessage(desc, data);
PX_ASSERT(mStreamState == DataStreamState::Open);
return boolToError(handlePvdEvent(SetPropertyMessage(toStream(instance), toStream(msgName), data)));
}
#if PX_DEBUG
bool checkBeginPropertyMessageGroup(const NamespacedName& msgName)
{
ScopedMetaData meta(mMetaDataProvider);
PropertyMessageDescription desc(meta->findPropertyMessage(msgName));
return desc.mStringOffsets.size() == 0;
}
#endif
// If you need to send of lot of identical messages, this avoids a hashtable lookup per message.
virtual PvdError beginPropertyMessageGroup(const NamespacedName& msgName)
{
#if PX_DEBUG
PX_ASSERT(messageExists(msgName));
PX_ASSERT(checkBeginPropertyMessageGroup(msgName));
#endif
PX_ASSERT(mStreamState == DataStreamState::Open);
mStreamState = DataStreamState::PropertyMessageGroup;
ScopedMetaData meta(mMetaDataProvider);
mMessageDesc = meta->findPropertyMessage(msgName);
return boolToError(handlePvdEvent(BeginPropertyMessageGroup(toStream(msgName))));
}
virtual PvdError sendPropertyMessageFromGroup(const void* instance, DataRef<const uint8_t> data)
{
PX_ASSERT(mStreamState == DataStreamState::PropertyMessageGroup);
PX_ASSERT(isInstanceValid(instance));
#if PX_DEBUG
PX_ASSERT(checkPropertyMessage(instance, mMessageDesc.mMessageName));
#endif
if(mMessageDesc.mMessageByteSize != data.size())
{
PX_ASSERT(false);
return PvdErrorType::ArgumentError;
}
if(data.size() < mMessageDesc.mMessageByteSize)
return PvdErrorType::ArgumentError;
data = bufferPropertyMessage(mMessageDesc, data);
return boolToError(handlePvdEvent(SendPropertyMessageFromGroup(toStream(instance), data)));
}
virtual PvdError endPropertyMessageGroup()
{
PX_ASSERT(mStreamState == DataStreamState::PropertyMessageGroup);
mStreamState = DataStreamState::Open;
return boolToError(handlePvdEvent(EndPropertyMessageGroup()));
}
virtual PvdError pushBackObjectRef(const void* instance, String propName, const void* data)
{
PX_ASSERT(isInstanceValid(instance));
PX_ASSERT(isInstanceValid(data));
PX_ASSERT(mStreamState == DataStreamState::Open);
return boolToError(handlePvdEvent(PushBackObjectRef(toStream(instance), toStream(propName), toStream(data))));
}
virtual PvdError removeObjectRef(const void* instance, String propName, const void* data)
{
PX_ASSERT(isInstanceValid(instance));
PX_ASSERT(isInstanceValid(data));
PX_ASSERT(mStreamState == DataStreamState::Open);
return boolToError(handlePvdEvent(RemoveObjectRef(toStream(instance), toStream(propName), toStream(data))));
}
// Instance elimination.
virtual PvdError destroyInstance(const void* instance)
{
PX_ASSERT(isInstanceValid(instance));
PX_ASSERT(mStreamState == DataStreamState::Open);
mMetaDataProvider.destroyInstance(instance);
return boolToError(handlePvdEvent(DestroyInstance(toStream(instance))));
}
// Profiling hooks
virtual PvdError beginSection(const void* instance, String name)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
return boolToError(handlePvdEvent(
BeginSection(toStream(instance), toStream(name), PxTime::getCurrentCounterValue())));
}
virtual PvdError endSection(const void* instance, String name)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
return boolToError(handlePvdEvent(
EndSection(toStream(instance), toStream(name), PxTime::getCurrentCounterValue())));
}
virtual PvdError originShift(const void* scene, PxVec3 shift)
{
PX_ASSERT(mStreamState == DataStreamState::Open);
return boolToError(handlePvdEvent(OriginShift(toStream(scene), shift)));
}
virtual void addProfileZone(void* zone, const char* name)
{
handlePvdEvent(AddProfileZone(toStream(zone), name));
}
virtual void addProfileZoneEvent(void* zone, const char* name, uint16_t eventId, bool compileTimeEnabled)
{
handlePvdEvent(AddProfileZoneEvent(toStream(zone), name, eventId, compileTimeEnabled));
}
// add a variable sized event
void addEvent(const EventSerializeable& evt, PvdCommStreamEventTypes::Enum evtType)
{
MeasureStream measure;
PvdCommStreamEventSink::writeStreamEvent(evt, evtType, measure);
EventGroup evtGroup(measure.mSize, 1, mStreamId, PxTime::getCurrentCounterValue());
EventStreamifier<PxPvdTransport> streamifier(mTransport.lock());
evtGroup.serialize(streamifier);
PvdCommStreamEventSink::writeStreamEvent(evt, evtType, mTransport);
mTransport.unlock();
}
void setIsTopLevelUIElement(const void* instance, bool topLevel)
{
addEvent(SetIsTopLevel(static_cast<uint64_t>(reinterpret_cast<size_t>(instance)), topLevel),
getCommStreamEventType<SetIsTopLevel>());
}
void sendErrorMessage(uint32_t code, const char* message, const char* file, uint32_t line)
{
addEvent(ErrorMessage(code, message, file, line), getCommStreamEventType<ErrorMessage>());
}
void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target)
{
addEvent(SetCamera(name, origin, up, target), getCommStreamEventType<SetCamera>());
}
template <typename TEventType>
bool handlePvdEvent(const TEventType& evt)
{
addEvent(evt, getCommStreamEventType<TEventType>());
return mConnected;
}
virtual PvdPropertyDefinitionHelper& getPropertyDefinitionHelper()
{
mPropertyDefinitionHelper.clearBufferedData();
return mPropertyDefinitionHelper;
}
virtual bool isConnected()
{
return mConnected;
}
virtual void* allocateMemForCmd(uint32_t length)
{
return mPvdCommandPool.allocate(length);
}
virtual void pushPvdCommand(PvdCommand& cmd)
{
mPvdCommandArray.pushBack(&cmd);
}
virtual void flushPvdCommand()
{
uint32_t cmdQueueSize = mPvdCommandArray.size();
for(uint32_t i = 0; i < cmdQueueSize; i++)
{
if(mPvdCommandArray[i])
{
// if(mPvdCommandArray[i]->canRun(*this))
mPvdCommandArray[i]->run(*this);
mPvdCommandArray[i]->~PvdCommand();
}
}
mPvdCommandArray.clear();
mPvdCommandPool.clear();
}
PX_NOCOPY(PvdOutStream)
};
}
PvdDataStream* PvdDataStream::create(PxPvd* pvd)
{
if(pvd == NULL)
{
PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PvdDataStream::create - pvd must be non-NULL!");
return NULL;
}
PvdImpl* pvdImpl = static_cast<PvdImpl*>(pvd);
return PVD_NEW(PvdOutStream)(*pvdImpl->getTransport(), pvdImpl->getMetaDataProvider(), pvdImpl->getNextStreamId());
}
| 27,599 | C++ | 30.98146 | 121 | 0.744302 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventBufferClientManager.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_EVENT_BUFFER_CLIENT_MANAGER_H
#define PX_PROFILE_EVENT_BUFFER_CLIENT_MANAGER_H
#include "PxProfileEventBufferClient.h"
namespace physx { namespace profile {
/**
\brief Manager keep collections of PxProfileEventBufferClient clients.
@see PxProfileEventBufferClient
*/
class PxProfileEventBufferClientManager
{
protected:
virtual ~PxProfileEventBufferClientManager(){}
public:
/**
\brief Adds new client.
\param inClient Client to add.
*/
virtual void addClient( PxProfileEventBufferClient& inClient ) = 0;
/**
\brief Removes a client.
\param inClient Client to remove.
*/
virtual void removeClient( PxProfileEventBufferClient& inClient ) = 0;
/**
\brief Check if manager has clients.
\return True if manager has added clients.
*/
virtual bool hasClients() const = 0;
};
/**
\brief Manager keep collections of PxProfileZoneClient clients.
@see PxProfileZoneClient
*/
class PxProfileZoneClientManager
{
protected:
virtual ~PxProfileZoneClientManager(){}
public:
/**
\brief Adds new client.
\param inClient Client to add.
*/
virtual void addClient( PxProfileZoneClient& inClient ) = 0;
/**
\brief Removes a client.
\param inClient Client to remove.
*/
virtual void removeClient( PxProfileZoneClient& inClient ) = 0;
/**
\brief Check if manager has clients.
\return True if manager has added clients.
*/
virtual bool hasClients() const = 0;
};
} }
#endif
| 3,029 | C | 30.894737 | 74 | 0.745791 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileDataBuffer.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_DATA_BUFFER_H
#define PX_PROFILE_DATA_BUFFER_H
#include "PxProfileAllocatorWrapper.h"
#include "PxProfileMemoryBuffer.h"
#include "PxProfileEventBufferClient.h"
namespace physx { namespace profile {
template<typename TMutex
, typename TScopedLock>
class DataBuffer //base class for buffers that cache data and then dump the data to clients.
{
public:
typedef TMutex TMutexType;
typedef TScopedLock TScopedLockType;
typedef PxProfileWrapperNamedAllocator TU8AllocatorType;
typedef MemoryBuffer<TU8AllocatorType > TMemoryBufferType;
typedef PxProfileArray<PxProfileEventBufferClient*> TBufferClientArray;
protected:
PxProfileAllocatorWrapper mWrapper;
TMemoryBufferType mDataArray;
TBufferClientArray mBufferClients;
uint32_t mBufferFullAmount;
EventContextInformation mEventContextInformation;
TMutexType* mBufferMutex;
volatile bool mHasClients;
EventSerializer<TMemoryBufferType > mSerializer;
public:
DataBuffer( PxAllocatorCallback* inFoundation
, uint32_t inBufferFullAmount
, TMutexType* inBufferMutex
, const char* inAllocationName )
: mWrapper( inFoundation )
, mDataArray( TU8AllocatorType( mWrapper, inAllocationName ) )
, mBufferClients( mWrapper )
, mBufferFullAmount( inBufferFullAmount )
, mBufferMutex( inBufferMutex )
, mHasClients( false )
, mSerializer( &mDataArray )
{
//The data array is never resized really. We ensure
//it is bigger than it will ever need to be.
mDataArray.reserve( inBufferFullAmount + 68 );
}
virtual ~DataBuffer()
{
while(mBufferClients.size() )
{
removeClient( *mBufferClients[0] );
}
}
PxProfileAllocatorWrapper& getWrapper() { return mWrapper; }
TMutexType* getBufferMutex() { return mBufferMutex; }
void setBufferMutex(TMutexType* mutex) { mBufferMutex = mutex; }
void addClient( PxProfileEventBufferClient& inClient )
{
TScopedLockType lock( mBufferMutex );
mBufferClients.pushBack( &inClient );
mHasClients = true;
}
void removeClient( PxProfileEventBufferClient& inClient )
{
TScopedLockType lock( mBufferMutex );
for ( uint32_t idx =0; idx < mBufferClients.size(); ++idx )
{
if (mBufferClients[idx] == &inClient )
{
inClient.handleClientRemoved();
mBufferClients.replaceWithLast( idx );
break;
}
}
mHasClients = mBufferClients.size() != 0;
}
bool hasClients() const
{
return mHasClients;
}
virtual void flushEvents()
{
TScopedLockType lock(mBufferMutex);
const uint8_t* theData = mDataArray.begin();
uint32_t theDataSize = mDataArray.size();
sendDataToClients(theData, theDataSize);
mDataArray.clear();
clearCachedData();
}
//Used for chaining together event buffers.
virtual void handleBufferFlush( const uint8_t* inData, uint32_t inDataSize )
{
TScopedLockType lock( mBufferMutex );
if ( inData && inDataSize )
{
clearCachedData();
if ( mDataArray.size() + inDataSize >= mBufferFullAmount )
flushEvents();
if ( inDataSize >= mBufferFullAmount )
sendDataToClients( inData, inDataSize );
else
mDataArray.write( inData, inDataSize );
}
}
protected:
virtual void clearCachedData()
{
}
private:
void sendDataToClients( const uint8_t* inData, uint32_t inDataSize )
{
uint32_t clientCount = mBufferClients.size();
for( uint32_t idx =0; idx < clientCount; ++idx )
mBufferClients[idx]->handleBufferFlush( inData, inDataSize );
}
};
}}
#endif
| 5,270 | C | 30.753012 | 93 | 0.725806 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdBits.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_BITS_H
#define PX_PVD_BITS_H
#include "PxPvdObjectModelBaseTypes.h"
namespace physx
{
namespace pvdsdk
{
// Marshallers cannot assume src is aligned, but they can assume dest is aligned.
typedef void (*TSingleMarshaller)(const uint8_t* src, uint8_t* dest);
typedef void (*TBlockMarshaller)(const uint8_t* src, uint8_t* dest, uint32_t numItems);
template <uint8_t ByteCount>
static inline void doSwapBytes(uint8_t* __restrict inData)
{
for(uint32_t idx = 0; idx < ByteCount / 2; ++idx)
{
uint32_t endIdx = ByteCount - idx - 1;
uint8_t theTemp = inData[idx];
inData[idx] = inData[endIdx];
inData[endIdx] = theTemp;
}
}
template <uint8_t ByteCount>
static inline void doSwapBytes(uint8_t* __restrict inData, uint32_t itemCount)
{
uint8_t* end = inData + itemCount * ByteCount;
for(; inData < end; inData += ByteCount)
doSwapBytes<ByteCount>(inData);
}
static inline void swapBytes(uint8_t* __restrict dataPtr, uint32_t numBytes, uint32_t itemWidth)
{
uint32_t numItems = numBytes / itemWidth;
switch(itemWidth)
{
case 1:
break;
case 2:
doSwapBytes<2>(dataPtr, numItems);
break;
case 4:
doSwapBytes<4>(dataPtr, numItems);
break;
case 8:
doSwapBytes<8>(dataPtr, numItems);
break;
case 16:
doSwapBytes<16>(dataPtr, numItems);
break;
default:
PX_ASSERT(false);
break;
}
}
static inline void swapBytes(uint8_t&)
{
}
static inline void swapBytes(int8_t&)
{
}
static inline void swapBytes(uint16_t& inData)
{
doSwapBytes<2>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(int16_t& inData)
{
doSwapBytes<2>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(uint32_t& inData)
{
doSwapBytes<4>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(int32_t& inData)
{
doSwapBytes<4>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(float& inData)
{
doSwapBytes<4>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(uint64_t& inData)
{
doSwapBytes<8>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(int64_t& inData)
{
doSwapBytes<8>(reinterpret_cast<uint8_t*>(&inData));
}
static inline void swapBytes(double& inData)
{
doSwapBytes<8>(reinterpret_cast<uint8_t*>(&inData));
}
static inline bool checkLength(const uint8_t* inStart, const uint8_t* inStop, uint32_t inLength)
{
return static_cast<uint32_t>(inStop - inStart) >= inLength;
}
}
}
#endif
| 3,989 | C | 29 | 96 | 0.73803 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdCommStreamEvents.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_COMM_STREAM_EVENTS_H
#define PX_PVD_COMM_STREAM_EVENTS_H
#include "foundation/PxVec3.h"
#include "foundation/PxFlags.h"
#include "foundation/PxTime.h"
#include "PxPvdObjectModelBaseTypes.h"
namespace physx
{
namespace pvdsdk
{
struct CommStreamFlagTypes
{
enum Enum
{
Is64BitPtr = 1
};
};
typedef PxFlags<CommStreamFlagTypes::Enum, uint32_t> CommStreamFlags;
template <typename TDataType>
struct PvdCommVariableSizedEventCheck
{
bool variable_size_check;
};
// Pick out the events that are possibly very large.
// This helps us keep our buffers close to the size the user requested.
#define DECLARE_TYPE_VARIABLE_SIZED(type) \
template <> \
struct PvdCommVariableSizedEventCheck<type> \
{ \
uint32_t variable_size_check; \
};
struct NameHandleValue;
struct StreamPropMessageArg;
struct StringHandleEvent;
struct CreateClass;
struct DeriveClass;
struct CreateProperty;
struct CreatePropertyMessage;
struct CreateInstance;
struct SetPropertyValue;
struct BeginSetPropertyValue;
struct AppendPropertyValueData;
struct EndSetPropertyValue;
struct SetPropertyMessage;
struct BeginPropertyMessageGroup;
struct SendPropertyMessageFromGroup;
struct EndPropertyMessageGroup;
struct CreateDestroyInstanceProperty;
struct PushBackObjectRef;
struct RemoveObjectRef;
struct BeginSection;
struct EndSection;
struct SetPickable;
struct SetColor;
struct SetIsTopLevel;
struct SetCamera;
struct AddProfileZone;
struct AddProfileZoneEvent;
struct StreamEndEvent;
struct ErrorMessage;
struct OriginShift;
struct DestroyInstance;
#define DECLARE_COMM_STREAM_EVENTS \
\
DECLARE_PVD_COMM_STREAM_EVENT(StringHandleEvent) \
DECLARE_PVD_COMM_STREAM_EVENT(CreateClass) \
DECLARE_PVD_COMM_STREAM_EVENT(DeriveClass) \
DECLARE_PVD_COMM_STREAM_EVENT(CreateProperty) \
DECLARE_PVD_COMM_STREAM_EVENT(CreatePropertyMessage) \
DECLARE_PVD_COMM_STREAM_EVENT(CreateInstance) \
DECLARE_PVD_COMM_STREAM_EVENT(SetPropertyValue) \
DECLARE_PVD_COMM_STREAM_EVENT(BeginSetPropertyValue) \
DECLARE_PVD_COMM_STREAM_EVENT(AppendPropertyValueData) \
DECLARE_PVD_COMM_STREAM_EVENT(EndSetPropertyValue) \
DECLARE_PVD_COMM_STREAM_EVENT(SetPropertyMessage) \
DECLARE_PVD_COMM_STREAM_EVENT(BeginPropertyMessageGroup) \
DECLARE_PVD_COMM_STREAM_EVENT(SendPropertyMessageFromGroup) \
DECLARE_PVD_COMM_STREAM_EVENT(EndPropertyMessageGroup) \
DECLARE_PVD_COMM_STREAM_EVENT(DestroyInstance) \
DECLARE_PVD_COMM_STREAM_EVENT(PushBackObjectRef) \
DECLARE_PVD_COMM_STREAM_EVENT(RemoveObjectRef) \
DECLARE_PVD_COMM_STREAM_EVENT(BeginSection) \
DECLARE_PVD_COMM_STREAM_EVENT(EndSection) \
DECLARE_PVD_COMM_STREAM_EVENT(SetPickable) \
DECLARE_PVD_COMM_STREAM_EVENT(SetColor) \
DECLARE_PVD_COMM_STREAM_EVENT(SetIsTopLevel) \
DECLARE_PVD_COMM_STREAM_EVENT(SetCamera) \
DECLARE_PVD_COMM_STREAM_EVENT(AddProfileZone) \
DECLARE_PVD_COMM_STREAM_EVENT(AddProfileZoneEvent) \
DECLARE_PVD_COMM_STREAM_EVENT(StreamEndEvent) \
DECLARE_PVD_COMM_STREAM_EVENT(ErrorMessage) \
DECLARE_PVD_COMM_STREAM_EVENT_NO_COMMA(OriginShift)
struct PvdCommStreamEventTypes
{
enum Enum
{
Unknown = 0,
#define DECLARE_PVD_COMM_STREAM_EVENT(x) x,
#define DECLARE_PVD_COMM_STREAM_EVENT_NO_COMMA(x) x
DECLARE_COMM_STREAM_EVENTS
#undef DECLARE_PVD_COMM_STREAM_EVENT_NO_COMMA
#undef DECLARE_PVD_COMM_STREAM_EVENT
, Last
};
};
template <typename TDataType>
struct DatatypeToCommEventType
{
bool compile_error;
};
template <PvdCommStreamEventTypes::Enum TEnumType>
struct CommEventTypeToDatatype
{
bool compile_error;
};
#define DECLARE_PVD_COMM_STREAM_EVENT(x) \
template <> \
struct DatatypeToCommEventType<x> \
{ \
enum Enum \
{ \
EEventTypeMap = PvdCommStreamEventTypes::x \
}; \
}; \
template <> \
struct CommEventTypeToDatatype<PvdCommStreamEventTypes::x> \
{ \
typedef x TEventType; \
};
#define DECLARE_PVD_COMM_STREAM_EVENT_NO_COMMA(x) \
\
template<> struct DatatypeToCommEventType<x> \
{ \
enum Enum \
{ \
EEventTypeMap = PvdCommStreamEventTypes::x \
}; \
}; \
\
template<> struct CommEventTypeToDatatype<PvdCommStreamEventTypes::x> \
{ \
typedef x TEventType; \
};
DECLARE_COMM_STREAM_EVENTS
#undef DECLARE_PVD_COMM_STREAM_EVENT_NO_COMMA
#undef DECLARE_PVD_COMM_STREAM_EVENT
template <typename TDataType>
PvdCommStreamEventTypes::Enum getCommStreamEventType()
{
return static_cast<PvdCommStreamEventTypes::Enum>(DatatypeToCommEventType<TDataType>::EEventTypeMap);
}
struct StreamNamespacedName
{
StringHandle mNamespace; // StringHandle handles
StringHandle mName;
StreamNamespacedName(StringHandle ns = 0, StringHandle nm = 0) : mNamespace(ns), mName(nm)
{
}
};
class EventSerializeable;
class PvdEventSerializer
{
protected:
virtual ~PvdEventSerializer()
{
}
public:
virtual void streamify(uint8_t& val) = 0;
virtual void streamify(uint16_t& val) = 0;
virtual void streamify(uint32_t& val) = 0;
virtual void streamify(float& val) = 0;
virtual void streamify(uint64_t& val) = 0;
virtual void streamify(String& val) = 0;
virtual void streamify(DataRef<const uint8_t>& data) = 0;
virtual void streamify(DataRef<NameHandleValue>& data) = 0;
virtual void streamify(DataRef<StreamPropMessageArg>& data) = 0;
virtual void streamify(DataRef<StringHandle>& data) = 0;
void streamify(StringHandle& hdl)
{
streamify(hdl.mHandle);
}
void streamify(CommStreamFlags& flags)
{
uint32_t val(flags);
streamify(val);
flags = CommStreamFlags(val);
}
void streamify(PvdCommStreamEventTypes::Enum& val)
{
uint8_t detyped = static_cast<uint8_t>(val);
streamify(detyped);
val = static_cast<PvdCommStreamEventTypes::Enum>(detyped);
}
void streamify(PropertyType::Enum& val)
{
uint8_t detyped = static_cast<uint8_t>(val);
streamify(detyped);
val = static_cast<PropertyType::Enum>(detyped);
}
void streamify(bool& val)
{
uint8_t detyped = uint8_t(val ? 1 : 0);
streamify(detyped);
val = detyped ? true : false;
}
void streamify(StreamNamespacedName& name)
{
streamify(name.mNamespace);
streamify(name.mName);
}
void streamify(PvdColor& color)
{
streamify(color.r);
streamify(color.g);
streamify(color.b);
streamify(color.a);
}
void streamify(PxVec3& vec)
{
streamify(vec.x);
streamify(vec.y);
streamify(vec.z);
}
static uint32_t measure(const EventSerializeable& evt);
};
class EventSerializeable
{
protected:
virtual ~EventSerializeable()
{
}
public:
virtual void serialize(PvdEventSerializer& serializer) = 0;
};
/** Numbers generated from random.org
129919156 17973702 401496246 144984007 336950759
907025328 837150850 679717896 601529147 269478202
*/
struct StreamInitialization : public EventSerializeable
{
static uint32_t getStreamId()
{
return 837150850;
}
static uint32_t getStreamVersion()
{
return 1;
}
uint32_t mStreamId;
uint32_t mStreamVersion;
uint64_t mTimestampNumerator;
uint64_t mTimestampDenominator;
CommStreamFlags mStreamFlags;
StreamInitialization()
: mStreamId(getStreamId())
, mStreamVersion(getStreamVersion())
, mTimestampNumerator(physx::PxTime::getCounterFrequency().mNumerator * 10)
, mTimestampDenominator(physx::PxTime::getCounterFrequency().mDenominator)
, mStreamFlags(sizeof(void*) == 4 ? 0 : 1)
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mStreamId);
s.streamify(mStreamVersion);
s.streamify(mTimestampNumerator);
s.streamify(mTimestampDenominator);
s.streamify(mStreamFlags);
}
};
struct EventGroup : public EventSerializeable
{
uint32_t mDataSize; // in bytes, data directly follows this header
uint32_t mNumEvents;
uint64_t mStreamId;
uint64_t mTimestamp;
EventGroup(uint32_t dataSize = 0, uint32_t numEvents = 0, uint64_t streamId = 0, uint64_t ts = 0)
: mDataSize(dataSize), mNumEvents(numEvents), mStreamId(streamId), mTimestamp(ts)
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mDataSize);
s.streamify(mNumEvents);
s.streamify(mStreamId);
s.streamify(mTimestamp);
}
};
struct StringHandleEvent : public EventSerializeable
{
String mString;
uint32_t mHandle;
StringHandleEvent(String str, uint32_t hdl) : mString(str), mHandle(hdl)
{
}
StringHandleEvent()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mString);
s.streamify(mHandle);
}
};
DECLARE_TYPE_VARIABLE_SIZED(StringHandleEvent)
typedef uint64_t Timestamp;
struct CreateClass : public EventSerializeable
{
StreamNamespacedName mName;
CreateClass(StreamNamespacedName nm) : mName(nm)
{
}
CreateClass()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mName);
}
};
struct DeriveClass : public EventSerializeable
{
StreamNamespacedName mParent;
StreamNamespacedName mChild;
DeriveClass(StreamNamespacedName p, StreamNamespacedName c) : mParent(p), mChild(c)
{
}
DeriveClass()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mParent);
s.streamify(mChild);
}
};
struct NameHandleValue : public EventSerializeable
{
StringHandle mName;
uint32_t mValue;
NameHandleValue(StringHandle name, uint32_t val) : mName(name), mValue(val)
{
}
NameHandleValue()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mName);
s.streamify(mValue);
}
};
/*virtual PvdError createProperty( StreamNamespacedName clsName, StringHandle name, StringHandle semantic
, StreamNamespacedName dtypeName, PropertyType::Enum propertyType
, DataRef<NamedValue> values = DataRef<NamedValue>() ) = 0; */
struct CreateProperty : public EventSerializeable
{
StreamNamespacedName mClass;
StringHandle mName;
StringHandle mSemantic;
StreamNamespacedName mDatatypeName;
PropertyType::Enum mPropertyType;
DataRef<NameHandleValue> mValues;
CreateProperty(StreamNamespacedName cls, StringHandle name, StringHandle semantic, StreamNamespacedName dtypeName,
PropertyType::Enum ptype, DataRef<NameHandleValue> values)
: mClass(cls), mName(name), mSemantic(semantic), mDatatypeName(dtypeName), mPropertyType(ptype), mValues(values)
{
}
CreateProperty()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mClass);
s.streamify(mName);
s.streamify(mSemantic);
s.streamify(mDatatypeName);
s.streamify(mPropertyType);
s.streamify(mValues);
}
};
struct StreamPropMessageArg : public EventSerializeable
{
StringHandle mPropertyName;
StreamNamespacedName mDatatypeName;
uint32_t mMessageOffset;
uint32_t mByteSize;
StreamPropMessageArg(StringHandle pname, StreamNamespacedName dtypeName, uint32_t offset, uint32_t byteSize)
: mPropertyName(pname), mDatatypeName(dtypeName), mMessageOffset(offset), mByteSize(byteSize)
{
}
StreamPropMessageArg()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mPropertyName);
s.streamify(mDatatypeName);
s.streamify(mMessageOffset);
s.streamify(mByteSize);
}
};
/*
virtual PvdError createPropertyMessage( StreamNamespacedName cls, StreamNamespacedName msgName
, DataRef<PropertyMessageArg> entries, uint32_t messageSizeInBytes ) =
0;*/
struct CreatePropertyMessage : public EventSerializeable
{
StreamNamespacedName mClass;
StreamNamespacedName mMessageName;
DataRef<StreamPropMessageArg> mMessageEntries;
uint32_t mMessageByteSize;
CreatePropertyMessage(StreamNamespacedName cls, StreamNamespacedName msgName, DataRef<StreamPropMessageArg> propArg,
uint32_t messageByteSize)
: mClass(cls), mMessageName(msgName), mMessageEntries(propArg), mMessageByteSize(messageByteSize)
{
}
CreatePropertyMessage()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mClass);
s.streamify(mMessageName);
s.streamify(mMessageEntries);
s.streamify(mMessageByteSize);
}
};
/**Changing immediate data on instances*/
// virtual PvdError createInstance( StreamNamespacedName cls, uint64_t instance ) = 0;
struct CreateInstance : public EventSerializeable
{
StreamNamespacedName mClass;
uint64_t mInstanceId;
CreateInstance(StreamNamespacedName cls, uint64_t streamId) : mClass(cls), mInstanceId(streamId)
{
}
CreateInstance()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mClass);
s.streamify(mInstanceId);
}
};
// virtual PvdError setPropertyValue( uint64_t instance, StringHandle name, DataRef<const uint8_t> data,
// StreamNamespacedName incomingTypeName ) = 0;
struct SetPropertyValue : public EventSerializeable
{
uint64_t mInstanceId;
StringHandle mPropertyName;
DataRef<const uint8_t> mData;
StreamNamespacedName mIncomingTypeName;
uint32_t mNumItems;
SetPropertyValue(uint64_t instance, StringHandle name, DataRef<const uint8_t> data,
StreamNamespacedName incomingTypeName, uint32_t numItems)
: mInstanceId(instance), mPropertyName(name), mData(data), mIncomingTypeName(incomingTypeName), mNumItems(numItems)
{
}
SetPropertyValue()
{
}
void serializeBeginning(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mPropertyName);
s.streamify(mIncomingTypeName);
s.streamify(mNumItems);
}
void serialize(PvdEventSerializer& s)
{
serializeBeginning(s);
s.streamify(mData);
}
};
DECLARE_TYPE_VARIABLE_SIZED(SetPropertyValue)
struct BeginSetPropertyValue : public EventSerializeable
{
uint64_t mInstanceId;
StringHandle mPropertyName;
StreamNamespacedName mIncomingTypeName;
BeginSetPropertyValue(uint64_t instance, StringHandle name, StreamNamespacedName incomingTypeName)
: mInstanceId(instance), mPropertyName(name), mIncomingTypeName(incomingTypeName)
{
}
BeginSetPropertyValue()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mPropertyName);
s.streamify(mIncomingTypeName);
}
};
// virtual PvdError appendPropertyValueData( DataRef<const uint8_t> data ) = 0;
struct AppendPropertyValueData : public EventSerializeable
{
DataRef<const uint8_t> mData;
uint32_t mNumItems;
AppendPropertyValueData(DataRef<const uint8_t> data, uint32_t numItems) : mData(data), mNumItems(numItems)
{
}
AppendPropertyValueData()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mData);
s.streamify(mNumItems);
}
};
DECLARE_TYPE_VARIABLE_SIZED(AppendPropertyValueData)
// virtual PvdError endSetPropertyValue() = 0;
struct EndSetPropertyValue : public EventSerializeable
{
EndSetPropertyValue()
{
}
void serialize(PvdEventSerializer&)
{
}
};
// virtual PvdError setPropertyMessage( uint64_t instance, StreamNamespacedName msgName, DataRef<const uint8_t> data ) =
// 0;
struct SetPropertyMessage : public EventSerializeable
{
uint64_t mInstanceId;
StreamNamespacedName mMessageName;
DataRef<const uint8_t> mData;
SetPropertyMessage(uint64_t instance, StreamNamespacedName msgName, DataRef<const uint8_t> data)
: mInstanceId(instance), mMessageName(msgName), mData(data)
{
}
SetPropertyMessage()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mMessageName);
s.streamify(mData);
}
};
DECLARE_TYPE_VARIABLE_SIZED(SetPropertyMessage)
// virtual PvdError beginPropertyMessageGroup( StreamNamespacedName msgName ) = 0;
struct BeginPropertyMessageGroup : public EventSerializeable
{
StreamNamespacedName mMsgName;
BeginPropertyMessageGroup(StreamNamespacedName msgName) : mMsgName(msgName)
{
}
BeginPropertyMessageGroup()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mMsgName);
}
};
// virtual PvdError sendPropertyMessageFromGroup( uint64_t instance, DataRef<const uint8_t*> data ) = 0;
struct SendPropertyMessageFromGroup : public EventSerializeable
{
uint64_t mInstance;
DataRef<const uint8_t> mData;
SendPropertyMessageFromGroup(uint64_t instance, DataRef<const uint8_t> data) : mInstance(instance), mData(data)
{
}
SendPropertyMessageFromGroup()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstance);
s.streamify(mData);
}
};
DECLARE_TYPE_VARIABLE_SIZED(SendPropertyMessageFromGroup)
// virtual PvdError endPropertyMessageGroup() = 0;
struct EndPropertyMessageGroup : public EventSerializeable
{
EndPropertyMessageGroup()
{
}
void serialize(PvdEventSerializer&)
{
}
};
struct PushBackObjectRef : public EventSerializeable
{
uint64_t mInstanceId;
StringHandle mProperty;
uint64_t mObjectRef;
PushBackObjectRef(uint64_t instId, StringHandle prop, uint64_t objRef)
: mInstanceId(instId), mProperty(prop), mObjectRef(objRef)
{
}
PushBackObjectRef()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mProperty);
s.streamify(mObjectRef);
}
};
struct RemoveObjectRef : public EventSerializeable
{
uint64_t mInstanceId;
StringHandle mProperty;
uint64_t mObjectRef;
RemoveObjectRef(uint64_t instId, StringHandle prop, uint64_t objRef)
: mInstanceId(instId), mProperty(prop), mObjectRef(objRef)
{
}
RemoveObjectRef()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mProperty);
s.streamify(mObjectRef);
}
};
// virtual PvdError destroyInstance( uint64_t key ) = 0;
struct DestroyInstance : public EventSerializeable
{
uint64_t mInstanceId;
DestroyInstance(uint64_t instance) : mInstanceId(instance)
{
}
DestroyInstance()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
}
};
// virtual PvdError beginSection( uint64_t sectionId, StringHandle name ) = 0;
struct BeginSection : public EventSerializeable
{
uint64_t mSectionId;
StringHandle mName;
Timestamp mTimestamp;
BeginSection(uint64_t sectionId, StringHandle name, uint64_t timestamp)
: mSectionId(sectionId), mName(name), mTimestamp(timestamp)
{
}
BeginSection()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mSectionId);
s.streamify(mName);
s.streamify(mTimestamp);
}
};
// virtual PvdError endSection( uint64_t sectionId, StringHandle name ) = 0;
struct EndSection : public EventSerializeable
{
uint64_t mSectionId;
StringHandle mName;
Timestamp mTimestamp;
EndSection(uint64_t sectionId, StringHandle name, uint64_t timestamp)
: mSectionId(sectionId), mName(name), mTimestamp(timestamp)
{
}
EndSection()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mSectionId);
s.streamify(mName);
s.streamify(mTimestamp);
}
};
// virtual void setPickable( void* instance, bool pickable ) = 0;
struct SetPickable : public EventSerializeable
{
uint64_t mInstanceId;
bool mPickable;
SetPickable(uint64_t instId, bool pick) : mInstanceId(instId), mPickable(pick)
{
}
SetPickable()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mPickable);
}
};
// virtual void setColor( void* instance, const PvdColor& color ) = 0;
struct SetColor : public EventSerializeable
{
uint64_t mInstanceId;
PvdColor mColor;
SetColor(uint64_t instId, PvdColor color) : mInstanceId(instId), mColor(color)
{
}
SetColor()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mColor);
}
};
// virtual void setColor( void* instance, const PvdColor& color ) = 0;
struct SetIsTopLevel : public EventSerializeable
{
uint64_t mInstanceId;
bool mIsTopLevel;
SetIsTopLevel(uint64_t instId, bool topLevel) : mInstanceId(instId), mIsTopLevel(topLevel)
{
}
SetIsTopLevel() : mIsTopLevel(false)
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mIsTopLevel);
}
};
struct SetCamera : public EventSerializeable
{
String mName;
PxVec3 mPosition;
PxVec3 mUp;
PxVec3 mTarget;
SetCamera(String name, const PxVec3& pos, const PxVec3& up, const PxVec3& target)
: mName(name), mPosition(pos), mUp(up), mTarget(target)
{
}
SetCamera() : mName(NULL)
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mName);
s.streamify(mPosition);
s.streamify(mUp);
s.streamify(mTarget);
}
};
struct ErrorMessage : public EventSerializeable
{
uint32_t mCode;
String mMessage;
String mFile;
uint32_t mLine;
ErrorMessage(uint32_t code, String message, String file, uint32_t line)
: mCode(code), mMessage(message), mFile(file), mLine(line)
{
}
ErrorMessage() : mMessage(NULL), mFile(NULL)
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mCode);
s.streamify(mMessage);
s.streamify(mFile);
s.streamify(mLine);
}
};
struct AddProfileZone : public EventSerializeable
{
uint64_t mInstanceId;
String mName;
AddProfileZone(uint64_t iid, String nm) : mInstanceId(iid), mName(nm)
{
}
AddProfileZone() : mName(NULL)
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mName);
}
};
struct AddProfileZoneEvent : public EventSerializeable
{
uint64_t mInstanceId;
String mName;
uint16_t mEventId;
bool mCompileTimeEnabled;
AddProfileZoneEvent(uint64_t iid, String nm, uint16_t eid, bool cte)
: mInstanceId(iid), mName(nm), mEventId(eid), mCompileTimeEnabled(cte)
{
}
AddProfileZoneEvent()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mName);
s.streamify(mEventId);
s.streamify(mCompileTimeEnabled);
}
};
struct StreamEndEvent : public EventSerializeable
{
String mName;
StreamEndEvent() : mName("StreamEnd")
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mName);
}
};
struct OriginShift : public EventSerializeable
{
uint64_t mInstanceId;
PxVec3 mShift;
OriginShift(uint64_t iid, const PxVec3& shift) : mInstanceId(iid), mShift(shift)
{
}
OriginShift()
{
}
void serialize(PvdEventSerializer& s)
{
s.streamify(mInstanceId);
s.streamify(mShift);
}
};
} // pvdsdk
} // physx
#endif
| 25,795 | C | 25.109312 | 120 | 0.673231 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdProfileZoneClient.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxPvdImpl.h"
#include "PxPvdProfileZoneClient.h"
#include "PxPvdProfileZone.h"
namespace physx
{
namespace pvdsdk
{
struct ProfileZoneClient : public profile::PxProfileZoneClient, public PxUserAllocated
{
profile::PxProfileZone& mZone;
PvdDataStream& mStream;
ProfileZoneClient(profile::PxProfileZone& zone, PvdDataStream& stream) : mZone(zone), mStream(stream)
{
}
~ProfileZoneClient()
{
mZone.removeClient(*this);
}
virtual void createInstance()
{
mStream.addProfileZone(&mZone, mZone.getName());
mStream.createInstance(&mZone);
mZone.addClient(*this);
profile::PxProfileNames names(mZone.getProfileNames());
PVD_FOREACH(idx, names.eventCount)
{
handleEventAdded(names.events[idx]);
}
}
virtual void handleEventAdded(const profile::PxProfileEventName& inName)
{
mStream.addProfileZoneEvent(&mZone, inName.name, inName.eventId.eventId, inName.eventId.compileTimeEnabled);
}
virtual void handleBufferFlush(const uint8_t* inData, uint32_t inLength)
{
mStream.setPropertyValue(&mZone, "events", inData, inLength);
}
virtual void handleClientRemoved()
{
mStream.destroyInstance(&mZone);
}
private:
ProfileZoneClient& operator=(const ProfileZoneClient&);
};
}
}
using namespace physx;
using namespace pvdsdk;
PvdProfileZoneClient::PvdProfileZoneClient(PvdImpl& pvd) : mSDKPvd(pvd), mPvdDataStream(NULL), mIsConnected(false)
{
}
PvdProfileZoneClient::~PvdProfileZoneClient()
{
mSDKPvd.removeClient(this);
// all zones should removed
PX_ASSERT(mProfileZoneClients.size() == 0);
}
PvdDataStream* PvdProfileZoneClient::getDataStream()
{
return mPvdDataStream;
}
bool PvdProfileZoneClient::isConnected() const
{
return mIsConnected;
}
void PvdProfileZoneClient::onPvdConnected()
{
if(mIsConnected)
return;
mIsConnected = true;
mPvdDataStream = PvdDataStream::create(&mSDKPvd);
}
void PvdProfileZoneClient::onPvdDisconnected()
{
if(!mIsConnected)
return;
mIsConnected = false;
flush();
mPvdDataStream->release();
mPvdDataStream = NULL;
}
void PvdProfileZoneClient::flush()
{
PVD_FOREACH(idx, mProfileZoneClients.size())
mProfileZoneClients[idx]->mZone.flushProfileEvents();
}
void PvdProfileZoneClient::onZoneAdded(profile::PxProfileZone& zone)
{
PX_ASSERT(mIsConnected);
ProfileZoneClient* client = PVD_NEW(ProfileZoneClient)(zone, *mPvdDataStream);
mMutex.lock();
client->createInstance();
mProfileZoneClients.pushBack(client);
mMutex.unlock();
}
void PvdProfileZoneClient::onZoneRemoved(profile::PxProfileZone& zone)
{
for(uint32_t i = 0; i < mProfileZoneClients.size(); i++)
{
if(&zone == &mProfileZoneClients[i]->mZone)
{
mMutex.lock();
ProfileZoneClient* client = mProfileZoneClients[i];
mProfileZoneClients.replaceWithLast(i);
PVD_DELETE(client);
mMutex.unlock();
return;
}
}
}
| 4,503 | C++ | 26.975155 | 114 | 0.758383 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventBufferClient.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_EVENT_BUFFER_CLIENT_H
#define PX_PROFILE_EVENT_BUFFER_CLIENT_H
#include "PxProfileEventNames.h"
namespace physx { namespace profile {
/**
\brief Client handles the data when an event buffer flushes. This data
can be parsed (PxProfileEventHandler.h) as a binary set of events.
*/
class PxProfileEventBufferClient
{
protected:
virtual ~PxProfileEventBufferClient(){}
public:
/**
\brief Callback when the event buffer is full. This data is serialized profile events
and can be read back using: PxProfileEventHandler::parseEventBuffer.
\param inData Provided buffer data.
\param inLength Data length.
@see PxProfileEventHandler::parseEventBuffer.
*/
virtual void handleBufferFlush( const uint8_t* inData, uint32_t inLength ) = 0;
/**
\brief Happens if something removes all the clients from the manager.
*/
virtual void handleClientRemoved() = 0;
};
/**
\brief Client handles new profile event add.
*/
class PxProfileZoneClient : public PxProfileEventBufferClient
{
protected:
virtual ~PxProfileZoneClient(){}
public:
/**
\brief Callback when new profile event is added.
\param inName Added profile event name.
*/
virtual void handleEventAdded( const PxProfileEventName& inName ) = 0;
};
} }
#endif
| 2,848 | C | 34.172839 | 87 | 0.754565 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdUserRenderImpl.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_USER_RENDER_IMPL_H
#define PX_PVD_USER_RENDER_IMPL_H
#include "PxPvdUserRenderer.h"
namespace physx
{
namespace pvdsdk
{
struct PvdUserRenderTypes
{
enum Enum
{
Unknown = 0,
#define DECLARE_PVD_IMMEDIATE_RENDER_TYPE(type) type,
#define DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA(type) type
#include "PxPvdUserRenderTypes.h"
#undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA
#undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE
};
};
class RenderSerializer
{
protected:
virtual ~RenderSerializer()
{
}
public:
virtual void streamify(uint64_t& val) = 0;
virtual void streamify(float& val) = 0;
virtual void streamify(uint32_t& val) = 0;
virtual void streamify(uint8_t& val) = 0;
virtual void streamify(DataRef<uint8_t>& val) = 0;
virtual void streamify(DataRef<PxDebugPoint>& val) = 0;
virtual void streamify(DataRef<PxDebugLine>& val) = 0;
virtual void streamify(DataRef<PxDebugTriangle>& val) = 0;
virtual void streamify(PxDebugText& val) = 0;
virtual bool isGood() = 0;
virtual uint32_t hasData() = 0;
void streamify(PvdUserRenderTypes::Enum& val)
{
uint8_t data = static_cast<uint8_t>(val);
streamify(data);
val = static_cast<PvdUserRenderTypes::Enum>(data);
}
void streamify(PxVec3& val)
{
streamify(val[0]);
streamify(val[1]);
streamify(val[2]);
}
void streamify(PvdColor& val)
{
streamify(val.r);
streamify(val.g);
streamify(val.b);
streamify(val.a);
}
void streamify(PxTransform& val)
{
streamify(val.q.x);
streamify(val.q.y);
streamify(val.q.z);
streamify(val.q.w);
streamify(val.p.x);
streamify(val.p.y);
streamify(val.p.z);
}
void streamify(bool& val)
{
uint8_t tempVal = uint8_t(val ? 1 : 0);
streamify(tempVal);
val = tempVal ? true : false;
}
};
template <typename TBulkRenderType>
struct BulkRenderEvent
{
DataRef<TBulkRenderType> mData;
BulkRenderEvent(const TBulkRenderType* data, uint32_t count) : mData(data, count)
{
}
BulkRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(mData);
}
};
struct SetInstanceIdRenderEvent
{
uint64_t mInstanceId;
SetInstanceIdRenderEvent(uint64_t iid) : mInstanceId(iid)
{
}
SetInstanceIdRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(mInstanceId);
}
};
struct PointsRenderEvent : BulkRenderEvent<PxDebugPoint>
{
PointsRenderEvent(const PxDebugPoint* data, uint32_t count) : BulkRenderEvent<PxDebugPoint>(data, count)
{
}
PointsRenderEvent()
{
}
};
struct LinesRenderEvent : BulkRenderEvent<PxDebugLine>
{
LinesRenderEvent(const PxDebugLine* data, uint32_t count) : BulkRenderEvent<PxDebugLine>(data, count)
{
}
LinesRenderEvent()
{
}
};
struct TrianglesRenderEvent : BulkRenderEvent<PxDebugTriangle>
{
TrianglesRenderEvent(const PxDebugTriangle* data, uint32_t count) : BulkRenderEvent<PxDebugTriangle>(data, count)
{
}
TrianglesRenderEvent()
{
}
};
struct DebugRenderEvent
{
DataRef<PxDebugPoint> mPointData;
DataRef<PxDebugLine> mLineData;
DataRef<PxDebugTriangle> mTriangleData;
DebugRenderEvent(const PxDebugPoint* pointData, uint32_t pointCount, const PxDebugLine* lineData,
uint32_t lineCount, const PxDebugTriangle* triangleData, uint32_t triangleCount)
: mPointData(pointData, pointCount), mLineData(lineData, lineCount), mTriangleData(triangleData, triangleCount)
{
}
DebugRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(mPointData);
serializer.streamify(mLineData);
serializer.streamify(mTriangleData);
}
};
struct TextRenderEvent
{
PxDebugText mText;
TextRenderEvent(const PxDebugText& text)
{
mText.color = text.color;
mText.position = text.position;
mText.size = text.size;
mText.string = text.string;
}
TextRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(mText);
}
};
struct JointFramesRenderEvent
{
PxTransform parent;
PxTransform child;
JointFramesRenderEvent(const PxTransform& p, const PxTransform& c) : parent(p), child(c)
{
}
JointFramesRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(parent);
serializer.streamify(child);
}
};
struct LinearLimitRenderEvent
{
PxTransform t0;
PxTransform t1;
float value;
bool active;
LinearLimitRenderEvent(const PxTransform& _t0, const PxTransform& _t1, float _value, bool _active)
: t0(_t0), t1(_t1), value(_value), active(_active)
{
}
LinearLimitRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(t0);
serializer.streamify(t1);
serializer.streamify(value);
serializer.streamify(active);
}
};
struct AngularLimitRenderEvent
{
PxTransform t0;
float lower;
float upper;
bool active;
AngularLimitRenderEvent(const PxTransform& _t0, float _lower, float _upper, bool _active)
: t0(_t0), lower(_lower), upper(_upper), active(_active)
{
}
AngularLimitRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(t0);
serializer.streamify(lower);
serializer.streamify(upper);
serializer.streamify(active);
}
};
struct LimitConeRenderEvent
{
PxTransform t;
float ySwing;
float zSwing;
bool active;
LimitConeRenderEvent(const PxTransform& _t, float _ySwing, float _zSwing, bool _active)
: t(_t), ySwing(_ySwing), zSwing(_zSwing), active(_active)
{
}
LimitConeRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(t);
serializer.streamify(ySwing);
serializer.streamify(zSwing);
serializer.streamify(active);
}
};
struct DoubleConeRenderEvent
{
PxTransform t;
float angle;
bool active;
DoubleConeRenderEvent(const PxTransform& _t, float _angle, bool _active) : t(_t), angle(_angle), active(_active)
{
}
DoubleConeRenderEvent()
{
}
void serialize(RenderSerializer& serializer)
{
serializer.streamify(t);
serializer.streamify(angle);
serializer.streamify(active);
}
};
template <typename TDataType>
struct RenderSerializerMap
{
void serialize(RenderSerializer& s, TDataType& d)
{
d.serialize(s);
}
};
template <>
struct RenderSerializerMap<uint8_t>
{
void serialize(RenderSerializer& s, uint8_t& d)
{
s.streamify(d);
}
};
template <>
struct RenderSerializerMap<PxDebugPoint>
{
void serialize(RenderSerializer& s, PxDebugPoint& d)
{
s.streamify(d.pos);
s.streamify(d.color);
}
};
template <>
struct RenderSerializerMap<PxDebugLine>
{
void serialize(RenderSerializer& s, PxDebugLine& d)
{
s.streamify(d.pos0);
s.streamify(d.color0);
s.streamify(d.pos1);
s.streamify(d.color1);
}
};
template <>
struct RenderSerializerMap<PxDebugTriangle>
{
void serialize(RenderSerializer& s, PxDebugTriangle& d)
{
s.streamify(d.pos0);
s.streamify(d.color0);
s.streamify(d.pos1);
s.streamify(d.color1);
s.streamify(d.pos2);
s.streamify(d.color2);
}
};
template <typename TDataType>
struct PvdTypeToRenderType
{
bool compile_error;
};
#define DECLARE_PVD_IMMEDIATE_RENDER_TYPE(type) \
template <> \
struct PvdTypeToRenderType<type##RenderEvent> \
{ \
enum Enum \
{ \
EnumVal = PvdUserRenderTypes::type \
}; \
};
#include "PxPvdUserRenderTypes.h"
#undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE
template <typename TDataType>
PvdUserRenderTypes::Enum getPvdRenderTypeFromType()
{
return static_cast<PvdUserRenderTypes::Enum>(PvdTypeToRenderType<TDataType>::EnumVal);
}
}
}
#endif
| 9,152 | C | 22.712435 | 114 | 0.721045 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileZoneImpl.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_ZONE_IMPL_H
#define PX_PROFILE_ZONE_IMPL_H
#include "PxPvdProfileZone.h"
#include "PxProfileZoneManager.h"
#include "PxProfileContextProviderImpl.h"
#include "PxProfileScopedMutexLock.h"
#include "PxProfileEventBufferAtomic.h"
#include "foundation/PxMutex.h"
namespace physx { namespace profile {
/**
\brief Simple event filter that enables all events.
*/
struct PxProfileNullEventFilter
{
void setEventEnabled( const PxProfileEventId&, bool) { PX_ASSERT(false); }
bool isEventEnabled( const PxProfileEventId&) const { return true; }
};
typedef PxMutexT<PxProfileWrapperReflectionAllocator<uint8_t> > TZoneMutexType;
typedef ScopedLockImpl<TZoneMutexType> TZoneLockType;
typedef EventBuffer< PxDefaultContextProvider, TZoneMutexType, TZoneLockType, PxProfileNullEventFilter > TZoneEventBufferType;
//typedef EventBufferAtomic< PxDefaultContextProvider, TZoneMutexType, TZoneLockType, PxProfileNullEventFilter > TZoneEventBufferType;
template<typename TNameProvider>
class ZoneImpl : TZoneEventBufferType //private inheritance intended
, public PxProfileZone
, public PxProfileEventBufferClient
{
typedef PxMutexT<PxProfileWrapperReflectionAllocator<uint8_t> > TMutexType;
typedef PxProfileHashMap<const char*, uint32_t> TNameToEvtIndexMap;
//ensure we don't reuse event ids.
typedef PxProfileHashMap<uint16_t, const char*> TEvtIdToNameMap;
typedef TMutexType::ScopedLock TLockType;
const char* mName;
mutable TMutexType mMutex;
PxProfileArray<PxProfileEventName> mEventNames;
// to avoid locking, read-only and read-write map exist
TNameToEvtIndexMap mNameToEvtIndexMapR;
TNameToEvtIndexMap mNameToEvtIndexMapRW;
//ensure we don't reuse event ids.
TEvtIdToNameMap mEvtIdToNameMap;
PxProfileZoneManager* mProfileZoneManager;
PxProfileArray<PxProfileZoneClient*> mZoneClients;
volatile bool mEventsActive;
PX_NOCOPY(ZoneImpl<TNameProvider>)
public:
ZoneImpl( PxAllocatorCallback* inAllocator, const char* inName, uint32_t bufferSize = 0x10000 /*64k*/, const TNameProvider& inProvider = TNameProvider() )
: TZoneEventBufferType( inAllocator, bufferSize, PxDefaultContextProvider(), NULL, PxProfileNullEventFilter() )
, mName( inName )
, mMutex( PxProfileWrapperReflectionAllocator<uint8_t>( mWrapper ) )
, mEventNames( mWrapper )
, mNameToEvtIndexMapR( mWrapper )
, mNameToEvtIndexMapRW( mWrapper )
, mEvtIdToNameMap( mWrapper )
, mProfileZoneManager( NULL )
, mZoneClients( mWrapper )
, mEventsActive( false )
{
TZoneEventBufferType::setBufferMutex( &mMutex );
//Initialize the event name structure with existing names from the name provider.
PxProfileNames theNames( inProvider.getProfileNames() );
for ( uint32_t idx = 0; idx < theNames.eventCount; ++idx )
{
const PxProfileEventName& theName (theNames.events[idx]);
doAddName( theName.name, theName.eventId.eventId, theName.eventId.compileTimeEnabled );
}
TZoneEventBufferType::addClient( *this );
}
virtual ~ZoneImpl() {
if ( mProfileZoneManager != NULL )
mProfileZoneManager->removeProfileZone( *this );
mProfileZoneManager = NULL;
TZoneEventBufferType::removeClient( *this );
}
void doAddName( const char* inName, uint16_t inEventId, bool inCompileTimeEnabled )
{
TLockType theLocker( mMutex );
mEvtIdToNameMap.insert( inEventId, inName );
uint32_t idx = static_cast<uint32_t>( mEventNames.size() );
mNameToEvtIndexMapRW.insert( inName, idx );
mEventNames.pushBack( PxProfileEventName( inName, PxProfileEventId( inEventId, inCompileTimeEnabled ) ) );
}
virtual void flushEventIdNameMap()
{
// copy the RW map into R map
if (mNameToEvtIndexMapRW.size())
{
for (TNameToEvtIndexMap::Iterator iter = mNameToEvtIndexMapRW.getIterator(); !iter.done(); ++iter)
{
mNameToEvtIndexMapR.insert(iter->first, iter->second);
}
mNameToEvtIndexMapRW.clear();
}
}
virtual uint16_t getEventIdForName( const char* inName )
{
return getEventIdsForNames( &inName, 1 );
}
virtual uint16_t getEventIdsForNames( const char** inNames, uint32_t inLen )
{
if ( inLen == 0 )
return 0;
// search the read-only map first
const TNameToEvtIndexMap::Entry* theEntry( mNameToEvtIndexMapR.find( inNames[0] ) );
if ( theEntry )
return mEventNames[theEntry->second].eventId;
TLockType theLocker(mMutex);
const TNameToEvtIndexMap::Entry* theReEntry(mNameToEvtIndexMapRW.find(inNames[0]));
if (theReEntry)
return mEventNames[theReEntry->second].eventId;
//Else git R dun.
uint16_t nameSize = static_cast<uint16_t>( mEventNames.size() );
//We don't allow 0 as an event id.
uint16_t eventId = nameSize;
//Find a contiguous set of unique event ids
bool foundAnEventId = false;
do
{
foundAnEventId = false;
++eventId;
for ( uint16_t idx = 0; idx < inLen && foundAnEventId == false; ++idx )
foundAnEventId = mEvtIdToNameMap.find( uint16_t(eventId + idx) ) != NULL;
}
while( foundAnEventId );
uint32_t clientCount = mZoneClients.size();
for ( uint16_t nameIdx = 0; nameIdx < inLen; ++nameIdx )
{
uint16_t newId = uint16_t(eventId + nameIdx);
doAddName( inNames[nameIdx], newId, true );
for( uint32_t clientIdx =0; clientIdx < clientCount; ++clientIdx )
mZoneClients[clientIdx]->handleEventAdded( PxProfileEventName( inNames[nameIdx], PxProfileEventId( newId ) ) );
}
return eventId;
}
virtual void setProfileZoneManager(PxProfileZoneManager* inMgr)
{
mProfileZoneManager = inMgr;
}
virtual PxProfileZoneManager* getProfileZoneManager()
{
return mProfileZoneManager;
}
const char* getName() { return mName; }
PxProfileEventBufferClient* getEventBufferClient() { return this; }
//SDK implementation
void addClient( PxProfileZoneClient& inClient )
{
TLockType lock( mMutex );
mZoneClients.pushBack( &inClient );
mEventsActive = true;
}
void removeClient( PxProfileZoneClient& inClient )
{
TLockType lock( mMutex );
for ( uint32_t idx =0; idx < mZoneClients.size(); ++idx )
{
if (mZoneClients[idx] == &inClient )
{
inClient.handleClientRemoved();
mZoneClients.replaceWithLast( idx );
break;
}
}
mEventsActive = mZoneClients.size() != 0;
}
virtual bool hasClients() const
{
return mEventsActive;
}
virtual PxProfileNames getProfileNames() const
{
TLockType theLocker( mMutex );
const PxProfileEventName* theNames = mEventNames.begin();
uint32_t theEventCount = uint32_t(mEventNames.size());
return PxProfileNames( theEventCount, theNames );
}
virtual void release()
{
PX_PROFILE_DELETE( mWrapper.getAllocator(), this );
}
//Implementation chaining the buffer flush to our clients
virtual void handleBufferFlush( const uint8_t* inData, uint32_t inLength )
{
TLockType theLocker( mMutex );
uint32_t clientCount = mZoneClients.size();
for( uint32_t idx =0; idx < clientCount; ++idx )
mZoneClients[idx]->handleBufferFlush( inData, inLength );
}
//Happens if something removes all the clients from the manager.
virtual void handleClientRemoved() {}
//Send a profile event, optionally with a context. Events are sorted by thread
//and context in the client side.
virtual void startEvent( uint16_t inId, uint64_t contextId)
{
if( mEventsActive )
{
TZoneEventBufferType::startEvent( inId, contextId );
}
}
virtual void stopEvent( uint16_t inId, uint64_t contextId)
{
if( mEventsActive )
{
TZoneEventBufferType::stopEvent( inId, contextId );
}
}
virtual void startEvent( uint16_t inId, uint64_t contextId, uint32_t threadId)
{
if( mEventsActive )
{
TZoneEventBufferType::startEvent( inId, contextId, threadId );
}
}
virtual void stopEvent( uint16_t inId, uint64_t contextId, uint32_t threadId )
{
if( mEventsActive )
{
TZoneEventBufferType::stopEvent( inId, contextId, threadId );
}
}
virtual void atEvent(uint16_t inId, uint64_t contextId, uint32_t threadId, uint64_t start, uint64_t stop)
{
if (mEventsActive)
{
TZoneEventBufferType::startEvent(inId, threadId, contextId, 0, 0, start);
TZoneEventBufferType::stopEvent(inId, threadId, contextId, 0, 0, stop);
}
}
/**
* Set an specific events value. This is different than the profiling value
* for the event; it is a value recorded and kept around without a timestamp associated
* with it. This value is displayed when the event itself is processed.
*/
virtual void eventValue( uint16_t inId, uint64_t contextId, int64_t inValue )
{
if( mEventsActive )
{
TZoneEventBufferType::eventValue( inId, contextId, inValue );
}
}
virtual void flushProfileEvents()
{
TZoneEventBufferType::flushProfileEvents();
}
};
}}
#endif
| 10,615 | C | 32.701587 | 156 | 0.723033 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileZoneManager.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PROFILE_ZONE_MANAGER_H
#define PX_PROFILE_ZONE_MANAGER_H
#include "PxProfileEventSender.h"
#include "PxProfileEventNames.h"
namespace physx {
class PxAllocatorCallback;
namespace profile {
class PxProfileZone;
class PxProfileNameProvider;
/**
\brief Profile zone handler for zone add/remove notification.
*/
class PxProfileZoneHandler
{
protected:
virtual ~PxProfileZoneHandler(){}
public:
/**
\brief On zone added notification
\note Not a threadsafe call; handlers are expected to be able to handle
this from any thread.
\param inSDK Added zone.
*/
virtual void onZoneAdded( PxProfileZone& inSDK ) = 0;
/**
\brief On zone removed notification
\note Not a threadsafe call; handlers are expected to be able to handle
this from any thread.
\param inSDK removed zone.
*/
virtual void onZoneRemoved( PxProfileZone& inSDK ) = 0;
};
/**
\brief The profiling system was setup in the expectation that there would be several
systems that each had its own island of profile information. PhysX, client code,
and APEX would be the first examples of these. Each one of these islands is represented
by a profile zone.
The Manager is a singleton-like object where all these different systems can be registered
so that clients of the profiling system can have one point to capture *all* profiling events.
Flushing the manager implies that you want to loop through all the profile zones and flush
each one.
@see PxProfileEventFlusher
*/
class PxProfileZoneManager
: public PxProfileEventFlusher //Tell all SDK's to flush their queue of profile events.
{
protected:
virtual ~PxProfileZoneManager(){}
public:
/**
\brief Add new profile zone for the manager.
\note Threadsafe call, can be done from any thread. Handlers that are already connected
will get a new callback on the current thread.
\param inSDK Profile zone to add.
*/
virtual void addProfileZone( PxProfileZone& inSDK ) = 0;
/**
\brief Removes profile zone from the manager.
\note Threadsafe call, can be done from any thread. Handlers that are already connected
will get a new callback on the current thread.
\param inSDK Profile zone to remove.
*/
virtual void removeProfileZone( PxProfileZone& inSDK ) = 0;
/**
\brief Add profile zone handler callback for the profile zone notifications.
\note Threadsafe call. The new handler will immediately be notified about all
known SDKs.
\param inHandler Profile zone handler to add.
*/
virtual void addProfileZoneHandler( PxProfileZoneHandler& inHandler ) = 0;
/**
\brief Removes profile zone handler callback for the profile zone notifications.
\note Threadsafe call. The new handler will immediately be notified about all
known SDKs.
\param inHandler Profile zone handler to remove.
*/
virtual void removeProfileZoneHandler( PxProfileZoneHandler& inHandler ) = 0;
/**
\brief Create a new profile zone. This means you don't need access to a PxFoundation to
create your profile zone object, and your object is automatically registered with
the profile zone manager.
You still need to release your object when you are finished with it.
\param inSDKName Name of the SDK object.
\param inNames Option set of event id to name mappings.
\param inEventBufferByteSize rough maximum size of the event buffer. May exceed this size
by sizeof one event. When full an immediate call to all listeners is made.
*/
virtual PxProfileZone& createProfileZone( const char* inSDKName, PxProfileNames inNames = PxProfileNames(), uint32_t inEventBufferByteSize = 0x4000 /*16k*/ ) = 0;
/**
\brief Releases the profile manager instance.
*/
virtual void release() = 0;
/**
\brief Create the profile zone manager.
\param inAllocatorCallback Allocator callback.
*/
static PxProfileZoneManager& createProfileZoneManager(PxAllocatorCallback* inAllocatorCallback );
};
} }
#endif
| 5,530 | C | 34.455128 | 164 | 0.752622 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileMemoryBuffer.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_MEMORY_BUFFER_H
#define PX_PROFILE_MEMORY_BUFFER_H
#include "foundation/PxAllocator.h"
#include "foundation/PxMemory.h"
namespace physx { namespace profile {
template<typename TAllocator = typename PxAllocatorTraits<uint8_t>::Type >
class MemoryBuffer : public TAllocator
{
uint8_t* mBegin;
uint8_t* mEnd;
uint8_t* mCapacityEnd;
public:
MemoryBuffer( const TAllocator& inAlloc = TAllocator() ) : TAllocator( inAlloc ), mBegin( 0 ), mEnd( 0 ), mCapacityEnd( 0 ) {}
~MemoryBuffer()
{
if ( mBegin ) TAllocator::deallocate( mBegin );
}
uint32_t size() const { return static_cast<uint32_t>( mEnd - mBegin ); }
uint32_t capacity() const { return static_cast<uint32_t>( mCapacityEnd - mBegin ); }
uint8_t* begin() { return mBegin; }
uint8_t* end() { return mEnd; }
void setEnd(uint8_t* nEnd) { mEnd = nEnd; }
const uint8_t* begin() const { return mBegin; }
const uint8_t* end() const { return mEnd; }
void clear() { mEnd = mBegin; }
uint32_t write( uint8_t inValue )
{
growBuf( 1 );
*mEnd = inValue;
++mEnd;
return 1;
}
template<typename TDataType>
uint32_t write( const TDataType& inValue )
{
uint32_t writtenSize = sizeof(TDataType);
growBuf(writtenSize);
const uint8_t* __restrict readPtr = reinterpret_cast< const uint8_t* >( &inValue );
uint8_t* __restrict writePtr = mEnd;
for ( uint32_t idx = 0; idx < sizeof(TDataType); ++idx ) writePtr[idx] = readPtr[idx];
mEnd += writtenSize;
return writtenSize;
}
template<typename TDataType>
uint32_t write( const TDataType* inValue, uint32_t inLength )
{
if ( inValue && inLength )
{
uint32_t writeSize = inLength * sizeof( TDataType );
growBuf( writeSize );
PxMemCopy( mBegin + size(), inValue, writeSize );
mEnd += writeSize;
return writeSize;
}
return 0;
}
// used by atomic write. Store the data and write the end afterwards
// we dont check the buffer size, it should not resize on the fly
template<typename TDataType>
uint32_t write(const TDataType* inValue, uint32_t inLength, int32_t index)
{
if (inValue && inLength)
{
uint32_t writeSize = inLength * sizeof(TDataType);
PX_ASSERT(mBegin + index + writeSize < mCapacityEnd);
PxMemCopy(mBegin + index, inValue, writeSize);
return writeSize;
}
return 0;
}
void growBuf( uint32_t inAmount )
{
uint32_t newSize = size() + inAmount;
reserve( newSize );
}
void resize( uint32_t inAmount )
{
reserve( inAmount );
mEnd = mBegin + inAmount;
}
void reserve( uint32_t newSize )
{
uint32_t currentSize = size();
if ( newSize >= capacity() )
{
const uint32_t allocSize = mBegin ? newSize * 2 : newSize;
uint8_t* newData = static_cast<uint8_t*>(TAllocator::allocate(allocSize, PX_FL));
memset(newData, 0xf,allocSize);
if ( mBegin )
{
PxMemCopy( newData, mBegin, currentSize );
TAllocator::deallocate( mBegin );
}
mBegin = newData;
mEnd = mBegin + currentSize;
mCapacityEnd = mBegin + allocSize;
}
}
};
class TempMemoryBuffer
{
uint8_t* mBegin;
uint8_t* mEnd;
uint8_t* mCapacityEnd;
public:
TempMemoryBuffer(uint8_t* data, int32_t size) : mBegin(data), mEnd(data), mCapacityEnd(data + size) {}
~TempMemoryBuffer()
{
}
uint32_t size() const { return static_cast<uint32_t>(mEnd - mBegin); }
uint32_t capacity() const { return static_cast<uint32_t>(mCapacityEnd - mBegin); }
const uint8_t* begin() { return mBegin; }
uint8_t* end() { return mEnd; }
const uint8_t* begin() const { return mBegin; }
const uint8_t* end() const { return mEnd; }
uint32_t write(uint8_t inValue)
{
*mEnd = inValue;
++mEnd;
return 1;
}
template<typename TDataType>
uint32_t write(const TDataType& inValue)
{
uint32_t writtenSize = sizeof(TDataType);
const uint8_t* __restrict readPtr = reinterpret_cast<const uint8_t*>(&inValue);
uint8_t* __restrict writePtr = mEnd;
for (uint32_t idx = 0; idx < sizeof(TDataType); ++idx) writePtr[idx] = readPtr[idx];
mEnd += writtenSize;
return writtenSize;
}
template<typename TDataType>
uint32_t write(const TDataType* inValue, uint32_t inLength)
{
if (inValue && inLength)
{
uint32_t writeSize = inLength * sizeof(TDataType);
PxMemCopy(mBegin + size(), inValue, writeSize);
mEnd += writeSize;
return writeSize;
}
return 0;
}
};
}}
#endif
| 6,145 | C | 31.17801 | 128 | 0.683645 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectRegistrar.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxPvdObjectRegistrar.h"
namespace physx
{
namespace pvdsdk
{
bool ObjectRegistrar::addItem(const void* inItem)
{
physx::PxMutex::ScopedLock lock(mRefCountMapLock);
if(mRefCountMap.find(inItem))
{
uint32_t& counter = mRefCountMap[inItem];
counter++;
return false;
}
else
{
mRefCountMap.insert(inItem, 1);
return true;
}
}
bool ObjectRegistrar::decItem(const void* inItem)
{
physx::PxMutex::ScopedLock lock(mRefCountMapLock);
const physx::PxHashMap<const void*, uint32_t>::Entry* entry = mRefCountMap.find(inItem);
if(entry)
{
uint32_t& retval(const_cast<uint32_t&>(entry->second));
if(retval)
--retval;
uint32_t theValue = retval;
if(theValue == 0)
{
mRefCountMap.erase(inItem);
return true;
}
}
return false;
}
void ObjectRegistrar::clear()
{
physx::PxMutex::ScopedLock lock(mRefCountMapLock);
mRefCountMap.clear();
}
} // pvdsdk
} // physx
| 2,599 | C++ | 31.5 | 89 | 0.744517 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdProfileZone.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_PROFILE_ZONE_H
#define PX_PVD_PROFILE_ZONE_H
#include "foundation/PxPreprocessor.h"
#include "PxProfileEventBufferClientManager.h"
#include "PxProfileEventNames.h"
#include "PxProfileEventSender.h"
namespace physx {
class PxAllocatorCallback;
namespace profile {
class PxProfileZoneManager;
/**
\brief The profiling system was setup in the expectation that there would be several
systems that each had its own island of profile information. PhysX, client code,
and APEX would be the first examples of these. Each one of these islands is represented
by a profile zone.
A profile zone combines a name, a place where all the events coming from its interface
can flushed, and a mapping from event number to full event name.
It also provides a top level filtering service where profile events
can be filtered by event id.
The profile zone implements a system where if there is no one
listening to events it doesn't provide a mechanism to send them. In this way
the event system is short circuited when there aren't any clients.
All functions on this interface should be considered threadsafe.
@see PxProfileZoneClientManager, PxProfileNameProvider, PxProfileEventSender, PxProfileEventFlusher
*/
class PxProfileZone : public PxProfileZoneClientManager
, public PxProfileNameProvider
, public PxProfileEventSender
, public PxProfileEventFlusher
{
protected:
virtual ~PxProfileZone(){}
public:
/**
\brief Get profile zone name.
\return Zone name.
*/
virtual const char* getName() = 0;
/**
\brief Release the profile zone.
*/
virtual void release() = 0;
/**
\brief Set profile zone manager for the zone.
\param inMgr Profile zone manager.
*/
virtual void setProfileZoneManager(PxProfileZoneManager* inMgr) = 0;
/**
\brief Get profile zone manager for the zone.
\return Profile zone manager.
*/
virtual PxProfileZoneManager* getProfileZoneManager() = 0;
/**
\brief Get or create a new event id for a given name.
If you pass in a previously defined event name (including one returned)
from the name provider) you will just get the same event id back.
\param inName Profile event name.
*/
virtual uint16_t getEventIdForName( const char* inName ) = 0;
/**
\brief Specifies that it is a safe point to flush read-write name map into
read-only map. Make sure getEventIdForName is not called from a different thread.
*/
virtual void flushEventIdNameMap() = 0;
/**
\brief Reserve a contiguous set of profile event ids for a set of names.
This function does not do any meaningful error checking other than to ensure
that if it does generate new ids they are contiguous. If the first name is already
registered, that is the ID that will be returned regardless of what other
names are registered. Thus either use this function alone (without the above
function) or don't use it.
If you register "one","two","three" and the function returns an id of 4, then
"one" is mapped to 4, "two" is mapped to 5, and "three" is mapped to 6.
\param inNames set of names to register.
\param inLen Length of the name list.
\return The first id associated with the first name. The rest of the names
will be associated with monotonically incrementing uint16_t values from the first
id.
*/
virtual uint16_t getEventIdsForNames( const char** inNames, uint32_t inLen ) = 0;
/**
\brief Create a new profile zone.
\param inAllocator memory allocation is controlled through the foundation if one is passed in.
\param inSDKName Name of the profile zone; useful for clients to understand where events came from.
\param inNames Mapping from event id -> event name.
\param inEventBufferByteSize Size of the canonical event buffer. This does not need to be a large number
as profile events are fairly small individually.
\return a profile zone implementation.
*/
static PxProfileZone& createProfileZone(PxAllocatorCallback* inAllocator, const char* inSDKName, PxProfileNames inNames = PxProfileNames(), uint32_t inEventBufferByteSize = 0x10000 /*64k*/);
};
} }
#endif
| 5,725 | C | 39.041958 | 192 | 0.751092 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileMemoryEvents.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_MEMORY_EVENTS_H
#define PX_PROFILE_MEMORY_EVENTS_H
#include "PxProfileEvents.h"
//Memory events define their own event stream
namespace physx { namespace profile {
struct MemoryEventTypes
{
enum Enum
{
Unknown = 0,
StringTableEvent, //introduce a new mapping of const char* -> integer
AllocationEvent,
DeallocationEvent,
FullAllocationEvent
};
};
template<unsigned numBits, typename TDataType>
inline unsigned char convertToNBits( TDataType inType )
{
uint8_t conversion = static_cast<uint8_t>( inType );
PX_ASSERT( conversion < (1 << numBits) );
return conversion;
}
template<typename TDataType>
inline unsigned char convertToTwoBits( TDataType inType )
{
return convertToNBits<2>( inType );
}
template<typename TDataType>
inline unsigned char convertToFourBits( TDataType inType )
{
return convertToNBits<4>( inType );
}
inline EventStreamCompressionFlags::Enum fromNumber( uint8_t inNum ) { return static_cast<EventStreamCompressionFlags::Enum>( inNum ); }
template<unsigned lhs, unsigned rhs>
inline void compileCheckSize()
{
PX_COMPILE_TIME_ASSERT( lhs <= rhs );
}
//Used for predictable bit fields.
template<typename TDataType
, uint8_t TNumBits
, uint8_t TOffset
, typename TInputType>
struct BitMaskSetter
{
//Create a mask that masks out the orginal value shift into place
static TDataType createOffsetMask() { return TDataType(createMask() << TOffset); }
//Create a mask of TNumBits number of tis
static TDataType createMask() { return static_cast<TDataType>((1 << TNumBits) - 1); }
void setValue( TDataType& inCurrent, TInputType inData )
{
PX_ASSERT( inData < ( 1 << TNumBits ) );
//Create a mask to remove the current value.
TDataType theMask = TDataType(~(createOffsetMask()));
//Clear out current value.
inCurrent = TDataType(inCurrent & theMask);
//Create the new value.
TDataType theAddition = static_cast<TDataType>( inData << TOffset );
//or it into the existing value.
inCurrent = TDataType(inCurrent | theAddition);
}
TInputType getValue( TDataType inCurrent )
{
return static_cast<TInputType>( ( inCurrent >> TOffset ) & createMask() );
}
};
struct MemoryEventHeader
{
uint16_t mValue;
typedef BitMaskSetter<uint16_t, 4, 0, uint8_t> TTypeBitmask;
typedef BitMaskSetter<uint16_t, 2, 4, uint8_t> TAddrCompressBitmask;
typedef BitMaskSetter<uint16_t, 2, 6, uint8_t> TTypeCompressBitmask;
typedef BitMaskSetter<uint16_t, 2, 8, uint8_t> TFnameCompressBitmask;
typedef BitMaskSetter<uint16_t, 2, 10, uint8_t> TSizeCompressBitmask;
typedef BitMaskSetter<uint16_t, 2, 12, uint8_t> TLineCompressBitmask;
//That leaves size as the only thing not compressed usually.
MemoryEventHeader( MemoryEventTypes::Enum inType = MemoryEventTypes::Unknown )
: mValue( 0 )
{
uint8_t defaultCompression( convertToTwoBits( EventStreamCompressionFlags::U64 ) );
TTypeBitmask().setValue( mValue, convertToFourBits( inType ) );
TAddrCompressBitmask().setValue( mValue, defaultCompression );
TTypeCompressBitmask().setValue( mValue, defaultCompression );
TFnameCompressBitmask().setValue( mValue, defaultCompression );
TSizeCompressBitmask().setValue( mValue, defaultCompression );
TLineCompressBitmask().setValue( mValue, defaultCompression );
}
MemoryEventTypes::Enum getType() const { return static_cast<MemoryEventTypes::Enum>( TTypeBitmask().getValue( mValue ) ); }
#define DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR( name ) \
void set##name( EventStreamCompressionFlags::Enum inEnum ) { T##name##Bitmask().setValue( mValue, convertToTwoBits( inEnum ) ); } \
EventStreamCompressionFlags::Enum get##name() const { return fromNumber( T##name##Bitmask().getValue( mValue ) ); }
DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR( AddrCompress )
DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR( TypeCompress )
DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR( FnameCompress )
DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR( SizeCompress )
DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR( LineCompress )
#undef DEFINE_MEMORY_HEADER_COMPRESSION_ACCESSOR
bool operator==( const MemoryEventHeader& inOther ) const
{
return mValue == inOther.mValue;
}
template<typename TStreamType>
void streamify( TStreamType& inStream )
{
inStream.streamify( "Header", mValue );
}
};
//Declaration of type level getMemoryEventType function that maps enumeration event types to datatypes
template<typename TDataType>
inline MemoryEventTypes::Enum getMemoryEventType() { PX_ASSERT( false ); return MemoryEventTypes::Unknown; }
inline bool safeStrEq( const char* lhs, const char* rhs )
{
if ( lhs == rhs )
return true;
//If they aren't equal, and one of them is null,
//then they can't be equal.
//This is assuming that the null char* is not equal to
//the empty "" char*.
if ( !lhs || !rhs )
return false;
return ::strcmp( lhs, rhs ) == 0;
}
struct StringTableEvent
{
const char* mString;
uint32_t mHandle;
void init( const char* inStr = "", uint32_t inHdl = 0 )
{
mString = inStr;
mHandle = inHdl;
}
void init( const StringTableEvent& inData )
{
mString = inData.mString;
mHandle = inData.mHandle;
}
bool operator==( const StringTableEvent& inOther ) const
{
return mHandle == inOther.mHandle
&& safeStrEq( mString, inOther.mString );
}
void setup( MemoryEventHeader& ) const {}
template<typename TStreamType>
void streamify( TStreamType& inStream, const MemoryEventHeader& )
{
inStream.streamify( "String", mString );
inStream.streamify( "Handle", mHandle );
}
};
template<> inline MemoryEventTypes::Enum getMemoryEventType<StringTableEvent>() { return MemoryEventTypes::StringTableEvent; }
struct MemoryEventData
{
uint64_t mAddress;
void init( uint64_t addr )
{
mAddress = addr;
}
void init( const MemoryEventData& inData)
{
mAddress = inData.mAddress;
}
bool operator==( const MemoryEventData& inOther ) const
{
return mAddress == inOther.mAddress;
}
void setup( MemoryEventHeader& inHeader ) const
{
inHeader.setAddrCompress( findCompressionValue( mAddress ) );
}
template<typename TStreamType>
void streamify( TStreamType& inStream, const MemoryEventHeader& inHeader )
{
inStream.streamify( "Address", mAddress, inHeader.getAddrCompress() );
}
};
struct AllocationEvent : public MemoryEventData
{
uint32_t mSize;
uint32_t mType;
uint32_t mFile;
uint32_t mLine;
void init( size_t size = 0, uint32_t type = 0, uint32_t file = 0, uint32_t line = 0, uint64_t addr = 0 )
{
MemoryEventData::init( addr );
mSize = static_cast<uint32_t>( size );
mType = type;
mFile = file;
mLine = line;
}
void init( const AllocationEvent& inData )
{
MemoryEventData::init( inData );
mSize = inData.mSize;
mType = inData.mType;
mFile = inData.mFile;
mLine = inData.mLine;
}
bool operator==( const AllocationEvent& inOther ) const
{
return MemoryEventData::operator==( inOther )
&& mSize == inOther.mSize
&& mType == inOther.mType
&& mFile == inOther.mFile
&& mLine == inOther.mLine;
}
void setup( MemoryEventHeader& inHeader ) const
{
inHeader.setTypeCompress( findCompressionValue( mType ) );
inHeader.setFnameCompress( findCompressionValue( mFile ) );
inHeader.setSizeCompress( findCompressionValue( mSize ) );
inHeader.setLineCompress( findCompressionValue( mLine ) );
MemoryEventData::setup( inHeader );
}
template<typename TStreamType>
void streamify( TStreamType& inStream, const MemoryEventHeader& inHeader )
{
inStream.streamify( "Size", mSize, inHeader.getSizeCompress() );
inStream.streamify( "Type", mType, inHeader.getTypeCompress() );
inStream.streamify( "File", mFile, inHeader.getFnameCompress() );
inStream.streamify( "Line", mLine, inHeader.getLineCompress() );
MemoryEventData::streamify( inStream, inHeader );
}
};
template<> inline MemoryEventTypes::Enum getMemoryEventType<AllocationEvent>() { return MemoryEventTypes::AllocationEvent; }
struct FullAllocationEvent : public MemoryEventData
{
size_t mSize;
const char* mType;
const char* mFile;
uint32_t mLine;
void init( size_t size, const char* type, const char* file, uint32_t line, uint64_t addr )
{
MemoryEventData::init( addr );
mSize = size;
mType = type;
mFile = file;
mLine = line;
}
void init( const FullAllocationEvent& inData )
{
MemoryEventData::init( inData );
mSize = inData.mSize;
mType = inData.mType;
mFile = inData.mFile;
mLine = inData.mLine;
}
bool operator==( const FullAllocationEvent& inOther ) const
{
return MemoryEventData::operator==( inOther )
&& mSize == inOther.mSize
&& safeStrEq( mType, inOther.mType )
&& safeStrEq( mFile, inOther.mFile )
&& mLine == inOther.mLine;
}
void setup( MemoryEventHeader& ) const {}
};
template<> inline MemoryEventTypes::Enum getMemoryEventType<FullAllocationEvent>() { return MemoryEventTypes::FullAllocationEvent; }
struct DeallocationEvent : public MemoryEventData
{
void init( uint64_t addr = 0 ) { MemoryEventData::init( addr ); }
void init( const DeallocationEvent& inData ) { MemoryEventData::init( inData ); }
};
template<> inline MemoryEventTypes::Enum getMemoryEventType<DeallocationEvent>() { return MemoryEventTypes::DeallocationEvent; }
class MemoryEvent
{
public:
typedef PX_PROFILE_UNION_5(StringTableEvent, AllocationEvent, DeallocationEvent, FullAllocationEvent, uint8_t) EventData;
private:
MemoryEventHeader mHeader;
EventData mData;
public:
MemoryEvent() {}
MemoryEvent( MemoryEventHeader inHeader, const EventData& inData = EventData() )
: mHeader( inHeader )
, mData( inData )
{
}
template<typename TDataType>
MemoryEvent( const TDataType& inType )
: mHeader( getMemoryEventType<TDataType>() )
, mData( inType )
{
//set the appropriate compression bits.
inType.setup( mHeader );
}
const MemoryEventHeader& getHeader() const { return mHeader; }
const EventData& getData() const { return mData; }
template<typename TDataType>
const TDataType& getValue() const { PX_ASSERT( mHeader.getType() == getMemoryEventType<TDataType>() ); return mData.toType<TDataType>(); }
template<typename TDataType>
TDataType& getValue() { PX_ASSERT( mHeader.getType() == getMemoryEventType<TDataType>() ); return mData.toType<TDataType>(); }
template<typename TRetVal, typename TOperator>
inline TRetVal visit( TOperator inOp ) const;
bool operator==( const MemoryEvent& inOther ) const
{
if ( !(mHeader == inOther.mHeader ) ) return false;
if ( mHeader.getType() )
return inOther.visit<bool>( EventDataEqualOperator<EventData>( mData ) );
return true;
}
};
template<typename TRetVal, typename TOperator>
inline TRetVal visit( MemoryEventTypes::Enum inEventType, const MemoryEvent::EventData& inData, TOperator inOperator )
{
switch( inEventType )
{
case MemoryEventTypes::StringTableEvent: return inOperator( inData.toType( Type2Type<StringTableEvent>() ) );
case MemoryEventTypes::AllocationEvent: return inOperator( inData.toType( Type2Type<AllocationEvent>() ) );
case MemoryEventTypes::DeallocationEvent: return inOperator( inData.toType( Type2Type<DeallocationEvent>() ) );
case MemoryEventTypes::FullAllocationEvent: return inOperator( inData.toType( Type2Type<FullAllocationEvent>() ) );
case MemoryEventTypes::Unknown: return inOperator( static_cast<uint8_t>( inEventType ) );
}
return TRetVal();
}
template<typename TRetVal, typename TOperator>
inline TRetVal MemoryEvent::visit( TOperator inOp ) const
{
return physx::profile::visit<TRetVal>( mHeader.getType(), mData, inOp );
}
}}
#endif
| 13,543 | C | 31.953771 | 140 | 0.72148 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdFoundation.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_FOUNDATION_H
#define PX_PVD_FOUNDATION_H
#include "foundation/PxVec3.h"
#include "foundation/PxTransform.h"
#include "foundation/PxBounds3.h"
#include "foundation/PxHashSet.h"
#include "foundation/PxHashMap.h"
#include "foundation/PxArray.h"
#include "foundation/PxString.h"
#include "foundation/PxPool.h"
#include "PxPvdObjectModelBaseTypes.h"
namespace physx
{
namespace pvdsdk
{
extern PxAllocatorCallback* gPvdAllocatorCallback;
class ForwardingAllocator : public PxAllocatorCallback
{
void* allocate(size_t size, const char* typeName, const char* filename, int line)
{
return PxGetBroadcastAllocator()->allocate(size, typeName, filename, line);
}
void deallocate(void* ptr)
{
PxGetBroadcastAllocator()->deallocate(ptr);
}
};
class RawMemoryBuffer
{
uint8_t* mBegin;
uint8_t* mEnd;
uint8_t* mCapacityEnd;
const char* mBufDataName;
public:
RawMemoryBuffer(const char* name) : mBegin(0), mEnd(0), mCapacityEnd(0),mBufDataName(name)
{
PX_UNUSED(mBufDataName);
}
~RawMemoryBuffer()
{
PX_FREE(mBegin);
}
uint32_t size() const
{
return static_cast<uint32_t>(mEnd - mBegin);
}
uint32_t capacity() const
{
return static_cast<uint32_t>(mCapacityEnd - mBegin);
}
uint8_t* begin()
{
return mBegin;
}
uint8_t* end()
{
return mEnd;
}
const uint8_t* begin() const
{
return mBegin;
}
const uint8_t* end() const
{
return mEnd;
}
void clear()
{
mEnd = mBegin;
}
const char* cStr()
{
if(mEnd && (*mEnd != 0))
write(0);
return reinterpret_cast<const char*>(mBegin);
}
uint32_t write(uint8_t inValue)
{
*growBuf(1) = inValue;
return 1;
}
template <typename TDataType>
uint32_t write(const TDataType& inValue)
{
const uint8_t* __restrict readPtr = reinterpret_cast<const uint8_t*>(&inValue);
uint8_t* __restrict writePtr = growBuf(sizeof(TDataType));
for(uint32_t idx = 0; idx < sizeof(TDataType); ++idx)
writePtr[idx] = readPtr[idx];
return sizeof(TDataType);
}
template <typename TDataType>
uint32_t write(const TDataType* inValue, uint32_t inLength)
{
uint32_t writeSize = inLength * sizeof(TDataType);
if(inValue && inLength)
{
physx::intrinsics::memCopy(growBuf(writeSize), inValue, writeSize);
}
if(inLength && !inValue)
{
PX_ASSERT(false);
// You can't not write something, because that will cause
// the receiving end to crash.
for(uint32_t idx = 0; idx < writeSize; ++idx)
write(0);
}
return writeSize;
}
uint8_t* growBuf(uint32_t inAmount)
{
uint32_t offset = size();
uint32_t newSize = offset + inAmount;
reserve(newSize);
mEnd += inAmount;
return mBegin + offset;
}
void writeZeros(uint32_t inAmount)
{
uint32_t offset = size();
growBuf(inAmount);
physx::intrinsics::memZero(begin() + offset, inAmount);
}
void reserve(uint32_t newSize)
{
uint32_t currentSize = size();
if(newSize && newSize >= capacity())
{
uint32_t newDataSize = newSize > 4096 ? newSize + (newSize >> 2) : newSize*2;
uint8_t* newData = static_cast<uint8_t*>(PX_ALLOC(newDataSize, mBufDataName));
if(mBegin)
{
physx::intrinsics::memCopy(newData, mBegin, currentSize);
PX_FREE(mBegin);
}
mBegin = newData;
mEnd = mBegin + currentSize;
mCapacityEnd = mBegin + newDataSize;
}
}
};
struct ForwardingMemoryBuffer : public RawMemoryBuffer
{
ForwardingMemoryBuffer(const char* bufDataName) : RawMemoryBuffer(bufDataName)
{
}
ForwardingMemoryBuffer& operator<<(const char* inString)
{
if(inString && *inString)
{
uint32_t len = static_cast<uint32_t>(strlen(inString));
write(inString, len);
}
return *this;
}
template <typename TDataType>
inline ForwardingMemoryBuffer& toStream(const char* inFormat, const TDataType inData)
{
char buffer[128] = { 0 };
Pxsnprintf(buffer, 128, inFormat, inData);
*this << buffer;
return *this;
}
inline ForwardingMemoryBuffer& operator<<(bool inData)
{
*this << (inData ? "true" : "false");
return *this;
}
inline ForwardingMemoryBuffer& operator<<(int32_t inData)
{
return toStream("%d", inData);
}
inline ForwardingMemoryBuffer& operator<<(uint16_t inData)
{
return toStream("%u", uint32_t(inData));
}
inline ForwardingMemoryBuffer& operator<<(uint8_t inData)
{
return toStream("%u", uint32_t(inData));
}
inline ForwardingMemoryBuffer& operator<<(char inData)
{
return toStream("%c", inData);
}
inline ForwardingMemoryBuffer& operator<<(uint32_t inData)
{
return toStream("%u", inData);
}
inline ForwardingMemoryBuffer& operator<<(uint64_t inData)
{
return toStream("%I64u", inData);
}
inline ForwardingMemoryBuffer& operator<<(int64_t inData)
{
return toStream("%I64d", inData);
}
inline ForwardingMemoryBuffer& operator<<(const void* inData)
{
return *this << static_cast<uint64_t>(reinterpret_cast<size_t>(inData));
}
inline ForwardingMemoryBuffer& operator<<(float inData)
{
return toStream("%g", double(inData));
}
inline ForwardingMemoryBuffer& operator<<(double inData)
{
return toStream("%g", inData);
}
inline ForwardingMemoryBuffer& operator<<(const PxVec3& inData)
{
*this << inData[0];
*this << " ";
*this << inData[1];
*this << " ";
*this << inData[2];
return *this;
}
inline ForwardingMemoryBuffer& operator<<(const PxQuat& inData)
{
*this << inData.x;
*this << " ";
*this << inData.y;
*this << " ";
*this << inData.z;
*this << " ";
*this << inData.w;
return *this;
}
inline ForwardingMemoryBuffer& operator<<(const PxTransform& inData)
{
*this << inData.q;
*this << " ";
*this << inData.p;
return *this;
}
inline ForwardingMemoryBuffer& operator<<(const PxBounds3& inData)
{
*this << inData.minimum;
*this << " ";
*this << inData.maximum;
return *this;
}
};
template <typename TDataType>
inline void* PvdAllocate(const char* typeName, const char* file, int line)
{
PX_ASSERT(gPvdAllocatorCallback);
return gPvdAllocatorCallback->allocate(sizeof(TDataType), typeName, file, line);
}
template <typename TDataType>
inline void PvdDeleteAndDeallocate(TDataType* inDType)
{
PX_ASSERT(gPvdAllocatorCallback);
if(inDType)
{
inDType->~TDataType();
gPvdAllocatorCallback->deallocate(inDType);
}
}
}
}
#define PVD_NEW(dtype) new (PvdAllocate<dtype>(#dtype, PX_FL)) dtype
#define PVD_DELETE(obj) PvdDeleteAndDeallocate(obj);
//#define PVD_NEW(dtype) PX_NEW(dtype)
//#define PVD_DELETE(obj) PX_DELETE(obj)
#define PVD_FOREACH(varname, stop) for(uint32_t varname = 0; varname < stop; ++varname)
#define PVD_POINTER_TO_U64(ptr) static_cast<uint64_t>(reinterpret_cast<size_t>(ptr))
#endif
| 8,132 | C | 24.737342 | 91 | 0.703763 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/include/PxPvdUserRenderer.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_USER_RENDERER_H
#define PX_PVD_USER_RENDERER_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxVec3.h"
#include "foundation/PxTransform.h"
#include "common/PxRenderBuffer.h"
#include "pvd/PxPvd.h"
#include "PxPvdDataStream.h"
#include "foundation/PxUserAllocated.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxPvd;
#if !PX_DOXYGEN
namespace pvdsdk
{
#endif
class RendererEventClient;
class PvdUserRenderer : public PxUserAllocated
{
protected:
virtual ~PvdUserRenderer()
{
}
public:
virtual void release() = 0;
virtual void setClient(RendererEventClient* client) = 0;
// Instance to associate the further rendering with.
virtual void setInstanceId(const void* instanceId) = 0;
// Draw these points associated with this instance
virtual void drawPoints(const PxDebugPoint* points, uint32_t count) = 0;
// Draw these lines associated with this instance
virtual void drawLines(const PxDebugLine* lines, uint32_t count) = 0;
// Draw these triangles associated with this instance
virtual void drawTriangles(const PxDebugTriangle* triangles, uint32_t count) = 0;
// Draw this text associated with this instance
virtual void drawText(const PxDebugText& text) = 0;
// Draw SDK debug render
virtual void drawRenderbuffer(const PxDebugPoint* pointData, uint32_t pointCount, const PxDebugLine* lineData,
uint32_t lineCount, const PxDebugTriangle* triangleData, uint32_t triangleCount) = 0;
// Constraint visualization routines
virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) = 0;
virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, float value) = 0;
virtual void visualizeAngularLimit(const PxTransform& t0, float lower, float upper) = 0;
virtual void visualizeLimitCone(const PxTransform& t, float tanQSwingY, float tanQSwingZ) = 0;
virtual void visualizeDoubleCone(const PxTransform& t, float angle) = 0;
// Clear the immedate buffer.
virtual void flushRenderEvents() = 0;
static PvdUserRenderer* create(uint32_t bufferSize = 0x2000);
};
class RendererEventClient
{
public:
virtual ~RendererEventClient(){}
virtual void handleBufferFlush(const uint8_t* inData, uint32_t inLength) = 0;
};
#if !PX_DOXYGEN
}
}
#endif
/** @} */
#endif
| 3,856 | C | 34.385321 | 116 | 0.759855 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/include/PxPvdClient.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PVD_CLIENT_H
#define PX_PVD_CLIENT_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxFlags.h"
#include "foundation/PxVec3.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
class PvdDataStream;
class PvdUserRenderer;
/**
\brief PvdClient is the per-client connection to PVD.
It provides callback when PVD is connected/disconnted.
It provides access to the internal object so that advanced users can create extension client.
*/
class PvdClient
{
public:
virtual PvdDataStream* getDataStream() = 0;
virtual bool isConnected() const = 0;
virtual void onPvdConnected() = 0;
virtual void onPvdDisconnected() = 0;
virtual void flush() = 0;
protected:
virtual ~PvdClient()
{
}
};
#if !PX_DOXYGEN
} // namespace pvdsdk
} // namespace physx
#endif
/** @} */
#endif
| 2,497 | C | 31.441558 | 93 | 0.752103 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/include/PxPvdDataStream.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_DATA_STREAM_H
#define PX_PVD_DATA_STREAM_H
/** \addtogroup pvd
@{
*/
#include "pvd/PxPvd.h"
#include "PxPvdErrorCodes.h"
#include "PxPvdObjectModelBaseTypes.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
class PvdPropertyDefinitionHelper;
class PvdMetaDataStream
{
protected:
virtual ~PvdMetaDataStream()
{
}
public:
virtual PvdError createClass(const NamespacedName& nm) = 0;
template <typename TDataType>
PvdError createClass()
{
return createClass(getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError deriveClass(const NamespacedName& parent, const NamespacedName& child) = 0;
template <typename TParentType, typename TChildType>
PvdError deriveClass()
{
return deriveClass(getPvdNamespacedNameForType<TParentType>(), getPvdNamespacedNameForType<TChildType>());
}
virtual bool isClassExist(const NamespacedName& nm) = 0;
template <typename TDataType>
bool isClassExist()
{
return isClassExist(getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError createProperty(const NamespacedName& clsName, const char* name, const char* semantic,
const NamespacedName& dtypeName, PropertyType::Enum propertyType,
DataRef<NamedValue> values = DataRef<NamedValue>()) = 0;
template <typename TClsType, typename TDataType>
PvdError createProperty(String name, String semantic = "", PropertyType::Enum propertyType = PropertyType::Scalar,
DataRef<NamedValue> values = DataRef<NamedValue>())
{
return createProperty(getPvdNamespacedNameForType<TClsType>(), name, semantic,
getPvdNamespacedNameForType<TDataType>(), propertyType, values);
}
virtual PvdError createPropertyMessage(const NamespacedName& cls, const NamespacedName& msgName,
DataRef<PropertyMessageArg> entries, uint32_t messageSizeInBytes) = 0;
template <typename TClsType, typename TMsgType>
PvdError createPropertyMessage(DataRef<PropertyMessageArg> entries)
{
return createPropertyMessage(getPvdNamespacedNameForType<TClsType>(), getPvdNamespacedNameForType<TMsgType>(),
entries, sizeof(TMsgType));
}
};
class PvdInstanceDataStream
{
protected:
virtual ~PvdInstanceDataStream()
{
}
public:
virtual PvdError createInstance(const NamespacedName& cls, const void* instance) = 0;
template <typename TDataType>
PvdError createInstance(const TDataType* inst)
{
return createInstance(getPvdNamespacedNameForType<TDataType>(), inst);
}
virtual bool isInstanceValid(const void* instance) = 0;
// If the property will fit or is already completely in memory
virtual PvdError setPropertyValue(const void* instance, String name, DataRef<const uint8_t> data,
const NamespacedName& incomingTypeName) = 0;
template <typename TDataType>
PvdError setPropertyValue(const void* instance, String name, const TDataType& value)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(&value);
return setPropertyValue(instance, name, DataRef<const uint8_t>(dataStart, dataStart + sizeof(TDataType)),
getPvdNamespacedNameForType<TDataType>());
}
template <typename TDataType>
PvdError setPropertyValue(const void* instance, String name, const TDataType* value, uint32_t numItems)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(value);
return setPropertyValue(instance, name,
DataRef<const uint8_t>(dataStart, dataStart + sizeof(TDataType) * numItems),
getPvdNamespacedNameForType<TDataType>());
}
// Else if the property is very large (contact reports) you can send it in chunks.
virtual PvdError beginSetPropertyValue(const void* instance, String name, const NamespacedName& incomingTypeName) = 0;
template <typename TDataType>
PvdError beginSetPropertyValue(const void* instance, String name)
{
return beginSetPropertyValue(instance, name, getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError appendPropertyValueData(DataRef<const uint8_t> data) = 0;
template <typename TDataType>
PvdError appendPropertyValueData(const TDataType* value, uint32_t numItems)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(value);
return appendPropertyValueData(DataRef<const uint8_t>(dataStart, dataStart + numItems * sizeof(TDataType)));
}
virtual PvdError endSetPropertyValue() = 0;
// Set a set of properties to various values on an object.
virtual PvdError setPropertyMessage(const void* instance, const NamespacedName& msgName,
DataRef<const uint8_t> data) = 0;
template <typename TDataType>
PvdError setPropertyMessage(const void* instance, const TDataType& value)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(&value);
return setPropertyMessage(instance, getPvdNamespacedNameForType<TDataType>(),
DataRef<const uint8_t>(dataStart, sizeof(TDataType)));
}
// If you need to send of lot of identical messages, this avoids a hashtable lookup per message.
virtual PvdError beginPropertyMessageGroup(const NamespacedName& msgName) = 0;
template <typename TDataType>
PvdError beginPropertyMessageGroup()
{
return beginPropertyMessageGroup(getPvdNamespacedNameForType<TDataType>());
}
virtual PvdError sendPropertyMessageFromGroup(const void* instance, DataRef<const uint8_t> data) = 0;
template <typename TDataType>
PvdError sendPropertyMessageFromGroup(const void* instance, const TDataType& value)
{
const uint8_t* dataStart = reinterpret_cast<const uint8_t*>(&value);
return sendPropertyMessageFromGroup(instance, DataRef<const uint8_t>(dataStart, sizeof(TDataType)));
}
virtual PvdError endPropertyMessageGroup() = 0;
// These functions ensure the target array doesn't contain duplicates
virtual PvdError pushBackObjectRef(const void* instId, String propName, const void* objRef) = 0;
virtual PvdError removeObjectRef(const void* instId, String propName, const void* objRef) = 0;
// Instance elimination.
virtual PvdError destroyInstance(const void* key) = 0;
// Profiling hooks
virtual PvdError beginSection(const void* instance, String name) = 0;
virtual PvdError endSection(const void* instance, String name) = 0;
// Origin Shift
virtual PvdError originShift(const void* scene, PxVec3 shift) = 0;
public:
/*For some cases, pvd command cannot be run immediately. For example, when create joints, while the actors may still
*pending for insert, the joints update commands can be run deffered.
*/
class PvdCommand
{
public:
// Assigned is needed for copying
PvdCommand(const PvdCommand&)
{
}
PvdCommand& operator=(const PvdCommand&)
{
return *this;
}
public:
PvdCommand()
{
}
virtual ~PvdCommand()
{
}
// Not pure virtual so can have default PvdCommand obj
virtual bool canRun(PvdInstanceDataStream&)
{
return false;
}
virtual void run(PvdInstanceDataStream&)
{
}
};
// PVD SDK provide this helper function to allocate cmd's memory and release them at after flush the command queue
virtual void* allocateMemForCmd(uint32_t length) = 0;
// PVD will call the destructor of PvdCommand object at the end fo flushPvdCommand
virtual void pushPvdCommand(PvdCommand& cmd) = 0;
virtual void flushPvdCommand() = 0;
};
class PvdDataStream : public PvdInstanceDataStream, public PvdMetaDataStream
{
protected:
virtual ~PvdDataStream()
{
}
public:
virtual void release() = 0;
virtual bool isConnected() = 0;
virtual void addProfileZone(void* zone, const char* name) = 0;
virtual void addProfileZoneEvent(void* zone, const char* name, uint16_t eventId, bool compileTimeEnabled) = 0;
virtual PvdPropertyDefinitionHelper& getPropertyDefinitionHelper() = 0;
virtual void setIsTopLevelUIElement(const void* instance, bool topLevel) = 0;
virtual void sendErrorMessage(uint32_t code, const char* message, const char* file, uint32_t line) = 0;
virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target) = 0;
/**
\brief Create a new PvdDataStream.
\param pvd A pointer to a valid PxPvd instance. This must be non-null.
*/
static PvdDataStream* create(PxPvd* pvd);
};
#if !PX_DOXYGEN
} // pvdsdk
} // physx
#endif
/** @} */
#endif
| 9,961 | C | 35.357664 | 119 | 0.740086 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/include/PxPvdDataStreamHelpers.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_DATA_STREAM_HELPERS_H
#define PX_PVD_DATA_STREAM_HELPERS_H
/** \addtogroup pvd
@{
*/
#include "PxPvdObjectModelBaseTypes.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
class PvdPropertyDefinitionHelper
{
protected:
virtual ~PvdPropertyDefinitionHelper()
{
}
public:
/**
Push a name c such that it appends such as a.b.c.
*/
virtual void pushName(const char* inName, const char* inAppendStr = ".") = 0;
/**
Push a name c such that it appends like a.b[c]
*/
virtual void pushBracketedName(const char* inName, const char* leftBracket = "[", const char* rightBracket = "]") = 0;
/**
* Pop the current name
*/
virtual void popName() = 0;
virtual void clearNameStack() = 0;
/**
* Get the current name at the top of the name stack.
* Would return "a.b.c" or "a.b[c]" in the above examples.
*/
virtual const char* getTopName() = 0;
virtual void addNamedValue(const char* name, uint32_t value) = 0;
virtual void clearNamedValues() = 0;
virtual DataRef<NamedValue> getNamedValues() = 0;
/**
* Define a property using the top of the name stack and the passed-in semantic
*/
virtual void createProperty(const NamespacedName& clsName, const char* inSemantic, const NamespacedName& dtypeName,
PropertyType::Enum propType = PropertyType::Scalar) = 0;
template <typename TClsType, typename TDataType>
void createProperty(const char* inSemantic = "", PropertyType::Enum propType = PropertyType::Scalar)
{
createProperty(getPvdNamespacedNameForType<TClsType>(), inSemantic, getPvdNamespacedNameForType<TDataType>(),
propType);
}
// The datatype used for instances needs to be pointer unless you actually have pvdsdk::InstanceId members on your
// value structs.
virtual void addPropertyMessageArg(const NamespacedName& inDatatype, uint32_t inOffset, uint32_t inSize) = 0;
template <typename TDataType>
void addPropertyMessageArg(uint32_t offset)
{
addPropertyMessageArg(getPvdNamespacedNameForType<TDataType>(), offset, static_cast<uint32_t>(sizeof(TDataType)));
}
virtual void addPropertyMessage(const NamespacedName& clsName, const NamespacedName& msgName,
uint32_t inStructSizeInBytes) = 0;
template <typename TClsType, typename TMsgType>
void addPropertyMessage()
{
addPropertyMessage(getPvdNamespacedNameForType<TClsType>(), getPvdNamespacedNameForType<TMsgType>(),
static_cast<uint32_t>(sizeof(TMsgType)));
}
virtual void clearPropertyMessageArgs() = 0;
void clearBufferedData()
{
clearNameStack();
clearPropertyMessageArgs();
clearNamedValues();
}
};
#if !PX_DOXYGEN
} // pvdsdk
} // physx
#endif
/** @} */
#endif
| 4,289 | C | 34.163934 | 119 | 0.73094 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/include/PxPvdObjectModelBaseTypes.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#ifndef PX_PVD_OBJECT_MODEL_BASE_TYPES_H
#define PX_PVD_OBJECT_MODEL_BASE_TYPES_H
/** \addtogroup pvd
@{
*/
#include "foundation/PxAssert.h"
#if !PX_DOXYGEN
namespace physx
{
namespace pvdsdk
{
#endif
using namespace physx;
inline const char* nonNull(const char* str)
{
return str ? str : "";
}
// strcmp will crash if passed a null string, however,
// so we need to make sure that doesn't happen. We do that
// by equating NULL and the empty string, "".
inline bool safeStrEq(const char* lhs, const char* rhs)
{
return ::strcmp(nonNull(lhs), nonNull(rhs)) == 0;
}
// Does this string have useful information in it.
inline bool isMeaningful(const char* str)
{
return *(nonNull(str)) > 0;
}
inline uint32_t safeStrLen(const char* str)
{
str = nonNull(str);
return static_cast<uint32_t>(strlen(str));
}
struct ObjectRef
{
int32_t mInstanceId;
ObjectRef(int32_t iid = -1) : mInstanceId(iid)
{
}
operator int32_t() const
{
return mInstanceId;
}
bool hasValue() const
{
return mInstanceId > 0;
}
};
struct U32Array4
{
uint32_t mD0;
uint32_t mD1;
uint32_t mD2;
uint32_t mD3;
U32Array4(uint32_t d0, uint32_t d1, uint32_t d2, uint32_t d3) : mD0(d0), mD1(d1), mD2(d2), mD3(d3)
{
}
U32Array4() : mD0(0), mD1(0), mD2(0), mD3(0)
{
}
};
typedef bool PvdBool;
typedef const char* String;
typedef void* VoidPtr;
typedef double PvdF64;
typedef float PvdF32;
typedef int64_t PvdI64;
typedef uint64_t PvdU64;
typedef int32_t PvdI32;
typedef uint32_t PvdU32;
typedef int16_t PvdI16;
typedef uint16_t PvdU16;
typedef int8_t PvdI8;
typedef uint8_t PvdU8;
struct PvdColor
{
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
PvdColor(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255) : r(_r), g(_g), b(_b), a(_a)
{
}
PvdColor() : r(0), g(0), b(0), a(255)
{
}
PvdColor(uint32_t abgr)
{
uint8_t* valPtr = reinterpret_cast<uint8_t*>(&abgr);
r = valPtr[0];
g = valPtr[1];
b = valPtr[2];
a = valPtr[3];
}
};
struct StringHandle
{
uint32_t mHandle;
StringHandle(uint32_t val = 0) : mHandle(val)
{
}
operator uint32_t() const
{
return mHandle;
}
};
#define DECLARE_TYPES \
DECLARE_BASE_PVD_TYPE(PvdI8) \
DECLARE_BASE_PVD_TYPE(PvdU8) \
DECLARE_BASE_PVD_TYPE(PvdI16) \
DECLARE_BASE_PVD_TYPE(PvdU16) \
DECLARE_BASE_PVD_TYPE(PvdI32) \
DECLARE_BASE_PVD_TYPE(PvdU32) \
DECLARE_BASE_PVD_TYPE(PvdI64) \
DECLARE_BASE_PVD_TYPE(PvdU64) \
DECLARE_BASE_PVD_TYPE(PvdF32) \
DECLARE_BASE_PVD_TYPE(PvdF64) \
DECLARE_BASE_PVD_TYPE(PvdBool) \
DECLARE_BASE_PVD_TYPE(PvdColor) \
DECLARE_BASE_PVD_TYPE(String) \
DECLARE_BASE_PVD_TYPE(StringHandle) \
DECLARE_BASE_PVD_TYPE(ObjectRef) \
DECLARE_BASE_PVD_TYPE(VoidPtr) \
DECLARE_BASE_PVD_TYPE(PxVec2) \
DECLARE_BASE_PVD_TYPE(PxVec3) \
DECLARE_BASE_PVD_TYPE(PxVec4) \
DECLARE_BASE_PVD_TYPE(PxBounds3) \
DECLARE_BASE_PVD_TYPE(PxQuat) \
DECLARE_BASE_PVD_TYPE(PxTransform) \
DECLARE_BASE_PVD_TYPE(PxMat33) \
DECLARE_BASE_PVD_TYPE(PxMat44) \
DECLARE_BASE_PVD_TYPE(U32Array4)
struct PvdBaseType
{
enum Enum
{
None = 0,
InternalStart = 1,
InternalStop = 64,
#define DECLARE_BASE_PVD_TYPE(type) type,
DECLARE_TYPES
Last
#undef DECLARE_BASE_PVD_TYPE
};
};
struct NamespacedName
{
String mNamespace;
String mName;
NamespacedName(String ns, String nm) : mNamespace(ns), mName(nm)
{
}
NamespacedName(String nm = "") : mNamespace(""), mName(nm)
{
}
bool operator==(const NamespacedName& other) const
{
return safeStrEq(mNamespace, other.mNamespace) && safeStrEq(mName, other.mName);
}
};
struct NamedValue
{
String mName;
uint32_t mValue;
NamedValue(String nm = "", uint32_t val = 0) : mName(nm), mValue(val)
{
}
};
template <typename T>
struct BaseDataTypeToTypeMap
{
bool compile_error;
};
template <PvdBaseType::Enum>
struct BaseTypeToDataTypeMap
{
bool compile_error;
};
// Users can extend this mapping with new datatypes.
template <typename T>
struct PvdDataTypeToNamespacedNameMap
{
bool Name;
};
// This mapping tells you the what class id to use for the base datatypes
//
#define DECLARE_BASE_PVD_TYPE(type) \
template <> \
struct BaseDataTypeToTypeMap<type> \
{ \
enum Enum \
{ \
BaseTypeEnum = PvdBaseType::type \
}; \
}; \
template <> \
struct BaseDataTypeToTypeMap<const type&> \
{ \
enum Enum \
{ \
BaseTypeEnum = PvdBaseType::type \
}; \
}; \
template <> \
struct BaseTypeToDataTypeMap<PvdBaseType::type> \
{ \
typedef type TDataType; \
}; \
template <> \
struct PvdDataTypeToNamespacedNameMap<type> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<type>() : Name("physx3", #type) \
{ \
} \
}; \
template <> \
struct PvdDataTypeToNamespacedNameMap<const type&> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<const type&>() : Name("physx3", #type) \
{ \
} \
};
DECLARE_TYPES
#undef DECLARE_BASE_PVD_TYPE
template <typename TDataType>
inline int32_t getPvdTypeForType()
{
return static_cast<PvdBaseType::Enum>(BaseDataTypeToTypeMap<TDataType>::BaseTypeEnum);
}
template <typename TDataType>
inline NamespacedName getPvdNamespacedNameForType()
{
return PvdDataTypeToNamespacedNameMap<TDataType>().Name;
}
#define DEFINE_PVD_TYPE_NAME_MAP(type, ns, name) \
template <> \
struct PvdDataTypeToNamespacedNameMap<type> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<type>() : Name(ns, name) \
{ \
} \
};
#define DEFINE_PVD_TYPE_ALIAS(newType, oldType) \
template <> \
struct PvdDataTypeToNamespacedNameMap<newType> \
{ \
NamespacedName Name; \
PvdDataTypeToNamespacedNameMap<newType>() : Name(PvdDataTypeToNamespacedNameMap<oldType>().Name) \
{ \
} \
};
DEFINE_PVD_TYPE_ALIAS(const void*, void*)
struct ArrayData
{
uint8_t* mBegin;
uint8_t* mEnd;
uint8_t* mCapacity; //>= stop
ArrayData(uint8_t* beg = NULL, uint8_t* end = NULL, uint8_t* cap = NULL) : mBegin(beg), mEnd(end), mCapacity(cap)
{
}
uint8_t* begin()
{
return mBegin;
}
uint8_t* end()
{
return mEnd;
}
uint32_t byteCapacity()
{
return static_cast<uint32_t>(mCapacity - mBegin);
}
uint32_t byteSize() const
{
return static_cast<uint32_t>(mEnd - mBegin);
} // in bytes
uint32_t numberOfItems(uint32_t objectByteSize)
{
if(objectByteSize)
return byteSize() / objectByteSize;
return 0;
}
void forgetData()
{
mBegin = mEnd = mCapacity = 0;
}
};
template <typename T>
class DataRef
{
const T* mBegin;
const T* mEnd;
public:
DataRef(const T* b, uint32_t count) : mBegin(b), mEnd(b + count)
{
}
DataRef(const T* b = NULL, const T* e = NULL) : mBegin(b), mEnd(e)
{
}
DataRef(const DataRef& o) : mBegin(o.mBegin), mEnd(o.mEnd)
{
}
DataRef& operator=(const DataRef& o)
{
mBegin = o.mBegin;
mEnd = o.mEnd;
return *this;
}
uint32_t size() const
{
return static_cast<uint32_t>(mEnd - mBegin);
}
const T* begin() const
{
return mBegin;
}
const T* end() const
{
return mEnd;
}
const T& operator[](uint32_t idx) const
{
PX_ASSERT(idx < size());
return mBegin[idx];
}
const T& back() const
{
PX_ASSERT(mEnd > mBegin);
return *(mEnd - 1);
}
};
struct PropertyType
{
enum Enum
{
Unknown = 0,
Scalar,
Array
};
};
// argument to the create property message function
struct PropertyMessageArg
{
String mPropertyName;
NamespacedName mDatatypeName;
// where in the message this property starts.
uint32_t mMessageOffset;
// size of this entry object
uint32_t mByteSize;
PropertyMessageArg(String propName, NamespacedName dtype, uint32_t msgOffset, uint32_t byteSize)
: mPropertyName(propName), mDatatypeName(dtype), mMessageOffset(msgOffset), mByteSize(byteSize)
{
}
PropertyMessageArg() : mPropertyName(""), mMessageOffset(0), mByteSize(0)
{
}
};
class PvdUserRenderer;
DEFINE_PVD_TYPE_NAME_MAP(PvdUserRenderer, "_debugger_", "PvdUserRenderer")
#if !PX_DOXYGEN
}
}
#endif
/** @} */
#endif
| 14,371 | C | 32.501165 | 120 | 0.455431 |
NVIDIA-Omniverse/PhysX/physx/source/pvd/include/PxProfileAllocatorWrapper.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PROFILE_ALLOCATOR_WRAPPER_H
#define PX_PROFILE_ALLOCATOR_WRAPPER_H
#include "foundation/PxPreprocessor.h"
#include "foundation/PxAllocatorCallback.h"
#include "foundation/PxErrorCallback.h"
#include "foundation/PxAssert.h"
#include "foundation/PxHashMap.h"
#include "foundation/PxArray.h"
namespace physx { namespace profile {
/**
\brief Helper struct to encapsulate the user allocator callback
Useful for array and hash templates
*/
struct PxProfileAllocatorWrapper
{
PxAllocatorCallback* mUserAllocator;
PxProfileAllocatorWrapper( PxAllocatorCallback& inUserAllocator )
: mUserAllocator( &inUserAllocator )
{
}
PxProfileAllocatorWrapper( PxAllocatorCallback* inUserAllocator )
: mUserAllocator( inUserAllocator )
{
}
PxAllocatorCallback& getAllocator() const
{
PX_ASSERT( NULL != mUserAllocator );
return *mUserAllocator;
}
};
/**
\brief Helper class to encapsulate the reflection allocator
*/
template <typename T>
class PxProfileWrapperReflectionAllocator
{
static const char* getName()
{
#if PX_LINUX || PX_OSX || PX_EMSCRIPTEN || PX_SWITCH
return __PRETTY_FUNCTION__;
#else
return typeid(T).name();
#endif
}
PxProfileAllocatorWrapper* mWrapper;
public:
PxProfileWrapperReflectionAllocator(PxProfileAllocatorWrapper& inWrapper) : mWrapper( &inWrapper ) {}
PxProfileWrapperReflectionAllocator( const PxProfileWrapperReflectionAllocator& inOther )
: mWrapper( inOther.mWrapper )
{
}
PxProfileWrapperReflectionAllocator& operator=( const PxProfileWrapperReflectionAllocator& inOther )
{
mWrapper = inOther.mWrapper;
return *this;
}
PxAllocatorCallback& getAllocator() { return mWrapper->getAllocator(); }
void* allocate(size_t size, const char* filename, int line)
{
#if PX_CHECKED // checked and debug builds
if(!size)
return 0;
return getAllocator().allocate(size, getName(), filename, line);
#else
return getAllocator().allocate(size, "<no allocation names in this config>", filename, line);
#endif
}
void deallocate(void* ptr)
{
if(ptr)
getAllocator().deallocate(ptr);
}
};
/**
\brief Helper class to encapsulate the named allocator
*/
struct PxProfileWrapperNamedAllocator
{
PxProfileAllocatorWrapper* mWrapper;
const char* mAllocationName;
PxProfileWrapperNamedAllocator(PxProfileAllocatorWrapper& inWrapper, const char* inAllocationName)
: mWrapper( &inWrapper )
, mAllocationName( inAllocationName )
{}
PxProfileWrapperNamedAllocator( const PxProfileWrapperNamedAllocator& inOther )
: mWrapper( inOther.mWrapper )
, mAllocationName( inOther.mAllocationName )
{
}
PxProfileWrapperNamedAllocator& operator=( const PxProfileWrapperNamedAllocator& inOther )
{
mWrapper = inOther.mWrapper;
mAllocationName = inOther.mAllocationName;
return *this;
}
PxAllocatorCallback& getAllocator() { return mWrapper->getAllocator(); }
void* allocate(size_t size, const char* filename, int line)
{
if(!size)
return 0;
return getAllocator().allocate(size, mAllocationName, filename, line);
}
void deallocate(void* ptr)
{
if(ptr)
getAllocator().deallocate(ptr);
}
};
/**
\brief Helper struct to encapsulate the array
*/
template<class T>
struct PxProfileArray : public PxArray<T, PxProfileWrapperReflectionAllocator<T> >
{
typedef PxProfileWrapperReflectionAllocator<T> TAllocatorType;
PxProfileArray( PxProfileAllocatorWrapper& inWrapper )
: PxArray<T, TAllocatorType >( TAllocatorType( inWrapper ) )
{
}
PxProfileArray( const PxProfileArray< T >& inOther )
: PxArray<T, TAllocatorType >( inOther, inOther )
{
}
};
/**
\brief Helper struct to encapsulate the array
*/
template<typename TKeyType, typename TValueType, typename THashType=PxHash<TKeyType> >
struct PxProfileHashMap : public PxHashMap<TKeyType, TValueType, THashType, PxProfileWrapperReflectionAllocator< TValueType > >
{
typedef PxHashMap<TKeyType, TValueType, THashType, PxProfileWrapperReflectionAllocator< TValueType > > THashMapType;
typedef PxProfileWrapperReflectionAllocator<TValueType> TAllocatorType;
PxProfileHashMap( PxProfileAllocatorWrapper& inWrapper )
: THashMapType( TAllocatorType( inWrapper ) )
{
}
};
/**
\brief Helper function to encapsulate the profile allocation
*/
template<typename TDataType>
inline TDataType* PxProfileAllocate( PxAllocatorCallback* inAllocator, const char* file, int inLine )
{
PxProfileAllocatorWrapper wrapper( inAllocator );
typedef PxProfileWrapperReflectionAllocator< TDataType > TAllocator;
TAllocator theAllocator( wrapper );
return reinterpret_cast<TDataType*>( theAllocator.allocate( sizeof( TDataType ), file, inLine ) );
}
/**
\brief Helper function to encapsulate the profile allocation
*/
template<typename TDataType>
inline TDataType* PxProfileAllocate( PxAllocatorCallback& inAllocator, const char* file, int inLine )
{
return PxProfileAllocate<TDataType>( &inAllocator, file, inLine );
}
/**
\brief Helper function to encapsulate the profile deallocation
*/
template<typename TDataType>
inline void PxProfileDeleteAndDeallocate( PxProfileAllocatorWrapper& inAllocator, TDataType* inDType )
{
PX_ASSERT(inDType);
PxAllocatorCallback& allocator( inAllocator.getAllocator() );
inDType->~TDataType();
allocator.deallocate( inDType );
}
/**
\brief Helper function to encapsulate the profile deallocation
*/
template<typename TDataType>
inline void PxProfileDeleteAndDeallocate( PxAllocatorCallback& inAllocator, TDataType* inDType )
{
PxProfileAllocatorWrapper wrapper( &inAllocator );
PxProfileDeleteAndDeallocate( wrapper, inDType );
}
} }
#define PX_PROFILE_NEW( allocator, dtype ) new (physx::profile::PxProfileAllocate<dtype>( allocator, PX_FL)) dtype
#define PX_PROFILE_DELETE( allocator, obj ) physx::profile::PxProfileDeleteAndDeallocate( allocator, obj );
#endif
| 7,606 | C | 32.073913 | 128 | 0.756902 |
NVIDIA-Omniverse/PhysX/physx/source/physxcooking/src/Cooking.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "Cooking.h"
#include "GuCooking.h"
#include "GuBVH.h"
///////////////////////////////////////////////////////////////////////////////
using namespace physx;
using namespace Gu;
#include "cooking/PxCookingInternal.h"
#include "GuTriangleMeshBV4.h"
physx::PxTriangleMesh* PxCreateTriangleMeshInternal(const physx::PxTriangleMeshInternalData& data)
{
TriangleMesh* np;
PX_NEW_SERIALIZED(np, BV4TriangleMesh)(data);
return np;
}
physx::PxBVH* PxCreateBVHInternal(const physx::PxBVHInternalData& data)
{
BVH* np;
PX_NEW_SERIALIZED(np, BVH)(data);
return np;
}
///////////////////////////////////////////////////////////////////////////////
PxInsertionCallback* PxGetStandaloneInsertionCallback()
{
return immediateCooking::getInsertionCallback();
}
bool PxCookBVH(const PxBVHDesc& desc, PxOutputStream& stream)
{
return immediateCooking::cookBVH(desc, stream);
}
PxBVH* PxCreateBVH(const PxBVHDesc& desc, PxInsertionCallback& insertionCallback)
{
return immediateCooking::createBVH(desc, insertionCallback);
}
bool PxCookHeightField(const PxHeightFieldDesc& desc, PxOutputStream& stream)
{
return immediateCooking::cookHeightField(desc, stream);
}
PxHeightField* PxCreateHeightField(const PxHeightFieldDesc& desc, PxInsertionCallback& insertionCallback)
{
return immediateCooking::createHeightField(desc, insertionCallback);
}
bool PxCookConvexMesh(const PxCookingParams& params, const PxConvexMeshDesc& desc, PxOutputStream& stream, PxConvexMeshCookingResult::Enum* condition)
{
return immediateCooking::cookConvexMesh(params, desc, stream, condition);
}
PxConvexMesh* PxCreateConvexMesh(const PxCookingParams& params, const PxConvexMeshDesc& desc, PxInsertionCallback& insertionCallback, PxConvexMeshCookingResult::Enum* condition)
{
return immediateCooking::createConvexMesh(params, desc, insertionCallback, condition);
}
bool PxValidateConvexMesh(const PxCookingParams& params, const PxConvexMeshDesc& desc)
{
return immediateCooking::validateConvexMesh(params, desc);
}
bool PxComputeHullPolygons(const PxCookingParams& params, const PxSimpleTriangleMesh& mesh, PxAllocatorCallback& inCallback, PxU32& nbVerts, PxVec3*& vertices, PxU32& nbIndices, PxU32*& indices, PxU32& nbPolygons, PxHullPolygon*& hullPolygons)
{
return immediateCooking::computeHullPolygons(params, mesh, inCallback, nbVerts, vertices, nbIndices, indices, nbPolygons, hullPolygons);
}
bool PxValidateTriangleMesh(const PxCookingParams& params, const PxTriangleMeshDesc& desc)
{
return immediateCooking::validateTriangleMesh(params, desc);
}
PxTriangleMesh* PxCreateTriangleMesh(const PxCookingParams& params, const PxTriangleMeshDesc& desc, PxInsertionCallback& insertionCallback, PxTriangleMeshCookingResult::Enum* condition)
{
return immediateCooking::createTriangleMesh(params, desc, insertionCallback, condition);
}
bool PxCookTriangleMesh(const PxCookingParams& params, const PxTriangleMeshDesc& desc, PxOutputStream& stream, PxTriangleMeshCookingResult::Enum* condition)
{
return immediateCooking::cookTriangleMesh(params, desc, stream, condition);
}
bool PxCookTetrahedronMesh(const PxCookingParams& params, const PxTetrahedronMeshDesc& meshDesc, PxOutputStream& stream)
{
return immediateCooking::cookTetrahedronMesh(params, meshDesc, stream);
}
PxTetrahedronMesh* PxCreateTetrahedronMesh(const PxCookingParams& params, const PxTetrahedronMeshDesc& meshDesc, PxInsertionCallback& insertionCallback)
{
return immediateCooking::createTetrahedronMesh(params, meshDesc, insertionCallback);
}
bool PxCookSoftBodyMesh(const PxCookingParams& params, const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc, const PxSoftBodySimulationDataDesc& softbodyDataDesc, PxOutputStream& stream)
{
return immediateCooking::cookSoftBodyMesh(params, simulationMeshDesc, collisionMeshDesc, softbodyDataDesc, stream);
}
PxSoftBodyMesh* PxCreateSoftBodyMesh(const PxCookingParams& params, const PxTetrahedronMeshDesc& simulationMeshDesc, const PxTetrahedronMeshDesc& collisionMeshDesc, const PxSoftBodySimulationDataDesc& softbodyDataDesc, PxInsertionCallback& insertionCallback)
{
return immediateCooking::createSoftBodyMesh(params, simulationMeshDesc, collisionMeshDesc, softbodyDataDesc, insertionCallback);
}
PxCollisionMeshMappingData* PxComputeModelsMapping(const PxCookingParams& params, PxTetrahedronMeshData& simulationMesh, const PxTetrahedronMeshData& collisionMesh, const PxSoftBodyCollisionData& collisionData, const PxBoundedData* vertexToTet)
{
return immediateCooking::computeModelsMapping(params, simulationMesh, collisionMesh, collisionData, vertexToTet);
}
PxCollisionTetrahedronMeshData* PxComputeCollisionData(const PxCookingParams& params, const PxTetrahedronMeshDesc& collisionMeshDesc)
{
return immediateCooking::computeCollisionData(params, collisionMeshDesc);
}
PxSimulationTetrahedronMeshData* PxComputeSimulationData(const PxCookingParams& params, const PxTetrahedronMeshDesc& simulationMeshDesc)
{
return immediateCooking::computeSimulationData(params, simulationMeshDesc);
}
PxSoftBodyMesh* PxAssembleSoftBodyMesh(PxTetrahedronMeshData& simulationMesh, PxSoftBodySimulationData& simulationData, PxTetrahedronMeshData& collisionMesh, PxSoftBodyCollisionData& collisionData, PxCollisionMeshMappingData& mappingData, PxInsertionCallback& insertionCallback)
{
return immediateCooking::assembleSoftBodyMesh(simulationMesh, simulationData, collisionMesh, collisionData, mappingData, insertionCallback);
}
PxSoftBodyMesh* PxAssembleSoftBodyMesh_Sim(PxSimulationTetrahedronMeshData& simulationMesh, PxCollisionTetrahedronMeshData& collisionMesh, PxCollisionMeshMappingData& mappingData, PxInsertionCallback& insertionCallback)
{
return immediateCooking::assembleSoftBodyMesh_Sim(simulationMesh, collisionMesh, mappingData, insertionCallback);
}
| 7,525 | C++ | 45.745341 | 278 | 0.807575 |
NVIDIA-Omniverse/PhysX/physx/source/task/src/TaskManager.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
#include "task/PxTask.h"
#include "foundation/PxErrors.h"
#include "foundation/PxHashMap.h"
#include "foundation/PxAllocator.h"
#include "foundation/PxAtomic.h"
#include "foundation/PxMutex.h"
#include "foundation/PxArray.h"
#include "foundation/PxThread.h"
#define LOCK() PxMutex::ScopedLock _lock_(mMutex)
namespace physx
{
const int EOL = -1;
typedef PxHashMap<const char *, PxTaskID> PxTaskNameToIDMap;
struct PxTaskDepTableRow
{
PxTaskID mTaskID;
int mNextDep;
};
typedef PxArray<PxTaskDepTableRow> PxTaskDepTable;
class PxTaskTableRow
{
public:
PxTaskTableRow() : mRefCount( 1 ), mStartDep(EOL), mLastDep(EOL) {}
void addDependency( PxTaskDepTable& depTable, PxTaskID taskID )
{
int newDep = int(depTable.size());
PxTaskDepTableRow row;
row.mTaskID = taskID;
row.mNextDep = EOL;
depTable.pushBack( row );
if( mLastDep == EOL )
{
mStartDep = mLastDep = newDep;
}
else
{
depTable[ uint32_t(mLastDep) ].mNextDep = newDep;
mLastDep = newDep;
}
}
PxTask * mTask;
volatile int mRefCount;
PxTaskType::Enum mType;
int mStartDep;
int mLastDep;
};
typedef PxArray<PxTaskTableRow> PxTaskTable;
/* Implementation of PxTaskManager abstract API */
class PxTaskMgr : public PxTaskManager, public PxUserAllocated
{
PX_NOCOPY(PxTaskMgr)
public:
PxTaskMgr(PxErrorCallback& , PxCpuDispatcher*);
~PxTaskMgr();
void setCpuDispatcher( PxCpuDispatcher& ref )
{
mCpuDispatcher = &ref;
}
PxCpuDispatcher* getCpuDispatcher() const
{
return mCpuDispatcher;
}
void resetDependencies();
void startSimulation();
void stopSimulation();
void taskCompleted( PxTask& task );
PxTaskID getNamedTask( const char *name );
PxTaskID submitNamedTask( PxTask *task, const char *name, PxTaskType::Enum type = PxTaskType::eCPU );
PxTaskID submitUnnamedTask( PxTask& task, PxTaskType::Enum type = PxTaskType::eCPU );
PxTask* getTaskFromID( PxTaskID );
void dispatchTask( PxTaskID taskID );
void resolveRow( PxTaskID taskID );
void release();
void finishBefore( PxTask& task, PxTaskID taskID );
void startAfter( PxTask& task, PxTaskID taskID );
void addReference( PxTaskID taskID );
void decrReference( PxTaskID taskID );
int32_t getReference( PxTaskID taskID ) const;
void decrReference( PxLightCpuTask& lighttask );
void addReference( PxLightCpuTask& lighttask );
PxErrorCallback& mErrorCallback;
PxCpuDispatcher *mCpuDispatcher;
PxTaskNameToIDMap mName2IDmap;
volatile int mPendingTasks;
PxMutex mMutex;
PxTaskDepTable mDepTable;
PxTaskTable mTaskTable;
PxArray<PxTaskID> mStartDispatch;
};
PxTaskManager* PxTaskManager::createTaskManager(PxErrorCallback& errorCallback, PxCpuDispatcher* cpuDispatcher)
{
return PX_NEW(PxTaskMgr)(errorCallback, cpuDispatcher);
}
PxTaskMgr::PxTaskMgr(PxErrorCallback& errorCallback, PxCpuDispatcher* cpuDispatcher)
: mErrorCallback (errorCallback)
, mCpuDispatcher( cpuDispatcher )
, mPendingTasks( 0 )
, mDepTable("PxTaskDepTable")
, mTaskTable("PxTaskTable")
, mStartDispatch("StartDispatch")
{
}
PxTaskMgr::~PxTaskMgr()
{
}
void PxTaskMgr::release()
{
PX_DELETE_THIS;
}
void PxTaskMgr::decrReference(PxLightCpuTask& lighttask)
{
/* This does not need a lock! */
if (!PxAtomicDecrement(&lighttask.mRefCount))
{
PX_ASSERT(mCpuDispatcher);
if (mCpuDispatcher)
{
mCpuDispatcher->submitTask(lighttask);
}
else
{
lighttask.release();
}
}
}
void PxTaskMgr::addReference(PxLightCpuTask& lighttask)
{
/* This does not need a lock! */
PxAtomicIncrement(&lighttask.mRefCount);
}
/*
* Called by the owner (Scene) at the start of every frame, before
* asking for tasks to be submitted.
*/
void PxTaskMgr::resetDependencies()
{
PX_ASSERT( !mPendingTasks ); // only valid if you don't resubmit named tasks, this is true for the SDK
PX_ASSERT( mCpuDispatcher );
mTaskTable.clear();
mDepTable.clear();
mName2IDmap.clear();
mPendingTasks = 0;
}
/*
* Called by the owner (Scene) to start simulating the task graph.
* Dispatch all tasks with refCount == 1
*/
void PxTaskMgr::startSimulation()
{
PX_ASSERT( mCpuDispatcher );
/* Handle empty task graph */
if( mPendingTasks == 0 )
return;
for( PxTaskID i = 0 ; i < mTaskTable.size() ; i++ )
{
if( mTaskTable[ i ].mType == PxTaskType::eCOMPLETED )
{
continue;
}
if( !PxAtomicDecrement( &mTaskTable[ i ].mRefCount ) )
{
mStartDispatch.pushBack(i);
}
}
for( uint32_t i=0; i<mStartDispatch.size(); ++i)
{
dispatchTask( mStartDispatch[i] );
}
//mStartDispatch.resize(0);
mStartDispatch.forceSize_Unsafe(0);
}
void PxTaskMgr::stopSimulation()
{
}
PxTaskID PxTaskMgr::getNamedTask( const char *name )
{
const PxTaskNameToIDMap::Entry *ret;
{
LOCK();
ret = mName2IDmap.find( name );
}
if( ret )
{
return ret->second;
}
else
{
// create named entry in task table, without a task
return submitNamedTask( NULL, name, PxTaskType::eNOT_PRESENT );
}
}
PxTask* PxTaskMgr::getTaskFromID( PxTaskID id )
{
LOCK(); // todo: reader lock necessary?
return mTaskTable[ id ].mTask;
}
/* If called at runtime, must be thread-safe */
PxTaskID PxTaskMgr::submitNamedTask( PxTask *task, const char *name, PxTaskType::Enum type )
{
if( task )
{
task->mTm = this;
task->submitted();
}
LOCK();
const PxTaskNameToIDMap::Entry *ret = mName2IDmap.find( name );
if( ret )
{
PxTaskID prereg = ret->second;
if( task )
{
/* name was registered for us by a dependent task */
PX_ASSERT( !mTaskTable[ prereg ].mTask );
PX_ASSERT( mTaskTable[ prereg ].mType == PxTaskType::eNOT_PRESENT );
mTaskTable[ prereg ].mTask = task;
mTaskTable[ prereg ].mType = type;
task->mTaskID = prereg;
}
return prereg;
}
else
{
PxAtomicIncrement(&mPendingTasks);
PxTaskID id = static_cast<PxTaskID>(mTaskTable.size());
mName2IDmap[ name ] = id;
if( task )
{
task->mTaskID = id;
}
PxTaskTableRow r;
r.mTask = task;
r.mType = type;
mTaskTable.pushBack(r);
return id;
}
}
/*
* Add an unnamed task to the task table
*/
PxTaskID PxTaskMgr::submitUnnamedTask( PxTask& task, PxTaskType::Enum type )
{
PxAtomicIncrement(&mPendingTasks);
task.mTm = this;
task.submitted();
LOCK();
task.mTaskID = static_cast<PxTaskID>(mTaskTable.size());
PxTaskTableRow r;
r.mTask = &task;
r.mType = type;
mTaskTable.pushBack(r);
return task.mTaskID;
}
/* Called by worker threads (or cooperating application threads) when a
* PxTask has completed. Propogate depdenencies, decrementing all
* referenced tasks' refCounts. If any of those reach zero, activate
* those tasks.
*/
void PxTaskMgr::taskCompleted( PxTask& task )
{
LOCK();
resolveRow(task.mTaskID);
}
/* ================== Private Functions ======================= */
/*
* Add a dependency to force 'task' to complete before the
* referenced 'taskID' is allowed to be dispatched.
*/
void PxTaskMgr::finishBefore( PxTask& task, PxTaskID taskID )
{
LOCK();
PX_ASSERT( mTaskTable[ taskID ].mType != PxTaskType::eCOMPLETED );
mTaskTable[ task.mTaskID ].addDependency( mDepTable, taskID );
PxAtomicIncrement( &mTaskTable[ taskID ].mRefCount );
}
/*
* Add a dependency to force 'task' to wait for the referenced 'taskID'
* to complete before it is allowed to be dispatched.
*/
void PxTaskMgr::startAfter( PxTask& task, PxTaskID taskID )
{
LOCK();
PX_ASSERT( mTaskTable[ taskID ].mType != PxTaskType::eCOMPLETED );
mTaskTable[ taskID ].addDependency( mDepTable, task.mTaskID );
PxAtomicIncrement( &mTaskTable[ task.mTaskID ].mRefCount );
}
void PxTaskMgr::addReference( PxTaskID taskID )
{
LOCK();
PxAtomicIncrement( &mTaskTable[ taskID ].mRefCount );
}
/*
* Remove one reference count from a task. Must be done here to make it thread safe.
*/
void PxTaskMgr::decrReference( PxTaskID taskID )
{
LOCK();
if( !PxAtomicDecrement( &mTaskTable[ taskID ].mRefCount ) )
{
dispatchTask(taskID);
}
}
int32_t PxTaskMgr::getReference(PxTaskID taskID) const
{
return mTaskTable[ taskID ].mRefCount;
}
/*
* A task has completed, decrement all dependencies and submit tasks
* that are ready to run. Signal simulation end if ther are no more
* pending tasks.
*/
void PxTaskMgr::resolveRow( PxTaskID taskID )
{
int depRow = mTaskTable[ taskID ].mStartDep;
while( depRow != EOL )
{
PxTaskDepTableRow& row = mDepTable[ uint32_t(depRow) ];
PxTaskTableRow& dtt = mTaskTable[ row.mTaskID ];
if( !PxAtomicDecrement( &dtt.mRefCount ) )
{
dispatchTask( row.mTaskID );
}
depRow = row.mNextDep;
}
PxAtomicDecrement( &mPendingTasks );
}
/*
* Submit a ready task to its appropriate dispatcher.
*/
void PxTaskMgr::dispatchTask( PxTaskID taskID )
{
LOCK(); // todo: reader lock necessary?
PxTaskTableRow& tt = mTaskTable[ taskID ];
// prevent re-submission
if( tt.mType == PxTaskType::eCOMPLETED )
{
mErrorCallback.reportError(PxErrorCode::eDEBUG_WARNING, "PxTask dispatched twice", PX_FL);
return;
}
switch ( tt.mType )
{
case PxTaskType::eCPU:
mCpuDispatcher->submitTask( *tt.mTask );
break;
case PxTaskType::eNOT_PRESENT:
/* No task registered with this taskID, resolve its dependencies */
PX_ASSERT(!tt.mTask);
//PxGetFoundation().error(PX_INFO, "unregistered task resolved");
resolveRow( taskID );
break;
case PxTaskType::eCOMPLETED:
default:
mErrorCallback.reportError(PxErrorCode::eDEBUG_WARNING, "Unknown task type", PX_FL);
resolveRow( taskID );
break;
}
tt.mType = PxTaskType::eCOMPLETED;
}
}// end physx namespace
| 11,436 | C++ | 24.701124 | 111 | 0.689314 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBTreeUpdateMap.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_AABB_TREE_UPDATE_MAP_H
#define GU_AABB_TREE_UPDATE_MAP_H
#include "common/PxPhysXCommonConfig.h"
#include "GuPrunerTypedef.h"
#include "foundation/PxArray.h"
namespace physx
{
namespace Gu
{
class AABBTree;
// Maps pruning pool indices to AABB-tree indices (i.e. locates the object's box in the aabb-tree nodes pool)
//
// The map spans pool indices from 0..N-1, where N is the number of pool entries when the map was created from a tree.
//
// It maps:
// to node indices in the range 0..M-1, where M is the number of nodes in the tree the map was created from,
// or to INVALID_NODE_ID if the pool entry was removed or pool index is outside input domain.
//
// The map is the inverse of the tree mapping: (node[map[poolID]].primitive == poolID) is true at all times.
class AABBTreeUpdateMap
{
public:
AABBTreeUpdateMap() {}
~AABBTreeUpdateMap() {}
void release()
{
mMapping.reset();
}
// indices offset used when indices are shifted from objects (used for merged trees)
PX_PHYSX_COMMON_API void initMap(PxU32 numPoolObjects, const AABBTree& tree);
PX_PHYSX_COMMON_API void invalidate(PoolIndex poolIndex, PoolIndex replacementPoolIndex, AABBTree& tree);
PX_FORCE_INLINE TreeNodeIndex operator[](PxU32 poolIndex) const
{
return poolIndex < mMapping.size() ? mMapping[poolIndex] : INVALID_NODE_ID;
}
private:
// maps from prunerIndex (index in the PruningPool) to treeNode index
// this will only map to leaf tree nodes
PxArray<TreeNodeIndex> mMapping;
};
}
}
#endif
| 3,359 | C | 39.975609 | 119 | 0.719857 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBTreeUpdateMap.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuAABBTreeUpdateMap.h"
#include "GuAABBTree.h"
#include "GuAABBTreeNode.h"
using namespace physx;
using namespace Gu;
static const PxU32 SHRINK_THRESHOLD = 1024;
void AABBTreeUpdateMap::initMap(PxU32 nbObjects, const AABBTree& tree)
{
if(!nbObjects)
{
release();
return;
}
// Memory management
{
const PxU32 mapSize = nbObjects;
const PxU32 targetCapacity = mapSize + (mapSize>>2);
PxU32 currentCapacity = mMapping.capacity();
if( ( targetCapacity < (currentCapacity>>1) ) && ( (currentCapacity-targetCapacity) > SHRINK_THRESHOLD ) )
{
// trigger reallocation of a smaller array, there is enough memory to save
currentCapacity = 0;
}
if(mapSize > currentCapacity)
{
// the mapping values are invalid and reset below in any case
// so there is no need to copy the values at all
mMapping.reset();
mMapping.reserve(targetCapacity); // since size is 0, reserve will also just allocate
}
mMapping.forceSize_Unsafe(mapSize);
for(PxU32 i=0;i<mapSize;i++)
mMapping[i] = INVALID_NODE_ID;
}
const PxU32 nbNodes = tree.getNbNodes();
const BVHNode* nodes = tree.getNodes();
const PxU32* indices = tree.getIndices();
for(TreeNodeIndex i=0;i<nbNodes;i++)
{
if(nodes[i].isLeaf())
{
const PxU32 nbPrims = nodes[i].getNbRuntimePrimitives();
// PT: with multiple primitives per node, several mapping entries will point to the same node.
PX_ASSERT(nbPrims<16);
for(PxU32 j=0;j<nbPrims;j++)
{
const PxU32 index = nodes[i].getPrimitives(indices)[j];
PX_ASSERT(index<nbObjects);
mMapping[index] = i;
}
}
}
}
void AABBTreeUpdateMap::invalidate(PoolIndex prunerIndex0, PoolIndex prunerIndex1, AABBTree& tree)
{
// prunerIndex0 and prunerIndex1 are both indices into the pool, not handles
// prunerIndex0 is the index in the pruning pool for the node that was just removed
// prunerIndex1 is the index in the pruning pool for the node
const TreeNodeIndex nodeIndex0 = prunerIndex0<mMapping.size() ? mMapping[prunerIndex0] : INVALID_NODE_ID;
const TreeNodeIndex nodeIndex1 = prunerIndex1<mMapping.size() ? mMapping[prunerIndex1] : INVALID_NODE_ID;
//printf("map invalidate pi0:%x ni0:%x\t",prunerIndex0,nodeIndex0);
//printf(" replace with pi1:%x ni1:%x\n",prunerIndex1,nodeIndex1);
// if nodeIndex0 exists:
// invalidate node 0
// invalidate map prunerIndex0
// if nodeIndex1 exists:
// point node 1 to prunerIndex0
// map prunerIndex0 to node 1
// invalidate map prunerIndex1
// eventually:
// - node 0 is invalid
// - prunerIndex0 is mapped to node 1 or
// is not mapped if prunerIndex1 is not mapped
// is not mapped if prunerIndex0==prunerIndex1
// - node 1 points to prunerIndex0 or
// is invalid if prunerIndex1 is not mapped
// is invalid if prunerIndex0==prunerIndex1
// - prunerIndex1 is not mapped
BVHNode* nodes = tree.getNodes();
if(nodeIndex0!=INVALID_NODE_ID)
{
PX_ASSERT(nodeIndex0 < tree.getNbNodes());
PX_ASSERT(nodes[nodeIndex0].isLeaf());
BVHNode* node0 = nodes + nodeIndex0;
const PxU32 nbPrims = node0->getNbRuntimePrimitives();
PX_ASSERT(nbPrims < 16);
// retrieve the primitives pointer
PxU32* primitives = node0->getPrimitives(tree.getIndices());
PX_ASSERT(primitives);
// PT: look for desired pool index in the leaf
bool foundIt = false;
for(PxU32 i=0;i<nbPrims;i++)
{
PX_ASSERT(mMapping[primitives[i]] == nodeIndex0); // PT: all primitives should point to the same leaf node
if(prunerIndex0 == primitives[i])
{
foundIt = true;
const PxU32 last = nbPrims-1;
node0->setNbRunTimePrimitives(last);
primitives[i] = INVALID_POOL_ID; // Mark primitive index as invalid in the node
mMapping[prunerIndex0] = INVALID_NODE_ID; // invalidate the node index for pool 0
// PT: swap within the leaf node. No need to update the mapping since they should all point
// to the same tree node anyway.
if(last!=i)
PxSwap(primitives[i], primitives[last]);
break;
}
}
PX_ASSERT(foundIt);
PX_UNUSED(foundIt);
}
if (nodeIndex1!=INVALID_NODE_ID)
{
// PT: with multiple primitives per leaf, tree nodes may very well be the same for different pool indices.
// However the pool indices may be the same when a swap has been skipped in the pruning pool, in which
// case there is nothing to do.
if(prunerIndex0!=prunerIndex1)
{
PX_ASSERT(nodeIndex1 < tree.getNbNodes());
PX_ASSERT(nodes[nodeIndex1].isLeaf());
BVHNode* node1 = nodes + nodeIndex1;
const PxU32 nbPrims = node1->getNbRuntimePrimitives();
PX_ASSERT(nbPrims < 16);
// retrieve the primitives pointer
PxU32* primitives = node1->getPrimitives(tree.getIndices());
PX_ASSERT(primitives);
// PT: look for desired pool index in the leaf
bool foundIt = false;
for(PxU32 i=0;i<nbPrims;i++)
{
PX_ASSERT(mMapping[primitives[i]] == nodeIndex1); // PT: all primitives should point to the same leaf node
if(prunerIndex1 == primitives[i])
{
foundIt = true;
primitives[i] = prunerIndex0; // point node 1 to the pool object moved to ID 0
mMapping[prunerIndex0] = nodeIndex1; // pool 0 is pointed at by node 1 now
mMapping[prunerIndex1] = INVALID_NODE_ID; // pool 1 is no longer stored in the tree
break;
}
}
PX_ASSERT(foundIt);
PX_UNUSED(foundIt);
}
}
}
| 7,030 | C++ | 34.510101 | 110 | 0.714936 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuIncrementalAABBPruner.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// PT: TODO: this class isn't actually used at the moment
#define COMPILE_INCREMENTAL_AABB_PRUNER
#ifdef COMPILE_INCREMENTAL_AABB_PRUNER
#include "common/PxProfileZone.h"
#include "CmVisualization.h"
#include "foundation/PxBitUtils.h"
#include "GuIncrementalAABBPruner.h"
#include "GuIncrementalAABBTree.h"
#include "GuCallbackAdapter.h"
#include "GuAABBTree.h"
#include "GuAABBTreeQuery.h"
#include "GuSphere.h"
#include "GuBox.h"
#include "GuCapsule.h"
#include "GuQuery.h"
using namespace physx;
using namespace Gu;
// PT: TODO: this is copied from SqBounds.h, should be either moved to Gu and shared or passed as a user parameter
#define SQ_PRUNER_EPSILON 0.005f
#define SQ_PRUNER_INFLATION (1.0f + SQ_PRUNER_EPSILON) // pruner test shape inflation (not narrow phase shape)
#define PARANOIA_CHECKS 0
IncrementalAABBPruner::IncrementalAABBPruner(PxU32 sceneLimit, PxU64 contextID) :
mAABBTree (NULL),
mPool (contextID, TRANSFORM_CACHE_GLOBAL),
mContextID (contextID)
{
mMapping.resizeUninitialized(sceneLimit);
mPool.preallocate(sceneLimit);
mChangedLeaves.reserve(sceneLimit);
}
IncrementalAABBPruner::~IncrementalAABBPruner()
{
release();
}
bool IncrementalAABBPruner::addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* data, const PxTransform* transforms, PxU32 count, bool )
{
PX_PROFILE_ZONE("SceneQuery.prunerAddObjects", mContextID);
if(!count)
return true;
const PxU32 valid = mPool.addObjects(results, bounds, data, transforms, count);
if(mAABBTree)
{
for(PxU32 i=0;i<valid;i++)
{
const PrunerHandle& handle = results[i];
const PoolIndex poolIndex = mPool.getIndex(handle);
mChangedLeaves.clear();
IncrementalAABBTreeNode* node = mAABBTree->insert(poolIndex, mPool.getCurrentWorldBoxes(), mChangedLeaves);
updateMapping(poolIndex, node);
}
#if PARANOIA_CHECKS
test();
#endif
}
return valid==count;
}
void IncrementalAABBPruner::updateMapping(const PoolIndex poolIndex, IncrementalAABBTreeNode* node)
{
// resize mapping if needed
if(mMapping.size() <= poolIndex)
{
mMapping.resize(mMapping.size() * 2);
}
// if a node was split we need to update the node indices and also the sibling indices
if(!mChangedLeaves.empty())
{
if(node && node->isLeaf())
{
for(PxU32 j = 0; j < node->getNbPrimitives(); j++)
{
mMapping[node->getPrimitives(NULL)[j]] = node;
}
}
for(PxU32 i = 0; i < mChangedLeaves.size(); i++)
{
IncrementalAABBTreeNode* changedNode = mChangedLeaves[i];
PX_ASSERT(changedNode->isLeaf());
for(PxU32 j = 0; j < changedNode->getNbPrimitives(); j++)
{
mMapping[changedNode->getPrimitives(NULL)[j]] = changedNode;
}
}
}
else
{
mMapping[poolIndex] = node;
}
}
void IncrementalAABBPruner::updateObjects(const PrunerHandle* handles, PxU32 count, float inflation, const PxU32* boundsIndices, const PxBounds3* newBounds, const PxTransform32* newTransforms)
{
PX_PROFILE_ZONE("SceneQuery.prunerUpdateObjects", mContextID);
if(!count)
return;
if(handles && boundsIndices && newBounds)
mPool.updateAndInflateBounds(handles, boundsIndices, newBounds, newTransforms, count, inflation);
if(!mAABBTree)
return;
const PxBounds3* poolBounds = mPool.getCurrentWorldBoxes();
for(PxU32 i=0; i<count; i++)
{
const PrunerHandle h = handles[i];
const PoolIndex poolIndex = mPool.getIndex(h);
mChangedLeaves.clear();
IncrementalAABBTreeNode* node = mAABBTree->update(mMapping[poolIndex], poolIndex, poolBounds, mChangedLeaves);
// we removed node during update, need to update the mapping
updateMapping(poolIndex, node);
}
#if PARANOIA_CHECKS
test();
#endif
}
void IncrementalAABBPruner::removeObjects(const PrunerHandle* handles, PxU32 count, PrunerPayloadRemovalCallback* removalCallback)
{
PX_PROFILE_ZONE("SceneQuery.prunerRemoveObjects", mContextID);
if(!count)
return;
for(PxU32 i=0; i<count; i++)
{
const PrunerHandle h = handles[i];
const PoolIndex poolIndex = mPool.getIndex(h); // save the pool index for removed object
const PoolIndex poolRelocatedLastIndex = mPool.removeObject(h, removalCallback); // save the lastIndex returned by removeObject
if(mAABBTree)
{
IncrementalAABBTreeNode* node = mAABBTree->remove(mMapping[poolIndex], poolIndex, mPool.getCurrentWorldBoxes());
// if node moved to its parent
if (node && node->isLeaf())
{
for (PxU32 j = 0; j < node->getNbPrimitives(); j++)
{
const PoolIndex index = node->getPrimitives(NULL)[j];
mMapping[index] = node;
}
}
mMapping[poolIndex] = mMapping[poolRelocatedLastIndex];
// fix indices if we made a swap
if(poolRelocatedLastIndex != poolIndex)
mAABBTree->fixupTreeIndices(mMapping[poolIndex], poolRelocatedLastIndex, poolIndex);
if(!mAABBTree->getNodes())
{
release();
}
}
}
#if PARANOIA_CHECKS
test();
#endif
}
bool IncrementalAABBPruner::overlap(const ShapeData& queryVolume, PrunerOverlapCallback& pcbArgName) const
{
bool again = true;
if(mAABBTree && mAABBTree->getNodes())
{
OverlapCallbackAdapter pcb(pcbArgName, mPool);
switch(queryVolume.getType())
{
case PxGeometryType::eBOX:
{
if(queryVolume.isOBB())
{
const DefaultOBBAABBTest test(queryVolume);
again = AABBTreeOverlap<true, OBBAABBTest, IncrementalAABBTree, IncrementalAABBTreeNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
else
{
const DefaultAABBAABBTest test(queryVolume);
again = AABBTreeOverlap<true, AABBAABBTest, IncrementalAABBTree, IncrementalAABBTreeNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
}
break;
case PxGeometryType::eCAPSULE:
{
const DefaultCapsuleAABBTest test(queryVolume, SQ_PRUNER_INFLATION);
again = AABBTreeOverlap<true, CapsuleAABBTest, IncrementalAABBTree, IncrementalAABBTreeNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
break;
case PxGeometryType::eSPHERE:
{
const DefaultSphereAABBTest test(queryVolume);
again = AABBTreeOverlap<true, SphereAABBTest, IncrementalAABBTree, IncrementalAABBTreeNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
break;
case PxGeometryType::eCONVEXMESH:
{
const DefaultOBBAABBTest test(queryVolume);
again = AABBTreeOverlap<true, OBBAABBTest, IncrementalAABBTree, IncrementalAABBTreeNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
break;
default:
PX_ALWAYS_ASSERT_MESSAGE("unsupported overlap query volume geometry type");
}
}
return again;
}
bool IncrementalAABBPruner::sweep(const ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& pcbArgName) const
{
bool again = true;
if(mAABBTree && mAABBTree->getNodes())
{
const PxBounds3& aabb = queryVolume.getPrunerInflatedWorldAABB();
RaycastCallbackAdapter pcb(pcbArgName, mPool);
again = AABBTreeRaycast<true, true, IncrementalAABBTree, IncrementalAABBTreeNode, RaycastCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, aabb.getCenter(), unitDir, inOutDistance, aabb.getExtents(), pcb);
}
return again;
}
bool IncrementalAABBPruner::raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& pcbArgName) const
{
bool again = true;
if(mAABBTree && mAABBTree->getNodes())
{
RaycastCallbackAdapter pcb(pcbArgName, mPool);
again = AABBTreeRaycast<false, true, IncrementalAABBTree, IncrementalAABBTreeNode, RaycastCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, origin, unitDir, inOutDistance, PxVec3(0.0f), pcb);
}
return again;
}
// This isn't part of the pruner virtual interface, but it is part of the public interface
// of AABBPruner - it gets called by SqManager to force a rebuild, and requires a commit() before
// queries can take place
void IncrementalAABBPruner::purge()
{
release();
}
// Commit either performs a refit if background rebuild is not yet finished
// or swaps the current tree for the second tree rebuilt in the background
void IncrementalAABBPruner::commit()
{
PX_PROFILE_ZONE("SceneQuery.prunerCommit", mContextID);
if (!mAABBTree)
{
fullRebuildAABBTree();
return;
}
}
void IncrementalAABBPruner::fullRebuildAABBTree()
{
// Don't bother building an AABB-tree if there isn't a single static object
const PxU32 nbObjects = mPool.getNbActiveObjects();
if (!nbObjects)
return;
const PxU32 indicesSize = PxNextPowerOfTwo(nbObjects);
if(indicesSize > mMapping.size())
{
mMapping.resizeUninitialized(indicesSize);
}
// copy the temp optimized tree into the new incremental tree
mAABBTree = PX_NEW(IncrementalAABBTree)();
mAABBTree->build(AABBTreeBuildParams(INCR_NB_OBJECTS_PER_NODE, nbObjects, &mPool.getCurrentAABBTreeBounds()), mMapping);
#if PARANOIA_CHECKS
test();
#endif
}
void IncrementalAABBPruner::shiftOrigin(const PxVec3& shift)
{
mPool.shiftOrigin(shift);
if(mAABBTree)
mAABBTree->shiftOrigin(shift);
}
void IncrementalAABBPruner::visualize(PxRenderOutput& out, PxU32 primaryColor, PxU32 /*secondaryColor*/) const
{
// getAABBTree() asserts when pruner is dirty. NpScene::visualization() does not enforce flushUpdate. see DE7834
visualizeTree(out, primaryColor, mAABBTree);
// Render added objects not yet in the tree
//out << PxTransform(PxIdentity);
//out << PxU32(PxDebugColor::eARGB_WHITE);
}
void IncrementalAABBPruner::release() // this can be called from purge()
{
PX_DELETE(mAABBTree);
}
void IncrementalAABBPruner::test()
{
if(mAABBTree)
{
mAABBTree->hierarchyCheck(mPool.getNbActiveObjects(), mPool.getCurrentWorldBoxes());
for(PxU32 i = 0; i < mPool.getNbActiveObjects(); i++)
{
mAABBTree->checkTreeLeaf(mMapping[i], i);
}
}
}
void IncrementalAABBPruner::merge(const void* )
{
//const AABBPrunerMergeData& pruningStructure = *reinterpret_cast<const AABBPrunerMergeData*> (mergeParams);
//if(mAABBTree)
//{
// // index in pruning pool, where new objects were added
// const PxU32 pruningPoolIndex = mPool.getNbActiveObjects() - pruningStructure.mNbObjects;
// // create tree from given nodes and indices
// AABBTreeMergeData aabbTreeMergeParams(pruningStructure.mNbNodes, pruningStructure.mAABBTreeNodes,
// pruningStructure.mNbObjects, pruningStructure.mAABBTreeIndices, pruningPoolIndex);
// if (!mIncrementalRebuild)
// {
// // merge tree directly
// mAABBTree->mergeTree(aabbTreeMergeParams);
// }
// else
// {
// mBucketPruner.addTree(aabbTreeMergeParams, mTimeStamp);
// }
//}
}
void IncrementalAABBPruner::getGlobalBounds(PxBounds3& bounds) const
{
if(mAABBTree && mAABBTree->getNodes())
{
StoreBounds(bounds, mAABBTree->getNodes()->mBVMin, mAABBTree->getNodes()->mBVMax);
}
else
bounds.setEmpty();
}
#endif
| 12,574 | C++ | 30.516291 | 222 | 0.745904 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuPruningPool.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_PRUNING_POOL_H
#define GU_PRUNING_POOL_H
#include "common/PxPhysXCommonConfig.h"
#include "GuPrunerTypedef.h"
#include "GuPrunerPayload.h"
#include "GuBounds.h"
#include "GuAABBTreeBounds.h"
namespace physx
{
namespace Gu
{
enum TransformCacheMode
{
TRANSFORM_CACHE_UNUSED,
TRANSFORM_CACHE_LOCAL,
TRANSFORM_CACHE_GLOBAL
};
// This class is designed to maintain a two way mapping between pair(PrunerPayload/userdata,AABB) and PrunerHandle
// Internally there's also an index for handles (AP: can be simplified?)
// This class effectively stores bounded pruner payloads/userdata, returns a PrunerHandle and allows O(1)
// access to them using a PrunerHandle
// Supported operations are add, remove, update bounds
class PX_PHYSX_COMMON_API PruningPool : public PxUserAllocated
{
PX_NOCOPY(PruningPool)
public:
PruningPool(PxU64 contextID, TransformCacheMode mode/*=TRANSFORM_CACHE_UNUSED*/);
~PruningPool();
PX_FORCE_INLINE const PrunerPayload& getPayloadData(PrunerHandle handle, PrunerPayloadData* data=NULL) const
{
const PoolIndex index = getIndex(handle);
if(data)
{
PxBounds3* wb = const_cast<PxBounds3*>(mWorldBoxes.getBounds());
data->mBounds = wb + index;
data->mTransform = mTransforms ? mTransforms + index : NULL;
}
return mObjects[index];
}
void shiftOrigin(const PxVec3& shift);
// PT: adds 'count' objects to the pool. Needs 'count' bounds and 'count' payloads passed as input. Writes out 'count' handles
// in 'results' array. Function returns number of successfully added objects, ideally 'count' but can be less in case we run
// out of memory.
PxU32 addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* data, const PxTransform* transforms, PxU32 count);
// this function will swap the last object with the hole formed by removed PrunerHandle object
// and return the removed last object's index in the pool
PoolIndex removeObject(PrunerHandle h, PrunerPayloadRemovalCallback* removalCallback);
// Data access
PX_FORCE_INLINE PoolIndex getIndex(PrunerHandle h)const { return mHandleToIndex[h]; }
PX_FORCE_INLINE PrunerPayload* getObjects() const { return mObjects; }
PX_FORCE_INLINE const PxTransform* getTransforms() const { return mTransforms; }
PX_FORCE_INLINE PxTransform* getTransforms() { return mTransforms; }
PX_FORCE_INLINE bool setTransform(PrunerHandle handle, const PxTransform& transform)
{
if(!mTransforms)
return false;
mTransforms[getIndex(handle)] = transform;
return true;
}
PX_FORCE_INLINE PxU32 getNbActiveObjects() const { return mNbObjects; }
PX_FORCE_INLINE const PxBounds3* getCurrentWorldBoxes() const { return mWorldBoxes.getBounds(); }
PX_FORCE_INLINE PxBounds3* getCurrentWorldBoxes() { return mWorldBoxes.getBounds(); }
PX_FORCE_INLINE const AABBTreeBounds& getCurrentAABBTreeBounds() const { return mWorldBoxes; }
void updateAndInflateBounds(const PrunerHandle* handles, const PxU32* boundsIndices, const PxBounds3* newBounds, const PxTransform32* newTransforms, PxU32 count, float epsilon);
void preallocate(PxU32 entries);
// protected:
PxU32 mNbObjects; //!< Current number of objects
PxU32 mMaxNbObjects; //!< Max. number of objects (capacity for mWorldBoxes, mObjects)
//!< these arrays are parallel
AABBTreeBounds mWorldBoxes; //!< List of world boxes, stores mNbObjects, capacity=mMaxNbObjects
PrunerPayload* mObjects; //!< List of objects, stores mNbObjects, capacity=mMaxNbObjects
PxTransform* mTransforms;
const TransformCacheMode mTransformCacheMode;
// private:
PoolIndex* mHandleToIndex; //!< Maps from PrunerHandle to internal index (payload/userData index in mObjects)
PrunerHandle* mIndexToHandle; //!< Inverse map from objectIndex to PrunerHandle
// this is the head of a list of holes formed in mHandleToIndex by removed handles
// the rest of the list is stored in holes in mHandleToIndex (in place)
PrunerHandle mFirstRecycledHandle;
PxU64 mContextID;
bool resize(PxU32 newCapacity);
};
}
}
#endif
| 6,129 | C | 46.153846 | 187 | 0.715614 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuWindingNumberT.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_WINDING_NUMBER_T_H
#define GU_WINDING_NUMBER_T_H
/** \addtogroup geomutils
@{
*/
#include "GuTriangle.h"
#include "foundation/PxArray.h"
#include "foundation/PxHashMap.h"
#include "foundation/PxVec3.h"
#include "GuBVH.h"
#include "GuAABBTreeQuery.h"
#include "GuAABBTreeNode.h"
#include "GuWindingNumberCluster.h"
namespace physx
{
namespace Gu
{
using Triangle = Gu::IndexedTriangleT<PxI32>;
template<typename R, typename V3>
struct SecondOrderClusterApproximationT : public ClusterApproximationT<R, V3>
{
PxMat33 WeightedOuterProductSum;
PX_FORCE_INLINE SecondOrderClusterApproximationT() {}
PX_FORCE_INLINE SecondOrderClusterApproximationT(R radius, R areaSum, const V3& weightedCentroid, const V3& weightedNormalSum, const PxMat33& weightedOuterProductSum) :
ClusterApproximationT<R, V3>(radius, areaSum, weightedCentroid, weightedNormalSum), WeightedOuterProductSum(weightedOuterProductSum)
{ }
};
//Evaluates a first order winding number approximation for a given cluster (cluster = bunch of triangles)
template<typename R, typename V3>
PX_FORCE_INLINE R firstOrderClusterApproximation(const V3& weightedCentroid, const V3& weightedNormalSum,
const V3& evaluationPoint)
{
const V3 dir = weightedCentroid - evaluationPoint;
const R l = dir.magnitude();
return (R(0.25 / 3.141592653589793238462643383) / (l * l * l)) * weightedNormalSum.dot(dir);
}
template<typename R, typename V3>
PX_FORCE_INLINE R clusterApproximation(const ClusterApproximationT<R, V3>& c, const V3& evaluationPoint)
{
return firstOrderClusterApproximation(c.WeightedCentroid, c.WeightedNormalSum, evaluationPoint);
}
//Evaluates a second order winding number approximation for a given cluster (cluster = bunch of triangles)
template<typename R, typename V3>
PX_FORCE_INLINE R secondOrderClusterApproximation(const V3& weightedCentroid, const V3& weightedNormalSum,
const PxMat33& weightedOuterProductSum, const V3& evaluationPoint)
{
const V3 dir = weightedCentroid - evaluationPoint;
const R l = dir.magnitude();
const R l2 = l * l;
const R scaling = R(0.25 / 3.141592653589793238462643383) / (l2 * l);
const R firstOrder = scaling * weightedNormalSum.dot(dir);
const R scaling2 = -R(3.0) * scaling / l2;
const R m11 = scaling + scaling2 * dir.x * dir.x, m12 = scaling2 * dir.x * dir.y, m13 = scaling2 * dir.x * dir.z;
const R m21 = scaling2 * dir.y * dir.x, m22 = scaling + scaling2 * dir.y * dir.y, m23 = scaling2 * dir.y * dir.z;
const R m31 = scaling2 * dir.z * dir.x, m32 = scaling2 * dir.z * dir.y, m33 = scaling + scaling2 * dir.z * dir.z;
return firstOrder + (weightedOuterProductSum.column0.x * m11 + weightedOuterProductSum.column1.x * m12 + weightedOuterProductSum.column2.x * m13 +
weightedOuterProductSum.column0.y * m21 + weightedOuterProductSum.column1.y * m22 + weightedOuterProductSum.column2.y * m23 +
weightedOuterProductSum.column0.z * m31 + weightedOuterProductSum.column1.z * m32 + weightedOuterProductSum.column2.z * m33);
}
template<typename R, typename V3>
PX_FORCE_INLINE R clusterApproximation(const SecondOrderClusterApproximationT<R, V3>& c, const V3& evaluationPoint)
{
return secondOrderClusterApproximation(c.WeightedCentroid, c.WeightedNormalSum, c.WeightedOuterProductSum, evaluationPoint);
}
//Computes parameters to approximately represent a cluster (cluster = bunch of triangles) to be used to compute a winding number approximation
template<typename R, typename V3>
void approximateCluster(const PxArray<PxI32>& triangleSet, PxU32 start, PxU32 end, const PxU32* triangles, const V3* points,
const PxArray<R>& triangleAreas, const PxArray<V3>& triangleNormalsTimesTriangleArea, const PxArray<V3>& triangleCentroids, ClusterApproximationT<R, V3>& cluster)
{
V3 weightedCentroid(0., 0., 0.);
R areaSum = 0;
V3 weightedNormalSum(0., 0., 0.);
for (PxU32 i = start; i < end; ++i)
{
PxI32 triId = triangleSet[i];
areaSum += triangleAreas[triId];
weightedCentroid += triangleCentroids[triId] * triangleAreas[triId];
weightedNormalSum += triangleNormalsTimesTriangleArea[triId];
}
weightedCentroid = weightedCentroid / areaSum;
R radiusSquared = 0;
for (PxU32 i = start; i < end; ++i)
{
PxI32 triId = triangleSet[i];
const PxU32* tri = &triangles[3 * triId];
R d2 = (weightedCentroid - points[tri[0]]).magnitudeSquared();
if (d2 > radiusSquared) radiusSquared = d2;
d2 = (weightedCentroid - points[tri[1]]).magnitudeSquared();
if (d2 > radiusSquared) radiusSquared = d2;
d2 = (weightedCentroid - points[tri[2]]).magnitudeSquared();
if (d2 > radiusSquared) radiusSquared = d2;
}
cluster = ClusterApproximationT<R, V3>(PxSqrt(radiusSquared), areaSum, weightedCentroid, weightedNormalSum/*, weightedOuterProductSum*/);
}
//Computes parameters to approximately represent a cluster (cluster = bunch of triangles) to be used to compute a winding number approximation
template<typename R, typename V3>
void approximateCluster(const PxArray<PxI32>& triangleSet, PxU32 start, PxU32 end, const PxU32* triangles, const V3* points,
const PxArray<R>& triangleAreas, const PxArray<V3>& triangleNormalsTimesTriangleArea, const PxArray<V3>& triangleCentroids, SecondOrderClusterApproximationT<R, V3>& cluster)
{
V3 weightedCentroid(0., 0., 0.);
R areaSum = 0;
V3 weightedNormalSum(0., 0., 0.);
for (PxU32 i = start; i < end; ++i)
{
PxI32 triId = triangleSet[i];
areaSum += triangleAreas[triId];
weightedCentroid += triangleCentroids[triId] * triangleAreas[triId];
weightedNormalSum += triangleNormalsTimesTriangleArea[triId];
}
weightedCentroid = weightedCentroid / areaSum;
R radiusSquared = 0;
PxMat33 weightedOuterProductSum(PxZERO::PxZero);
for (PxU32 i = start; i < end; ++i)
{
PxI32 triId = triangleSet[i];
const PxU32* tri = &triangles[3 * triId];
R d2 = (weightedCentroid - points[tri[0]]).magnitudeSquared();
if (d2 > radiusSquared) radiusSquared = d2;
d2 = (weightedCentroid - points[tri[1]]).magnitudeSquared();
if (d2 > radiusSquared) radiusSquared = d2;
d2 = (weightedCentroid - points[tri[2]]).magnitudeSquared();
if (d2 > radiusSquared) radiusSquared = d2;
weightedOuterProductSum = weightedOuterProductSum + PxMat33::outer(triangleCentroids[triId] - weightedCentroid, triangleNormalsTimesTriangleArea[triId]);
}
cluster = SecondOrderClusterApproximationT<R, V3>(PxSqrt(radiusSquared), areaSum, weightedCentroid, weightedNormalSum, weightedOuterProductSum);
}
//Exact winding number evaluation, needs to be called for every triangle close to the winding number query point
template<typename R, typename V3>
PX_FORCE_INLINE R evaluateExact(V3 a, V3 b, V3 c, const V3& p)
{
const R twoOver4PI = R(0.5 / 3.141592653589793238462643383);
a -= p;
b -= p;
c -= p;
const R la = a.magnitude(),
lb = b.magnitude(),
lc = c.magnitude();
const R y = a.x * b.y * c.z - a.x * b.z * c.y - a.y * b.x * c.z + a.y * b.z * c.x + a.z * b.x * c.y - a.z * b.y * c.x;
const R x = (la * lb * lc + (a.x * b.x + a.y * b.y + a.z * b.z) * lc +
(b.x * c.x + b.y * c.y + b.z * c.z) * la + (c.x * a.x + c.y * a.y + c.z * a.z) * lb);
return twoOver4PI * PxAtan2(y, x);
}
struct Section
{
PxI32 start;
PxI32 end;
Section(PxI32 s, PxI32 e) : start(s), end(e)
{}
};
//Helper method that recursively traverses the given BVH tree and computes a cluster approximation for every node and links it to the node
template<typename R, typename V3>
void precomputeClusterInformation(PxI32 nodeId, const BVHNode* tree, const PxU32* triangles, const PxU32 numTriangles,
const V3* points, PxHashMap<PxU32, ClusterApproximationT<R, V3>>& infos, const PxArray<R> triangleAreas,
const PxArray<V3>& triangleNormalsTimesTriangleArea, const PxArray<V3>& triangleCentroids)
{
PxArray<PxI32> stack;
stack.pushBack(nodeId);
PxArray<Section> returnStack;
PxArray<PxI32> triIndices;
triIndices.reserve(numTriangles);
infos.reserve(PxU32(1.2f*numTriangles));
while (stack.size() > 0)
{
nodeId = stack.popBack();
if (nodeId >= 0)
{
const BVHNode& node = tree[nodeId];
if (node.isLeaf())
{
triIndices.pushBack(node.getPrimitiveIndex());
returnStack.pushBack(Section(triIndices.size() - 1, triIndices.size()));
continue;
}
stack.pushBack(-nodeId - 1); //Marker for return index
stack.pushBack(node.getPosIndex());
stack.pushBack(node.getPosIndex() + 1);
}
else
{
Section trianglesA = returnStack.popBack();
Section trianglesB = returnStack.popBack();
Section sum(trianglesB.start, trianglesA.end);
nodeId = -nodeId - 1;
ClusterApproximationT<R, V3> c;
approximateCluster<R, V3>(triIndices, sum.start, sum.end, triangles, points, triangleAreas, triangleNormalsTimesTriangleArea, triangleCentroids, c);
infos.insert(PxU32(nodeId), c);
returnStack.pushBack(sum);
}
}
}
//Precomputes a cluster approximation for every node in the BVH tree
template<typename R, typename V3>
void precomputeClusterInformation(const BVHNode* tree, const PxU32* triangles, const PxU32 numTriangles,
const V3* points, PxHashMap<PxU32, ClusterApproximationT<R, V3>>& result, PxI32 rootNodeIndex)
{
PxArray<R> triangleAreas;
triangleAreas.resize(numTriangles);
PxArray<V3> triangleNormalsTimesTriangleArea;
triangleNormalsTimesTriangleArea.resize(numTriangles);
PxArray<V3> triangleCentroids;
triangleCentroids.resize(numTriangles);
for (PxU32 i = 0; i < numTriangles; ++i)
{
const PxU32* tri = &triangles[3 * i];
const V3& a = points[tri[0]];
const V3& b = points[tri[1]];
const V3& c = points[tri[2]];
triangleNormalsTimesTriangleArea[i] = (b - a).cross(c - a) * R(0.5);
triangleAreas[i] = triangleNormalsTimesTriangleArea[i].magnitude();
triangleCentroids[i] = (a + b + c) * R(1.0 / 3.0);
}
result.clear();
precomputeClusterInformation(rootNodeIndex, tree, triangles, numTriangles, points, result, triangleAreas, triangleNormalsTimesTriangleArea, triangleCentroids);
}
template<typename R, typename V3>
class WindingNumberTraversalController
{
public:
R mWindingNumber = 0;
private:
const PxU32* mTriangles;
const V3* mPoints;
const PxHashMap<PxU32, ClusterApproximationT<R, V3>>& mClusters;
V3 mQueryPoint;
R mDistanceThresholdBeta;
public:
PX_FORCE_INLINE WindingNumberTraversalController(const PxU32* triangles, const V3* points,
const PxHashMap<PxU32, ClusterApproximationT<R, V3>>& clusters, const V3& queryPoint, R distanceThresholdBeta = 2)
: mTriangles(triangles), mPoints(points), mClusters(clusters), mQueryPoint(queryPoint), mDistanceThresholdBeta(distanceThresholdBeta)
{ }
PX_FORCE_INLINE Gu::TraversalControl::Enum analyze(const BVHNode& node, PxI32 nodeIndex)
{
if (node.isLeaf())
{
PX_ASSERT(node.getNbPrimitives() == 1);
const PxU32* tri = &mTriangles[3 * node.getPrimitiveIndex()];
mWindingNumber += evaluateExact<R, V3>(mPoints[tri[0]], mPoints[tri[1]], mPoints[tri[2]], mQueryPoint);
return Gu::TraversalControl::eDontGoDeeper;
}
const ClusterApproximationT<R, V3>& cluster = mClusters.find(nodeIndex)->second;
const R distSquared = (mQueryPoint - cluster.WeightedCentroid).magnitudeSquared();
const R threshold = mDistanceThresholdBeta * cluster.Radius;
if (distSquared > threshold * threshold)
{
//mWindingNumber += secondOrderClusterApproximation(cluster.WeightedCentroid, cluster.WeightedNormalSum, cluster.WeightedOuterProductSum, mQueryPoint);
mWindingNumber += firstOrderClusterApproximation<R, V3>(cluster.WeightedCentroid, cluster.WeightedNormalSum, mQueryPoint); // secondOrderClusterApproximation(cluster.WeightedCentroid, cluster.WeightedNormalSum, cluster.WeightedOuterProductSum, mQueryPoint);
return Gu::TraversalControl::eDontGoDeeper;
}
return Gu::TraversalControl::eGoDeeper;
}
private:
PX_NOCOPY(WindingNumberTraversalController)
};
template<typename R, typename V3>
R computeWindingNumber(const BVHNode* tree, const V3& q, R beta, const PxHashMap<PxU32, ClusterApproximationT<R, V3>>& clusters,
const PxU32* triangles, const V3* points)
{
WindingNumberTraversalController<R, V3> c(triangles, points, clusters, q, beta);
traverseBVH<WindingNumberTraversalController<R, V3>>(tree, c);
return c.mWindingNumber;
}
}
}
/** @} */
#endif
| 14,073 | C | 41.264264 | 261 | 0.732822 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBTree.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_AABBTREE_H
#define GU_AABBTREE_H
#include "foundation/PxMemory.h"
#include "foundation/PxArray.h"
#include "foundation/PxBounds3.h"
#include "foundation/PxUserAllocated.h"
#include "common/PxPhysXCommonConfig.h"
#include "GuPrunerTypedef.h"
namespace physx
{
namespace Gu
{
struct BVHNode;
struct SAH_Buffers;
class NodeAllocator;
struct BuildStats;
class AABBTreeBounds;
// PT: TODO: sometimes we export member functions, sometimes we export the whole class. What's the story here?
#if PX_VC
#pragma warning(push)
#pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class
#endif
//! Contains AABB-tree build parameters
class PX_PHYSX_COMMON_API AABBTreeBuildParams : public PxUserAllocated
{
public:
AABBTreeBuildParams(PxU32 limit = 1, PxU32 nb_prims = 0, const AABBTreeBounds* bounds = NULL, BVHBuildStrategy bs = BVH_SPLATTER_POINTS) :
mLimit (limit),
mNbPrimitives (nb_prims),
mBounds (bounds),
mCache (NULL),
mBuildStrategy (bs)
{
}
~AABBTreeBuildParams()
{
reset();
}
PX_FORCE_INLINE void reset()
{
mLimit = mNbPrimitives = 0;
mBounds = NULL;
PX_FREE(mCache);
}
PxU32 mLimit; //!< Limit number of primitives / node. If limit is 1, build a complete tree (2*N-1 nodes)
PxU32 mNbPrimitives; //!< Number of (source) primitives.
const AABBTreeBounds* mBounds; //!< Shortcut to an app-controlled array of AABBs.
mutable PxVec3* mCache; //!< Cache for AABB centers - managed by build code.
BVHBuildStrategy mBuildStrategy;
};
//! AABB tree node used for building
class PX_PHYSX_COMMON_API AABBTreeBuildNode : public PxUserAllocated
{
public:
PX_FORCE_INLINE AABBTreeBuildNode() {}
PX_FORCE_INLINE ~AABBTreeBuildNode() {}
PX_FORCE_INLINE const PxBounds3& getAABB() const { return mBV; }
PX_FORCE_INLINE const AABBTreeBuildNode* getPos() const { return mPos; }
PX_FORCE_INLINE const AABBTreeBuildNode* getNeg() const { const AABBTreeBuildNode* P = mPos; return P ? P + 1 : NULL; }
PX_FORCE_INLINE bool isLeaf() const { return !getPos(); }
PxBounds3 mBV; //!< Global bounding-volume enclosing all the node-related primitives
const AABBTreeBuildNode* mPos; //!< "Positive" & "Negative" children
PxU32 mNodeIndex; //!< Index of node-related primitives (in the tree's mIndices array)
PxU32 mNbPrimitives; //!< Number of primitives for this node
PX_FORCE_INLINE PxU32 getNbPrimitives() const { return mNbPrimitives; }
PX_FORCE_INLINE PxU32 getNbRuntimePrimitives() const { return mNbPrimitives; }
PX_FORCE_INLINE void setNbRunTimePrimitives(PxU32 val) { mNbPrimitives = val; }
PX_FORCE_INLINE const PxU32* getPrimitives(const PxU32* base) const { return base + mNodeIndex; }
PX_FORCE_INLINE PxU32* getPrimitives(PxU32* base) { return base + mNodeIndex; }
void subdivide(const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices);
void subdivideSAH(const AABBTreeBuildParams& params, SAH_Buffers& sah, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices);
void _buildHierarchy(const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices);
void _buildHierarchySAH(const AABBTreeBuildParams& params, SAH_Buffers& sah, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices);
};
//! For complete trees we can predict the final number of nodes and preallocate them. For incomplete trees we can't.
//! But we don't want to allocate nodes one by one (which would be quite slow), so we use this helper class to
//! allocate N nodes at once, while minimizing the amount of nodes allocated for nothing. An initial amount of
//! nodes is estimated using the max number for a complete tree, and the user-defined number of primitives per leaf.
//! In ideal cases this estimated number will be quite close to the final number of nodes. When that number is not
//! enough though, slabs of N=1024 extra nodes are allocated until the build is complete.
class PX_PHYSX_COMMON_API NodeAllocator : public PxUserAllocated
{
public:
NodeAllocator();
~NodeAllocator();
void release();
void init(PxU32 nbPrimitives, PxU32 limit);
AABBTreeBuildNode* getBiNode();
AABBTreeBuildNode* mPool;
struct Slab
{
PX_FORCE_INLINE Slab() {}
PX_FORCE_INLINE Slab(AABBTreeBuildNode* pool, PxU32 nbUsedNodes, PxU32 maxNbNodes) : mPool(pool), mNbUsedNodes(nbUsedNodes), mMaxNbNodes(maxNbNodes) {}
AABBTreeBuildNode* mPool;
PxU32 mNbUsedNodes;
PxU32 mMaxNbNodes;
};
PxArray<Slab> mSlabs;
PxU32 mCurrentSlabIndex;
PxU32 mTotalNbNodes;
};
#if PX_VC
#pragma warning(pop)
#endif
/*
* \brief Builds AABBtree from given parameters.
* \param params [in/out] AABBTree build params
* \param nodeAllocator [in/out] Node allocator
* \param stats [out] Statistics
* \return Indices buffer allocated during build, or NULL if failed
*/
PX_PHYSX_COMMON_API PxU32* buildAABBTree(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats);
// PT: TODO: explain how users should call these functions and maybe revisit this
PX_PHYSX_COMMON_API void flattenTree(const NodeAllocator& nodeAllocator, BVHNode* dest, const PxU32* remap = NULL);
PX_PHYSX_COMMON_API void buildAABBTree(PxU32 nbBounds, const AABBTreeBounds& bounds, PxArray<BVHNode>& tree);
PxU32 reshuffle(PxU32 nb, PxU32* const PX_RESTRICT prims, const PxVec3* PX_RESTRICT centers, float splitValue, PxU32 axis);
class BitArray
{
public:
BitArray() : mBits(NULL), mSize(0) {}
BitArray(PxU32 nb_bits) { init(nb_bits); }
~BitArray() { PX_FREE(mBits); }
bool init(PxU32 nb_bits);
// Data management
PX_FORCE_INLINE void setBit(PxU32 bit_number)
{
mBits[bit_number>>5] |= 1<<(bit_number&31);
}
PX_FORCE_INLINE void clearBit(PxU32 bit_number)
{
mBits[bit_number>>5] &= ~(1<<(bit_number&31));
}
PX_FORCE_INLINE void toggleBit(PxU32 bit_number)
{
mBits[bit_number>>5] ^= 1<<(bit_number&31);
}
PX_FORCE_INLINE void clearAll() { PxMemZero(mBits, mSize*4); }
PX_FORCE_INLINE void setAll() { PxMemSet(mBits, 0xff, mSize*4); }
void resize(PxU32 maxBitNumber);
// Data access
PX_FORCE_INLINE PxIntBool isSet(PxU32 bit_number) const
{
return PxIntBool(mBits[bit_number>>5] & (1<<(bit_number&31)));
}
PX_FORCE_INLINE const PxU32* getBits() const { return mBits; }
PX_FORCE_INLINE PxU32 getSize() const { return mSize; }
protected:
PxU32* mBits; //!< Array of bits
PxU32 mSize; //!< Size of the array in dwords
};
//! Contains AABB-tree merge parameters
class AABBTreeMergeData
{
public:
AABBTreeMergeData(PxU32 nbNodes, const BVHNode* nodes, PxU32 nbIndices, const PxU32* indices, PxU32 indicesOffset) :
mNbNodes(nbNodes), mNodes(nodes), mNbIndices(nbIndices), mIndices(indices), mIndicesOffset(indicesOffset)
{
}
~AABBTreeMergeData() {}
PX_FORCE_INLINE const BVHNode& getRootNode() const { return *mNodes; }
public:
PxU32 mNbNodes; //!< Number of nodes of AABB tree merge
const BVHNode* mNodes; //!< Nodes of AABB tree merge
PxU32 mNbIndices; //!< Number of indices of AABB tree merge
const PxU32* mIndices; //!< Indices of AABB tree merge
PxU32 mIndicesOffset; //!< Indices offset from pruning pool
};
// Progressive building
class FIFOStack;
//~Progressive building
// PT: base class used to share some data and code between Gu::AABBtree and Gu::BVH. This is WIP and subject to change.
// Design dictated by refactoring necessities rather than a grand vision of something.
class BVHCoreData : public PxUserAllocated
{
public:
BVHCoreData() : mNbIndices(0), mNbNodes(0), mNodes(NULL), mIndices(NULL) {}
PX_FORCE_INLINE PxU32 getNbIndices() const { return mNbIndices; }
PX_FORCE_INLINE const PxU32* getIndices() const { return mIndices; }
PX_FORCE_INLINE PxU32* getIndices() { return mIndices; }
PX_FORCE_INLINE void setIndices(PxU32* indices) { mIndices = indices; }
PX_FORCE_INLINE PxU32 getNbNodes() const { return mNbNodes; }
PX_FORCE_INLINE const BVHNode* getNodes() const { return mNodes; }
PX_FORCE_INLINE BVHNode* getNodes() { return mNodes; }
PX_PHYSX_COMMON_API void fullRefit(const PxBounds3* boxes);
// PT: I'm leaving the above accessors here to avoid refactoring the SQ code using them, but members became public.
PxU32 mNbIndices; //!< Nb indices
PxU32 mNbNodes; //!< Number of nodes in the tree.
BVHNode* mNodes; //!< Linear pool of nodes.
PxU32* mIndices; //!< Indices in the app list. Indices are reorganized during build (permutation).
};
class BVHPartialRefitData : public BVHCoreData
{
public:
PX_PHYSX_COMMON_API BVHPartialRefitData();
PX_PHYSX_COMMON_API ~BVHPartialRefitData();
PX_PHYSX_COMMON_API void releasePartialRefitData(bool clearRefitMap);
// adds node[index] to a list of nodes to refit when refitMarkedNodes is called
// Note that this includes updating the hierarchy up the chain
PX_PHYSX_COMMON_API void markNodeForRefit(TreeNodeIndex nodeIndex);
PX_PHYSX_COMMON_API void refitMarkedNodes(const PxBounds3* boxes);
PX_FORCE_INLINE PxU32* getUpdateMap() { return mUpdateMap; }
protected:
PxU32* mParentIndices; //!< PT: hot/cold split, keep parent data in separate array
PxU32* mUpdateMap; //!< PT: Local index to tree node index
BitArray mRefitBitmask; //!< bit is set for each node index in markForRefit
PxU32 mRefitHighestSetWord;
PxU32* getParentIndices();
public:
void createUpdateMap(PxU32 nbObjects);
};
//! AABB-tree, N primitives/leaf
// PT: TODO: each PX_PHYSX_COMMON_API is a cross-DLL call, should we split that class in Gu/Sq parts to minimize this?
class AABBTree : public BVHPartialRefitData
{
public:
PX_PHYSX_COMMON_API AABBTree();
PX_PHYSX_COMMON_API ~AABBTree();
// Build
PX_PHYSX_COMMON_API bool build(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator);
// Progressive building
PX_PHYSX_COMMON_API PxU32 progressiveBuild(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats, PxU32 progress, PxU32 limit);
//~Progressive building
PX_PHYSX_COMMON_API void release(bool clearRefitMap=true);
// Merge tree with another one
PX_PHYSX_COMMON_API void mergeTree(const AABBTreeMergeData& tree);
// Initialize tree from given merge data
PX_PHYSX_COMMON_API void initTree(const AABBTreeMergeData& tree);
// Data access
PX_FORCE_INLINE PxU32 getTotalPrims() const { return mTotalPrims; }
PX_PHYSX_COMMON_API void shiftOrigin(const PxVec3& shift);
// Shift indices of the tree by offset. Used for merged trees, when initial indices needs to be shifted to match indices in current pruning pool
PX_PHYSX_COMMON_API void shiftIndices(PxU32 offset);
#if PX_DEBUG
void validate() {}
#endif
private:
PxU32 mTotalPrims; //!< Copy of final BuildStats::mTotalPrims
// Progressive building
FIFOStack* mStack;
//~Progressive building
bool buildInit(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats);
void buildEnd(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, const BuildStats& stats);
// tree merge
void mergeRuntimeNode(BVHNode& targetNode, const AABBTreeMergeData& tree, PxU32 targetNodeIndex);
void mergeRuntimeLeaf(BVHNode& targetNode, const AABBTreeMergeData& tree, PxU32 targetNodeIndex);
void addRuntimeChilds(PxU32& nodeIndex, const AABBTreeMergeData& tree);
void traverseRuntimeNode(BVHNode& targetNode, const AABBTreeMergeData& tree, PxU32 nodeIndex);
};
} // namespace Gu
}
#endif // GU_AABBTREE_H
| 14,093 | C | 41.197605 | 161 | 0.698858 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuMaverickNode.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuMaverickNode.h"
using namespace physx;
using namespace Gu;
const PxU32 MaverickNode::mIndices[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
bool MaverickNode::addObject(const PrunerPayload& object, PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform, PxU32 timeStamp)
{
if(mNbFree<FREE_PRUNER_SIZE)
{
const PxU32 index = mNbFree++;
mFreeObjects[index] = object;
mFreeHandles[index] = handle;
mFreeBounds[index] = worldAABB;
mFreeTransforms[index] = transform;
mFreeStamps[index] = timeStamp;
return true;
}
return false;
}
bool MaverickNode::updateObject(const PrunerPayload& object, const PxBounds3& worldAABB, const PxTransform& transform)
{
for(PxU32 i=0;i<mNbFree;i++)
{
if(mFreeObjects[i]==object)
{
mFreeBounds[i] = worldAABB;
mFreeTransforms[i] = transform;
return true;
}
}
return false;
}
bool MaverickNode::updateObject(PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform)
{
for(PxU32 i=0;i<mNbFree;i++)
{
if(mFreeHandles[i]==handle)
{
mFreeBounds[i] = worldAABB;
mFreeTransforms[i] = transform;
return true;
}
}
return false;
}
void MaverickNode::remove(PxU32 index)
{
mNbFree--;
if(index!=mNbFree)
{
mFreeBounds[index] = mFreeBounds[mNbFree];
mFreeTransforms[index] = mFreeTransforms[mNbFree];
mFreeObjects[index] = mFreeObjects[mNbFree];
mFreeHandles[index] = mFreeHandles[mNbFree];
mFreeStamps[index] = mFreeStamps[mNbFree];
}
}
bool MaverickNode::removeObject(const PrunerPayload& object, PxU32& timeStamp)
{
for(PxU32 i=0;i<mNbFree;i++)
{
if(mFreeObjects[i]==object)
{
// We found the object we want to remove. Close the gap as usual.
timeStamp = mFreeStamps[i];
remove(i);
return true;
}
}
return false;
}
bool MaverickNode::removeObject(PrunerHandle handle, PxU32& timeStamp)
{
for(PxU32 i=0;i<mNbFree;i++)
{
if(mFreeHandles[i]==handle)
{
// We found the object we want to remove. Close the gap as usual.
timeStamp = mFreeStamps[i];
remove(i);
return true;
}
}
return false;
}
PxU32 MaverickNode::removeMarkedObjects(PxU32 timeStamp)
{
PxU32 nbRemoved=0;
PxU32 i=0;
while(i<mNbFree)
{
if(mFreeStamps[i]==timeStamp)
{
nbRemoved++;
remove(i);
}
else i++;
}
return nbRemoved;
}
void MaverickNode::shiftOrigin(const PxVec3& shift)
{
for(PxU32 i=0;i<mNbFree;i++)
{
mFreeBounds[i].minimum -= shift;
mFreeBounds[i].maximum -= shift;
mFreeTransforms[i].p -= shift;
}
}
| 4,206 | C++ | 27.619047 | 153 | 0.725392 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuBucketPruner.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_BUCKET_PRUNER_H
#define GU_BUCKET_PRUNER_H
#include "common/PxPhysXCommonConfig.h"
#include "GuPruner.h"
#include "GuSqInternal.h"
#include "GuPruningPool.h"
#include "foundation/PxHash.h"
#define FREE_PRUNER_SIZE 16
//#define USE_REGULAR_HASH_MAP
#ifdef USE_REGULAR_HASH_MAP
#include "foundation/PxHashMap.h"
#endif
namespace physx
{
class PxRenderOutput;
namespace Gu
{
typedef PxU32 BucketWord;
#if PX_VC
#pragma warning(push)
#pragma warning( disable : 4324 ) // Padding was added at the end of a structure because of a __declspec(align) value.
#endif
PX_ALIGN_PREFIX(16) struct BucketBox
{
PxVec3 mCenter;
PxU32 mData0; // Integer-encoded min value along sorting axis
PxVec3 mExtents;
PxU32 mData1; // Integer-encoded max value along sorting axis
#ifdef _DEBUG
// PT: we need the original min value for debug checks. Using the center/extents version
// fails because recomputing the min from them introduces FPU accuracy errors in the values.
float mDebugMin;
#endif
PX_FORCE_INLINE PxVec3 getMin() const
{
return mCenter - mExtents;
}
PX_FORCE_INLINE PxVec3 getMax() const
{
return mCenter + mExtents;
}
PX_FORCE_INLINE void setEmpty()
{
mCenter = PxVec3(0.0f);
mExtents = PxVec3(-PX_MAX_BOUNDS_EXTENTS);
#ifdef _DEBUG
mDebugMin = PX_MAX_BOUNDS_EXTENTS;
#endif
}
}PX_ALIGN_SUFFIX(16);
PX_ALIGN_PREFIX(16) struct BucketPrunerNode
{
BucketPrunerNode();
void classifyBoxes( float limitX, float limitZ,
PxU32 nb,
BucketBox* PX_RESTRICT boxes,
const PrunerPayload* PX_RESTRICT objects,
const PxTransform* PX_RESTRICT transforms,
BucketBox* PX_RESTRICT sortedBoxes,
PrunerPayload* PX_RESTRICT sortedObjects,
PxTransform* PX_RESTRICT sortedTransforms,
bool isCrossBucket, PxU32 sortAxis);
PX_FORCE_INLINE void initCounters()
{
for(PxU32 i=0;i<5;i++)
mCounters[i] = 0;
for(PxU32 i=0;i<5;i++)
mOffsets[i] = 0;
}
BucketWord mCounters[5]; // Number of objects in each of the 5 children
BucketWord mOffsets[5]; // Start index of objects for each of the 5 children
BucketBox mBucketBox[5]; // AABBs around objects for each of the 5 children
PxU16 mOrder[8]; // PNS: 5 children => 3 bits/index => 3*5=15 bits total, for each of the 8 canonical directions
}PX_ALIGN_SUFFIX(16);
PX_FORCE_INLINE PxU32 PxComputeHash(const PrunerPayload& payload)
{
#if PX_P64_FAMILY
// const PxU32 h0 = PxHash((const void*)payload.data[0]);
// const PxU32 h1 = PxHash((const void*)payload.data[1]);
const PxU32 h0 = PxU32(PX_MAX_U32 & payload.data[0]);
const PxU32 h1 = PxU32(PX_MAX_U32 & payload.data[1]);
return physx::PxComputeHash(PxU64(h0)|(PxU64(h1)<<32));
#else
return physx::PxComputeHash(PxU64(payload.data[0])|(PxU64(payload.data[1])<<32));
#endif
}
#ifdef USE_REGULAR_HASH_MAP
struct BucketPrunerPair : public PxUserAllocated
{
PX_FORCE_INLINE BucketPrunerPair() {}
PX_FORCE_INLINE BucketPrunerPair(PxU32 index, PxU32 stamp) : mCoreIndex(index), mTimeStamp(stamp) {}
PxU32 mCoreIndex; // index in mCoreObjects
PxU32 mTimeStamp;
};
typedef PxHashMap<PrunerPayload, BucketPrunerPair> BucketPrunerMap;
#else
struct BucketPrunerPair : public PxUserAllocated
{
PrunerPayload mData;
PxU32 mCoreIndex; // index in mCoreObjects
PxU32 mTimeStamp;
};
// Custom hash-map - currently faster than the regular hash-map (PxHashMap), in particular for 'find-and-erase' operations.
class BucketPrunerMap : public PxUserAllocated
{
public:
BucketPrunerMap();
~BucketPrunerMap();
void purge();
void shrinkMemory();
BucketPrunerPair* addPair (const PrunerPayload& payload, PxU32 coreIndex, PxU32 timeStamp);
bool removePair (const PrunerPayload& payload, PxU32& coreIndex, PxU32& timeStamp);
const BucketPrunerPair* findPair (const PrunerPayload& payload) const;
PX_FORCE_INLINE PxU32 getPairIndex(const BucketPrunerPair* pair) const
{
return (PxU32((size_t(pair) - size_t(mActivePairs)))/sizeof(BucketPrunerPair));
}
PxU32 mHashSize;
PxU32 mMask;
PxU32 mNbActivePairs;
PxU32* mHashTable;
PxU32* mNext;
BucketPrunerPair* mActivePairs;
PxU32 mReservedMemory;
PX_FORCE_INLINE BucketPrunerPair* findPair(const PrunerPayload& payload, PxU32 hashValue) const;
void removePairInternal(const PrunerPayload& payload, PxU32 hashValue, PxU32 pairIndex);
void reallocPairs();
void reserveMemory(PxU32 memSize);
};
#endif
class BucketPrunerCore : public PxUserAllocated
{
public:
PX_PHYSX_COMMON_API BucketPrunerCore(bool externalMemory=true);
PX_PHYSX_COMMON_API ~BucketPrunerCore();
void release();
void setExternalMemory(PxU32 nbObjects, PxBounds3* boxes, PrunerPayload* objects, PxTransform* transforms);
PX_PHYSX_COMMON_API bool addObject(const PrunerPayload& object, const PxBounds3& worldAABB, const PxTransform& transform, PxU32 timeStamp=0);
bool removeObject(const PrunerPayload& object, PxU32& timeStamp);
bool updateObject(const PxBounds3& worldAABB, const PrunerPayload& object, const PxTransform& transform);
// PT: look for objects marked with input timestamp everywhere in the structure, and remove them. This is the same
// as calling 'removeObject' individually for all these objects, but much more efficient. Returns number of removed objects.
PxU32 removeMarkedObjects(PxU32 timeStamp);
PX_PHYSX_COMMON_API bool raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback&) const;
PX_PHYSX_COMMON_API bool overlap(const ShapeData& queryVolume, PrunerOverlapCallback&) const;
PX_PHYSX_COMMON_API bool sweep(const ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback&) const;
void getGlobalBounds(PxBounds3& bounds) const;
void shiftOrigin(const PxVec3& shift);
void visualize(PxRenderOutput& out, PxU32 color) const;
PX_FORCE_INLINE void build() { classifyBoxes(); }
#ifdef FREE_PRUNER_SIZE
PX_FORCE_INLINE PxU32 getNbObjects() const { return mNbFree + mCoreNbObjects; }
#else
PX_FORCE_INLINE PxU32 getNbObjects() const { return mCoreNbObjects; }
#endif
// private:
PxU32 mCoreNbObjects; // Current number of objects in core arrays
PxU32 mCoreCapacity; // Capacity of core arrays
PxBounds3* mCoreBoxes; // Core array
PrunerPayload* mCoreObjects; // Core array
PxTransform* mCoreTransforms;
PxU32* mCoreRemap; // Remaps core index to sorted index, i.e. sortedIndex = mCoreRemap[coreIndex]
BucketBox* mSortedWorldBoxes; // Sorted array
PrunerPayload* mSortedObjects; // Sorted array
PxTransform* mSortedTransforms;
#ifdef FREE_PRUNER_SIZE
PxU32 mNbFree; // Current number of objects in the "free array" (mFreeObjects/mFreeBounds)
PrunerPayload mFreeObjects[FREE_PRUNER_SIZE]; // mNbFree objects are stored here
PxBounds3 mFreeBounds[FREE_PRUNER_SIZE]; // mNbFree object bounds are stored here
PxTransform mFreeTransforms[FREE_PRUNER_SIZE]; // mNbFree transforms are stored here
PxU32 mFreeStamps[FREE_PRUNER_SIZE];
#endif
BucketPrunerMap mMap; // Maps (PrunerPayload) object to corresponding index in core array.
// Objects in the free array do not appear in this map.
PxU32 mSortedNb;
PxU32 mSortedCapacity;
PxU32 mSortAxis;
BucketBox mGlobalBox; // Global bounds around all objects in the structure (except the ones in the "free" array)
BucketPrunerNode mLevel1;
BucketPrunerNode mLevel2[5];
BucketPrunerNode mLevel3[5][5];
bool mDirty;
bool mOwnMemory;
private:
PX_PHYSX_COMMON_API void classifyBoxes();
void allocateSortedMemory(PxU32 nb);
void resizeCore();
PX_FORCE_INLINE void addObjectInternal(const PrunerPayload& object, const PxBounds3& worldAABB, const PxTransform& transform, PxU32 timeStamp);
};
#if PX_VC
#pragma warning(pop)
#endif
class BucketPruner : public Pruner
{
public:
PX_PHYSX_COMMON_API BucketPruner(PxU64 contextID);
virtual ~BucketPruner();
// BasePruner
DECLARE_BASE_PRUNER_API
//~BasePruner
// Pruner
DECLARE_PRUNER_API_COMMON
//~Pruner
private:
BucketPrunerCore mCore;
PruningPool mPool;
};
}
}
#endif
| 10,356 | C | 35.46831 | 149 | 0.708285 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuRaycastTests.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxConvexMeshGeometry.h"
#include "geometry/PxTetrahedronMeshGeometry.h"
#include "geometry/PxCustomGeometry.h"
#include "GuMidphaseInterface.h"
#include "GuInternal.h"
#include "GuIntersectionRayCapsule.h"
#include "GuIntersectionRaySphere.h"
#include "GuIntersectionRayPlane.h"
#include "GuHeightFieldUtil.h"
#include "GuDistancePointSegment.h"
#include "GuConvexMesh.h"
#include "CmScaling.h"
using namespace physx;
using namespace Gu;
////////////////////////////////////////////////// raycasts //////////////////////////////////////////////////////////////////
PxU32 raycast_box(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eBOX);
PX_ASSERT(maxHits && hits);
PX_UNUSED(threadContext);
PX_UNUSED(maxHits);
PX_UNUSED(stride);
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
const PxTransform& absPose = pose;
PxVec3 localOrigin = rayOrigin - absPose.p;
localOrigin = absPose.q.rotateInv(localOrigin);
const PxVec3 localDir = absPose.q.rotateInv(rayDir);
PxVec3 localImpact;
PxReal t;
PxU32 rval = rayAABBIntersect2(-boxGeom.halfExtents, boxGeom.halfExtents, localOrigin, localDir, localImpact, t);
if(!rval)
return 0;
if(t>maxDist)
return 0;
hits->distance = t; //worldRay.orig.distance(hit.worldImpact); //should be the same, assuming ray dir was normalized!!
hits->faceIndex = 0xffffffff;
hits->u = 0.0f;
hits->v = 0.0f;
PxHitFlags outFlags = PxHitFlags(0);
if((hitFlags & PxHitFlag::ePOSITION))
{
outFlags |= PxHitFlag::ePOSITION;
if(t!=0.0f)
hits->position = absPose.transform(localImpact);
else
hits->position = rayOrigin;
}
// Compute additional information if needed
if(hitFlags & PxHitFlag::eNORMAL)
{
outFlags |= PxHitFlag::eNORMAL;
//Because rayAABBIntersect2 set t = 0 if start point inside shape
if(t == 0)
{
hits->normal = -rayDir;
}
else
{
//local space normal is:
rval--;
PxVec3 n(0.0f);
n[rval] = PxReal((localImpact[rval] > 0.0f) ? 1.0f : -1.0f);
hits->normal = absPose.q.rotate(n);
}
}
else
{
hits->normal = PxVec3(0.0f);
}
hits->flags = outFlags;
return 1;
}
PxU32 raycast_sphere(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eSPHERE);
PX_ASSERT(maxHits && hits);
PX_UNUSED(threadContext);
PX_UNUSED(maxHits);
PX_UNUSED(stride);
const PxSphereGeometry& sphereGeom = static_cast<const PxSphereGeometry&>(geom);
if(!intersectRaySphere(rayOrigin, rayDir, maxDist, pose.p, sphereGeom.radius, hits->distance, &hits->position))
return 0;
/* // PT: should be useless now
hit.distance = worldRay.orig.distance(hit.worldImpact);
if(hit.distance>maxDist)
return false;
*/
// PT: we can't avoid computing the position here since it's needed to compute the normal anyway
hits->faceIndex = 0xffffffff;
hits->u = 0.0f;
hits->v = 0.0f;
// Compute additional information if needed
PxHitFlags outFlags = PxHitFlag::ePOSITION;
if(hitFlags & PxHitFlag::eNORMAL)
{
// User requested impact normal
//Because intersectRaySphere set distance = 0 if start point inside shape
if(hits->distance == 0.0f)
{
hits->normal = -rayDir;
}
else
{
hits->normal = hits->position - pose.p;
hits->normal.normalize();
}
outFlags |= PxHitFlag::eNORMAL;
}
else
{
hits->normal = PxVec3(0.0f);
}
hits->flags = outFlags;
return 1;
}
PxU32 raycast_capsule(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eCAPSULE);
PX_ASSERT(maxHits && hits);
PX_UNUSED(threadContext);
PX_UNUSED(maxHits);
PX_UNUSED(stride);
const PxCapsuleGeometry& capsuleGeom = static_cast<const PxCapsuleGeometry&>(geom);
// TODO: PT: could we simplify this ?
Capsule capsule;
getCapsuleSegment(pose, capsuleGeom, capsule);
capsule.radius = capsuleGeom.radius;
PxReal t = 0.0f;
if(!intersectRayCapsule(rayOrigin, rayDir, capsule, t))
return 0;
if(t<0.0f || t>maxDist)
return 0;
// PT: we can't avoid computing the position here since it's needed to compute the normal anyway
hits->position = rayOrigin + rayDir*t; // PT: will be rayOrigin for t=0.0f (i.e. what the spec wants)
hits->distance = t;
hits->faceIndex = 0xffffffff;
hits->u = 0.0f;
hits->v = 0.0f;
// Compute additional information if needed
PxHitFlags outFlags = PxHitFlag::ePOSITION;
if(hitFlags & PxHitFlag::eNORMAL)
{
outFlags |= PxHitFlag::eNORMAL;
if(t==0.0f)
{
hits->normal = -rayDir;
}
else
{
PxReal capsuleT;
distancePointSegmentSquared(capsule, hits->position, &capsuleT);
capsule.computePoint(hits->normal, capsuleT);
hits->normal = hits->position - hits->normal; //this should never be zero. It should have a magnitude of the capsule radius.
hits->normal.normalize();
}
}
else
{
hits->normal = PxVec3(0.0f);
}
hits->flags = outFlags;
return 1;
}
PxU32 raycast_plane(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::ePLANE);
PX_ASSERT(maxHits && hits);
PX_UNUSED(threadContext);
PX_UNUSED(hitFlags);
PX_UNUSED(maxHits);
PX_UNUSED(stride);
PX_UNUSED(geom);
// const PxPlaneGeometry& planeGeom = static_cast<const PxPlaneGeometry&>(geom);
// Perform backface culling so that we can pick objects beyond planes
const PxPlane plane = getPlane(pose);
if(rayDir.dot(plane.n)>=0.0f)
return false;
PxReal distanceAlongLine;
if(!intersectRayPlane(rayOrigin, rayDir, plane, distanceAlongLine, &hits->position))
return 0;
/*
PxReal test = worldRay.orig.distance(hit.worldImpact);
PxReal dd;
PxVec3 pp;
PxSegmentPlaneIntersect(worldRay.orig, worldRay.orig+worldRay.dir*1000.0f, plane, dd, pp);
*/
if(distanceAlongLine<0.0f)
return 0;
if(distanceAlongLine>maxDist)
return 0;
hits->distance = distanceAlongLine;
hits->faceIndex = 0xffffffff;
hits->u = 0.0f;
hits->v = 0.0f;
hits->flags = PxHitFlag::ePOSITION|PxHitFlag::eNORMAL;
hits->normal = plane.n;
return 1;
}
PxU32 raycast_convexMesh(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eCONVEXMESH);
PX_ASSERT(maxHits && hits);
PX_ASSERT(PxAbs(rayDir.magnitudeSquared()-1)<1e-4f);
PX_UNUSED(threadContext);
PX_UNUSED(maxHits);
PX_UNUSED(stride);
const PxConvexMeshGeometry& convexGeom = static_cast<const PxConvexMeshGeometry&>(geom);
ConvexMesh* convexMesh = static_cast<ConvexMesh*>(convexGeom.convexMesh);
PxGeomRaycastHit& hit = *hits;
//scaling: transform the ray to vertex space
const PxMat34 world2vertexSkew = convexGeom.scale.getInverse() * pose.getInverse();
//ConvexMesh* cmesh = static_cast<ConvexMesh*>(convexGeom.convexMesh);
const PxU32 nPolys = convexMesh->getNbPolygonsFast();
const HullPolygonData* PX_RESTRICT polysEA = convexMesh->getPolygons();
const HullPolygonData* polys = polysEA;
const PxVec3 vrayOrig = world2vertexSkew.transform(rayOrigin);
const PxVec3 vrayDir = world2vertexSkew.rotate(rayDir);
/*
Purely convex planes based algorithm
Iterate all planes of convex, with following rules:
* determine of ray origin is inside them all or not.
* planes parallel to ray direction are immediate early out if we're on the outside side (plane normal is sep axis)
* else
- for all planes the ray direction "enters" from the front side, track the one furthest along the ray direction (A)
- for all planes the ray direction "exits" from the back side, track the one furthest along the negative ray direction (B)
if the ray origin is outside the convex and if along the ray, A comes before B, the directed line stabs the convex at A
*/
bool originInsideAllPlanes = true;
PxReal latestEntry = -FLT_MAX;
PxReal earliestExit = FLT_MAX;
// PxU32 bestPolygonIndex = 0;
hit.faceIndex = 0xffffffff;
for(PxU32 i=0;i<nPolys;i++)
{
const HullPolygonData& poly = polys[i];
const PxPlane& vertSpacePlane = poly.mPlane;
const PxReal distToPlane = vertSpacePlane.distance(vrayOrig);
const PxReal dn = vertSpacePlane.n.dot(vrayDir);
const PxReal distAlongRay = -distToPlane/dn; // PT: TODO: potential divide by zero here!
// PT: TODO: this is computed again in the last branch!
if(distToPlane > 0.0f)
originInsideAllPlanes = false; //origin not behind plane == ray starts outside the convex.
if(dn > 1E-7f) //the ray direction "exits" from the back side
{
earliestExit = physx::intrinsics::selectMin(earliestExit, distAlongRay);
}
else if(dn < -1E-7f) //the ray direction "enters" from the front side
{
if(distAlongRay > latestEntry)
{
latestEntry = distAlongRay;
hit.faceIndex = i;
}
}
else
{
//plane normal and ray dir are orthogonal
if(distToPlane > 0.0f)
return 0; //a plane is parallel with ray -- and we're outside the ray -- we definitely miss the entire convex!
}
}
if(originInsideAllPlanes) //ray starts inside convex
{
hit.distance = 0.0f;
hit.faceIndex = 0xffffffff;
hit.u = 0.0f;
hit.v = 0.0f;
hit.position = rayOrigin;
hit.normal = -rayDir;
hit.flags = PxHitFlag::eNORMAL|PxHitFlag::ePOSITION;
return 1;
}
// AP: changed to latestEntry < maxDist-1e-5f so that we have a conservatively negative result near end of ray
if(latestEntry < earliestExit && latestEntry > 0.0f && latestEntry < maxDist-1e-5f)
{
PxHitFlags outFlags = PxHitFlag::eFACE_INDEX;
if(hitFlags & PxHitFlag::ePOSITION)
{
outFlags |= PxHitFlag::ePOSITION;
const PxVec3 pointOnPlane = vrayOrig + latestEntry * vrayDir;
hit.position = pose.transform(Cm::toMat33(convexGeom.scale) * pointOnPlane);
}
hit.distance = latestEntry;
hit.u = 0.0f;
hit.v = 0.0f;
hit.normal = PxVec3(0.0f);
// Compute additional information if needed
if(hitFlags & PxHitFlag::eNORMAL)
{
outFlags |= PxHitFlag::eNORMAL;
//when we have nonuniform scaling we actually have to transform by the transpose of the inverse of vertex2worldSkew.M == transpose of world2vertexSkew:
hit.normal = world2vertexSkew.rotateTranspose(polys[hit.faceIndex].mPlane.n);
hit.normal.normalize();
}
hit.flags = outFlags;
return 1;
}
return 0;
}
PxU32 raycast_particlesystem(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::ePARTICLESYSTEM);
PX_ASSERT(PxAbs(rayDir.magnitudeSquared() - 1)<1e-4f);
PX_UNUSED(threadContext);
PX_UNUSED(stride);
PX_UNUSED(rayDir);
PX_UNUSED(pose);
PX_UNUSED(rayOrigin);
PX_UNUSED(maxHits);
PX_UNUSED(maxDist);
PX_UNUSED(hits);
PX_UNUSED(hitFlags);
PX_UNUSED(geom);
return 0;
}
PxU32 raycast_softbody(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eTETRAHEDRONMESH);
PX_ASSERT(PxAbs(rayDir.magnitudeSquared() - 1)<1e-4f);
PX_UNUSED(threadContext);
PX_UNUSED(stride);
PX_UNUSED(rayDir);
PX_UNUSED(pose);
PX_UNUSED(rayOrigin);
PX_UNUSED(maxHits);
PX_UNUSED(maxDist);
PX_UNUSED(hits);
PX_UNUSED(hitFlags);
const PxTetrahedronMeshGeometry& meshGeom = static_cast<const PxTetrahedronMeshGeometry&>(geom);
PX_UNUSED(meshGeom);
//ML: need to implement raycastTetrahedronMesh
return 0;
}
PxU32 raycast_triangleMesh(GU_RAY_FUNC_PARAMS)
{
PX_UNUSED(threadContext);
PX_ASSERT(geom.getType() == PxGeometryType::eTRIANGLEMESH);
PX_ASSERT(PxAbs(rayDir.magnitudeSquared()-1)<1e-4f);
const PxTriangleMeshGeometry& meshGeom = static_cast<const PxTriangleMeshGeometry&>(geom);
TriangleMesh* meshData = static_cast<TriangleMesh*>(meshGeom.triangleMesh);
return Midphase::raycastTriangleMesh(meshData, meshGeom, pose, rayOrigin, rayDir, maxDist, hitFlags, maxHits, hits, stride);
}
PxU32 raycast_hairsystem(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eHAIRSYSTEM);
PX_ASSERT(PxAbs(rayDir.magnitudeSquared() - 1)<1e-4f);
PX_UNUSED(threadContext);
PX_UNUSED(stride);
PX_UNUSED(rayDir);
PX_UNUSED(pose);
PX_UNUSED(rayOrigin);
PX_UNUSED(maxHits);
PX_UNUSED(maxDist);
PX_UNUSED(hits);
PX_UNUSED(hitFlags);
PX_UNUSED(geom);
return 0;
}
namespace
{
struct HFTraceSegmentCallback
{
PX_NOCOPY(HFTraceSegmentCallback)
public:
PxU8* mHits;
const PxU32 mMaxHits;
const PxU32 mStride;
PxU32 mNbHits;
const HeightFieldUtil& mUtil;
const PxTransform& mPose;
const PxVec3& mRayDir;
const PxVec3& mLocalRayDir;
const PxVec3& mLocalRayOrig;
const PxHitFlags mHitFlags;
const bool mIsDoubleSided;
HFTraceSegmentCallback( PxGeomRaycastHit* hits, PxU32 maxHits, PxU32 stride, const PxHitFlags hitFlags, const HeightFieldUtil& hfUtil, const PxTransform& pose,
const PxVec3& rayDir, const PxVec3& localRayDir, const PxVec3& localRayOrig,
bool isDoubleSided) :
mHits (reinterpret_cast<PxU8*>(hits)),
mMaxHits (maxHits),
mStride (stride),
mNbHits (0),
mUtil (hfUtil),
mPose (pose),
mRayDir (rayDir),
mLocalRayDir (localRayDir),
mLocalRayOrig (localRayOrig),
mHitFlags (hitFlags),
mIsDoubleSided (isDoubleSided)
{
PX_ASSERT(maxHits > 0);
}
PX_FORCE_INLINE bool onEvent(PxU32, const PxU32*)
{
return true;
}
PX_FORCE_INLINE bool underFaceHit(const HeightFieldUtil&, const PxVec3&, const PxVec3&, PxF32, PxF32, PxF32, PxU32)
{
return true; // true means continue traversal
}
PxAgain faceHit(const HeightFieldUtil&, const PxVec3& aHitPoint, PxU32 aTriangleIndex, PxReal u, PxReal v)
{
// traversal is strictly sorted so there's no need to sort hits
if(mNbHits >= mMaxHits)
return false; // false = stop traversal
PxGeomRaycastHit& hit = *reinterpret_cast<PxGeomRaycastHit*>(mHits);
mNbHits++;
mHits += mStride;
hit.position = aHitPoint;
hit.faceIndex = aTriangleIndex;
hit.u = u;
hit.v = v;
hit.flags = PxHitFlag::eUV | PxHitFlag::eFACE_INDEX; // UVs and face index are always set
if(mHitFlags & PxHitFlag::eNORMAL)
{
// We need the normal for the dot product.
PxVec3 normal = mPose.q.rotate(mUtil.getNormalAtShapePoint(hit.position.x, hit.position.z));
normal.normalize();
if(mIsDoubleSided && normal.dot(mRayDir) > 0.0f) // comply with normal spec for double sided (should always face opposite rayDir)
hit.normal = -normal;
else
hit.normal = normal;
hit.flags |= PxHitFlag::eNORMAL;
}
hit.distance = physx::intrinsics::selectMax(0.f, (hit.position - mLocalRayOrig).dot(mLocalRayDir));
if(mHitFlags & PxHitFlag::ePOSITION)
{
hit.position = mPose.transform(hit.position);
hit.flags |= PxHitFlag::ePOSITION;
}
return (mNbHits < mMaxHits); // true = continue traversal, false = stop traversal
}
};
}
PxU32 raycast_heightField(GU_RAY_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eHEIGHTFIELD);
PX_ASSERT(maxHits && hits);
PX_UNUSED(threadContext);
const PxHeightFieldGeometry& hfGeom = static_cast<const PxHeightFieldGeometry&>(geom);
const PxTransform invAbsPose = pose.getInverse();
const PxVec3 localRayOrig = invAbsPose.transform(rayOrigin);
const PxVec3 localRayDir = invAbsPose.rotate(rayDir);
const bool isDoubleSided = hfGeom.heightFieldFlags.isSet(PxMeshGeometryFlag::eDOUBLE_SIDED);
const bool bothSides = isDoubleSided || (hitFlags & PxHitFlag::eMESH_BOTH_SIDES);
const HeightFieldTraceUtil hfUtil(hfGeom);
PxVec3 normRayDir = localRayDir;
normRayDir.normalizeSafe(); // nothing will happen if length is < PX_NORMALIZATION_EPSILON
// pretest if we intersect HF bounds. If no early exit, if yes move the origin and shorten the maxDist
// to deal with precision issues with large maxDist
PxBounds3 hfLocalBounds;
hfUtil.computeLocalBounds(hfLocalBounds);
// PT: inflate the bounds like we do in the scene-tree (see PX-1179)
const PxVec3 center = hfLocalBounds.getCenter();
const PxVec3 extents = hfLocalBounds.getExtents() * 1.01f; //SQ_PRUNER_INFLATION;
hfLocalBounds.minimum = center - extents;
hfLocalBounds.maximum = center + extents;
PxVec3 localImpact;
PxReal t; // closest intersection, t==0 hit inside
PxU32 rval = rayAABBIntersect2(hfLocalBounds.minimum, hfLocalBounds.maximum, localRayOrig, localRayDir, localImpact, t);
// early exit we miss the AABB
if (!rval)
return 0;
if (t > maxDist)
return 0;
// PT: if eMESH_ANY is used then eMESH_MULTIPLE won't be, and we'll stop the query after 1 hit is found. There is no difference
// between 'any hit' and 'closest hit' for HFs since hits are reported in order.
HFTraceSegmentCallback callback(hits, hitFlags.isSet(PxHitFlag::eMESH_MULTIPLE) ? maxHits : 1, stride, hitFlags, hfUtil, pose,
rayDir, localRayDir, localRayOrig, isDoubleSided); // make sure we return only 1 hit without eMESH_MULTIPLE
PxReal offset = 0.0f;
PxReal maxDistOffset = maxDist;
PxVec3 localRayOrigOffset = localRayOrig;
// if we don't start inside the AABB box, offset the start pos, because of precision issues with large maxDist
if(t > 0.0f)
{
offset = t - GU_RAY_SURFACE_OFFSET;
// move the rayOrig to offset start pos
localRayOrigOffset = localRayOrig + normRayDir*offset;
}
// shorten the maxDist of the offset that was cut off and clip it
// we pick either the original maxDist, if maxDist is huge we clip it
maxDistOffset = PxMin(maxDist - offset, GU_RAY_SURFACE_OFFSET + 2.0f * PxMax(hfLocalBounds.maximum.x - hfLocalBounds.minimum.x, PxMax(hfLocalBounds.maximum.y - hfLocalBounds.minimum.y, hfLocalBounds.maximum.z - hfLocalBounds.minimum.z)));
hfUtil.traceSegment<HFTraceSegmentCallback, false, false>(localRayOrigOffset, normRayDir, maxDistOffset,
&callback, hfLocalBounds, !bothSides);
return callback.mNbHits;
}
static PxU32 raycast_custom(GU_RAY_FUNC_PARAMS)
{
const PxCustomGeometry& customGeom = static_cast<const PxCustomGeometry&>(geom);
if(customGeom.isValid())
return customGeom.callbacks->raycast(rayOrigin, rayDir, geom, pose, maxDist, hitFlags, maxHits, hits, stride, threadContext);
return 0;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PT: table is not static because it's accessed as 'extern' within Gu (bypassing the function call).
RaycastFunc gRaycastMap[] =
{
raycast_sphere,
raycast_plane,
raycast_capsule,
raycast_box,
raycast_convexMesh,
raycast_particlesystem,
raycast_softbody,
raycast_triangleMesh,
raycast_heightField,
raycast_hairsystem,
raycast_custom
};
PX_COMPILE_TIME_ASSERT(sizeof(gRaycastMap) / sizeof(gRaycastMap[0]) == PxGeometryType::eGEOMETRY_COUNT);
// PT: the function is used by external modules (Np, CCT, Sq)
const Gu::GeomRaycastTable& Gu::getRaycastFuncTable()
{
return gRaycastMap;
}
| 20,109 | C++ | 30.619497 | 239 | 0.718385 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBTree.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuAABBTreeBounds.h"
#include "GuAABBTree.h"
#include "GuAABBTreeBuildStats.h"
#include "GuBounds.h"
#include "GuAABBTreeNode.h"
#include "GuSAH.h"
#include "foundation/PxMathUtils.h"
#include "foundation/PxFPU.h"
using namespace physx;
using namespace Gu;
///////////////////////////////////////////////////////////////////////////////
void AABBTreeBounds::init(PxU32 nbBounds, const PxBounds3* bounds)
{
PX_FREE(mBounds);
// PT: we always allocate one extra box, to make sure we can safely use V4 loads on the array
mBounds = PX_ALLOCATE(PxBounds3, (nbBounds + 1), "AABBTreeBounds");
if(bounds)
PxMemCopy(mBounds, bounds, nbBounds*sizeof(PxBounds3));
}
void AABBTreeBounds::resize(PxU32 newSize, PxU32 previousSize)
{
PxBounds3* newBounds = PX_ALLOCATE(PxBounds3, (newSize + 1), "AABBTreeBounds");
if(mBounds && previousSize)
PxMemCopy(newBounds, mBounds, sizeof(PxBounds3)*previousSize);
PX_FREE(mBounds);
mBounds = newBounds;
}
void AABBTreeBounds::release()
{
if(!mUserAllocated)
PX_FREE(mBounds);
}
///////////////////////////////////////////////////////////////////////////////
NodeAllocator::NodeAllocator() : mPool(NULL), mCurrentSlabIndex(0), mTotalNbNodes(0)
{
}
NodeAllocator::~NodeAllocator()
{
release();
}
void NodeAllocator::release()
{
const PxU32 nbSlabs = mSlabs.size();
for (PxU32 i = 0; i<nbSlabs; i++)
{
Slab& s = mSlabs[i];
PX_DELETE_ARRAY(s.mPool);
}
mSlabs.reset();
mCurrentSlabIndex = 0;
mTotalNbNodes = 0;
}
void NodeAllocator::init(PxU32 nbPrimitives, PxU32 limit)
{
const PxU32 maxSize = nbPrimitives * 2 - 1; // PT: max possible #nodes for a complete tree
const PxU32 estimatedFinalSize = maxSize <= 1024 ? maxSize : maxSize / limit;
mPool = PX_NEW(AABBTreeBuildNode)[estimatedFinalSize];
PxMemZero(mPool, sizeof(AABBTreeBuildNode)*estimatedFinalSize);
// Setup initial node. Here we have a complete permutation of the app's primitives.
mPool->mNodeIndex = 0;
mPool->mNbPrimitives = nbPrimitives;
mSlabs.pushBack(Slab(mPool, 1, estimatedFinalSize));
mCurrentSlabIndex = 0;
mTotalNbNodes = 1;
}
// PT: TODO: inline this?
AABBTreeBuildNode* NodeAllocator::getBiNode()
{
mTotalNbNodes += 2;
Slab& currentSlab = mSlabs[mCurrentSlabIndex];
if (currentSlab.mNbUsedNodes + 2 <= currentSlab.mMaxNbNodes)
{
AABBTreeBuildNode* biNode = currentSlab.mPool + currentSlab.mNbUsedNodes;
currentSlab.mNbUsedNodes += 2;
return biNode;
}
else
{
// Allocate new slab
const PxU32 size = 1024;
AABBTreeBuildNode* pool = PX_NEW(AABBTreeBuildNode)[size];
PxMemZero(pool, sizeof(AABBTreeBuildNode)*size);
mSlabs.pushBack(Slab(pool, 2, size));
mCurrentSlabIndex++;
return pool;
}
}
///////////////////////////////////////////////////////////////////////////////
PxU32 Gu::reshuffle(PxU32 nb, PxU32* const PX_RESTRICT prims, const PxVec3* PX_RESTRICT centers, float splitValue, PxU32 axis)
{
// PT: to avoid calling the unsafe [] operator
const size_t ptrValue = size_t(centers) + axis*sizeof(float);
const PxVec3* PX_RESTRICT centersX = reinterpret_cast<const PxVec3*>(ptrValue);
// Loop through all node-related primitives. Their indices range from mNodePrimitives[0] to mNodePrimitives[mNbPrimitives-1].
// Those indices map the global list in the tree builder.
PxU32 nbPos = 0;
for(PxU32 i=0; i<nb; i++)
{
// Get index in global list
const PxU32 index = prims[i];
// Test against the splitting value. The primitive value is tested against the enclosing-box center.
// [We only need an approximate partition of the enclosing box here.]
const float primitiveValue = centersX[index].x;
PX_ASSERT(primitiveValue == centers[index][axis]);
// Reorganize the list of indices in this order: positive - negative.
if (primitiveValue > splitValue)
{
// Swap entries
prims[i] = prims[nbPos];
prims[nbPos] = index;
// Count primitives assigned to positive space
nbPos++;
}
}
return nbPos;
}
static PxU32 split(const PxBounds3& box, PxU32 nb, PxU32* const PX_RESTRICT prims, PxU32 axis, const AABBTreeBuildParams& params)
{
// Get node split value
float splitValue = 0.0f;
//float defaultSplitValue = box.getCenter(axis);
//(void)defaultSplitValue;
if(params.mBuildStrategy==BVH_SPLATTER_POINTS_SPLIT_GEOM_CENTER)
{
// PT: experimental attempt at replicating BV4_SPLATTER_POINTS_SPLIT_GEOM_CENTER, but with boxes instead of triangles.
const PxBounds3* bounds = params.mBounds->getBounds();
for(PxU32 i=0;i<nb;i++)
{
const PxBounds3& current = bounds[prims[i]];
splitValue += current.getCenter(axis);
// splitValue += (*VP.Vertex[0])[axis];
// splitValue += (*VP.Vertex[1])[axis];
// splitValue += (*VP.Vertex[2])[axis];
}
// splitValue /= float(nb*3);
splitValue /= float(nb);
}
else
{
// Default split value = middle of the axis (using only the box)
splitValue = box.getCenter(axis);
}
return reshuffle(nb, prims, params.mCache, splitValue, axis);
}
void AABBTreeBuildNode::subdivide(const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices)
{
PxU32* const PX_RESTRICT primitives = indices + mNodeIndex;
const PxU32 nbPrims = mNbPrimitives;
// Compute global box & means for current node. The box is stored in mBV.
Vec4V meansV;
{
const PxBounds3* PX_RESTRICT boxes = params.mBounds->getBounds();
PX_ASSERT(boxes);
PX_ASSERT(primitives);
PX_ASSERT(nbPrims);
Vec4V minV = V4LoadU(&boxes[primitives[0]].minimum.x);
Vec4V maxV = V4LoadU(&boxes[primitives[0]].maximum.x);
meansV = V4LoadU(¶ms.mCache[primitives[0]].x);
for (PxU32 i = 1; i<nbPrims; i++)
{
const PxU32 index = primitives[i];
const Vec4V curMinV = V4LoadU(&boxes[index].minimum.x);
const Vec4V curMaxV = V4LoadU(&boxes[index].maximum.x);
meansV = V4Add(meansV, V4LoadU(¶ms.mCache[index].x));
minV = V4Min(minV, curMinV);
maxV = V4Max(maxV, curMaxV);
}
StoreBounds(mBV, minV, maxV);
const float coeff = 1.0f / float(nbPrims);
meansV = V4Scale(meansV, FLoad(coeff));
}
// Check the user-defined limit. Also ensures we stop subdividing if we reach a leaf node.
if (nbPrims <= params.mLimit)
return;
bool validSplit = true;
PxU32 nbPos;
{
// Compute variances
Vec4V varsV = V4Zero();
for (PxU32 i = 0; i<nbPrims; i++)
{
const PxU32 index = primitives[i];
Vec4V centerV = V4LoadU(¶ms.mCache[index].x);
centerV = V4Sub(centerV, meansV);
centerV = V4Mul(centerV, centerV);
varsV = V4Add(varsV, centerV);
}
const float coeffNb1 = 1.0f / float(nbPrims - 1);
varsV = V4Scale(varsV, FLoad(coeffNb1));
PX_ALIGN(16, PxVec4) vars;
V4StoreA(varsV, &vars.x);
// Choose axis with greatest variance
const PxU32 axis = PxLargestAxis(PxVec3(vars.x, vars.y, vars.z));
// Split along the axis
nbPos = split(mBV, nbPrims, primitives, axis, params);
// Check split validity
if (!nbPos || nbPos == nbPrims)
validSplit = false;
}
// Check the subdivision has been successful
if (!validSplit)
{
// Here, all boxes lie in the same sub-space. Two strategies:
// - if we are over the split limit, make an arbitrary 50-50 split
// - else stop subdividing
if (nbPrims>params.mLimit)
{
nbPos = nbPrims >> 1;
}
else return;
}
// Now create children and assign their pointers.
mPos = allocator.getBiNode();
stats.increaseCount(2);
// Assign children
PX_ASSERT(!isLeaf());
AABBTreeBuildNode* Pos = const_cast<AABBTreeBuildNode*>(mPos);
AABBTreeBuildNode* Neg = Pos + 1;
Pos->mNodeIndex = mNodeIndex;
Pos->mNbPrimitives = nbPos;
Neg->mNodeIndex = mNodeIndex + nbPos;
Neg->mNbPrimitives = mNbPrimitives - nbPos;
}
void AABBTreeBuildNode::_buildHierarchy(const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& nodeBase, PxU32* const indices)
{
// Subdivide current node
subdivide(params, stats, nodeBase, indices);
// Recurse
if (!isLeaf())
{
AABBTreeBuildNode* Pos = const_cast<AABBTreeBuildNode*>(getPos());
PX_ASSERT(Pos);
AABBTreeBuildNode* Neg = Pos + 1;
Pos->_buildHierarchy(params, stats, nodeBase, indices);
Neg->_buildHierarchy(params, stats, nodeBase, indices);
}
stats.mTotalPrims += mNbPrimitives;
}
void AABBTreeBuildNode::subdivideSAH(const AABBTreeBuildParams& params, SAH_Buffers& buffers, BuildStats& stats, NodeAllocator& allocator, PxU32* const indices)
{
PxU32* const PX_RESTRICT primitives = indices + mNodeIndex;
const PxU32 nbPrims = mNbPrimitives;
// Compute global box for current node. The box is stored in mBV.
computeGlobalBox(mBV, nbPrims, params.mBounds->getBounds(), primitives);
// Check the user-defined limit. Also ensures we stop subdividing if we reach a leaf node.
if (nbPrims <= params.mLimit)
return;
/////
PxU32 leftCount;
if(!buffers.split(leftCount, nbPrims, primitives, params.mBounds->getBounds(), params.mCache))
{
// Invalid split => fallback to previous strategy
subdivide(params, stats, allocator, indices);
return;
}
/////
// Now create children and assign their pointers.
mPos = allocator.getBiNode();
stats.increaseCount(2);
// Assign children
PX_ASSERT(!isLeaf());
AABBTreeBuildNode* Pos = const_cast<AABBTreeBuildNode*>(mPos);
AABBTreeBuildNode* Neg = Pos + 1;
Pos->mNodeIndex = mNodeIndex;
Pos->mNbPrimitives = leftCount;
Neg->mNodeIndex = mNodeIndex + leftCount;
Neg->mNbPrimitives = mNbPrimitives - leftCount;
}
void AABBTreeBuildNode::_buildHierarchySAH(const AABBTreeBuildParams& params, SAH_Buffers& sah, BuildStats& stats, NodeAllocator& nodeBase, PxU32* const indices)
{
// Subdivide current node
subdivideSAH(params, sah, stats, nodeBase, indices);
// Recurse
if (!isLeaf())
{
AABBTreeBuildNode* Pos = const_cast<AABBTreeBuildNode*>(getPos());
PX_ASSERT(Pos);
AABBTreeBuildNode* Neg = Pos + 1;
Pos->_buildHierarchySAH(params, sah, stats, nodeBase, indices);
Neg->_buildHierarchySAH(params, sah, stats, nodeBase, indices);
}
stats.mTotalPrims += mNbPrimitives;
}
///////////////////////////////////////////////////////////////////////////////
static PxU32* initAABBTreeBuild(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats)
{
const PxU32 numPrimitives = params.mNbPrimitives;
if(!numPrimitives)
return NULL;
// Init stats
stats.setCount(1);
// Initialize indices. This list will be modified during build.
PxU32* indices = PX_ALLOCATE(PxU32, numPrimitives, "AABB tree indices");
// Identity permutation
for(PxU32 i=0;i<numPrimitives;i++)
indices[i] = i;
// Allocate a pool of nodes
nodeAllocator.init(numPrimitives, params.mLimit);
// Compute box centers only once and cache them
params.mCache = PX_ALLOCATE(PxVec3, (numPrimitives+1), "cache");
const PxBounds3* PX_RESTRICT boxes = params.mBounds->getBounds();
const float half = 0.5f;
const FloatV halfV = FLoad(half);
for(PxU32 i=0;i<numPrimitives;i++)
{
const Vec4V curMinV = V4LoadU(&boxes[i].minimum.x);
const Vec4V curMaxV = V4LoadU(&boxes[i].maximum.x);
const Vec4V centerV = V4Scale(V4Add(curMaxV, curMinV), halfV);
V4StoreU(centerV, ¶ms.mCache[i].x);
}
return indices;
}
PxU32* Gu::buildAABBTree(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats)
{
// initialize the build first
PxU32* indices = initAABBTreeBuild(params, nodeAllocator, stats);
if(!indices)
return NULL;
// Build the hierarchy
if(params.mBuildStrategy==BVH_SAH)
{
SAH_Buffers buffers(params.mNbPrimitives);
nodeAllocator.mPool->_buildHierarchySAH(params, buffers, stats, nodeAllocator, indices);
}
else
nodeAllocator.mPool->_buildHierarchy(params, stats, nodeAllocator, indices);
return indices;
}
void Gu::flattenTree(const NodeAllocator& nodeAllocator, BVHNode* dest, const PxU32* remap)
{
// PT: gathers all build nodes allocated so far and flatten them to a linear destination array of smaller runtime nodes
PxU32 offset = 0;
const PxU32 nbSlabs = nodeAllocator.mSlabs.size();
for(PxU32 s=0;s<nbSlabs;s++)
{
const NodeAllocator::Slab& currentSlab = nodeAllocator.mSlabs[s];
AABBTreeBuildNode* pool = currentSlab.mPool;
for(PxU32 i=0;i<currentSlab.mNbUsedNodes;i++)
{
dest[offset].mBV = pool[i].mBV;
if(pool[i].isLeaf())
{
PxU32 index = pool[i].mNodeIndex;
if(remap)
index = remap[index];
const PxU32 nbPrims = pool[i].getNbPrimitives();
PX_ASSERT(nbPrims<16);
dest[offset].mData = (index<<5)|((nbPrims&15)<<1)|1;
}
else
{
PX_ASSERT(pool[i].mPos);
PxU32 localNodeIndex = 0xffffffff;
PxU32 nodeBase = 0;
for(PxU32 j=0;j<nbSlabs;j++)
{
if(pool[i].mPos >= nodeAllocator.mSlabs[j].mPool && pool[i].mPos < nodeAllocator.mSlabs[j].mPool + nodeAllocator.mSlabs[j].mNbUsedNodes)
{
localNodeIndex = PxU32(pool[i].mPos - nodeAllocator.mSlabs[j].mPool);
break;
}
nodeBase += nodeAllocator.mSlabs[j].mNbUsedNodes;
}
const PxU32 nodeIndex = nodeBase + localNodeIndex;
dest[offset].mData = nodeIndex << 1;
}
offset++;
}
}
}
void Gu::buildAABBTree(PxU32 nbBounds, const AABBTreeBounds& bounds, PxArray<BVHNode>& tree)
{
PX_SIMD_GUARD
// build the BVH
BuildStats stats;
NodeAllocator nodeAllocator;
PxU32* indices = buildAABBTree(AABBTreeBuildParams(1, nbBounds, &bounds), nodeAllocator, stats);
PX_ASSERT(indices);
// store the computed hierarchy
tree.resize(stats.getCount());
PX_ASSERT(tree.size() == nodeAllocator.mTotalNbNodes);
// store the results into BVHNode list
flattenTree(nodeAllocator, tree.begin(), indices);
PX_FREE(indices); // PT: we don't need the indices for a complete tree
}
///////////////////////////////////////////////////////////////////////////////
// Progressive building
class Gu::FIFOStack : public PxUserAllocated
{
public:
FIFOStack() : mStack("SQFIFOStack"), mCurIndex(0) {}
~FIFOStack() {}
PX_FORCE_INLINE PxU32 getNbEntries() const { return mStack.size(); }
PX_FORCE_INLINE void push(AABBTreeBuildNode* entry) { mStack.pushBack(entry); }
bool pop(AABBTreeBuildNode*& entry);
private:
PxArray<AABBTreeBuildNode*> mStack;
PxU32 mCurIndex; //!< Current index within the container
};
bool Gu::FIFOStack::pop(AABBTreeBuildNode*& entry)
{
const PxU32 NbEntries = mStack.size(); // Get current number of entries
if (!NbEntries)
return false; // Can be NULL when no value has been pushed. This is an invalid pop call.
entry = mStack[mCurIndex++]; // Get oldest entry, move to next one
if (mCurIndex == NbEntries)
{
// All values have been poped
mStack.clear();
mCurIndex = 0;
}
return true;
}
//~Progressive building
///////////////////////////////////////////////////////////////////////////////
BVHPartialRefitData::BVHPartialRefitData() : mParentIndices(NULL), mUpdateMap(NULL), mRefitHighestSetWord(0)
{
}
BVHPartialRefitData::~BVHPartialRefitData()
{
releasePartialRefitData(true);
}
void BVHPartialRefitData::releasePartialRefitData(bool clearRefitMap)
{
PX_FREE(mParentIndices);
PX_FREE(mUpdateMap);
if(clearRefitMap)
mRefitBitmask.clearAll();
mRefitHighestSetWord = 0;
}
static void createParentArray(PxU32 totalNbNodes, PxU32* parentIndices, const BVHNode* parentNode, const BVHNode* currentNode, const BVHNode* root)
{
const PxU32 parentIndex = PxU32(parentNode - root);
const PxU32 currentIndex = PxU32(currentNode - root);
PX_ASSERT(parentIndex<totalNbNodes);
PX_ASSERT(currentIndex<totalNbNodes);
PX_UNUSED(totalNbNodes);
parentIndices[currentIndex] = parentIndex;
if(!currentNode->isLeaf())
{
createParentArray(totalNbNodes, parentIndices, currentNode, currentNode->getPos(root), root);
createParentArray(totalNbNodes, parentIndices, currentNode, currentNode->getNeg(root), root);
}
}
PxU32* BVHPartialRefitData::getParentIndices()
{
// PT: lazy-create parent array. Memory is not wasted for purely static trees, or dynamic trees that only do "full refit".
if(!mParentIndices)
{
mParentIndices = PX_ALLOCATE(PxU32, mNbNodes, "AABB parent indices");
createParentArray(mNbNodes, mParentIndices, mNodes, mNodes, mNodes);
}
return mParentIndices;
}
void BVHPartialRefitData::createUpdateMap(PxU32 nbObjects)
{
// PT: we need an "update map" for PxBVH
// PT: TODO: consider refactoring with the AABBtree version
PX_FREE(mUpdateMap);
if(!nbObjects)
return;
mUpdateMap = PX_ALLOCATE(PxU32, nbObjects, "UpdateMap");
PxMemSet(mUpdateMap, 0xff, sizeof(PxU32)*nbObjects);
const PxU32 nbNodes = mNbNodes;
const BVHNode* nodes = mNodes;
const PxU32* indices = mIndices;
for(TreeNodeIndex i=0;i<nbNodes;i++)
{
if(nodes[i].isLeaf())
{
const PxU32 nbPrims = nodes[i].getNbRuntimePrimitives();
if(indices)
{
// PT: with multiple primitives per node, several mapping entries will point to the same node.
PX_ASSERT(nbPrims<16);
for(PxU32 j=0;j<nbPrims;j++)
{
const PxU32 index = nodes[i].getPrimitives(indices)[j];
PX_ASSERT(index<nbObjects);
mUpdateMap[index] = i;
}
}
else
{
PX_ASSERT(nbPrims==1);
const PxU32 index = nodes[i].getPrimitiveIndex();
PX_ASSERT(index<nbObjects);
mUpdateMap[index] = i;
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
static PX_FORCE_INLINE PxU32 BitsToDwords(PxU32 nb_bits)
{
return (nb_bits>>5) + ((nb_bits&31) ? 1 : 0);
}
bool BitArray::init(PxU32 nb_bits)
{
mSize = BitsToDwords(nb_bits);
// Get ram for n bits
PX_FREE(mBits);
mBits = PX_ALLOCATE(PxU32, mSize, "BitArray::mBits");
// Set all bits to 0
clearAll();
return true;
}
void BitArray::resize(PxU32 maxBitNumber)
{
const PxU32 newSize = BitsToDwords(maxBitNumber);
if (newSize <= mSize)
return;
PxU32* newBits = PX_ALLOCATE(PxU32, newSize, "BitArray::mBits");
PxMemZero(newBits + mSize, (newSize - mSize) * sizeof(PxU32));
PxMemCopy(newBits, mBits, mSize*sizeof(PxU32));
PX_FREE(mBits);
mBits = newBits;
mSize = newSize;
}
///////////////////////////////////////////////////////////////////////////////
static PX_FORCE_INLINE PxU32 getNbPrimitives(PxU32 data) { return (data>>1)&15; }
static PX_FORCE_INLINE const PxU32* getPrimitives(const PxU32* base, PxU32 data) { return base + (data>>5); }
static PX_FORCE_INLINE const BVHNode* getPos(const BVHNode* base, PxU32 data) { return base + (data>>1); }
static PX_FORCE_INLINE PxU32 isLeaf(PxU32 data) { return data&1; }
template<const bool hasIndices>
static PX_FORCE_INLINE void refitNode(BVHNode* PX_RESTRICT current, const PxBounds3* PX_RESTRICT boxes, const PxU32* PX_RESTRICT indices, BVHNode* PX_RESTRICT const nodeBase)
{
// PT: we can safely use V4 loads on both boxes and nodes here:
// - it's safe on boxes because we allocated one extra box in the pruning pool
// - it's safe on nodes because there's always some data within the node, after the BV
const PxU32 data = current->mData;
Vec4V resultMinV, resultMaxV;
if(isLeaf(data))
{
const PxU32 nbPrims = getNbPrimitives(data);
if(nbPrims)
{
if(hasIndices)
{
const PxU32* primitives = getPrimitives(indices, data);
resultMinV = V4LoadU(&boxes[*primitives].minimum.x);
resultMaxV = V4LoadU(&boxes[*primitives].maximum.x);
if(nbPrims>1)
{
const PxU32* last = primitives + nbPrims;
primitives++;
while(primitives!=last)
{
resultMinV = V4Min(resultMinV, V4LoadU(&boxes[*primitives].minimum.x));
resultMaxV = V4Max(resultMaxV, V4LoadU(&boxes[*primitives].maximum.x));
primitives++;
}
}
}
else
{
PX_ASSERT(nbPrims==1);
const PxU32 primIndex = data>>5;
resultMinV = V4LoadU(&boxes[primIndex].minimum.x);
resultMaxV = V4LoadU(&boxes[primIndex].maximum.x);
}
}
else
{
// Might happen after a node has been invalidated
const float max = GU_EMPTY_BOUNDS_EXTENTS;
resultMinV = V4Load(max);
resultMaxV = V4Load(-max);
}
}
else
{
const BVHNode* pos = getPos(nodeBase, data);
const BVHNode* neg = pos+1;
const PxBounds3& posBox = pos->mBV;
const PxBounds3& negBox = neg->mBV;
resultMinV = V4Min(V4LoadU(&posBox.minimum.x), V4LoadU(&negBox.minimum.x));
// resultMaxV = V4Max(V4LoadU(&posBox.maximum.x), V4LoadU(&negBox.maximum.x));
#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
Vec4V posMinV = V4LoadU(&posBox.minimum.z);
Vec4V negMinV = V4LoadU(&negBox.minimum.z);
posMinV = _mm_shuffle_ps(posMinV, posMinV, _MM_SHUFFLE(0, 3, 2, 1));
negMinV = _mm_shuffle_ps(negMinV, negMinV, _MM_SHUFFLE(0, 3, 2, 1));
resultMaxV = V4Max(posMinV, negMinV);
#else
// PT: fixes the perf issue but not really convincing
resultMaxV = Vec4V_From_Vec3V(V3Max(V3LoadU(&posBox.maximum.x), V3LoadU(&negBox.maximum.x)));
#endif
}
// PT: the V4 stores overwrite the data after the BV, but we just put it back afterwards
V4StoreU(resultMinV, ¤t->mBV.minimum.x);
V4StoreU(resultMaxV, ¤t->mBV.maximum.x);
current->mData = data;
}
template<const bool hasIndices>
static void refitLoop(const PxBounds3* PX_RESTRICT boxes, BVHNode* const PX_RESTRICT nodeBase, const PxU32* PX_RESTRICT indices, PxU32 nbNodes)
{
PX_ASSERT(boxes);
PX_ASSERT(nodeBase);
// Bottom-up update
PxU32 index = nbNodes;
while(index--)
{
BVHNode* current = nodeBase + index;
if(index)
PxPrefetch(current - 1);
// PxBounds3 before = current->mBV;
if(hasIndices)
refitNode<1>(current, boxes, indices, nodeBase);
else
refitNode<0>(current, boxes, indices, nodeBase);
// if(current->mBV.minimum==before.minimum && current->mBV.maximum==before.maximum)
// break;
}
}
void BVHCoreData::fullRefit(const PxBounds3* boxes)
{
if(mIndices)
refitLoop<1>(boxes, mNodes, mIndices, mNbNodes);
else
refitLoop<0>(boxes, mNodes, mIndices, mNbNodes);
}
void BVHPartialRefitData::markNodeForRefit(TreeNodeIndex nodeIndex)
{
BitArray* PX_RESTRICT refitBitmask = &mRefitBitmask;
if(!refitBitmask->getBits())
refitBitmask->init(mNbNodes);
PX_ASSERT(nodeIndex<mNbNodes);
const PxU32* PX_RESTRICT parentIndices = getParentIndices();
PxU32 refitHighestSetWord = mRefitHighestSetWord;
PxU32 currentIndex = nodeIndex;
while(1)
{
PX_ASSERT(currentIndex<mNbNodes);
if(refitBitmask->isSet(currentIndex))
{
// We can early exit if we already visited the node!
goto Exit;
}
else
{
refitBitmask->setBit(currentIndex);
const PxU32 currentMarkedWord = currentIndex>>5;
refitHighestSetWord = PxMax(refitHighestSetWord, currentMarkedWord);
const PxU32 parentIndex = parentIndices[currentIndex];
PX_ASSERT(parentIndex == 0 || parentIndex < currentIndex);
if(currentIndex == parentIndex)
break;
currentIndex = parentIndex;
}
}
Exit:
mRefitHighestSetWord = refitHighestSetWord;
}
#define FIRST_VERSION
#ifdef FIRST_VERSION
template<const bool hasIndices>
static void refitMarkedLoop(const PxBounds3* PX_RESTRICT boxes, BVHNode* const PX_RESTRICT nodeBase, const PxU32* PX_RESTRICT indices, PxU32* PX_RESTRICT bits, PxU32 nbToGo)
{
#ifdef _DEBUG
PxU32 nbRefit=0;
#endif
PxU32 size = nbToGo;
while(size--)
{
// Test 32 bits at a time
const PxU32 currentBits = bits[size];
if(!currentBits)
continue;
PxU32 index = (size+1)<<5;
PxU32 mask = PxU32(1<<((index-1)&31));
PxU32 count=32;
while(count--)
{
index--;
PxPrefetch(nodeBase + index);
PX_ASSERT(size==index>>5);
PX_ASSERT(mask==PxU32(1<<(index&31)));
if(currentBits & mask)
{
if(hasIndices)
refitNode<1>(nodeBase + index, boxes, indices, nodeBase);
else
refitNode<0>(nodeBase + index, boxes, indices, nodeBase);
#ifdef _DEBUG
nbRefit++;
#endif
}
mask>>=1;
}
bits[size] = 0;
}
}
void BVHPartialRefitData::refitMarkedNodes(const PxBounds3* boxes)
{
if(!mRefitBitmask.getBits())
return; // No refit needed
{
/*const*/ PxU32* bits = const_cast<PxU32*>(mRefitBitmask.getBits());
PxU32 size = mRefitHighestSetWord+1;
#ifdef _DEBUG
if(1)
{
const PxU32 totalSize = mRefitBitmask.getSize();
for(PxU32 i=size;i<totalSize;i++)
{
PX_ASSERT(!bits[i]);
}
}
#endif
if(mIndices)
refitMarkedLoop<1>(boxes, mNodes, mIndices, bits, size);
else
refitMarkedLoop<0>(boxes, mNodes, mIndices, bits, size);
mRefitHighestSetWord = 0;
// mRefitBitmask.clearAll();
}
}
#endif
//#define SECOND_VERSION
#ifdef SECOND_VERSION
void BVHPartialRefitData::refitMarkedNodes(const PxBounds3* boxes)
{
/*const*/ PxU32* bits = const_cast<PxU32*>(mRefitBitmask.getBits());
if(!bits)
return; // No refit needed
const PxU32 lastSetBit = mRefitBitmask.findLast();
const PxU32* indices = mIndices;
BVHNode* const nodeBase = mNodes;
// PT: ### bitmap iterator pattern
for(PxU32 w = 0; w <= lastSetBit >> 5; ++w)
{
for(PxU32 b = bits[w]; b; b &= b-1)
{
const PxU32 index = (PxU32)(w<<5|PxLowestSetBit(b));
while(size--)
{
// Test 32 bits at a time
const PxU32 currentBits = bits[size];
if(!currentBits)
continue;
PxU32 index = (size+1)<<5;
PxU32 mask = PxU32(1<<((index-1)&31));
PxU32 count=32;
while(count--)
{
index--;
PxPrefetch(nodeBase + index);
PX_ASSERT(size==index>>5);
PX_ASSERT(mask==PxU32(1<<(index&31)));
if(currentBits & mask)
{
refitNode(nodeBase + index, boxes, indices, nodeBase);
#ifdef _DEBUG
nbRefit++;
#endif
}
mask>>=1;
}
bits[size] = 0;
}
mRefitHighestSetWord = 0;
// mRefitBitmask.clearAll();
}
}
#endif
///////////////////////////////////////////////////////////////////////////////
AABBTree::AABBTree() : mTotalPrims(0)
{
// Progressive building
mStack = NULL;
//~Progressive building
}
AABBTree::~AABBTree()
{
release(false);
}
void AABBTree::release(bool clearRefitMap)
{
// Progressive building
PX_DELETE(mStack);
//~Progressive building
releasePartialRefitData(clearRefitMap);
// PT: TODO: move some to BVHCoreData dtor
PX_DELETE_ARRAY(mNodes);
PX_FREE(mIndices);
mNbNodes = 0;
mNbIndices = 0;
}
// Initialize nodes/indices from the input tree merge data
void AABBTree::initTree(const AABBTreeMergeData& tree)
{
PX_ASSERT(mIndices == NULL);
PX_ASSERT(mNodes == NULL);
PX_ASSERT(mParentIndices == NULL);
// allocate,copy indices
mIndices = PX_ALLOCATE(PxU32, tree.mNbIndices, "AABB tree indices");
mNbIndices = tree.mNbIndices;
PxMemCopy(mIndices, tree.mIndices, sizeof(PxU32)*tree.mNbIndices);
// allocate,copy nodes
mNodes = PX_NEW(BVHNode)[tree.mNbNodes];
mNbNodes = tree.mNbNodes;
PxMemCopy(mNodes, tree.mNodes, sizeof(BVHNode)*tree.mNbNodes);
}
// Shift indices of the tree by offset. Used for merged trees, when initial indices needs to be shifted to match indices in current pruning pool
void AABBTree::shiftIndices(PxU32 offset)
{
for (PxU32 i = 0; i < mNbIndices; i++)
{
mIndices[i] += offset;
}
}
bool AABBTree::buildInit(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats)
{
// Checkings
const PxU32 nbPrimitives = params.mNbPrimitives;
if(!nbPrimitives)
return false;
// Release previous tree
release();
// Initialize indices. This list will be modified during build.
mNbIndices = nbPrimitives;
PxU32* indices = initAABBTreeBuild(params, nodeAllocator, stats);
if(!indices)
return false;
PX_ASSERT(!mIndices);
mIndices = indices;
return true;
}
void AABBTree::buildEnd(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, const BuildStats& stats)
{
PX_FREE(params.mCache);
// Get back total number of nodes
mNbNodes = stats.getCount();
mTotalPrims = stats.mTotalPrims;
mNodes = PX_NEW(BVHNode)[mNbNodes];
PX_ASSERT(mNbNodes==nodeAllocator.mTotalNbNodes);
flattenTree(nodeAllocator, mNodes);
nodeAllocator.release();
}
bool AABBTree::build(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator)
{
const PxU32 nbPrimitives = params.mNbPrimitives;
if(!nbPrimitives)
return false;
// Release previous tree
release();
BuildStats stats;
mNbIndices = nbPrimitives;
mIndices = buildAABBTree(params, nodeAllocator, stats);
if(!mIndices)
return false;
buildEnd(params, nodeAllocator, stats);
return true;
}
void AABBTree::shiftOrigin(const PxVec3& shift)
{
BVHNode* const nodeBase = mNodes;
const PxU32 totalNbNodes = mNbNodes;
for(PxU32 i=0; i<totalNbNodes; i++)
{
BVHNode& current = nodeBase[i];
if((i+1) < totalNbNodes)
PxPrefetch(nodeBase + i + 1);
current.mBV.minimum -= shift;
current.mBV.maximum -= shift;
}
}
// Progressive building
static PxU32 incrementalBuildHierarchy(FIFOStack& stack, AABBTreeBuildNode* node, const AABBTreeBuildParams& params, BuildStats& stats, NodeAllocator& nodeBase, PxU32* const indices)
{
node->subdivide(params, stats, nodeBase, indices);
if(!node->isLeaf())
{
AABBTreeBuildNode* pos = const_cast<AABBTreeBuildNode*>(node->getPos());
PX_ASSERT(pos);
AABBTreeBuildNode* neg = pos + 1;
stack.push(neg);
stack.push(pos);
}
stats.mTotalPrims += node->mNbPrimitives;
return node->mNbPrimitives;
}
PxU32 AABBTree::progressiveBuild(const AABBTreeBuildParams& params, NodeAllocator& nodeAllocator, BuildStats& stats, PxU32 progress, PxU32 limit)
{
if(progress==0)
{
if(!buildInit(params, nodeAllocator, stats))
return PX_INVALID_U32;
mStack = PX_NEW(FIFOStack);
mStack->push(nodeAllocator.mPool);
return progress++;
}
else if(progress==1)
{
PxU32 stackCount = mStack->getNbEntries();
if(stackCount)
{
PxU32 Total = 0;
const PxU32 Limit = limit;
while(Total<Limit)
{
AABBTreeBuildNode* Entry;
if(mStack->pop(Entry))
Total += incrementalBuildHierarchy(*mStack, Entry, params, stats, nodeAllocator, mIndices);
else
break;
}
return progress;
}
buildEnd(params, nodeAllocator, stats);
PX_DELETE(mStack);
return 0; // Done!
}
return PX_INVALID_U32;
}
//~Progressive building
PX_FORCE_INLINE static void setLeafData(PxU32& leafData, const BVHNode& node, const PxU32 indicesOffset)
{
const PxU32 index = indicesOffset + (node.mData >> 5);
const PxU32 nbPrims = node.getNbPrimitives();
PX_ASSERT(nbPrims < 16);
leafData = (index << 5) | ((nbPrims & 15) << 1) | 1;
}
// Copy the tree into nodes. Update node indices, leaf indices.
void AABBTree::addRuntimeChilds(PxU32& nodeIndex, const AABBTreeMergeData& treeParams)
{
PX_ASSERT(nodeIndex < mNbNodes + treeParams.mNbNodes + 1);
const PxU32 baseNodeIndex = nodeIndex;
// copy the src tree into dest tree nodes, update its data
for (PxU32 i = 0; i < treeParams.mNbNodes; i++)
{
PX_ASSERT(nodeIndex < mNbNodes + treeParams.mNbNodes + 1);
mNodes[nodeIndex].mBV = treeParams.mNodes[i].mBV;
if (treeParams.mNodes[i].isLeaf())
{
setLeafData(mNodes[nodeIndex].mData, treeParams.mNodes[i], mNbIndices);
}
else
{
const PxU32 srcNodeIndex = baseNodeIndex + (treeParams.mNodes[i].getPosIndex());
mNodes[nodeIndex].mData = srcNodeIndex << 1;
mParentIndices[srcNodeIndex] = nodeIndex;
mParentIndices[srcNodeIndex + 1] = nodeIndex;
}
nodeIndex++;
}
}
// Merge tree into targetNode, where target node is a leaf
// 1. Allocate new nodes/parent, copy all the nodes/parents
// 2. Create new node at the end, copy the data from target node
// 3. Copy the merge tree after the new node, create the parent map for them, update the leaf indices
// Schematic view:
// Target Nodes: ...Tn...
// Input tree: R1->Rc0, Rc1...
// Merged tree: ...Tnc->...->Nc0,R1->Rc0,Rc1...
// where new node: Nc0==Tn and Tnc is not a leaf anymore and points to Nc0
void AABBTree::mergeRuntimeLeaf(BVHNode& targetNode, const AABBTreeMergeData& treeParams, PxU32 targetMergeNodeIndex)
{
PX_ASSERT(mParentIndices);
PX_ASSERT(targetNode.isLeaf());
// 1. Allocate new nodes/parent, copy all the nodes/parents
// allocate new runtime pool with max combine number of nodes
// we allocate only 1 additional node each merge
BVHNode* newRuntimePool = PX_NEW(BVHNode)[mNbNodes + treeParams.mNbNodes + 1];
PxU32* newParentIndices = PX_ALLOCATE(PxU32, (mNbNodes + treeParams.mNbNodes + 1), "AABB parent indices");
// copy the whole target nodes, we will add the new node at the end together with the merge tree
PxMemCopy(newRuntimePool, mNodes, sizeof(BVHNode)*(mNbNodes));
PxMemCopy(newParentIndices, mParentIndices, sizeof(PxU32)*(mNbNodes));
// 2. Create new node at the end, copy the data from target node
PxU32 nodeIndex = mNbNodes;
// copy the targetNode at the end of the new nodes
newRuntimePool[nodeIndex].mBV = targetNode.mBV;
newRuntimePool[nodeIndex].mData = targetNode.mData;
// update the parent information
newParentIndices[nodeIndex] = targetMergeNodeIndex;
// mark for refit
if (mRefitBitmask.getBits() && mRefitBitmask.isSet(targetMergeNodeIndex))
{
mRefitBitmask.setBit(nodeIndex);
const PxU32 currentMarkedWord = nodeIndex >> 5;
mRefitHighestSetWord = PxMax(mRefitHighestSetWord, currentMarkedWord);
}
// swap pointers
PX_DELETE_ARRAY(mNodes);
mNodes = newRuntimePool;
PX_FREE(mParentIndices);
mParentIndices = newParentIndices;
// 3. Copy the merge tree after the new node, create the parent map for them, update the leaf indices
nodeIndex++;
addRuntimeChilds(nodeIndex, treeParams);
PX_ASSERT(nodeIndex == mNbNodes + 1 + treeParams.mNbNodes);
// update the parent information for the input tree root node
mParentIndices[mNbNodes + 1] = targetMergeNodeIndex;
// fix the child information for the target node, was a leaf before
mNodes[targetMergeNodeIndex].mData = mNbNodes << 1;
// update the total number of nodes
mNbNodes = mNbNodes + 1 + treeParams.mNbNodes;
}
// Merge tree into targetNode, where target node is not a leaf
// 1. Allocate new nodes/parent, copy the nodes/parents till targetNodePosIndex
// 2. Create new node , copy the data from target node
// 3. Copy the rest of the target tree nodes/parents at the end -> targetNodePosIndex + 1 + treeParams.mNbNodes
// 4. Copy the merge tree after the new node, create the parent map for them, update the leaf indices
// 5. Go through the nodes copied at the end and fix the parents/childs
// Schematic view:
// Target Nodes: ...Tn->...->Tc0,Tc1...
// Input tree: R1->Rc0, Rc1...
// Merged tree: ...Tn->...->Nc0,R1->Rc0,Rc1...,Tc0,Tc1...
// where new node: Nc0->...->Tc0,Tc1
void AABBTree::mergeRuntimeNode(BVHNode& targetNode, const AABBTreeMergeData& treeParams, PxU32 targetMergeNodeIndex)
{
PX_ASSERT(mParentIndices);
PX_ASSERT(!targetNode.isLeaf());
// Get the target node child pos, this is where we insert the new node and the input tree
const PxU32 targetNodePosIndex = targetNode.getPosIndex();
// 1. Allocate new nodes/parent, copy the nodes/parents till targetNodePosIndex
// allocate new runtime pool with max combine number of nodes
// we allocate only 1 additional node each merge
BVHNode* newRuntimePool = PX_NEW(BVHNode)[mNbNodes + treeParams.mNbNodes + 1];
PxU32* newParentIndices = PX_ALLOCATE(PxU32, (mNbNodes + treeParams.mNbNodes + 1), "AABB parent indices");
// copy the untouched part of the nodes and parents
PxMemCopy(newRuntimePool, mNodes, sizeof(BVHNode)*(targetNodePosIndex));
PxMemCopy(newParentIndices, mParentIndices, sizeof(PxU32)*(targetNodePosIndex));
PxU32 nodeIndex = targetNodePosIndex;
// 2. Create new node , copy the data from target node
newRuntimePool[nodeIndex].mBV = targetNode.mBV;
newRuntimePool[nodeIndex].mData = ((targetNode.mData >> 1) + 1 + treeParams.mNbNodes) << 1;
// update parent information
newParentIndices[nodeIndex] = targetMergeNodeIndex;
// handle mark for refit
if(mRefitBitmask.getBits() && mRefitBitmask.isSet(targetMergeNodeIndex))
{
mRefitBitmask.setBit(nodeIndex);
const PxU32 currentMarkedWord = nodeIndex >> 5;
mRefitHighestSetWord = PxMax(mRefitHighestSetWord, currentMarkedWord);
}
// 3. Copy the rest of the target tree nodes/parents at the end -> targetNodePosIndex + 1 + treeParams.mNbNodes
if(mNbNodes - targetNodePosIndex)
{
PX_ASSERT(mNbNodes - targetNodePosIndex > 0);
PxMemCopy(newRuntimePool + targetNodePosIndex + 1 + treeParams.mNbNodes, mNodes + targetNodePosIndex, sizeof(BVHNode)*(mNbNodes - targetNodePosIndex));
PxMemCopy(newParentIndices + targetNodePosIndex + 1 + treeParams.mNbNodes, mParentIndices + targetNodePosIndex, sizeof(PxU32)*(mNbNodes - targetNodePosIndex));
}
// swap the pointers, release the old memory
PX_DELETE_ARRAY(mNodes);
mNodes = newRuntimePool;
PX_FREE(mParentIndices);
mParentIndices = newParentIndices;
// 4. Copy the merge tree after the new node, create the parent map for them, update the leaf indices
nodeIndex++;
addRuntimeChilds(nodeIndex, treeParams);
PX_ASSERT(nodeIndex == targetNodePosIndex + 1 + treeParams.mNbNodes);
// update the total number of nodes
mNbNodes = mNbNodes + 1 + treeParams.mNbNodes;
// update the parent information for the input tree root node
mParentIndices[targetNodePosIndex + 1] = targetMergeNodeIndex;
// 5. Go through the nodes copied at the end and fix the parents/childs
for (PxU32 i = targetNodePosIndex + 1 + treeParams.mNbNodes; i < mNbNodes; i++)
{
// check if the parent is the targetNode, if yes update the parent to new node
if(mParentIndices[i] == targetMergeNodeIndex)
{
mParentIndices[i] = targetNodePosIndex;
}
else
{
// if parent node has been moved, update the parent node
if(mParentIndices[i] >= targetNodePosIndex)
{
mParentIndices[i] = mParentIndices[i] + 1 + treeParams.mNbNodes;
}
else
{
// if parent has not been moved, update its child information
const PxU32 parentIndex = mParentIndices[i];
// update the child information to point to Pos child
if(i % 2 != 0)
{
const PxU32 srcNodeIndex = mNodes[parentIndex].getPosIndex();
// if child index points to a node that has been moved, update the child index
PX_ASSERT(!mNodes[parentIndex].isLeaf());
PX_ASSERT(srcNodeIndex > targetNodePosIndex);
mNodes[parentIndex].mData = (1 + treeParams.mNbNodes + srcNodeIndex) << 1;
}
}
}
if(!mNodes[i].isLeaf())
{
// update the child node index
const PxU32 srcNodeIndex = 1 + treeParams.mNbNodes + mNodes[i].getPosIndex();
mNodes[i].mData = srcNodeIndex << 1;
}
}
}
// traverse the target node, the tree is inside the targetNode, and find the best place where merge the tree
void AABBTree::traverseRuntimeNode(BVHNode& targetNode, const AABBTreeMergeData& treeParams, PxU32 nodeIndex)
{
const BVHNode& srcNode = treeParams.getRootNode();
PX_ASSERT(srcNode.mBV.isInside(targetNode.mBV));
// Check if the srcNode(tree) can fit inside any of the target childs. If yes, traverse the target tree child
BVHNode& targetPosChild = *targetNode.getPos(mNodes);
if(srcNode.mBV.isInside(targetPosChild.mBV))
{
return traverseRuntimeNode(targetPosChild, treeParams, targetNode.getPosIndex());
}
BVHNode& targetNegChild = *targetNode.getNeg(mNodes);
if (srcNode.mBV.isInside(targetNegChild.mBV))
{
return traverseRuntimeNode(targetNegChild, treeParams, targetNode.getNegIndex());
}
// we cannot traverse target anymore, lets add the srcTree to current target node
if(targetNode.isLeaf())
mergeRuntimeLeaf(targetNode, treeParams, nodeIndex);
else
mergeRuntimeNode(targetNode, treeParams, nodeIndex);
}
// Merge the input tree into current tree.
// Traverse the tree and find the smallest node, where the whole new tree fits. When we find the node
// we create one new node pointing to the original children and the to the input tree root.
void AABBTree::mergeTree(const AABBTreeMergeData& treeParams)
{
// allocate new indices buffer
PxU32* newIndices = PX_ALLOCATE(PxU32, (mNbIndices + treeParams.mNbIndices), "AABB tree indices");
PxMemCopy(newIndices, mIndices, sizeof(PxU32)*mNbIndices);
PX_FREE(mIndices);
mIndices = newIndices;
mTotalPrims += treeParams.mNbIndices;
// copy the new indices, re-index using the provided indicesOffset. Note that indicesOffset
// must be provided, as original mNbIndices can be different than indicesOffset dues to object releases.
for (PxU32 i = 0; i < treeParams.mNbIndices; i++)
{
mIndices[mNbIndices + i] = treeParams.mIndicesOffset + treeParams.mIndices[i];
}
// check the mRefitBitmask if we fit all the new nodes
mRefitBitmask.resize(mNbNodes + treeParams.mNbNodes + 1);
// create the parent information so we can update it
getParentIndices();
// if new tree is inside the root AABB we will traverse the tree to find better node where to attach the tree subnodes
// if the root is a leaf we merge with the root.
if(treeParams.getRootNode().mBV.isInside(mNodes[0].mBV) && !mNodes[0].isLeaf())
{
traverseRuntimeNode(mNodes[0], treeParams, 0);
}
else
{
if(mNodes[0].isLeaf())
{
mergeRuntimeLeaf(mNodes[0], treeParams, 0);
}
else
{
mergeRuntimeNode(mNodes[0], treeParams, 0);
}
// increase the tree root AABB
mNodes[0].mBV.include(treeParams.getRootNode().mBV);
}
#ifdef _DEBUG
//verify parent indices
for (PxU32 i = 0; i < mNbNodes; i++)
{
if (i)
{
PX_ASSERT(mNodes[mParentIndices[i]].getPosIndex() == i || mNodes[mParentIndices[i]].getNegIndex() == i);
}
if (!mNodes[i].isLeaf())
{
PX_ASSERT(mParentIndices[mNodes[i].getPosIndex()] == i);
PX_ASSERT(mParentIndices[mNodes[i].getNegIndex()] == i);
}
}
// verify the tree nodes, leafs
for (PxU32 i = 0; i < mNbNodes; i++)
{
if (mNodes[i].isLeaf())
{
const PxU32 index = mNodes[i].mData >> 5;
const PxU32 nbPrim = mNodes[i].getNbPrimitives();
PX_ASSERT(index + nbPrim <= mNbIndices + treeParams.mNbIndices);
}
else
{
const PxU32 nodeIndex = (mNodes[i].getPosIndex());
PX_ASSERT(nodeIndex < mNbNodes);
}
}
#endif // _DEBUG
mNbIndices += treeParams.mNbIndices;
}
| 43,247 | C++ | 29.456338 | 182 | 0.703864 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuExtendedBucketPruner.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_EXTENDED_BUCKET_PRUNER_H
#define GU_EXTENDED_BUCKET_PRUNER_H
#include "GuPrunerTypedef.h"
#include "GuAABBTreeUpdateMap.h"
#include "foundation/PxHashMap.h"
#include "GuAABBTreeBounds.h"
#include "GuSecondaryPruner.h"
namespace physx
{
class PxRenderOutput;
namespace Gu
{
class AABBTreeMergeData;
// Extended bucket pruner data, if an object belongs to the tree of trees, we need to
// remember node for the sub tree, the tree it belongs to and the main tree node
struct ExtendedBucketPrunerData
{
PxU32 mTimeStamp; // timestamp
TreeNodeIndex mSubTreeNode; // sub tree node index
PxU32 mMergeIndex; // index in bounds and merged trees array
};
// Merged tree structure, holds tree and its timeStamp, released when no objects is in the tree
// or timeStamped objects are released
struct MergedTree
{
AABBTree* mTree; // AABB tree
size_t mTimeStamp; //
};
// hashing function for PrunerPayload key
// PT: TODO: move this to PrunerPayload?
struct ExtendedBucketPrunerHash
{
PX_FORCE_INLINE uint32_t operator()(const PrunerPayload& payload) const
{
#if PX_P64_FAMILY
// const PxU32 h0 = PxHash((const void*)payload.data[0]);
// const PxU32 h1 = PxHash((const void*)payload.data[1]);
const PxU32 h0 = PxU32(PX_MAX_U32 & payload.data[0]);
const PxU32 h1 = PxU32(PX_MAX_U32 & payload.data[1]);
return physx::PxComputeHash(PxU64(h0) | (PxU64(h1) << 32));
#else
return physx::PxComputeHash(PxU64(payload.data[0]) | (PxU64(payload.data[1]) << 32));
#endif
}
PX_FORCE_INLINE bool equal(const PrunerPayload& k0, const PrunerPayload& k1) const
{
return (k0.data[0] == k1.data[0]) && (k0.data[1] == k1.data[1]);
}
};
// A.B. replace, this is useless, need to be able to traverse the map and release while traversing, also eraseAt failed
typedef PxHashMap<PrunerPayload, ExtendedBucketPrunerData, ExtendedBucketPrunerHash> ExtendedBucketPrunerMap;
// Extended bucket pruner holds single objects in a bucket pruner and AABBtrees in a tree of trees.
// Base usage of ExtendedBucketPruner is for dynamic AABBPruner new objects, that did not make it
// into new tree. Single objects go directly into a bucket pruner, while merged AABBtrees
// go into a tree of trees.
// PT: TODO: this is not a Pruner (doesn't use the Pruner API) so its name should be e.g. "ExtendedBucketPrunerCore".
// And it's also not always using a bucket pruner... so the whole "ExtendedBucketPruner" name everywhere is wrong.
class ExtendedBucketPruner
{
public:
ExtendedBucketPruner(PxU64 contextID, CompanionPrunerType type, const PruningPool* pool);
~ExtendedBucketPruner();
// release
void release();
// add single object into a bucket pruner directly
PX_FORCE_INLINE bool addObject(const PrunerPayload& object, PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform, PxU32 timeStamp, const PoolIndex poolIndex)
{
return mCompanion ? mCompanion->addObject(object, handle, worldAABB, transform, timeStamp, poolIndex) : true;
}
// add AABB tree from pruning structure - adds new primitive into main AABB tree
void addTree(const AABBTreeMergeData& mergeData, PxU32 timeStamp);
// update object
bool updateObject(const PxBounds3& worldAABB, const PxTransform& transform, const PrunerPayload& object, PrunerHandle handle, const PoolIndex poolIndex);
// remove object, removed object is replaced in pruning pool by swapped object, indices needs to be updated
bool removeObject(const PrunerPayload& object, PrunerHandle handle, PxU32 objectIndex, const PrunerPayload& swapObject, PxU32 swapObjectIndex);
// swap object index, the object index can be in core pruner or tree of trees
void swapIndex(PxU32 objectIndex, const PrunerPayload& swapObject, PxU32 swapObjectIndex, bool corePrunerIncluded = true);
// refit marked nodes in tree of trees
void refitMarkedNodes(const PxBounds3* boxes);
// notify timestampChange - swap trees in incremental pruner
PX_FORCE_INLINE void timeStampChange()
{
if(mCompanion)
mCompanion->timeStampChange();
}
// look for objects marked with input timestamp everywhere in the structure, and remove them. This is the same
// as calling 'removeObject' individually for all these objects, but much more efficient. Returns number of removed objects.
PxU32 removeMarkedObjects(PxU32 timeStamp);
// queries against the pruner
bool raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback&) const;
bool overlap(const ShapeData& queryVolume, PrunerOverlapCallback&) const;
bool sweep(const ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback&) const;
// origin shift
void shiftOrigin(const PxVec3& shift);
// debug visualize
void visualize(PxRenderOutput& out, PxU32 color) const;
PX_FORCE_INLINE void build()
{
if(mCompanion)
mCompanion->build();
}
PX_FORCE_INLINE PxU32 getNbObjects() const
{
const PxU32 nb = mCompanion ? mCompanion->getNbObjects() : 0;
return nb + mExtendedBucketPrunerMap.size();
}
void getGlobalBounds(PxBounds3&) const;
private:
// separate call for indices invalidation, object can be either in AABBPruner or Bucket pruner, but the swapped object can be
// in the tree of trees
void invalidateObject(const ExtendedBucketPrunerData& object, PxU32 objectIndex, const PrunerPayload& swapObject, PxU32 swapObjectIndex);
void resize(PxU32 size);
void buildMainAABBTree();
void cleanTrees();
#if PX_DEBUG
// Extended bucket pruner validity check
bool checkValidity();
#endif
CompanionPruner* mCompanion; // Companion pruner for single objects
const PruningPool* mPruningPool; // Pruning pool from AABB pruner
ExtendedBucketPrunerMap mExtendedBucketPrunerMap; // Map holding objects from tree merge - objects in tree of trees
AABBTree* mMainTree; // Main tree holding merged trees
AABBTreeUpdateMap mMainTreeUpdateMap; // Main tree updated map - merged trees index to nodes
AABBTreeUpdateMap mMergeTreeUpdateMap; // Merged tree update map used while tree is merged
AABBTreeBounds mBounds; // Merged trees bounds used for main tree building
MergedTree* mMergedTrees; // Merged trees
PxU32 mCurrentTreeIndex; // Current trees index
PxU32 mCurrentTreeCapacity; // Current tress capacity
bool mTreesDirty; // Dirty marker
};
}
}
#endif
| 8,527 | C | 44.121693 | 188 | 0.718658 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuSqInternal.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuSqInternal.h"
#include "CmVisualization.h"
#include "GuAABBTree.h"
#include "GuAABBTreeNode.h"
#include "GuIncrementalAABBTree.h"
#include "GuBVH.h"
using namespace physx;
using namespace Cm;
using namespace Gu;
static void drawBVH(const BVHNode* root, const BVHNode* node, PxRenderOutput& out_)
{
renderOutputDebugBox(out_, node->mBV);
if(node->isLeaf())
return;
drawBVH(root, node->getPos(root), out_);
drawBVH(root, node->getNeg(root), out_);
}
void visualizeTree(PxRenderOutput& out, PxU32 color, const BVH* tree)
{
if(tree && tree->getNodes())
{
out << PxTransform(PxIdentity);
out << color;
drawBVH(tree->getNodes(), tree->getNodes(), out);
}
}
void visualizeTree(PxRenderOutput& out, PxU32 color, const AABBTree* tree)
{
if(tree && tree->getNodes())
{
out << PxTransform(PxIdentity);
out << color;
drawBVH(tree->getNodes(), tree->getNodes(), out);
}
}
void visualizeTree(PxRenderOutput& out, PxU32 color, const IncrementalAABBTree* tree, DebugVizCallback* cb)
{
if(tree && tree->getNodes())
{
struct Local
{
static void _draw(const IncrementalAABBTreeNode* root, const IncrementalAABBTreeNode* node, PxRenderOutput& out_, DebugVizCallback* cb_)
{
PxBounds3 bounds;
V4StoreU(node->mBVMin, &bounds.minimum.x);
PX_ALIGN(16, PxVec4) max4;
V4StoreA(node->mBVMax, &max4.x);
bounds.maximum = PxVec3(max4.x, max4.y, max4.z);
bool discard = false;
if(cb_)
discard = cb_->visualizeNode(*node, bounds);
if(!discard)
Cm::renderOutputDebugBox(out_, bounds);
if(node->isLeaf())
return;
_draw(root, node->getPos(root), out_, cb_);
_draw(root, node->getNeg(root), out_, cb_);
}
};
out << PxTransform(PxIdentity);
out << color;
Local::_draw(tree->getNodes(), tree->getNodes(), out, cb);
}
}
| 3,507 | C++ | 33.392157 | 139 | 0.718848 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuBox.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxIntrinsics.h"
#include "GuBoxConversion.h"
#include "GuInternal.h"
using namespace physx;
void Gu::Box::create(const Gu::Capsule& capsule)
{
// Box center = center of the two LSS's endpoints
center = capsule.computeCenter();
// Box orientation
const PxVec3 dir = capsule.p1 - capsule.p0;
const float d = dir.magnitude();
if(d!=0.0f)
{
rot.column0 = dir / d;
PxComputeBasisVectors(rot.column0, rot.column1, rot.column2);
}
else
rot = PxMat33(PxIdentity);
// Box extents
extents.x = capsule.radius + (d * 0.5f);
extents.y = capsule.radius;
extents.z = capsule.radius;
}
/**
Returns edges.
\return 24 indices (12 edges) indexing the list returned by ComputePoints()
*/
const PxU8* Gu::getBoxEdges()
{
// 7+------+6 0 = ---
// /| /| 1 = +--
// / | / | 2 = ++-
// / 4+---/--+5 3 = -+-
// 3+------+2 / y z 4 = --+
// | / | / | / 5 = +-+
// |/ |/ |/ 6 = +++
// 0+------+1 *---x 7 = -++
static PxU8 Indices[] = {
0, 1, 1, 2, 2, 3, 3, 0,
7, 6, 6, 5, 5, 4, 4, 7,
1, 5, 6, 2,
3, 7, 4, 0
};
return Indices;
}
void Gu::computeOBBPoints(PxVec3* PX_RESTRICT pts, const PxVec3& center, const PxVec3& extents, const PxVec3& base0, const PxVec3& base1, const PxVec3& base2)
{
PX_ASSERT(pts);
// "Rotated extents"
const PxVec3 axis0 = base0 * extents.x;
const PxVec3 axis1 = base1 * extents.y;
const PxVec3 axis2 = base2 * extents.z;
// 7+------+6 0 = ---
// /| /| 1 = +--
// / | / | 2 = ++-
// / 4+---/--+5 3 = -+-
// 3+------+2 / y z 4 = --+
// | / | / | / 5 = +-+
// |/ |/ |/ 6 = +++
// 0+------+1 *---x 7 = -++
// Original code: 24 vector ops
/* pts[0] = box.center - Axis0 - Axis1 - Axis2;
pts[1] = box.center + Axis0 - Axis1 - Axis2;
pts[2] = box.center + Axis0 + Axis1 - Axis2;
pts[3] = box.center - Axis0 + Axis1 - Axis2;
pts[4] = box.center - Axis0 - Axis1 + Axis2;
pts[5] = box.center + Axis0 - Axis1 + Axis2;
pts[6] = box.center + Axis0 + Axis1 + Axis2;
pts[7] = box.center - Axis0 + Axis1 + Axis2;*/
// Rewritten: 12 vector ops
pts[0] = pts[3] = pts[4] = pts[7] = center - axis0;
pts[1] = pts[2] = pts[5] = pts[6] = center + axis0;
PxVec3 tmp = axis1 + axis2;
pts[0] -= tmp;
pts[1] -= tmp;
pts[6] += tmp;
pts[7] += tmp;
tmp = axis1 - axis2;
pts[2] += tmp;
pts[3] += tmp;
pts[4] -= tmp;
pts[5] -= tmp;
}
| 4,125 | C++ | 31.234375 | 158 | 0.620848 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBTreeQuery.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_AABBTREEQUERY_H
#define GU_AABBTREEQUERY_H
#include "GuBVHTestsSIMD.h"
#include "GuAABBTreeBounds.h"
#include "foundation/PxInlineArray.h"
#include "GuAABBTreeNode.h"
namespace physx
{
namespace Gu
{
#define RAW_TRAVERSAL_STACK_SIZE 256
//////////////////////////////////////////////////////////////////////////
static PX_FORCE_INLINE void getBoundsTimesTwo(Vec4V& center, Vec4V& extents, const PxBounds3* bounds, PxU32 poolIndex)
{
const PxBounds3* objectBounds = bounds + poolIndex;
// PT: it's safe to V4LoadU because the pointer comes from the AABBTreeBounds class
const Vec4V minV = V4LoadU(&objectBounds->minimum.x);
const Vec4V maxV = V4LoadU(&objectBounds->maximum.x);
center = V4Add(maxV, minV);
extents = V4Sub(maxV, minV);
}
//////////////////////////////////////////////////////////////////////////
template<const bool tHasIndices, typename Test, typename Node, typename QueryCallback>
static PX_FORCE_INLINE bool doOverlapLeafTest(const Test& test, const Node* node, const PxBounds3* bounds, const PxU32* indices, QueryCallback& visitor)
{
PxU32 nbPrims = node->getNbPrimitives();
const bool doBoxTest = nbPrims > 1;
const PxU32* prims = tHasIndices ? node->getPrimitives(indices) : NULL;
while(nbPrims--)
{
const PxU32 primIndex = tHasIndices ? *prims++ : node->getPrimitiveIndex();
if(doBoxTest)
{
Vec4V center2, extents2;
getBoundsTimesTwo(center2, extents2, bounds, primIndex);
const float half = 0.5f;
const FloatV halfV = FLoad(half);
const Vec4V extents_ = V4Scale(extents2, halfV);
const Vec4V center_ = V4Scale(center2, halfV);
if(!test(Vec3V_From_Vec4V(center_), Vec3V_From_Vec4V(extents_)))
continue;
}
if(!visitor.invoke(primIndex))
return false;
}
return true;
}
template<const bool tHasIndices, typename Test, typename Tree, typename Node, typename QueryCallback>
class AABBTreeOverlap
{
public:
bool operator()(const AABBTreeBounds& treeBounds, const Tree& tree, const Test& test, QueryCallback& visitor)
{
const PxBounds3* bounds = treeBounds.getBounds();
PxInlineArray<const Node*, RAW_TRAVERSAL_STACK_SIZE> stack;
stack.forceSize_Unsafe(RAW_TRAVERSAL_STACK_SIZE);
const Node* const nodeBase = tree.getNodes();
stack[0] = nodeBase;
PxU32 stackIndex = 1;
while(stackIndex > 0)
{
const Node* node = stack[--stackIndex];
Vec3V center, extents;
node->getAABBCenterExtentsV(¢er, &extents);
while(test(center, extents))
{
if(node->isLeaf())
{
if(!doOverlapLeafTest<tHasIndices, Test, Node>(test, node, bounds, tree.getIndices(), visitor))
return false;
break;
}
const Node* children = node->getPos(nodeBase);
node = children;
stack[stackIndex++] = children + 1;
if(stackIndex == stack.capacity())
stack.resizeUninitialized(stack.capacity() * 2);
node->getAABBCenterExtentsV(¢er, &extents);
}
}
return true;
}
};
//////////////////////////////////////////////////////////////////////////
template <const bool tInflate, const bool tHasIndices, typename Node, typename QueryCallback> // use inflate=true for sweeps, inflate=false for raycasts
static PX_FORCE_INLINE bool doLeafTest( const Node* node, Gu::RayAABBTest& test, const PxBounds3* bounds, const PxU32* indices, PxReal& maxDist, QueryCallback& pcb)
{
PxU32 nbPrims = node->getNbPrimitives();
const bool doBoxTest = nbPrims > 1;
const PxU32* prims = tHasIndices ? node->getPrimitives(indices) : NULL;
while(nbPrims--)
{
const PxU32 primIndex = tHasIndices ? *prims++ : node->getPrimitiveIndex();
if(doBoxTest)
{
Vec4V center_, extents_;
getBoundsTimesTwo(center_, extents_, bounds, primIndex);
if(!test.check<tInflate>(Vec3V_From_Vec4V(center_), Vec3V_From_Vec4V(extents_)))
continue;
}
// PT:
// - 'maxDist' is the current best distance. It can be seen as a "maximum allowed distance" (as passed to the
// template by users initially) but also as the "current minimum impact distance", so the name is misleading.
// Either way this is where we write & communicate the final/best impact distance to users.
//
// - the invoke function also takes a distance parameter, and this one is in/out. In input we must pass the
// current best distance to the leaf node, so that subsequent leaf-level queries can cull things away as
// much as possible. In output users return a shrunk distance value if they found a hit. We need to pass a
// copy of 'maxDist' ('md') since it would be too dangerous to rely on the arbitrary user code to always do
// the right thing. In particular if we'd pass 'maxDist' to invoke directly, and the called code would NOT
// respect the passed max value, it could potentially return a hit further than the best 'maxDist'. At which
// point the '(md < oldMaxDist)' test would fail but the damage would have already been done ('maxDist' would
// have already been overwritten with a larger value than before). Hence, we need 'md'.
//
// - now 'oldMaxDist' however is more subtle. In theory we wouldn't need it and we could just use '(md < maxDist)'
// in the test below. But that opens the door to subtle bugs: 'maxDist' is a reference to some value somewhere
// in the user's code, and we call the same user in invoke. It turns out that the invoke code can access and
// modify 'maxDist' on their side, even if we do not pass it to invoke. It's basically the same problem as
// before, but much more difficult to see. It does happen with the current PhysX implementations of the invoke
// functions: they modify the 'md' that we send them, but *also* 'maxDist' without the code below knowing
// about it. So the subsequent test fails again because md == maxDist. A potential solution would have been to
// work on a local copy of 'maxDist' in operator(), only writing out the final distance when returning from the
// function. Another solution used below is to introduce that local copy just here in the leaf code: that's
// where 'oldMaxDist' comes from.
PxReal oldMaxDist = maxDist;
PxReal md = maxDist;
if(!pcb.invoke(md, primIndex))
return false;
if(md < oldMaxDist)
{
maxDist = md;
test.setDistance(md);
}
}
return true;
}
//////////////////////////////////////////////////////////////////////////
template <const bool tInflate, const bool tHasIndices, typename Tree, typename Node, typename QueryCallback> // use inflate=true for sweeps, inflate=false for raycasts
class AABBTreeRaycast
{
public:
bool operator()(
const AABBTreeBounds& treeBounds, const Tree& tree,
const PxVec3& origin, const PxVec3& unitDir, PxReal& maxDist, const PxVec3& inflation,
QueryCallback& pcb)
{
const PxBounds3* bounds = treeBounds.getBounds();
// PT: we will pass center*2 and extents*2 to the ray-box code, to save some work per-box
// So we initialize the test with values multiplied by 2 as well, to get correct results
Gu::RayAABBTest test(origin*2.0f, unitDir*2.0f, maxDist, inflation*2.0f);
PxInlineArray<const Node*, RAW_TRAVERSAL_STACK_SIZE> stack;
stack.forceSize_Unsafe(RAW_TRAVERSAL_STACK_SIZE);
const Node* const nodeBase = tree.getNodes();
stack[0] = nodeBase;
PxU32 stackIndex = 1;
while(stackIndex--)
{
const Node* node = stack[stackIndex];
Vec3V center, extents;
node->getAABBCenterExtentsV2(¢er, &extents);
if(test.check<tInflate>(center, extents)) // TODO: try timestamp ray shortening to skip this
{
while(!node->isLeaf())
{
const Node* children = node->getPos(nodeBase);
Vec3V c0, e0;
children[0].getAABBCenterExtentsV2(&c0, &e0);
const PxU32 b0 = test.check<tInflate>(c0, e0);
Vec3V c1, e1;
children[1].getAABBCenterExtentsV2(&c1, &e1);
const PxU32 b1 = test.check<tInflate>(c1, e1);
if(b0 && b1) // if both intersect, push the one with the further center on the stack for later
{
// & 1 because FAllGrtr behavior differs across platforms
const PxU32 bit = FAllGrtr(V3Dot(V3Sub(c1, c0), test.mDir), FZero()) & 1;
stack[stackIndex++] = children + bit;
node = children + (1 - bit);
if(stackIndex == stack.capacity())
stack.resizeUninitialized(stack.capacity() * 2);
}
else if(b0)
node = children;
else if(b1)
node = children + 1;
else
goto skip_leaf_code;
}
if(!doLeafTest<tInflate, tHasIndices, Node>(node, test, bounds, tree.getIndices(), maxDist, pcb))
return false;
skip_leaf_code:;
}
}
return true;
}
};
struct TraversalControl
{
enum Enum {
eDontGoDeeper,
eGoDeeper,
eGoDeeperNegFirst,
eAbort
};
};
template<typename T>
void traverseBVH(const Gu::BVHNode* nodes, T& traversalController, PxI32 rootNodeIndex = 0)
{
PxI32 index = rootNodeIndex;
PxInlineArray<PxI32, RAW_TRAVERSAL_STACK_SIZE> todoStack;
while (true)
{
const Gu::BVHNode& a = nodes[index];
TraversalControl::Enum control = traversalController.analyze(a, index);
if (control == TraversalControl::eAbort)
return;
if (!a.isLeaf() && (control == TraversalControl::eGoDeeper || control == TraversalControl::eGoDeeperNegFirst))
{
if (control == TraversalControl::eGoDeeperNegFirst)
{
todoStack.pushBack(a.getPosIndex());
index = a.getNegIndex(); //index gets processed next - assign negative index to it
}
else
{
todoStack.pushBack(a.getNegIndex());
index = a.getPosIndex(); //index gets processed next - assign positive index to it
}
continue;
}
if (todoStack.empty()) break;
index = todoStack.popBack();
}
}
}
}
#endif // SQ_AABBTREEQUERY_H
| 11,774 | C | 37.733553 | 169 | 0.667658 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuSweepTests.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxCustomGeometry.h"
#include "GuSweepTests.h"
#include "GuVecCapsule.h"
#include "GuVecBox.h"
#include "GuVecTriangle.h"
#include "GuSweepTriangleUtils.h"
#include "GuInternal.h"
#include "GuGJKRaycast.h"
using namespace physx;
using namespace Gu;
using namespace Cm;
using namespace physx::aos;
//#define USE_VIRTUAL_GJK
#ifdef USE_VIRTUAL_GJK
static bool virtualGjkRaycastPenetration(const GjkConvex& a, const GjkConvex& b, const aos::Vec3VArg initialDir, const aos::FloatVArg initialLambda, const aos::Vec3VArg s, const aos::Vec3VArg r, aos::FloatV& lambda,
aos::Vec3V& normal, aos::Vec3V& closestA, const PxReal _inflation, const bool initialOverlap)
{
return gjkRaycastPenetration<GjkConvex, GjkConvex >(a, b, initialDir, initialLambda, s, r, lambda, normal, closestA, _inflation, initialOverlap);
}
#endif
bool sweepCapsule_BoxGeom(GU_CAPSULE_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(hitFlags);
PX_UNUSED(threadContext);
using namespace aos;
PX_ASSERT(geom.getType() == PxGeometryType::eBOX);
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
const FloatV zero = FZero();
const Vec3V zeroV = V3Zero();
const Vec3V boxExtents0 = V3LoadU(boxGeom.halfExtents);
const FloatV dist = FLoad(distance);
const Vec3V worldDir = V3LoadU(unitDir);
const PxTransformV capPos = loadTransformU(capsulePose_);
const PxTransformV boxPos = loadTransformU(pose);
const PxMatTransformV aToB(boxPos.transformInv(capPos));
const FloatV capsuleHalfHeight = FLoad(capsuleGeom_.halfHeight);
const FloatV capsuleRadius = FLoad(lss.radius);
BoxV box(zeroV, boxExtents0);
CapsuleV capsule(aToB.p, aToB.rotate(V3Scale(V3UnitX(), capsuleHalfHeight)), capsuleRadius);
const Vec3V dir = boxPos.rotateInv(V3Neg(V3Scale(worldDir, dist)));
const bool isMtd = hitFlags & PxHitFlag::eMTD;
FloatV toi = FMax();
Vec3V closestA, normal;//closestA and normal is in the local space of box
const LocalConvex<CapsuleV> convexA(capsule);
const LocalConvex<BoxV> convexB(box);
const Vec3V initialSearchDir = V3Sub(capsule.getCenter(), box.getCenter());
#ifdef USE_VIRTUAL_GJK
if(!virtualGjkRaycastPenetration(convexA, convexB, initialSearchDir, zero, zeroV, dir, toi, normal, closestA, lss.radius + inflation, isMtd))
return false;
#else
if(!gjkRaycastPenetration<LocalConvex<CapsuleV>, LocalConvex<BoxV> >(convexA, convexB, initialSearchDir, zero, zeroV, dir, toi, normal, closestA, lss.radius + inflation, isMtd))
return false;
#endif
sweepHit.flags = PxHitFlag::eNORMAL;
if(FAllGrtrOrEq(zero, toi))
{
//initial overlap
if(isMtd)
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const Vec3V worldPointA = boxPos.transform(closestA);
const Vec3V destNormal = boxPos.rotate(normal);
const FloatV length = toi;
const Vec3V destWorldPointA = V3NegScaleSub(destNormal, length, worldPointA);
V3StoreU(destWorldPointA, sweepHit.position);
V3StoreU(destNormal, sweepHit.normal);
FStore(length, &sweepHit.distance);
}
else
{
sweepHit.distance = 0.0f;
sweepHit.normal = -unitDir;
}
}
else
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const Vec3V worldPointA = boxPos.transform(closestA);
const Vec3V destNormal = boxPos.rotate(normal);
const FloatV length = FMul(dist, toi);
const Vec3V destWorldPointA = V3ScaleAdd(worldDir, length, worldPointA);
V3StoreU(destNormal, sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
return true;
}
bool sweepBox_SphereGeom(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eSPHERE);
PX_UNUSED(threadContext);
PX_UNUSED(hitFlags);
PX_UNUSED(boxGeom_);
const PxSphereGeometry& sphereGeom = static_cast<const PxSphereGeometry&>(geom);
const FloatV zero = FZero();
const Vec3V zeroV = V3Zero();
const Vec3V boxExtents = V3LoadU(box.extents);
const FloatV worldDist = FLoad(distance);
const Vec3V unitDirV = V3LoadU(unitDir);
const FloatV sphereRadius = FLoad(sphereGeom.radius);
const PxTransformV spherePos = loadTransformU(pose);
const PxTransformV boxPos = loadTransformU(boxPose_);
const PxMatTransformV aToB(boxPos.transformInv(spherePos));
const BoxV boxV(zeroV, boxExtents);
const CapsuleV capsuleV(aToB.p, sphereRadius);
//transform into b space
const Vec3V dir = boxPos.rotateInv(V3Scale(unitDirV, worldDist));
const bool isMtd = hitFlags & PxHitFlag::eMTD;
FloatV toi;
Vec3V closestA, normal;//closestA and normal is in the local space of box
const Vec3V initialSearchDir = V3Sub(capsuleV.getCenter(), boxV.getCenter());
const LocalConvex<CapsuleV> convexA(capsuleV);
const LocalConvex<BoxV> convexB(boxV);
#ifdef USE_VIRTUAL_GJK
if(!virtualGjkRaycastPenetration(convexA, convexB, initialSearchDir, zero, zeroV, dir, toi, normal, closestA, sphereGeom.radius+inflation, isMtd))
return false;
#else
if(!gjkRaycastPenetration<LocalConvex<CapsuleV>, LocalConvex<BoxV> >(convexA, convexB, initialSearchDir, zero, zeroV, dir, toi, normal, closestA, sphereGeom.radius+inflation, isMtd))
return false;
#endif
sweepHit.flags = PxHitFlag::eNORMAL;
//initial overlap
if(FAllGrtrOrEq(zero, toi))
{
if(isMtd)
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const Vec3V destWorldPointA = boxPos.transform(closestA);
const Vec3V destNormal = V3Neg(boxPos.rotate(normal));
const FloatV length = toi;
V3StoreU(destNormal, sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
else
{
sweepHit.distance = 0.0f;
sweepHit.normal = -unitDir;
}
}
else
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const Vec3V destWorldPointA = boxPos.transform(closestA);
const Vec3V destNormal = V3Neg(boxPos.rotate(normal));
const FloatV length = FMul(worldDist, toi);
V3StoreU(destNormal, sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
return true;
}
bool sweepBox_CapsuleGeom(GU_BOX_SWEEP_FUNC_PARAMS)
{
using namespace aos;
PX_ASSERT(geom.getType() == PxGeometryType::eCAPSULE);
PX_UNUSED(threadContext);
PX_UNUSED(hitFlags);
PX_UNUSED(boxGeom_);
const PxCapsuleGeometry& capsuleGeom = static_cast<const PxCapsuleGeometry&>(geom);
const FloatV capsuleHalfHeight = FLoad(capsuleGeom.halfHeight);
const FloatV capsuleRadius = FLoad(capsuleGeom.radius);
const FloatV zero = FZero();
const Vec3V zeroV = V3Zero();
const Vec3V boxExtents = V3LoadU(box.extents);
const FloatV worldDist = FLoad(distance);
const Vec3V unitDirV = V3LoadU(unitDir);
const PxTransformV capPos = loadTransformU(pose);
const PxTransformV boxPos = loadTransformU(boxPose_);
const PxMatTransformV aToB(boxPos.transformInv(capPos));
const BoxV boxV(zeroV, boxExtents);
const CapsuleV capsuleV(aToB.p, aToB.rotate(V3Scale(V3UnitX(), capsuleHalfHeight)), capsuleRadius);
//transform into b space
const Vec3V dir = boxPos.rotateInv(V3Scale(unitDirV, worldDist));
const bool isMtd = hitFlags & PxHitFlag::eMTD;
FloatV toi;
Vec3V closestA, normal;//closestA and normal is in the local space of box
const Vec3V initialSearchDir = V3Sub(capsuleV.getCenter(), boxV.getCenter());
const LocalConvex<CapsuleV> convexA(capsuleV);
const LocalConvex<BoxV> convexB(boxV);
#ifdef USE_VIRTUAL_GJK
if(!virtualGjkRaycastPenetration(convexA, convexB, initialSearchDir, zero, zeroV, dir, toi, normal, closestA, capsuleGeom.radius+inflation, isMtd))
return false;
#else
if(!gjkRaycastPenetration<LocalConvex<CapsuleV>, LocalConvex<BoxV> >(convexA, convexB, initialSearchDir, zero, zeroV, dir, toi, normal, closestA, capsuleGeom.radius+inflation, isMtd))
return false;
#endif
sweepHit.flags = PxHitFlag::eNORMAL;
//initial overlap
if(FAllGrtrOrEq(zero, toi))
{
if(isMtd)
{
sweepHit.flags |= PxHitFlag::ePOSITION;
//initial overlap is toi < 0
const FloatV length = toi;
const Vec3V destWorldPointA = boxPos.transform(closestA);
const Vec3V destNormal = boxPos.rotate(normal);
V3StoreU(V3Neg(destNormal), sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
else
{
sweepHit.distance = 0.0f;
sweepHit.normal = -unitDir;
}
return true;
}
else
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const Vec3V destWorldPointA = boxPos.transform(closestA);
const Vec3V destNormal = boxPos.rotate(normal);
const FloatV length = FMul(worldDist, toi);
V3StoreU(V3Neg(destNormal), sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
return true;
}
bool sweepBox_BoxGeom(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eBOX);
PX_UNUSED(threadContext);
PX_UNUSED(boxGeom_);
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
const FloatV zero = FZero();
const Vec3V zeroV = V3Zero();
const Vec3V boxExtents0 = V3LoadU(boxGeom.halfExtents);
const Vec3V boxExtents1 = V3LoadU(box.extents);
const FloatV worldDist = FLoad(distance);
const Vec3V unitDirV = V3LoadU(unitDir);
const PxTransformV boxTrans0 = loadTransformU(pose);
const PxTransformV boxTrans1 = loadTransformU(boxPose_);
const PxMatTransformV aToB(boxTrans1.transformInv(boxTrans0));
const BoxV box0(zeroV, boxExtents0);
const BoxV box1(zeroV, boxExtents1);
//transform into b space
const Vec3V dir = boxTrans1.rotateInv(V3Scale(unitDirV, worldDist));
const bool isMtd = hitFlags & PxHitFlag::eMTD;
FloatV toi;
Vec3V closestA, normal;//closestA and normal is in the local space of box
const RelativeConvex<BoxV> convexA(box0, aToB);
const LocalConvex<BoxV> convexB(box1);
#ifdef USE_VIRTUAL_GJK
if(!virtualGjkRaycastPenetration(convexA, convexB, aToB.p, zero, zeroV, dir, toi, normal, closestA, inflation, isMtd))
return false;
#else
if(!gjkRaycastPenetration<RelativeConvex<BoxV>, LocalConvex<BoxV> >(convexA, convexB, aToB.p, zero, zeroV, dir, toi, normal, closestA, inflation, isMtd))
return false;
#endif
sweepHit.flags = PxHitFlag::eNORMAL;
if(FAllGrtrOrEq(zero, toi))
{
if(isMtd)
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const FloatV length = toi;
const Vec3V destWorldPointA = boxTrans1.transform(closestA);
const Vec3V destNormal = V3Normalize(boxTrans1.rotate(normal));
V3StoreU(V3Neg(destNormal), sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
else
{
sweepHit.distance = 0.0f;
sweepHit.normal = -unitDir;
}
}
else
{
sweepHit.flags |= PxHitFlag::ePOSITION;
const Vec3V destWorldPointA = boxTrans1.transform(closestA);
const Vec3V destNormal = V3Normalize(boxTrans1.rotate(normal));
const FloatV length = FMul(worldDist, toi);
V3StoreU(V3Neg(destNormal), sweepHit.normal);
V3StoreU(destWorldPointA, sweepHit.position);
FStore(length, &sweepHit.distance);
}
return true;
}
bool Gu::sweepBoxTriangles(GU_SWEEP_TRIANGLES_FUNC_PARAMS(PxBoxGeometry))
{
PX_UNUSED(hitFlags);
if(!nbTris)
return false;
const bool meshBothSides = hitFlags & PxHitFlag::eMESH_BOTH_SIDES;
const bool doBackfaceCulling = !doubleSided && !meshBothSides;
Box box;
buildFrom(box, pose.p, geom.halfExtents, pose.q);
PxGeomSweepHit sweepHit;
// Move to AABB space
PxMat34 worldToBox;
computeWorldToBoxMatrix(worldToBox, box);
const PxVec3 localDir = worldToBox.rotate(unitDir);
const PxVec3 localMotion = localDir * distance;
const Vec3V base0 = V3LoadU(worldToBox.m.column0);
const Vec3V base1 = V3LoadU(worldToBox.m.column1);
const Vec3V base2 = V3LoadU(worldToBox.m.column2);
const Mat33V matV(base0, base1, base2);
const Vec3V p = V3LoadU(worldToBox.p);
const PxMatTransformV worldToBoxV(p, matV);
const FloatV zero = FZero();
const Vec3V zeroV = V3Zero();
const Vec3V boxExtents = V3LoadU(box.extents);
const Vec3V boxDir = V3LoadU(localDir);
const FloatV inflationV = FLoad(inflation);
const Vec3V absBoxDir = V3Abs(boxDir);
const FloatV boxRadiusV = FAdd(V3Dot(absBoxDir, boxExtents), inflationV);
BoxV boxV(zeroV, boxExtents);
#if PX_DEBUG
PxU32 totalTestsExpected = nbTris;
PxU32 totalTestsReal = 0;
PX_UNUSED(totalTestsExpected);
PX_UNUSED(totalTestsReal);
#endif
Vec3V boxLocalMotion = V3LoadU(localMotion);
Vec3V minClosestA = zeroV, minNormal = zeroV;
PxU32 minTriangleIndex = 0;
PxVec3 bestTriNormal(0.0f);
FloatV dist = FLoad(distance);
const PxTransformV boxPos = loadTransformU(pose);
bool status = false;
const PxU32 idx = cachedIndex ? *cachedIndex : 0;
for(PxU32 ii=0;ii<nbTris;ii++)
{
const PxU32 triangleIndex = getTriangleIndex(ii, idx);
const Vec3V localV0 = V3LoadU(triangles[triangleIndex].verts[0]);
const Vec3V localV1 = V3LoadU(triangles[triangleIndex].verts[1]);
const Vec3V localV2 = V3LoadU(triangles[triangleIndex].verts[2]);
const Vec3V triV0 = worldToBoxV.transform(localV0);
const Vec3V triV1 = worldToBoxV.transform(localV1);
const Vec3V triV2 = worldToBoxV.transform(localV2);
const Vec3V triNormal = V3Cross(V3Sub(triV2, triV1),V3Sub(triV0, triV1));
if(doBackfaceCulling && FAllGrtrOrEq(V3Dot(triNormal, boxLocalMotion), zero)) // backface culling
continue;
const FloatV dp0 = V3Dot(triV0, boxDir);
const FloatV dp1 = V3Dot(triV1, boxDir);
const FloatV dp2 = V3Dot(triV2, boxDir);
const FloatV dp = FMin(dp0, FMin(dp1, dp2));
const Vec3V dpV = V3Merge(dp0, dp1, dp2);
const FloatV temp1 = FAdd(boxRadiusV, dist);
const BoolV con0 = FIsGrtr(dp, temp1);
const BoolV con1 = V3IsGrtr(zeroV, dpV);
if(BAllEqTTTT(BOr(con0, con1)))
continue;
#if PX_DEBUG
totalTestsReal++;
#endif
TriangleV triangleV(triV0, triV1, triV2);
FloatV lambda;
Vec3V closestA, normal;//closestA and normal is in the local space of convex hull
const LocalConvex<TriangleV> convexA(triangleV);
const LocalConvex<BoxV> convexB(boxV);
const Vec3V initialSearchDir = V3Sub(triangleV.getCenter(), boxV.getCenter());
#ifdef USE_VIRTUAL_GJK
if(virtualGjkRaycastPenetration(convexA, convexB, initialSearchDir, zero, zeroV, boxLocalMotion, lambda, normal, closestA, inflation, false))
#else
if(gjkRaycastPenetration<LocalConvex<TriangleV>, LocalConvex<BoxV> >(convexA, convexB, initialSearchDir, zero, zeroV, boxLocalMotion, lambda, normal, closestA, inflation, false))
#endif
{
//hitCount++;
if(FAllGrtrOrEq(zero, lambda))
{
hit.distance = 0.0f;
hit.faceIndex = triangleIndex;
hit.normal = -unitDir;
hit.flags = PxHitFlag::eNORMAL;
return true;
}
dist = FMul(dist, lambda);
boxLocalMotion = V3Scale(boxDir, dist);
minClosestA = closestA;
minNormal = normal;
minTriangleIndex = triangleIndex;
V3StoreU(triNormal, bestTriNormal);
status = true;
if(hitFlags & PxHitFlag::eMESH_ANY)
break;
}
}
if(!status)
return false;
hit.faceIndex = minTriangleIndex;
const Vec3V destNormal = V3Neg(V3Normalize(boxPos.rotate(minNormal)));
const Vec3V destWorldPointA = boxPos.transform(minClosestA);
V3StoreU(destNormal, hit.normal);
V3StoreU(destWorldPointA, hit.position);
FStore(dist, &hit.distance);
// PT: by design, returned normal is opposed to the sweep direction.
if(shouldFlipNormal(hit.normal, meshBothSides, doubleSided, bestTriNormal, unitDir))
hit.normal = -hit.normal;
hit.flags = PxHitFlag::ePOSITION|PxHitFlag::eNORMAL;
return true;
}
bool sweepCapsule_SphereGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_PlaneGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_CapsuleGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_BoxGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_BoxGeom_Precise (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_ConvexGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_MeshGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepCapsule_HeightFieldGeom (GU_CAPSULE_SWEEP_FUNC_PARAMS);
bool sweepBox_SphereGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_SphereGeom_Precise (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_PlaneGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_CapsuleGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_CapsuleGeom_Precise (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_BoxGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_BoxGeom_Precise (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_ConvexGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_MeshGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_HeightFieldGeom (GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepBox_HeightFieldGeom_Precise(GU_BOX_SWEEP_FUNC_PARAMS);
bool sweepConvex_SphereGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
bool sweepConvex_PlaneGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
bool sweepConvex_CapsuleGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
bool sweepConvex_BoxGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
bool sweepConvex_ConvexGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
bool sweepConvex_MeshGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
bool sweepConvex_HeightFieldGeom (GU_CONVEX_SWEEP_FUNC_PARAMS);
static bool sweepCapsule_InvalidGeom(GU_CAPSULE_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(threadContext);
PX_UNUSED(capsuleGeom_);
PX_UNUSED(capsulePose_);
PX_UNUSED(geom);
PX_UNUSED(pose);
PX_UNUSED(lss);
PX_UNUSED(unitDir);
PX_UNUSED(distance);
PX_UNUSED(sweepHit);
PX_UNUSED(hitFlags);
PX_UNUSED(inflation);
return false;
}
static bool sweepBox_InvalidGeom(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(threadContext);
PX_UNUSED(boxPose_);
PX_UNUSED(boxGeom_);
PX_UNUSED(geom);
PX_UNUSED(pose);
PX_UNUSED(box);
PX_UNUSED(unitDir);
PX_UNUSED(distance);
PX_UNUSED(sweepHit);
PX_UNUSED(hitFlags);
PX_UNUSED(inflation);
return false;
}
static bool sweepConvex_InvalidGeom(GU_CONVEX_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(threadContext);
PX_UNUSED(geom);
PX_UNUSED(pose);
PX_UNUSED(convexGeom);
PX_UNUSED(convexPose);
PX_UNUSED(unitDir);
PX_UNUSED(distance);
PX_UNUSED(sweepHit);
PX_UNUSED(hitFlags);
PX_UNUSED(inflation);
return false;
}
static bool sweepCapsule_CustomGeom(GU_CAPSULE_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(lss);
if(geom.getType() == PxGeometryType::eCUSTOM)
return static_cast<const PxCustomGeometry&>(geom).callbacks->sweep(unitDir, distance, geom, pose, capsuleGeom_, capsulePose_, sweepHit, hitFlags, inflation, threadContext);
return false;
}
static bool sweepBox_CustomGeom(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(box);
if(geom.getType() == PxGeometryType::eCUSTOM)
return static_cast<const PxCustomGeometry&>(geom).callbacks->sweep(unitDir, distance, geom, pose, boxGeom_, boxPose_, sweepHit, hitFlags, inflation, threadContext);
return false;
}
static bool sweepConvex_CustomGeom(GU_CONVEX_SWEEP_FUNC_PARAMS)
{
if(geom.getType() == PxGeometryType::eCUSTOM)
return static_cast<const PxCustomGeometry&>(geom).callbacks->sweep(unitDir, distance, geom, pose, convexGeom, convexPose, sweepHit, hitFlags, inflation, threadContext);
return false;
}
Gu::GeomSweepFuncs gGeomSweepFuncs =
{
{
sweepCapsule_SphereGeom,
sweepCapsule_PlaneGeom,
sweepCapsule_CapsuleGeom,
sweepCapsule_BoxGeom,
sweepCapsule_ConvexGeom,
sweepCapsule_InvalidGeom,
sweepCapsule_InvalidGeom,
sweepCapsule_MeshGeom,
sweepCapsule_HeightFieldGeom,
sweepCapsule_InvalidGeom,
sweepCapsule_CustomGeom
},
{
sweepCapsule_SphereGeom,
sweepCapsule_PlaneGeom,
sweepCapsule_CapsuleGeom,
sweepCapsule_BoxGeom_Precise,
sweepCapsule_ConvexGeom,
sweepCapsule_InvalidGeom,
sweepCapsule_InvalidGeom,
sweepCapsule_MeshGeom ,
sweepCapsule_HeightFieldGeom,
sweepCapsule_InvalidGeom,
sweepCapsule_CustomGeom
},
{
sweepBox_SphereGeom,
sweepBox_PlaneGeom,
sweepBox_CapsuleGeom,
sweepBox_BoxGeom,
sweepBox_ConvexGeom,
sweepBox_InvalidGeom,
sweepBox_InvalidGeom,
sweepBox_MeshGeom,
sweepBox_HeightFieldGeom,
sweepBox_InvalidGeom,
sweepBox_CustomGeom
},
{
sweepBox_SphereGeom_Precise,
sweepBox_PlaneGeom,
sweepBox_CapsuleGeom_Precise,
sweepBox_BoxGeom_Precise,
sweepBox_ConvexGeom,
sweepBox_InvalidGeom,
sweepBox_InvalidGeom,
sweepBox_MeshGeom,
sweepBox_HeightFieldGeom_Precise,
sweepBox_InvalidGeom,
sweepBox_CustomGeom
},
{
sweepConvex_SphereGeom, // 0
sweepConvex_PlaneGeom, // 1
sweepConvex_CapsuleGeom, // 2
sweepConvex_BoxGeom, // 3
sweepConvex_ConvexGeom, // 4
sweepConvex_InvalidGeom, // 5
sweepConvex_InvalidGeom, // 6
sweepConvex_MeshGeom, // 7
sweepConvex_HeightFieldGeom,// 8
sweepConvex_InvalidGeom, // 9
sweepConvex_CustomGeom // 10
}
};
PX_PHYSX_COMMON_API const GeomSweepFuncs& Gu::getSweepFuncTable()
{
return gGeomSweepFuncs;
}
| 22,163 | C++ | 31.982143 | 216 | 0.753328 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuIncrementalAABBTree.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxMemory.h"
#include "foundation/PxVecMath.h"
#include "foundation/PxFPU.h"
#include "foundation/PxMathUtils.h"
#include "GuIncrementalAABBTree.h"
#include "GuAABBTreeBuildStats.h"
#include "GuAABBTreeNode.h"
#include "GuBVH.h"
using namespace physx;
using namespace aos;
using namespace Gu;
#define SUPPORT_TREE_ROTATION 1
#define DEALLOCATE_RESET 0
IncrementalAABBTree::IncrementalAABBTree():
mIndicesPool("AABBTreeIndicesPool", 256),
mNodesPool("AABBTreeNodesPool", 256 ),
mRoot(NULL)
{
}
IncrementalAABBTree::~IncrementalAABBTree()
{
release();
}
void IncrementalAABBTree::release()
{
if(mRoot)
{
releaseNode(mRoot);
mRoot = NULL;
}
}
void IncrementalAABBTree::releaseNode(IncrementalAABBTreeNode* node)
{
PX_ASSERT(node);
if(node->isLeaf())
{
mIndicesPool.deallocate(node->mIndices);
}
else
{
releaseNode(node->mChilds[0]);
releaseNode(node->mChilds[1]);
}
if(!node->mParent)
{
mNodesPool.deallocate(reinterpret_cast<IncrementalAABBTreeNodePair*>(node));
return;
}
if(node->mParent->mChilds[1] == node)
{
mNodesPool.deallocate(reinterpret_cast<IncrementalAABBTreeNodePair*>(node->mParent->mChilds[0]));
}
}
// check if node is inside the given bounds
PX_FORCE_INLINE static bool nodeInsideBounds(const Vec4V& nodeMin, const Vec4V& nodeMax, const Vec4V& parentMin, const Vec4V& parentMax)
{
return !(PxIntBool(V4AnyGrtr3(parentMin, nodeMin)) || PxIntBool(V4AnyGrtr3(nodeMax, parentMax)));
}
// update the node parent hierarchy, when insert happen, we can early exit when the node is inside its parent
// no further update is needed
PX_FORCE_INLINE static void updateHierarchyAfterInsert(IncrementalAABBTreeNode* node)
{
IncrementalAABBTreeNode* parent = node->mParent;
IncrementalAABBTreeNode* testNode = node;
while(parent)
{
// check if we can early exit
if(!nodeInsideBounds(testNode->mBVMin, testNode->mBVMax, parent->mBVMin, parent->mBVMax))
{
parent->mBVMin = V4Min(parent->mChilds[0]->mBVMin, parent->mChilds[1]->mBVMin);
parent->mBVMax = V4Max(parent->mChilds[0]->mBVMax, parent->mChilds[1]->mBVMax);
}
else
break;
testNode = parent;
parent = parent->mParent;
}
}
// add an index into the leaf indices list and update the node bounds
PX_FORCE_INLINE static void addPrimitiveIntoNode(IncrementalAABBTreeNode* node, const PoolIndex index, const Vec4V& minV, const Vec4V& maxV)
{
PX_ASSERT(node->isLeaf());
AABBTreeIndices& nodeIndices = *node->mIndices;
PX_ASSERT(nodeIndices.nbIndices < INCR_NB_OBJECTS_PER_NODE);
// store the new handle
nodeIndices.indices[nodeIndices.nbIndices++] = index;
// increase the node bounds
node->mBVMin = V4Min(node->mBVMin, minV);
node->mBVMax = V4Max(node->mBVMax, maxV);
updateHierarchyAfterInsert(node);
}
// check if node does intersect with given bounds
PX_FORCE_INLINE static bool nodeIntersection(IncrementalAABBTreeNode& node, const Vec4V& minV, const Vec4V& maxV)
{
return !(PxIntBool(V4AnyGrtr3(node.mBVMin, maxV)) || PxIntBool(V4AnyGrtr3(minV, node.mBVMax)));
}
// traversal strategy
PX_FORCE_INLINE static PxU32 traversalDirection(const IncrementalAABBTreeNode& child0, const IncrementalAABBTreeNode& child1, const Vec4V& testCenterV,
bool testRotation, bool& rotateNode, PxU32& largesRotateNode)
{
// traverse in the direction of a node which is closer
// we compare the node and object centers
const Vec4V centerCh0V = V4Add(child0.mBVMax, child0.mBVMin);
const Vec4V centerCh1V = V4Add(child1.mBVMax, child1.mBVMin);
const Vec4V ch0D = V4Sub(testCenterV, centerCh0V);
const Vec4V ch1D = V4Sub(testCenterV, centerCh1V);
if(testRotation)
{
// if some volume is 3x larger than we do a rotation
const float volumeCompare = 3.0f;
PX_ALIGN(16, PxVec4) sizeCh0;
PX_ALIGN(16, PxVec4) sizeCh1;
const Vec4V sizeCh0V = V4Sub(child0.mBVMax, child0.mBVMin);
const Vec4V sizeCh1V = V4Sub(child1.mBVMax, child1.mBVMin);
V4StoreA(sizeCh0V, &sizeCh0.x);
V4StoreA(sizeCh1V, &sizeCh1.x);
const float volumeCh0 = sizeCh0.x*sizeCh0.y*sizeCh0.z;
const float volumeCh1 = sizeCh1.x*sizeCh1.y*sizeCh1.z;
if((volumeCh0*volumeCompare < volumeCh1) || (volumeCh1*volumeCompare < volumeCh0))
{
largesRotateNode = (volumeCh0 > volumeCh1) ? 0u : 1u;
rotateNode = true;
}
}
const BoolV con = FIsGrtr(V4Dot3(ch0D, ch0D), V4Dot3(ch1D, ch1D));
return (BAllEqTTTT(con) == 1) ? PxU32(1) : PxU32(0);
}
// remove an index from the leaf
PX_FORCE_INLINE static void removePrimitiveFromNode(IncrementalAABBTreeNode* node, const PoolIndex index)
{
AABBTreeIndices& indices = *node->mIndices;
PX_ASSERT(indices.nbIndices > 1);
for (PxU32 i = indices.nbIndices; i--; )
{
if(node->mIndices->indices[i] == index)
{
node->mIndices->indices[i] = node->mIndices->indices[--indices.nbIndices];
return;
}
}
// if handle was not found something is wrong here
PX_ASSERT(0);
}
// check if bounds are equal with given node min/max
PX_FORCE_INLINE static bool boundsEqual(const Vec4V& testMin, const Vec4V& testMax, const Vec4V& nodeMin, const Vec4V& nodeMax)
{
return (PxIntBool(V4AllEq(nodeMin, testMin)) && PxIntBool(V4AllEq(testMax, nodeMax)));
}
// update the node hierarchy bounds when remove happen, we can early exit if the bounds are equal and no bounds update
// did happen
PX_FORCE_INLINE static void updateHierarchyAfterRemove(IncrementalAABBTreeNode* node, const PxBounds3* bounds)
{
if(node->isLeaf())
{
const AABBTreeIndices& indices = *node->mIndices;
PX_ASSERT(indices.nbIndices > 0);
Vec4V bvMin = V4LoadU(&bounds[indices.indices[0]].minimum.x);
Vec4V bvMax = V4LoadU(&bounds[indices.indices[0]].maximum.x);
for(PxU32 i = 1; i < indices.nbIndices; i++)
{
const Vec4V minV = V4LoadU(&bounds[indices.indices[i]].minimum.x);
const Vec4V maxV = V4LoadU(&bounds[indices.indices[i]].maximum.x);
bvMin = V4Min(bvMin, minV);
bvMax = V4Max(bvMax, maxV);
}
node->mBVMin = V4ClearW(bvMin);
node->mBVMax = V4ClearW(bvMax);
}
else
{
node->mBVMin = V4Min(node->mChilds[0]->mBVMin, node->mChilds[1]->mBVMin);
node->mBVMax = V4Max(node->mChilds[0]->mBVMax, node->mChilds[1]->mBVMax);
}
IncrementalAABBTreeNode* parent = node->mParent;
while(parent)
{
const Vec4V newMinV = V4Min(parent->mChilds[0]->mBVMin, parent->mChilds[1]->mBVMin);
const Vec4V newMaxV = V4Max(parent->mChilds[0]->mBVMax, parent->mChilds[1]->mBVMax);
const bool earlyExit = boundsEqual(newMinV, newMaxV, parent->mBVMin, parent->mBVMax);
if(earlyExit)
break;
parent->mBVMin = newMinV;
parent->mBVMax = newMaxV;
parent = parent->mParent;
}
}
// split the leaf node along the most significant axis
IncrementalAABBTreeNode* IncrementalAABBTree::splitLeafNode(IncrementalAABBTreeNode* node, const PoolIndex index, const Vec4V& minV, const Vec4V& maxV, const PxBounds3* bounds)
{
PX_ASSERT(node->isLeaf());
IncrementalAABBTreeNode* returnNode = NULL;
// create new pairs of nodes, parent will remain the node (the one we split)
IncrementalAABBTreeNode* child0 = reinterpret_cast<IncrementalAABBTreeNode*>(mNodesPool.allocate());
IncrementalAABBTreeNode* child1 = child0 + 1;
AABBTreeIndices* newIndices = mIndicesPool.allocate();
// get the split axis
PX_ALIGN(16, PxVec4) vars;
PX_ALIGN(16, PxVec4) center;
const float half = 0.5f;
const FloatV halfV = FLoad(half);
const Vec4V newMinV = V4Min(node->mBVMin, minV);
const Vec4V newMaxV = V4Max(node->mBVMax, maxV);
const Vec4V centerV = V4Scale(V4Add(newMaxV, newMinV), halfV);
const Vec4V varsV = V4Sub(newMaxV, newMinV);
V4StoreA(varsV, &vars.x);
V4StoreA(centerV, ¢er.x);
const PxU32 axis = PxLargestAxis(PxVec3(vars.x, vars.y, vars.z));
// setup parent
child0->mParent = node;
child1->mParent = node;
child0->mIndices = node->mIndices;
child0->mChilds[1] = NULL;
child1->mIndices = newIndices;
child1->mChilds[1] = NULL;
AABBTreeIndices& child0Indices = *child0->mIndices; // the original node indices
AABBTreeIndices& child1Indices = *child1->mIndices; // new empty indices
child1Indices.nbIndices = 0;
// split the node
for(PxU32 i = child0Indices.nbIndices; i--;)
{
const PxBounds3& primitiveBounds = bounds[child0Indices.indices[i]];
const float pCenter = primitiveBounds.getCenter(axis);
if(center[axis] >= pCenter)
{
// move to new node
child1Indices.indices[child1Indices.nbIndices++] = child0Indices.indices[i];
child0Indices.nbIndices--;
child0Indices.indices[i] = child0Indices.indices[child0Indices.nbIndices];
}
}
// check where to put the new node, if there is still a free space
if(child0Indices.nbIndices == 0 || child1Indices.nbIndices == INCR_NB_OBJECTS_PER_NODE)
{
child0Indices.nbIndices = 1;
child0Indices.indices[0] = index;
returnNode = child0;
}
else
{
if(child0Indices.nbIndices == INCR_NB_OBJECTS_PER_NODE)
{
child1Indices.nbIndices = 1;
child1Indices.indices[0] = index;
returnNode = child1;
}
else
{
const PxBounds3& primitiveBounds = bounds[index];
const float pCenter = primitiveBounds.getCenter(axis);
if(center[axis] >= pCenter)
{
// move to new node
child1Indices.indices[child1Indices.nbIndices++] = index;
returnNode = child1;
}
else
{
// move to old node
child0Indices.indices[child0Indices.nbIndices++] = index;
returnNode = child0;
}
}
}
// update bounds for the new nodes
Vec4V bvMin = V4LoadU(&bounds[child0Indices.indices[0]].minimum.x);
Vec4V bvMax = V4LoadU(&bounds[child0Indices.indices[0]].maximum.x);
for(PxU32 i = 1; i < child0Indices.nbIndices; i++)
{
const Vec4V nodeMinV = V4LoadU(&bounds[child0Indices.indices[i]].minimum.x);
const Vec4V nodeMaxV = V4LoadU(&bounds[child0Indices.indices[i]].maximum.x);
bvMin = V4Min(bvMin, nodeMinV);
bvMax = V4Max(bvMax, nodeMaxV);
}
child0->mBVMin = V4ClearW(bvMin);
child0->mBVMax = V4ClearW(bvMax);
bvMin = V4LoadU(&bounds[child1Indices.indices[0]].minimum.x);
bvMax = V4LoadU(&bounds[child1Indices.indices[0]].maximum.x);
for(PxU32 i = 1; i < child1Indices.nbIndices; i++)
{
const Vec4V nodeMinV = V4LoadU(&bounds[child1Indices.indices[i]].minimum.x);
const Vec4V nodeMaxV = V4LoadU(&bounds[child1Indices.indices[i]].maximum.x);
bvMin = V4Min(bvMin, nodeMinV);
bvMax = V4Max(bvMax, nodeMaxV);
}
child1->mBVMin = V4ClearW(bvMin);
child1->mBVMax = V4ClearW(bvMax);
// node parent is the same, setup the new childs
node->mChilds[0] = child0;
node->mChilds[1] = child1;
node->mBVMin = newMinV;
node->mBVMax = newMaxV;
updateHierarchyAfterInsert(node);
PX_ASSERT(returnNode);
return returnNode;
}
void IncrementalAABBTree::rotateTree(IncrementalAABBTreeNode* node, NodeList& changedLeaf, PxU32 largesRotateNodeIn, const PxBounds3* bounds, bool rotateAgain)
{
PX_ASSERT(!node->isLeaf());
IncrementalAABBTreeNode* smallerNode = node->mChilds[(largesRotateNodeIn == 0) ? 1 : 0];
IncrementalAABBTreeNode* largerNode = node->mChilds[largesRotateNodeIn];
PX_ASSERT(!largerNode->isLeaf());
// take a leaf from larger node and add it to the smaller node
const Vec4V testCenterV = V4Add(smallerNode->mBVMax, smallerNode->mBVMin);
IncrementalAABBTreeNode* rotationNode = NULL; // store a node that seems not balanced
PxU32 largesRotateNode = 0;
bool rotateNode = false;
PxU32 traversalIndex = traversalDirection(*largerNode->mChilds[0], *largerNode->mChilds[1], testCenterV, false, rotateNode, largesRotateNode);
IncrementalAABBTreeNode* closestNode = largerNode->mChilds[traversalIndex];
while(!closestNode->isLeaf())
{
PxPrefetchLine(closestNode->mChilds[0]->mChilds[0]);
PxPrefetchLine(closestNode->mChilds[1]->mChilds[0]);
traversalIndex = traversalDirection(*closestNode->mChilds[0], *closestNode->mChilds[1], testCenterV, false, rotateNode, largesRotateNode);
closestNode = closestNode->mChilds[traversalIndex];
}
// we have the leaf that we want to rotate
// create new parent and remove the current leaf
changedLeaf.findAndReplaceWithLast(closestNode);
IncrementalAABBTreeNode* parent = closestNode->mParent;
IncrementalAABBTreeNodePair* removedPair = reinterpret_cast<IncrementalAABBTreeNodePair*>(parent->mChilds[0]);
PX_ASSERT(!parent->isLeaf());
// copy the remaining child into parent
IncrementalAABBTreeNode* remainingChild = (parent->mChilds[0] == closestNode) ? parent->mChilds[1] : parent->mChilds[0];
parent->mBVMax = remainingChild->mBVMax;
parent->mBVMin = remainingChild->mBVMin;
if(remainingChild->isLeaf())
{
parent->mIndices = remainingChild->mIndices;
parent->mChilds[1] = NULL;
changedLeaf.findAndReplaceWithLast(remainingChild);
changedLeaf.pushBack(parent);
}
else
{
parent->mChilds[0] = remainingChild->mChilds[0];
parent->mChilds[0]->mParent = parent;
parent->mChilds[1] = remainingChild->mChilds[1];
parent->mChilds[1]->mParent = parent;
}
// update the hieararchy after the node removal
if(parent->mParent)
{
updateHierarchyAfterRemove(parent->mParent, bounds);
}
// find new spot for the node
// take a leaf from larger node and add it to the smaller node
IncrementalAABBTreeNode* newSpotNode = NULL;
if(smallerNode->isLeaf())
{
newSpotNode = smallerNode;
}
else
{
const Vec4V testClosestNodeCenterV = V4Add(closestNode->mBVMax, closestNode->mBVMin);
rotationNode = NULL; // store a node that seems not balanced
largesRotateNode = 0;
rotateNode = false;
bool testRotation = rotateAgain;
traversalIndex = traversalDirection(*smallerNode->mChilds[0], *smallerNode->mChilds[1], testClosestNodeCenterV, testRotation, rotateNode, largesRotateNode);
if(rotateNode && !smallerNode->mChilds[largesRotateNode]->isLeaf())
{
rotationNode = smallerNode;
testRotation = false;
}
newSpotNode = smallerNode->mChilds[traversalIndex];
while(!newSpotNode->isLeaf())
{
PxPrefetchLine(newSpotNode->mChilds[0]->mChilds[0]);
PxPrefetchLine(newSpotNode->mChilds[1]->mChilds[0]);
traversalIndex = traversalDirection(*newSpotNode->mChilds[0], *newSpotNode->mChilds[1], testClosestNodeCenterV, testRotation, rotateNode, largesRotateNode);
if(!rotationNode && rotateNode && !newSpotNode->mChilds[largesRotateNode]->isLeaf())
{
rotationNode = newSpotNode;
testRotation = false;
}
newSpotNode = newSpotNode->mChilds[traversalIndex];
}
}
// we have the closest leaf in the smaller child, lets merge it with the closestNode
if(newSpotNode->getNbPrimitives() + closestNode->getNbPrimitives() <= INCR_NB_OBJECTS_PER_NODE)
{
// all primitives fit into new spot, we merge here simply
AABBTreeIndices* targetIndices = newSpotNode->mIndices;
const AABBTreeIndices* sourceIndices = closestNode->mIndices;
for(PxU32 i = 0; i < sourceIndices->nbIndices; i++)
{
targetIndices->indices[targetIndices->nbIndices++] = sourceIndices->indices[i];
}
PX_ASSERT(targetIndices->nbIndices <= INCR_NB_OBJECTS_PER_NODE);
if(changedLeaf.find(newSpotNode) == changedLeaf.end())
changedLeaf.pushBack(newSpotNode);
mIndicesPool.deallocate(closestNode->mIndices);
newSpotNode->mBVMin = V4Min(newSpotNode->mBVMin, closestNode->mBVMin);
newSpotNode->mBVMax = V4Max(newSpotNode->mBVMax, closestNode->mBVMax);
updateHierarchyAfterInsert(newSpotNode);
}
else
{
// we need to make new parent with newSpotNode and closestNode as childs
// create new pairs of nodes, parent will remain the node (the one we split)
IncrementalAABBTreeNode* child0 = reinterpret_cast<IncrementalAABBTreeNode*>(mNodesPool.allocate());
IncrementalAABBTreeNode* child1 = child0 + 1;
// setup parent
child0->mParent = newSpotNode;
child1->mParent = newSpotNode;
child0->mIndices = newSpotNode->mIndices;
child0->mChilds[1] = NULL;
child0->mBVMin = newSpotNode->mBVMin;
child0->mBVMax = newSpotNode->mBVMax;
child1->mIndices = closestNode->mIndices;
child1->mChilds[1] = NULL;
child1->mBVMin = closestNode->mBVMin;
child1->mBVMax = closestNode->mBVMax;
// node parent is the same, setup the new childs
newSpotNode->mChilds[0] = child0;
newSpotNode->mChilds[1] = child1;
newSpotNode->mBVMin = V4Min(child0->mBVMin, child1->mBVMin);
newSpotNode->mBVMax = V4Max(child0->mBVMax, child1->mBVMax);
updateHierarchyAfterInsert(newSpotNode);
changedLeaf.findAndReplaceWithLast(newSpotNode);
changedLeaf.pushBack(child0);
changedLeaf.pushBack(child1);
}
// deallocate the closestNode, it has been moved
#if DEALLOCATE_RESET
removedPair->mNode0.mChilds[0] = NULL;
removedPair->mNode0.mChilds[1] = NULL;
removedPair->mNode1.mChilds[0] = NULL;
removedPair->mNode1.mChilds[1] = NULL;
#endif
mNodesPool.deallocate(removedPair);
// try to do one more rotation for the newly added node part of tree
if(rotationNode)
{
rotateTree(rotationNode, changedLeaf, largesRotateNode, bounds, false);
}
}
// insert new bounds into tree
IncrementalAABBTreeNode* IncrementalAABBTree::insert(const PoolIndex index, const PxBounds3* bounds, NodeList& changedLeaf)
{
PX_SIMD_GUARD;
// get the bounds, reset the W value
const Vec4V minV = V4ClearW(V4LoadU(&bounds[index].minimum.x));
const Vec4V maxV = V4ClearW(V4LoadU(&bounds[index].maximum.x));
// check if tree is empty
if(!mRoot)
{
// make it a leaf
AABBTreeIndices* indices = mIndicesPool.construct(index);
mRoot = reinterpret_cast<IncrementalAABBTreeNode*> (mNodesPool.allocate());
mRoot->mBVMin = minV;
mRoot->mBVMax = maxV;
mRoot->mIndices = indices;
mRoot->mChilds[1] = NULL;
mRoot->mParent = NULL;
return mRoot;
}
else
{
// check if root is a leaf
if(mRoot->isLeaf())
{
// if we still can insert the primitive into the leaf, or we need to split
if(mRoot->getNbPrimitives() < INCR_NB_OBJECTS_PER_NODE)
{
// simply add the primitive into the current leaf
addPrimitiveIntoNode(mRoot, index, minV, maxV);
return mRoot;
}
else
{
// need to split the node
// check if the leaf is not marked as changed, we need to remove it
if(!changedLeaf.empty())
{
PX_ASSERT(changedLeaf.size() == 1);
if(changedLeaf[0] == mRoot)
changedLeaf.popBack();
}
IncrementalAABBTreeNode* retNode = splitLeafNode(mRoot, index, minV, maxV, bounds);
mRoot = retNode->mParent;
IncrementalAABBTreeNode* sibling = (mRoot->mChilds[0] == retNode) ? mRoot->mChilds[1] : mRoot->mChilds[0];
if(sibling->isLeaf())
changedLeaf.pushBack(sibling);
changedLeaf.pushBack(retNode);
return retNode;
}
}
else
{
const Vec4V testCenterV = V4Add(maxV, minV);
IncrementalAABBTreeNode* returnNode = NULL;
IncrementalAABBTreeNode* rotationNode = NULL; // store a node that seems not balanced
PxU32 largesRotateNode = 0;
bool rotateNode = false;
#if SUPPORT_TREE_ROTATION
bool testRotation = true;
#else
bool testRotation = false;
#endif
// we dont need to modify root, lets traverse the tree to find the right spot
PxU32 traversalIndex = traversalDirection(*mRoot->mChilds[0], *mRoot->mChilds[1], testCenterV, testRotation, rotateNode, largesRotateNode);
if(rotateNode && !mRoot->mChilds[largesRotateNode]->isLeaf())
{
rotationNode = mRoot;
testRotation = false;
}
IncrementalAABBTreeNode* baseNode = mRoot->mChilds[traversalIndex];
while(!baseNode->isLeaf())
{
PxPrefetchLine(baseNode->mChilds[0]->mChilds[0]);
PxPrefetchLine(baseNode->mChilds[1]->mChilds[0]);
traversalIndex = traversalDirection(*baseNode->mChilds[0], *baseNode->mChilds[1], testCenterV, testRotation, rotateNode, largesRotateNode);
if(!rotationNode && rotateNode && !baseNode->mChilds[largesRotateNode]->isLeaf())
{
rotationNode = baseNode;
testRotation = false;
}
baseNode = baseNode->mChilds[traversalIndex];
}
// if we still can insert the primitive into the leaf, or we need to split
if(baseNode->getNbPrimitives() < INCR_NB_OBJECTS_PER_NODE)
{
// simply add the primitive into the current leaf
addPrimitiveIntoNode(baseNode, index, minV, maxV);
returnNode = baseNode;
if(!changedLeaf.empty())
{
PX_ASSERT(changedLeaf.size() == 1);
if(changedLeaf[0] != baseNode)
changedLeaf.pushBack(baseNode);
}
else
changedLeaf.pushBack(baseNode);
}
else
{
// split
// check if the leaf is not marked as changed, we need to remove it
if(!changedLeaf.empty())
{
PX_ASSERT(changedLeaf.size() == 1);
if(changedLeaf[0] == baseNode)
changedLeaf.popBack();
}
IncrementalAABBTreeNode* retNode = splitLeafNode(baseNode, index, minV, maxV, bounds);
const IncrementalAABBTreeNode* splitParent = retNode->mParent;
changedLeaf.pushBack(splitParent->mChilds[0]);
changedLeaf.pushBack(splitParent->mChilds[1]);
returnNode = retNode;
}
if(rotationNode)
{
rotateTree(rotationNode, changedLeaf, largesRotateNode, bounds, true);
returnNode = NULL;
}
return returnNode;
}
}
}
// update the index, do a full remove/insert update
IncrementalAABBTreeNode* IncrementalAABBTree::update(IncrementalAABBTreeNode* node, const PoolIndex index, const PxBounds3* bounds, NodeList& changedLeaf)
{
PX_SIMD_GUARD;
IncrementalAABBTreeNode* removedNode = remove(node, index, bounds);
if(removedNode && removedNode->isLeaf())
{
changedLeaf.pushBack(removedNode);
}
return insert(index, bounds, changedLeaf);
}
// update the index, faster version with a lazy update of objects that moved just a bit
IncrementalAABBTreeNode* IncrementalAABBTree::updateFast(IncrementalAABBTreeNode* node, const PoolIndex index, const PxBounds3* bounds, NodeList& changedLeaf)
{
PX_SIMD_GUARD;
const Vec4V minV = V4ClearW(V4LoadU(&bounds[index].minimum.x));
const Vec4V maxV = V4ClearW(V4LoadU(&bounds[index].maximum.x));
// for update fast, we dont care if the tree gets slowly unbalanced, we are building a new tree already
if(nodeIntersection(*node, minV, maxV))
{
updateHierarchyAfterRemove(node, bounds);
return node;
}
else
{
IncrementalAABBTreeNode* removedNode = remove(node, index, bounds);
if(removedNode && removedNode->isLeaf())
{
changedLeaf.pushBack(removedNode);
}
return insert(index, bounds, changedLeaf);
}
}
// remove primitive from the tree, return a node if it moved to its parent
IncrementalAABBTreeNode* IncrementalAABBTree::remove(IncrementalAABBTreeNode* node, const PoolIndex index, const PxBounds3* bounds)
{
PX_SIMD_GUARD;
PX_ASSERT(node->isLeaf());
// if we just remove the primitive from the list
if(node->getNbPrimitives() > 1)
{
removePrimitiveFromNode(node, index);
// update the hierarchy
updateHierarchyAfterRemove(node, bounds);
return NULL;
}
else
{
// if root node and the last primitive remove root
if(node == mRoot)
{
#if DEALLOCATE_RESET
IncrementalAABBTreeNodePair* removedPair = reinterpret_cast<IncrementalAABBTreeNodePair*>(node);
removedPair->mNode0.mChilds[0] = NULL;
removedPair->mNode0.mChilds[1] = NULL;
removedPair->mNode1.mChilds[0] = NULL;
removedPair->mNode1.mChilds[1] = NULL;
#endif
mNodesPool.deallocate(reinterpret_cast<IncrementalAABBTreeNodePair*>(node));
mRoot = NULL;
return NULL;
}
else
{
// create new parent and remove the current leaf
IncrementalAABBTreeNode* parent = node->mParent;
IncrementalAABBTreeNodePair* removedPair = reinterpret_cast<IncrementalAABBTreeNodePair*>(parent->mChilds[0]);
PX_ASSERT(!parent->isLeaf());
// copy the remaining child into parent
IncrementalAABBTreeNode* remainingChild = (parent->mChilds[0] == node) ? parent->mChilds[1] : parent->mChilds[0];
parent->mBVMax = remainingChild->mBVMax;
parent->mBVMin = remainingChild->mBVMin;
if(remainingChild->isLeaf())
{
parent->mIndices = remainingChild->mIndices;
parent->mChilds[1] = NULL;
}
else
{
parent->mChilds[0] = remainingChild->mChilds[0];
parent->mChilds[0]->mParent = parent;
parent->mChilds[1] = remainingChild->mChilds[1];
parent->mChilds[1]->mParent = parent;
}
if(parent->mParent)
{
updateHierarchyAfterRemove(parent->mParent, bounds);
}
mIndicesPool.deallocate(node->mIndices);
#if DEALLOCATE_RESET
removedPair->mNode0.mChilds[0] = NULL;
removedPair->mNode0.mChilds[1] = NULL;
removedPair->mNode1.mChilds[0] = NULL;
removedPair->mNode1.mChilds[1] = NULL;
#endif
mNodesPool.deallocate(removedPair);
return parent;
}
}
}
// fixup the indices
void IncrementalAABBTree::fixupTreeIndices(IncrementalAABBTreeNode* node, const PoolIndex index, const PoolIndex newIndex)
{
PX_ASSERT(node->isLeaf());
AABBTreeIndices& indices = *node->mIndices;
for(PxU32 i = 0; i < indices.nbIndices; i++)
{
if(indices.indices[i] == index)
{
indices.indices[i] = newIndex;
return;
}
}
PX_ASSERT(0);
}
// shift node
static void shiftNode(IncrementalAABBTreeNode* node, const Vec4V& shiftV)
{
node->mBVMax = V4Sub(node->mBVMax, shiftV);
node->mBVMin = V4Sub(node->mBVMin, shiftV);
if(!node->isLeaf())
{
shiftNode(node->mChilds[0], shiftV);
shiftNode(node->mChilds[1], shiftV);
}
}
// shift origin
void IncrementalAABBTree::shiftOrigin(const PxVec3& shift)
{
if(mRoot)
{
const Vec4V shiftV = V4ClearW(V4LoadU(&shift.x));
shiftNode(mRoot, shiftV);
}
}
static void checkNode(IncrementalAABBTreeNode* node, IncrementalAABBTreeNode* parent, const PxBounds3* bounds, PoolIndex maxIndex, PxU32& numIndices, PxU32& numNodes)
{
PX_ASSERT(node->mParent == parent);
PX_ASSERT(!parent->isLeaf());
PX_ASSERT(parent->mChilds[0] == node || parent->mChilds[1] == node);
numNodes++;
if(!node->isLeaf())
{
PX_ASSERT(nodeInsideBounds(node->mChilds[0]->mBVMin, node->mChilds[0]->mBVMax, node->mBVMin, node->mBVMax));
PX_ASSERT(nodeInsideBounds(node->mChilds[1]->mBVMin, node->mChilds[1]->mBVMax, node->mBVMin, node->mBVMax));
const Vec4V testMinV = V4Min(parent->mChilds[0]->mBVMin, parent->mChilds[1]->mBVMin);
const Vec4V testMaxV = V4Max(parent->mChilds[0]->mBVMax, parent->mChilds[1]->mBVMax);
PX_UNUSED(testMinV);
PX_UNUSED(testMaxV);
PX_ASSERT(nodeInsideBounds(node->mBVMin, node->mBVMax, testMinV, testMaxV));
checkNode(node->mChilds[0], node, bounds, maxIndex, numIndices, numNodes);
checkNode(node->mChilds[1], node, bounds, maxIndex, numIndices, numNodes);
}
else
{
const AABBTreeIndices& indices = *node->mIndices;
PX_ASSERT(indices.nbIndices);
Vec4V testMinV = V4ClearW(V4LoadU(&bounds[indices.indices[0]].minimum.x));
Vec4V testMaxV = V4ClearW(V4LoadU(&bounds[indices.indices[0]].maximum.x));
for(PxU32 i = 0; i < indices.nbIndices; i++)
{
PX_ASSERT(indices.indices[i] < maxIndex);
numIndices++;
const Vec4V minV = V4ClearW(V4LoadU(&bounds[indices.indices[i]].minimum.x));
const Vec4V maxV = V4ClearW(V4LoadU(&bounds[indices.indices[i]].maximum.x));
testMinV = V4Min(testMinV, minV);
testMaxV = V4Max(testMaxV, maxV);
PX_ASSERT(nodeInsideBounds(minV, maxV, node->mBVMin, node->mBVMax));
}
PX_ASSERT(boundsEqual(testMinV, testMaxV, node->mBVMin, node->mBVMax));
}
}
void IncrementalAABBTree::hierarchyCheck(PoolIndex maxIndex, const PxBounds3* bounds)
{
PxU32 numHandles = 0;
PxU32 numPosNodes = 0;
PxU32 numNegNodes = 0;
if(mRoot && !mRoot->isLeaf())
{
checkNode(mRoot->mChilds[0], mRoot, bounds, maxIndex, numHandles, numPosNodes);
checkNode(mRoot->mChilds[1], mRoot, bounds, maxIndex, numHandles, numNegNodes);
PX_ASSERT(numHandles == maxIndex);
}
}
void IncrementalAABBTree::hierarchyCheck(const PxBounds3* bounds)
{
PxU32 numHandles = 0;
PxU32 numPosNodes = 0;
PxU32 numNegNodes = 0;
if(mRoot && !mRoot->isLeaf())
{
checkNode(mRoot->mChilds[0], mRoot, bounds, 0xFFFFFFFF, numHandles, numPosNodes);
checkNode(mRoot->mChilds[1], mRoot, bounds, 0xFFFFFFFF, numHandles, numNegNodes);
}
}
void IncrementalAABBTree::checkTreeLeaf(IncrementalAABBTreeNode* leaf, PoolIndex h)
{
PX_ASSERT(leaf->isLeaf());
const AABBTreeIndices& indices = *leaf->mIndices;
bool found = false;
for(PxU32 i = 0; i < indices.nbIndices; i++)
{
if(indices.indices[i] == h)
{
found = true;
break;
}
}
PX_UNUSED(found);
PX_ASSERT(found);
}
PxU32 IncrementalAABBTree::getTreeLeafDepth(IncrementalAABBTreeNode* leaf)
{
PxU32 depth = 1;
IncrementalAABBTreeNode* parent = leaf->mParent;
while(parent)
{
depth++;
parent = parent->mParent;
}
return depth;
}
// build the tree from given bounds
bool IncrementalAABBTree::build(const AABBTreeBuildParams& params, PxArray<IncrementalAABBTreeNode*>& mapping)
{
// Init stats
BuildStats stats;
const PxU32 nbPrimitives = params.mNbPrimitives;
if (!nbPrimitives)
return false;
PxU32* indices = buildAABBTree(params, mNodeAllocator, stats);
PX_ASSERT(indices);
PX_FREE(params.mCache);
IncrementalAABBTreeNode** treeNodes = PX_ALLOCATE(IncrementalAABBTreeNode*, stats.getCount(), "temp node helper array");
PxMemSet(treeNodes, 0, sizeof(IncrementalAABBTreeNode*)*(stats.getCount()));
clone(mapping, indices, treeNodes);
mRoot = treeNodes[0];
mRoot->mParent = NULL;
PX_FREE(indices);
PX_FREE(treeNodes);
mNodeAllocator.release();
return true;
}
// clone the tree, the tree is computed in the NodeAllocator, similar to AABBTree flatten
void IncrementalAABBTree::clone(PxArray<IncrementalAABBTreeNode*>& mapping, const PxU32* _indices, IncrementalAABBTreeNode** treeNodes)
{
PxU32 offset = 0;
const PxU32 nbSlabs = mNodeAllocator.mSlabs.size();
for (PxU32 s = 0; s<nbSlabs; s++)
{
const NodeAllocator::Slab& currentSlab = mNodeAllocator.mSlabs[s];
AABBTreeBuildNode* pool = currentSlab.mPool;
for (PxU32 i = 0; i < currentSlab.mNbUsedNodes; i++)
{
IncrementalAABBTreeNode* destNode = treeNodes[offset];
if(!destNode)
{
destNode = reinterpret_cast<IncrementalAABBTreeNode*>(mNodesPool.allocate());
treeNodes[offset] = destNode;
}
destNode->mBVMin = V4ClearW(V4LoadU(&pool[i].mBV.minimum.x));
destNode->mBVMax = V4ClearW(V4LoadU(&pool[i].mBV.maximum.x));
if (pool[i].isLeaf())
{
AABBTreeIndices* indices = mIndicesPool.allocate();
destNode->mIndices = indices;
destNode->mChilds[1] = NULL;
indices->nbIndices = pool[i].getNbPrimitives();
PX_ASSERT(indices->nbIndices <= 16);
const PxU32* sourceIndices = _indices + pool[i].mNodeIndex;
for (PxU32 iIndices = 0; iIndices < indices->nbIndices; iIndices++)
{
const PxU32 sourceIndex = sourceIndices[iIndices];
indices->indices[iIndices] = sourceIndex;
PX_ASSERT(sourceIndex < mapping.size());
mapping[sourceIndex] = destNode;
}
}
else
{
PX_ASSERT(pool[i].mPos);
PxU32 localNodeIndex = 0xffffffff;
PxU32 nodeBase = 0;
for (PxU32 j = 0; j<nbSlabs; j++)
{
if (pool[i].mPos >= mNodeAllocator.mSlabs[j].mPool && pool[i].mPos < mNodeAllocator.mSlabs[j].mPool + mNodeAllocator.mSlabs[j].mNbUsedNodes)
{
localNodeIndex = PxU32(pool[i].mPos - mNodeAllocator.mSlabs[j].mPool);
break;
}
nodeBase += mNodeAllocator.mSlabs[j].mNbUsedNodes;
}
const PxU32 nodeIndex = nodeBase + localNodeIndex;
IncrementalAABBTreeNode* child0 = treeNodes[nodeIndex];
IncrementalAABBTreeNode* child1 = treeNodes[nodeIndex + 1];
if(!child0)
{
PX_ASSERT(!child1);
child0 = reinterpret_cast<IncrementalAABBTreeNode*>(mNodesPool.allocate());
child1 = child0 + 1;
treeNodes[nodeIndex] = child0;
treeNodes[nodeIndex + 1] = child1;
}
destNode->mChilds[0] = child0;
destNode->mChilds[1] = child1;
child0->mParent = destNode;
child1->mParent = destNode;
}
offset++;
}
}
}
void IncrementalAABBTree::copyNode(IncrementalAABBTreeNode& destNode, const BVHNode& sourceNode,
const BVHNode* nodeBase, IncrementalAABBTreeNode* parent, const PxU32* primitivesBase,
PxArray<IncrementalAABBTreeNode*>& mapping)
{
destNode.mParent = parent;
destNode.mBVMin = V4ClearW(V4LoadU(&sourceNode.mBV.minimum.x));
destNode.mBVMax = V4ClearW(V4LoadU(&sourceNode.mBV.maximum.x));
if(sourceNode.isLeaf())
{
AABBTreeIndices* indices = mIndicesPool.allocate();
destNode.mIndices = indices;
indices->nbIndices = sourceNode.getNbPrimitives();
const PxU32* sourceIndices = sourceNode.getPrimitives(primitivesBase);
for(PxU32 i = 0; i < indices->nbIndices; i++)
{
const PxU32 sourceIndex = sourceIndices[i];
indices->indices[i] = sourceIndex;
mapping[sourceIndex] = &destNode;
}
}
else
{
IncrementalAABBTreeNodePair* nodePair = mNodesPool.construct();
IncrementalAABBTreeNode* child0 = &nodePair->mNode0;
IncrementalAABBTreeNode* child1 = &nodePair->mNode1;
destNode.mChilds[0] = child0;
destNode.mChilds[1] = child1;
copyNode(*destNode.mChilds[0], *sourceNode.getPos(nodeBase), nodeBase, &destNode, primitivesBase, mapping);
copyNode(*destNode.mChilds[1], *sourceNode.getNeg(nodeBase), nodeBase, &destNode, primitivesBase, mapping);
}
}
// build the tree from the prebuild AABB tree
void IncrementalAABBTree::copy(const BVH& bvh, PxArray<IncrementalAABBTreeNode*>& mapping)
{
if(bvh.getNbBounds() == 0)
return;
IncrementalAABBTreeNodePair* nodePair = mNodesPool.construct();
mRoot = &nodePair->mNode0;
const BVHNode* nodes = bvh.getNodes();
copyNode(*mRoot, *nodes, nodes, NULL, bvh.getIndices(), mapping);
}
| 34,872 | C++ | 31.622077 | 178 | 0.722385 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuMTD.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_MTD_H
#define GU_MTD_H
#include "foundation/PxVec3.h"
#include "foundation/PxTransform.h"
#include "geometry/PxGeometry.h"
namespace physx
{
namespace Gu
{
// PT: we use a define to be able to quickly change the signature of all MTD functions.
// (this also ensures they all use consistent names for passed parameters).
// \param[out] mtd computed depenetration dir
// \param[out] depth computed depenetration depth
// \param[in] geom0 first geometry object
// \param[in] pose0 pose of first geometry object
// \param[in] geom1 second geometry object
// \param[in] pose1 pose of second geometry object
// \param[in] cache optional cached data for triggers
#define GU_MTD_FUNC_PARAMS PxVec3& mtd, PxF32& depth, \
const PxGeometry& geom0, const PxTransform32& pose0, \
const PxGeometry& geom1, const PxTransform32& pose1
// PT: function pointer for Geom-indexed MTD functions
// See GU_MTD_FUNC_PARAMS for function parameters details.
// \return true if an overlap was found, false otherwise
// \note depenetration vector D is equal to mtd * depth. It should be applied to the 1st object, to get out of the 2nd object.
typedef bool (*GeomMTDFunc) (GU_MTD_FUNC_PARAMS);
PX_FORCE_INLINE PxF32 manualNormalize(PxVec3& mtd, const PxVec3& normal, PxReal lenSq)
{
const PxF32 len = PxSqrt(lenSq);
// We do a *manual* normalization to check for singularity condition
if(lenSq < 1e-6f)
mtd = PxVec3(1.0f, 0.0f, 0.0f); // PT: zero normal => pick up random one
else
mtd = normal * 1.0f / len;
return len;
}
}
}
#endif
| 3,284 | C | 42.799999 | 128 | 0.740865 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuSDF.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_SDF_H
#define GU_SDF_H
/** \addtogroup geomutils
@{
*/
#include "common/PxPhysXCommonConfig.h"
#include "foundation/PxVec3.h"
#include "foundation/PxUserAllocated.h"
#include "foundation/PxArray.h"
#include "foundation/PxMathUtils.h"
namespace physx
{
class PxSDFBuilder;
class PxSerializationContext;
class PxDeserializationContext;
namespace Gu
{
/**
\brief Represents dimensions of signed distance field
*/
class Dim3
{
public:
/**
\brief Constructor
*/
Dim3()
{
}
/**
\brief Constructor
*/
Dim3(PxZERO d) : x(0), y(0), z(0)
{
PX_UNUSED(d);
}
/**
\brief Constructor
*/
Dim3(PxU32 _x, PxU32 _y, PxU32 _z) : x(_x), y(_y), z(_z)
{
}
/**
\brief Copy constructor
*/
Dim3(const Dim3& d) : x(d.x), y(d.y), z(d.z)
{
}
PxU32 x; //!< Size of X dimension
PxU32 y; //!< Size of Y dimension
PxU32 z; //!< Size of Z dimension
};
/**
\brief Represents a signed distance field.
*/
class SDF : public PxUserAllocated
{
public:
// PX_SERIALIZATION
SDF(const PxEMPTY) : mOwnsMemory(false) {}
void exportExtraData(PxSerializationContext& context);
void importExtraData(PxDeserializationContext& context);
static void getBinaryMetaData(PxOutputStream& stream);
//~PX_SERIALIZATION
/**
\brief Constructor
*/
SDF() : mSdf(NULL), mSubgridStartSlots(NULL), mSubgridSdf(NULL), mOwnsMemory(true)
{
}
/**
\brief Constructor
*/
SDF(PxZERO s)
: mMeshLower(PxZero), mSpacing(0.0f), mDims(PxZero), mNumSdfs(0), mSdf(NULL),
mSubgridSize(PxZero), mNumStartSlots(0), mSubgridStartSlots(NULL), mNumSubgridSdfs(0), mSubgridSdf(NULL), mSdfSubgrids3DTexBlockDim(PxZero),
mSubgridsMinSdfValue(0.0f), mSubgridsMaxSdfValue(0.0f), mBytesPerSparsePixel(0), mOwnsMemory(true)
{
PX_UNUSED(s);
}
/**
\brief Copy constructor
*/
SDF(const SDF& sdf)
: mMeshLower(sdf.mMeshLower), mSpacing(sdf.mSpacing), mDims(sdf.mDims), mNumSdfs(sdf.mNumSdfs), mSdf(sdf.mSdf),
mSubgridSize(sdf.mSubgridSize), mNumStartSlots(sdf.mNumStartSlots), mSubgridStartSlots(sdf.mSubgridStartSlots), mNumSubgridSdfs(sdf.mNumSubgridSdfs), mSubgridSdf(sdf.mSubgridSdf), mSdfSubgrids3DTexBlockDim(sdf.mSdfSubgrids3DTexBlockDim),
mSubgridsMinSdfValue(sdf.mSubgridsMinSdfValue), mSubgridsMaxSdfValue(sdf.mSubgridsMaxSdfValue), mBytesPerSparsePixel(sdf.mBytesPerSparsePixel),
mOwnsMemory(true)
{
}
static PX_FORCE_INLINE void decodeTriple(PxU32 id, PxU32& x, PxU32& y, PxU32& z)
{
x = id & 0x000003FF;
id = id >> 10;
y = id & 0x000003FF;
id = id >> 10;
z = id & 0x000003FF;
}
static PX_FORCE_INLINE PxReal decodeSample(PxU8* data, PxU32 index, PxU32 bytesPerSparsePixel, PxReal subgridsMinSdfValue, PxReal subgridsMaxSdfValue)
{
switch (bytesPerSparsePixel)
{
case 1:
return PxReal(data[index]) * (1.0f / 255.0f) * (subgridsMaxSdfValue - subgridsMinSdfValue) + subgridsMinSdfValue;
case 2:
{
PxU16* ptr = reinterpret_cast<PxU16*>(data);
return PxReal(ptr[index]) * (1.0f / 65535.0f) * (subgridsMaxSdfValue - subgridsMinSdfValue) + subgridsMinSdfValue;
}
case 4:
{
//If 4 bytes per subgrid pixel are available, then normal floats are used. No need to
//de-normalize integer values since the floats already contain real distance values
PxReal* ptr = reinterpret_cast<PxReal*>(data);
return ptr[index];
}
default:
PX_ASSERT(0);
}
return 0;
}
PX_PHYSX_COMMON_API PxReal decodeSparse(PxI32 xx, PxI32 yy, PxI32 zz) const;
PX_PHYSX_COMMON_API PxReal decodeDense(PxI32 x, PxI32 y, PxI32 z) const;
PX_FORCE_INLINE PxU32 nbSubgridsX() const
{
return mDims.x / mSubgridSize;
}
PX_FORCE_INLINE PxU32 nbSubgridsY() const
{
return mDims.y / mSubgridSize;
}
PX_FORCE_INLINE PxU32 nbSubgridsZ() const
{
return mDims.z / mSubgridSize;
}
PX_FORCE_INLINE PxVec3 getCellSize() const
{
return PxVec3(mSpacing);
}
PX_FORCE_INLINE bool subgridExists(PxU32 sgX, PxU32 sgY, PxU32 sgZ) const
{
const PxU32 nbX = mDims.x / mSubgridSize;
const PxU32 nbY = mDims.y / mSubgridSize;
//const PxU32 nbZ = mDims.z / mSubgridSize;
PxU32 startId = mSubgridStartSlots[sgZ * (nbX) * (nbY) + sgY * (nbX) + sgX];
return startId != 0xFFFFFFFFu;
}
/**
\brief Destructor
*/
~SDF();
PxReal* allocateSdfs(const PxVec3& meshLower, const PxReal& spacing, const PxU32 dimX, const PxU32 dimY, const PxU32 dimZ,
const PxU32 subgridSize, const PxU32 sdfSubgrids3DTexBlockDimX, const PxU32 sdfSubgrids3DTexBlockDimY, const PxU32 sdfSubgrids3DTexBlockDimZ,
PxReal subgridsMinSdfValue, PxReal subgridsMaxSdfValue, PxU32 bytesPerSparsePixel);
PxVec3 mMeshLower; //!< Lower bound of the original mesh
PxReal mSpacing; //!< Spacing of each sdf voxel
Dim3 mDims; //!< Dimension of the sdf
PxU32 mNumSdfs; //!< Number of sdf values
PxReal* mSdf; //!< Array of sdf
// Additional data to support sparse grid SDFs
PxU32 mSubgridSize; //!< The number of cells in a sparse subgrid block (full block has mSubgridSize^3 cells and (mSubgridSize+1)^3 samples). If set to zero, this indicates that only a dense background grid SDF is used without sparse blocks
PxU32 mNumStartSlots; //!< Array length of mSubgridStartSlots. Only used for serialization
PxU32* mSubgridStartSlots; //!< Array with start indices into the subgrid texture for every subgrid block. 10bits for z coordinate, 10bits for y and 10bits for x
PxU32 mNumSubgridSdfs; //!< Array length of mSubgridSdf. Only used for serialization
PxU8* mSubgridSdf; //!< The data to create the 3d texture containg the packed subgrid blocks. Stored as PxU8 to support multiple formats (8, 16 and 32 bits per pixel)
Dim3 mSdfSubgrids3DTexBlockDim; //!< Subgrid sdf is layed out as a 3d texture including packed blocks of size (mSubgridSize+1)^3
PxReal mSubgridsMinSdfValue; //!< The minimum value over all subgrid blocks. Used if normalized textures are used which is the case for 8 and 16bit formats
PxReal mSubgridsMaxSdfValue; //!< The maximum value over all subgrid blocks. Used if normalized textures are used which is the case for 8 and 16bit formats
PxU32 mBytesPerSparsePixel; //!< The number of bytes per subgrid pixel
bool mOwnsMemory; //!< Only false for binary deserialized data
};
/**
\brief Returns the number of times a point is enclosed by a triangle mesh. Therefore points with a winding number of 0 lie oufside of the mesh, others lie inside. The sign of the winding number
is dependent ond the triangle orientation. For close meshes, a robust inside/outside check should not test for a value of 0 exactly, inside = PxAbs(windingNumber) > 0.5f should be preferred.
\param[in] vertices The triangle mesh's vertices
\param[in] indices The triangle mesh's indices
\param[in] numTriangleIndices The number of indices
\param[in] width The number of grid points along the x direction
\param[in] height The number of grid points along the y direction
\param[in] depth The number of grid points along the z direction
\param[out] windingNumbers The winding number for the center of every grid cell, index rule is: index = z * width * height + y * width + x
\param[in] minExtents The grid's lower corner
\param[in] maxExtents The grid's upper corner
\param[out] sampleLocations Optional buffer to output the grid sample locations, index rule is: index = z * width * height + y * width + x
*/
PX_PHYSX_COMMON_API void windingNumbers(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
PxReal* windingNumbers, PxVec3 minExtents, PxVec3 maxExtents, PxVec3* sampleLocations = NULL);
/**
\brief Returns if a point is enclosed by a triangle mesh.
\param[in] vertices The triangle mesh's vertices
\param[in] indices The triangle mesh's indices
\param[in] numTriangleIndices The number of indices
\param[in] width The number of grid points along the x direction
\param[in] height The number of grid points along the y direction
\param[in] depth The number of grid points along the z direction
\param[out] insideResult Booleans that indicate if the center of a grid cell is inside or outside, index rule is: index = z * width * height + y * width + x
\param[in] minExtents The grid's lower corner, the box formed by minExtent and maxExtent must include all vertices
\param[in] maxExtents The grid's upper corner, the box formed by minExtent and maxExtent must include all vertices
\param[out] sampleLocations Optional buffer to output the grid sample locations, index rule is: index = z * width * height + y * width + x
*/
PX_PHYSX_COMMON_API void windingNumbersInsideCheck(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
bool* insideResult, PxVec3 minExtents, PxVec3 maxExtents, PxVec3* sampleLocations = NULL);
/**
\brief Returns the distance to the mesh's surface for all samples in a grid. The sign is dependent on the triangle orientation. Negative distances indicate that a sample is inside the mesh, positive
distances mean the sample is outside of the mesh.
\param[in] vertices The triangle mesh's vertices
\param[in] indices The triangle mesh's indices
\param[in] numTriangleIndices The number of indices
\param[in] width The number of grid points along the x direction
\param[in] height The number of grid points along the y direction
\param[in] depth The number of grid points along the z direction
\param[out] sdf The signed distance field (negative values indicate that a point is inside of the mesh), index rule is: index = z * width * height + y * width + x
\param[in] minExtents The grid's lower corner, the box formed by minExtent and maxExtent must include all vertices
\param[in] maxExtents The grid's upper corner, the box formed by minExtent and maxExtent must include all vertices
\param[out] sampleLocations Optional buffer to output the grid sample locations, index rule is: index = z * width * height + y * width + x
\param[in] cellCenteredSamples Determines if the sample points are chosen at cell centers or at cell origins
\param[in] numThreads The number of cpu threads to use during the computation
\param[in] sdfBuilder Optional pointer to a sdf builder to accelerate the sdf construction. The pointer is owned by the caller and must remain valid until the function terminates.
*/
PX_PHYSX_COMMON_API void SDFUsingWindingNumbers(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
PxReal* sdf, PxVec3 minExtents, PxVec3 maxExtents, PxVec3* sampleLocations = NULL, bool cellCenteredSamples = true,
PxU32 numThreads = 1, PxSDFBuilder* sdfBuilder = NULL);
/**
\brief Returns the distance to the mesh's surface for all samples in a grid. The sign is dependent on the triangle orientation. Negative distances indicate that a sample is inside the mesh, positive
distances mean the sample is outside of the mesh. Near mesh surfaces, a higher resolution is available than further away from the surface (sparse sdf format) to save memory.
The samples are not cell centered but located at the cell origin. This is a requirement of the sparse grid format.
\param[in] vertices The triangle mesh's vertices
\param[in] indices The triangle mesh's indices
\param[in] numTriangleIndices The number of indices
\param[in] width The number of grid points along the x direction
\param[in] height The number of grid points along the y direction
\param[in] depth The number of grid points along the z direction
\param[in] minExtents The grid's lower corner, the box formed by minExtent and maxExtent must include all vertices
\param[in] maxExtents The grid's upper corner, the box formed by minExtent and maxExtent must include all vertices
\param[in] narrowBandThicknessRelativeToExtentDiagonal The thickness of the narrow band as a fraction of the sdf box diagonal length. Can be as small as 0 but a value of at least 0.01 is recommended.
\param[in] cellsPerSubgrid The number of cells in a sparse subgrid block (full block has mSubgridSize^3 cells and (mSubgridSize+1)^3 samples)
\param[out] sdfCoarse The coarse sdf as a dense 3d array of lower resolution (resulution is (with/cellsPerSubgrid+1, height/cellsPerSubgrid+1, depth/cellsPerSubgrid+1))
\param[out] sdfFineStartSlots The start slot indices of the subgrid blocks. If a subgrid block is empty, the start slot will be 0xFFFFFFFF
\param[out] subgridData The array containing subgrid data blocks
\param[out] denseSdf Provides acces to the denxe sdf that is used for compuation internally
\param[out] subgridsMinSdfValue The minimum value over all subgrid blocks. Used if normalized textures are used which is the case for 8 and 16bit formats
\param[out] subgridsMaxSdfValue The maximum value over all subgrid blocks. Used if normalized textures are used which is the case for 8 and 16bit formats
\param[in] numThreads The number of cpu threads to use during the computation
\param[in] sdfBuilder Optional pointer to a sdf builder to accelerate the sdf construction. The pointer is owned by the caller and must remain valid until the function terminates.
*/
PX_PHYSX_COMMON_API void SDFUsingWindingNumbersSparse(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
const PxVec3& minExtents, const PxVec3& maxExtents, PxReal narrowBandThicknessRelativeToExtentDiagonal, PxU32 cellsPerSubgrid,
PxArray<PxReal>& sdfCoarse, PxArray<PxU32>& sdfFineStartSlots, PxArray<PxReal>& subgridData, PxArray<PxReal>& denseSdf,
PxReal& subgridsMinSdfValue, PxReal& subgridsMaxSdfValue, PxU32 numThreads = 1, PxSDFBuilder* sdfBuilder = NULL);
PX_PHYSX_COMMON_API void analyzeAndFixMesh(const PxVec3* vertices, const PxU32* indicesOrig, PxU32 numTriangleIndices, PxArray<PxU32>& repairedIndices);
/**
\brief Converts a sparse grid sdf to a format that can be used to create a 3d texture. 3d textures support very efficient
trilinear interpolation on the GPU which is very important during sdf evaluation.
\param[in] width The number of grid points along the x direction
\param[in] height The number of grid points along the y direction
\param[in] depth The number of grid points along the z direction
\param[in] cellsPerSubgrid The number of cells in a sparse subgrid block (full block has mSubgridSize^3 cells and (mSubgridSize+1)^3 samples)
\param[in,out] sdfFineStartSlots Array with linear start indices into the subgrid data array. This array gets converted by this method to start indices for every subgrid block in the 3d texture. The result uses 10bits for z coordinate, 10bits for y and 10bits for x
\param[in] sdfFineSubgridsIn Subgrid data array
\param[in] sdfFineSubgridsSize Number of elements in sdfFineSubgridsIn
\param[out] subgrids3DTexFormat The subgrid data organized in a 3d texture compatible order
\param[out] numSubgridsX Number of subgrid blocks in the 3d texture along x. The full texture dimension along x will be numSubgridsX*(cellsPerSubgrid+1).
\param[out] numSubgridsY Number of subgrid blocks in the 3d texture along y. The full texture dimension along y will be numSubgridsY*(cellsPerSubgrid+1).
\param[out] numSubgridsZ Number of subgrid blocks in the 3d texture along z. The full texture dimension along z will be numSubgridsZ*(cellsPerSubgrid+1).
*/
PX_PHYSX_COMMON_API void convertSparseSDFTo3DTextureLayout(PxU32 width, PxU32 height, PxU32 depth, PxU32 cellsPerSubgrid,
PxU32* sdfFineStartSlots, const PxReal* sdfFineSubgridsIn, PxU32 sdfFineSubgridsSize, PxArray<PxReal>& subgrids3DTexFormat,
PxU32& numSubgridsX, PxU32& numSubgridsY, PxU32& numSubgridsZ);
/**
\brief Extracts an isosurface as a triangular mesh from a signed distance function
\param[in] sdf The signed distance function
\param[out] isosurfaceVertices The vertices of the extracted isosurface
\param[out] isosurfaceTriangleIndices The triangles of the extracted isosurface
\param[in] numThreads The number of threads to use
*/
PX_PHYSX_COMMON_API void extractIsosurfaceFromSDF(const Gu::SDF& sdf, PxArray<PxVec3>& isosurfaceVertices, PxArray<PxU32>& isosurfaceTriangleIndices, PxU32 numThreads = 1);
/**
\brief A class that allows to efficiently project points onto the surface of a triangle mesh.
*/
class PxPointOntoTriangleMeshProjector
{
public:
/**
\brief Projects a point onto the surface of a triangle mesh.
\param[in] point The point to project
\return the projected point
*/
virtual PxVec3 projectPoint(const PxVec3& point) = 0;
/**
\brief Projects a point onto the surface of a triangle mesh.
\param[in] point The point to project
\param[out] closestTriangleIndex The index of the triangle on which the projected point is located
\return the projected point
*/
virtual PxVec3 projectPoint(const PxVec3& point, PxU32& closestTriangleIndex) = 0;
/**
\brief Releases the instance and its data
*/
virtual void release() = 0;
};
/**
\brief Creates a helper class that allows to efficiently project points onto the surface of a triangle mesh.
\param[in] vertices The triangle mesh's vertices
\param[in] triangleIndices The triangle mesh's indices
\param[in] numTriangles The number of triangles
\return A point onto triangle mesh projector instance. The caller needs to delete the instance once it is not used anymore by calling its release method
*/
PX_PHYSX_COMMON_API PxPointOntoTriangleMeshProjector* PxCreatePointOntoTriangleMeshProjector(const PxVec3* vertices, const PxU32* triangleIndices, PxU32 numTriangles);
/**
\brief Utility to convert from a linear index to x/y/z indices given the grid size (only sizeX and sizeY required)
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE void idToXYZ(PxU32 id, PxU32 sizeX, PxU32 sizeY, PxU32& xi, PxU32& yi, PxU32& zi)
{
xi = id % sizeX; id /= sizeX;
yi = id % sizeY;
zi = id / sizeY;
}
/**
\brief Utility to convert from x/y/z indices to a linear index given the grid size (only width and height required)
*/
PX_FORCE_INLINE PX_CUDA_CALLABLE PxU32 idx3D(PxU32 x, PxU32 y, PxU32 z, PxU32 width, PxU32 height)
{
return (z * height + y) * width + x;
}
/**
\brief Utility to encode 3 indices into a single integer. Each index is allowed to use up to 10 bits.
*/
PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 encodeTriple(PxU32 x, PxU32 y, PxU32 z)
{
PX_ASSERT(x >= 0 && x < 1024);
PX_ASSERT(y >= 0 && y < 1024);
PX_ASSERT(z >= 0 && z < 1024);
return (z << 20) | (y << 10) | x;
}
/**
\brief Computes sample point locations from x/y/z indices
*/
PX_ALIGN_PREFIX(16)
struct GridQueryPointSampler
{
private:
PxVec3 mOrigin;
PxVec3 mCellSize;
PxI32 mOffsetX, mOffsetY, mOffsetZ;
PxI32 mStepX, mStepY, mStepZ;
public:
PX_CUDA_CALLABLE GridQueryPointSampler() {}
PX_CUDA_CALLABLE GridQueryPointSampler(const PxVec3& origin, const PxVec3& cellSize, bool cellCenteredSamples,
PxI32 offsetX = 0, PxI32 offsetY = 0, PxI32 offsetZ = 0, PxI32 stepX = 1, PxI32 stepY = 1, PxI32 stepZ = 1)
: mCellSize(cellSize), mOffsetX(offsetX), mOffsetY(offsetY), mOffsetZ(offsetZ), mStepX(stepX), mStepY(stepY), mStepZ(stepZ)
{
if (cellCenteredSamples)
mOrigin = origin + 0.5f * cellSize;
else
mOrigin = origin;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getOrigin() const
{
return mOrigin;
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getActiveCellSize() const
{
return PxVec3(mCellSize.x * mStepX, mCellSize.y * mStepY, mCellSize.z * mStepZ);
}
PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3 getPoint(PxI32 x, PxI32 y, PxI32 z) const
{
return PxVec3(mOrigin.x + (x * mStepX + mOffsetX) * mCellSize.x,
mOrigin.y + (y * mStepY + mOffsetY) * mCellSize.y,
mOrigin.z + (z * mStepZ + mOffsetZ) * mCellSize.z);
}
}
PX_ALIGN_SUFFIX(16);
/**
\brief Represents a dense SDF and allows to evaluate it. Uses trilinear interpolation between samples.
*/
class DenseSDF
{
public:
PxU32 mWidth, mHeight, mDepth;
private:
PxReal* mSdf;
public:
PX_INLINE PX_CUDA_CALLABLE DenseSDF(PxU32 width, PxU32 height, PxU32 depth, PxReal* sdf)
{
initialize(width, height, depth, sdf);
}
DenseSDF() {}
PX_FORCE_INLINE PX_CUDA_CALLABLE void initialize(PxU32 width, PxU32 height, PxU32 depth, PxReal* sdf)
{
this->mWidth = width;
this->mHeight = height;
this->mDepth = depth;
this->mSdf = sdf;
}
PX_FORCE_INLINE PxU32 memoryConsumption()
{
return mWidth * mHeight * mDepth * sizeof(PxReal);
}
PX_INLINE PX_CUDA_CALLABLE PxReal sampleSDFDirect(const PxVec3& samplePoint)
{
const PxU32 xBase = PxClamp(PxU32(samplePoint.x), 0u, mWidth - 2);
const PxU32 yBase = PxClamp(PxU32(samplePoint.y), 0u, mHeight - 2);
const PxU32 zBase = PxClamp(PxU32(samplePoint.z), 0u, mDepth - 2);
return Interpolation::PxTriLerp(
mSdf[idx3D(xBase, yBase, zBase, mWidth, mHeight)],
mSdf[idx3D(xBase + 1, yBase, zBase, mWidth, mHeight)],
mSdf[idx3D(xBase, yBase + 1, zBase, mWidth, mHeight)],
mSdf[idx3D(xBase + 1, yBase + 1, zBase, mWidth, mHeight)],
mSdf[idx3D(xBase, yBase, zBase + 1, mWidth, mHeight)],
mSdf[idx3D(xBase + 1, yBase, zBase + 1, mWidth, mHeight)],
mSdf[idx3D(xBase, yBase + 1, zBase + 1, mWidth, mHeight)],
mSdf[idx3D(xBase + 1, yBase + 1, zBase + 1, mWidth, mHeight)], samplePoint.x - xBase, samplePoint.y - yBase, samplePoint.z - zBase);
}
};
}
}
/** @} */
#endif
| 23,659 | C | 45.120858 | 267 | 0.728602 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuMaverickNode.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_MAVERICK_NODE_H
#define GU_MAVERICK_NODE_H
#include "foundation/PxBounds3.h"
#include "foundation/PxTransform.h"
#include "common/PxPhysXCommonConfig.h"
#include "GuPrunerPayload.h"
#include "GuPrunerTypedef.h"
#define FREE_PRUNER_SIZE 16
#ifdef FREE_PRUNER_SIZE
namespace physx
{
namespace Gu
{
class MaverickNode
{
public:
MaverickNode() : mNbFree(0) {}
~MaverickNode() {}
PX_FORCE_INLINE void release() { mNbFree = 0; }
PX_FORCE_INLINE const PxU32* getPrimitives(const PxU32*) const { return mIndices; }
PX_FORCE_INLINE PxU32 getPrimitiveIndex() const { return 0; }
PX_FORCE_INLINE PxU32 getNbPrimitives() const { return mNbFree; }
bool addObject(const PrunerPayload& object, PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform, PxU32 timeStamp);
bool updateObject(const PrunerPayload& object, const PxBounds3& worldAABB, const PxTransform& transform);
bool updateObject(PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform);
bool removeObject(const PrunerPayload& object, PxU32& timeStamp);
bool removeObject(PrunerHandle handle, PxU32& timeStamp);
PxU32 removeMarkedObjects(PxU32 timeStamp);
void shiftOrigin(const PxVec3& shift);
void remove(PxU32 index);
PxU32 mNbFree; // Current number of objects in the "free array" (mFreeObjects/mFreeBounds)
PrunerPayload mFreeObjects[FREE_PRUNER_SIZE]; // mNbFree objects are stored here
PrunerHandle mFreeHandles[FREE_PRUNER_SIZE]; // mNbFree handles are stored here
PxBounds3 mFreeBounds[FREE_PRUNER_SIZE]; // mNbFree object bounds are stored here
PxTransform mFreeTransforms[FREE_PRUNER_SIZE]; // mNbFree transforms are stored here
PxU32 mFreeStamps[FREE_PRUNER_SIZE];
static const PxU32 mIndices[FREE_PRUNER_SIZE];
};
}
}
#endif
#endif
| 3,637 | C | 42.831325 | 148 | 0.739071 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuPruningPool.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuPruningPool.h"
#include "foundation/PxMemory.h"
#include "common/PxProfileZone.h"
using namespace physx;
using namespace Gu;
PruningPool::PruningPool(PxU64 contextID, TransformCacheMode mode) :
mNbObjects (0),
mMaxNbObjects (0),
mObjects (NULL),
mTransforms (NULL),
mTransformCacheMode (mode),
mHandleToIndex (NULL),
mIndexToHandle (NULL),
mFirstRecycledHandle(INVALID_PRUNERHANDLE),
mContextID (contextID)
{
}
PruningPool::~PruningPool()
{
mWorldBoxes.release();
PX_FREE(mIndexToHandle);
PX_FREE(mHandleToIndex);
PX_FREE(mTransforms);
PX_FREE(mObjects);
}
bool PruningPool::resize(PxU32 newCapacity)
{
PX_PROFILE_ZONE("PruningPool::resize", mContextID);
const bool useTransforms = mTransformCacheMode!=TRANSFORM_CACHE_UNUSED;
PxTransform* newTransforms = useTransforms ? PX_ALLOCATE(PxTransform, newCapacity, "Pruner transforms") : NULL;
if(useTransforms && !newTransforms)
return false;
PrunerPayload* newData = PX_ALLOCATE(PrunerPayload, newCapacity, "PrunerPayload*");
PrunerHandle* newIndexToHandle = PX_ALLOCATE(PrunerHandle, newCapacity, "Pruner Index Mapping");
PoolIndex* newHandleToIndex = PX_ALLOCATE(PoolIndex, newCapacity, "Pruner Index Mapping");
if( (!newData) || (!newIndexToHandle) || (!newHandleToIndex))
{
PX_FREE(newHandleToIndex);
PX_FREE(newIndexToHandle);
PX_FREE(newTransforms);
PX_FREE(newData);
return false;
}
mWorldBoxes.resize(newCapacity, mNbObjects);
if(mObjects) PxMemCopy(newData, mObjects, mNbObjects*sizeof(PrunerPayload));
if(mTransforms) PxMemCopy(newTransforms, mTransforms, mNbObjects*sizeof(PxTransform));
if(mIndexToHandle) PxMemCopy(newIndexToHandle, mIndexToHandle, mNbObjects*sizeof(PrunerHandle));
if(mHandleToIndex) PxMemCopy(newHandleToIndex, mHandleToIndex, mMaxNbObjects*sizeof(PoolIndex)); // PT: why mMaxNbObjects here? on purpose?
mMaxNbObjects = newCapacity;
PX_FREE(mIndexToHandle);
PX_FREE(mHandleToIndex);
PX_FREE(mTransforms);
PX_FREE(mObjects);
mObjects = newData;
mTransforms = newTransforms;
mHandleToIndex = newHandleToIndex;
mIndexToHandle = newIndexToHandle;
return true;
}
void PruningPool::preallocate(PxU32 newCapacity)
{
if(newCapacity>mMaxNbObjects)
resize(newCapacity);
}
PxU32 PruningPool::addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* data, const PxTransform* transforms, PxU32 count)
{
PX_PROFILE_ZONE("PruningPool::addObjects", mContextID);
PX_ASSERT((!transforms && mTransformCacheMode==TRANSFORM_CACHE_UNUSED) || (transforms && mTransformCacheMode!=TRANSFORM_CACHE_UNUSED));
for(PxU32 i=0;i<count;i++)
{
if(mNbObjects==mMaxNbObjects) // increase the capacity on overflow
{
const PxU32 newCapacity = PxU32(float(mMaxNbObjects)*1.5f);
if(!resize(PxMax<PxU32>(newCapacity, 64)))
//if(!resize(PxMax<PxU32>(mMaxNbObjects*2, 64)))
{
// pool can return an invalid handle if memory alloc fails
// should probably have an error here or not handle this
results[i] = INVALID_PRUNERHANDLE; // PT: we need to write the potentially invalid handle to let users know which object failed first
return i;
}
}
PX_ASSERT(mNbObjects!=mMaxNbObjects);
const PoolIndex index = mNbObjects++;
// update mHandleToIndex and mIndexToHandle mappings
PrunerHandle handle;
if(mFirstRecycledHandle != INVALID_PRUNERHANDLE)
{
// mFirstRecycledHandle is an entry into a freelist for removed slots
// this path is only taken if we have any removed slots
handle = mFirstRecycledHandle;
mFirstRecycledHandle = mHandleToIndex[handle];
}
else
{
handle = index;
}
// PT: TODO: investigate why we added mIndexToHandle/mHandleToIndex. The initial design with 'Prunable' objects didn't need these arrays.
// PT: these arrays are "parallel"
mWorldBoxes.getBounds() [index] = bounds[i]; // store the payload/userData and AABB in parallel arrays
mObjects [index] = data[i];
mIndexToHandle [index] = handle;
if(transforms && mTransforms)
mTransforms [index] = transforms[i];
mHandleToIndex[handle] = index;
results[i] = handle;
}
return count;
}
PoolIndex PruningPool::removeObject(PrunerHandle h, PrunerPayloadRemovalCallback* removalCallback)
{
PX_PROFILE_ZONE("PruningPool::removeObject", mContextID);
PX_ASSERT(mNbObjects);
// remove the object and its AABB by provided PrunerHandle and update mHandleToIndex and mIndexToHandle mappings
const PoolIndex indexOfRemovedObject = mHandleToIndex[h]; // retrieve object's index from handle
if(removalCallback)
removalCallback->invoke(1, &mObjects[indexOfRemovedObject]);
const PoolIndex indexOfLastObject = --mNbObjects; // swap the object at last index with index
if(indexOfLastObject!=indexOfRemovedObject)
{
// PT: move last object's data to recycled spot (from removed object)
// PT: the last object has moved so we need to handle the mappings for this object
// PT: TODO: investigate where this double-mapping comes from. It was not needed in the original design.
// PT: these arrays are "parallel"
PxBounds3* bounds = mWorldBoxes.getBounds();
const PrunerHandle handleOfLastObject = mIndexToHandle[indexOfLastObject];
bounds [indexOfRemovedObject] = bounds [indexOfLastObject];
mObjects [indexOfRemovedObject] = mObjects [indexOfLastObject];
if(mTransforms)
mTransforms [indexOfRemovedObject] = mTransforms [indexOfLastObject];
mIndexToHandle [indexOfRemovedObject] = handleOfLastObject;
mHandleToIndex[handleOfLastObject] = indexOfRemovedObject;
}
// mHandleToIndex also stores the freelist for removed handles (in place of holes formed by removed handles)
mHandleToIndex[h] = mFirstRecycledHandle; // update linked list of available recycled handles
mFirstRecycledHandle = h; // update the list head
return indexOfLastObject;
}
void PruningPool::shiftOrigin(const PxVec3& shift)
{
PX_PROFILE_ZONE("PruningPool::shiftOrigin", mContextID);
const PxU32 nb = mNbObjects;
PxBounds3* bounds = mWorldBoxes.getBounds();
for(PxU32 i=0; i<nb; i++)
{
bounds[i].minimum -= shift;
bounds[i].maximum -= shift;
}
if(mTransforms && mTransformCacheMode==TRANSFORM_CACHE_GLOBAL)
{
for(PxU32 i=0; i<nb; i++)
mTransforms[i].p -= shift;
}
}
template<const bool hasTransforms>
static void updateAndInflateBounds(PruningPool& pool, const PrunerHandle* PX_RESTRICT handles, const PxU32* PX_RESTRICT boundsIndices, const PxBounds3* PX_RESTRICT newBounds,
const PxTransform32* PX_RESTRICT newTransforms, PxU32 count, float epsilon)
{
PxBounds3* PX_RESTRICT bounds = pool.mWorldBoxes.getBounds();
PxTransform* PX_RESTRICT transforms = hasTransforms ? pool.mTransforms : NULL;
if(boundsIndices)
{
while(count--)
{
const PoolIndex poolIndex = pool.getIndex(*handles++);
PX_ASSERT(poolIndex!=INVALID_PRUNERHANDLE);
const PxU32 remappedIndex = *boundsIndices++;
if(hasTransforms)
transforms[poolIndex] = newTransforms[remappedIndex];
inflateBounds<true>(bounds[poolIndex], newBounds[remappedIndex], epsilon);
}
}
else
{
while(count--)
{
const PoolIndex poolIndex = pool.getIndex(*handles++);
PX_ASSERT(poolIndex!=INVALID_PRUNERHANDLE);
if(hasTransforms)
{
transforms[poolIndex] = *newTransforms;
newTransforms++;
}
inflateBounds<true>(bounds[poolIndex], *newBounds++, epsilon);
}
}
}
void PruningPool::updateAndInflateBounds(const PrunerHandle* handles, const PxU32* boundsIndices, const PxBounds3* newBounds,
const PxTransform32* newTransforms, PxU32 count, float epsilon)
{
PX_PROFILE_ZONE("PruningPool::updateAndInflateBounds", mContextID);
if(mTransforms)
::updateAndInflateBounds<1>(*this, handles, boundsIndices, newBounds, newTransforms, count, epsilon);
else
::updateAndInflateBounds<0>(*this, handles, boundsIndices, newBounds, NULL, count, epsilon);
}
| 9,531 | C++ | 34.834586 | 174 | 0.754066 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuActorShapeMap.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuActorShapeMap.h"
#include "foundation/PxMemory.h"
using namespace physx;
using namespace Gu;
namespace physx
{
namespace Gu
{
/*PX_FORCE_INLINE*/ uint32_t PxComputeHash(const ActorShapeMap::ActorShape& owner)
{
PX_ASSERT(!(size_t(owner.mActor)&3));
PX_ASSERT(!(size_t(owner.mShape)&3));
const uint32_t id0 = uint32_t(size_t(owner.mActor)>>2);
const uint32_t id1 = uint32_t(size_t(owner.mShape)>>2);
const uint64_t mix = (uint64_t(id0)<<32)|uint64_t(id1);
return ::PxComputeHash(mix);
}
}
}
ActorShapeMap::ActorShapeMap() : mCacheSize(0), mCache(NULL)
{
}
ActorShapeMap::~ActorShapeMap()
{
PX_FREE(mCache);
}
void ActorShapeMap::resizeCache(PxU32 index)
{
PxU32 size = mCacheSize ? mCacheSize*2 : 64;
const PxU32 minSize = index+1;
if(minSize>size)
size = minSize*2;
Cache* items = PX_ALLOCATE(Cache, size, "Cache");
if(mCache)
PxMemCopy(items, mCache, mCacheSize*sizeof(Cache));
PxMemZero(items+mCacheSize, (size-mCacheSize)*sizeof(Cache));
PX_FREE(mCache);
mCache = items;
mCacheSize = size;
}
bool ActorShapeMap::add(PxU32 actorIndex, const void* actor, const void* shape, ActorShapeData actorShapeData)
{
if(actorIndex!=PX_INVALID_INDEX)
{
if(actorIndex>=mCacheSize)
resizeCache(actorIndex);
//if(!mCache[actorIndex].mActor)
if(!mCache[actorIndex].mShape)
{
//mCache[actorIndex].mActor = actor;
mCache[actorIndex].mShape = shape;
mCache[actorIndex].mData = actorShapeData;
return true;
}
//PX_ASSERT(mCache[actorIndex].mActor==actor);
PX_ASSERT(mCache[actorIndex].mShape);
if(mCache[actorIndex].mShape==shape)
{
mCache[actorIndex].mData = actorShapeData;
return false;
}
}
return mDatabase.insert(ActorShape(actor, shape), actorShapeData);
}
bool ActorShapeMap::remove(PxU32 actorIndex, const void* actor, const void* shape, ActorShapeData* removed)
{
if(actorIndex!=PX_INVALID_INDEX)
{
//if(mCache[actorIndex].mActor==actor && mCache[actorIndex].mShape==shape)
if(mCache[actorIndex].mShape==shape)
{
//mCache[actorIndex].mActor = NULL;
mCache[actorIndex].mShape = NULL;
PX_ASSERT(!mDatabase.erase(ActorShape(actor, shape)));
if(removed)
*removed = mCache[actorIndex].mData;
return true;
}
}
PxHashMap<ActorShape, ActorShapeData>::Entry removedEntry;
const bool found = mDatabase.erase(ActorShape(actor, shape), removedEntry);
if(found && removed)
*removed = removedEntry.second;
return found;
}
ActorShapeData ActorShapeMap::find(PxU32 actorIndex, const void* actor, const void* shape) const
{
if(actorIndex!=PX_INVALID_INDEX)
{
if(mCache[actorIndex].mShape==shape)
//if(mCache[actorIndex].mActor==actor && mCache[actorIndex].mShape==shape)
{
return mCache[actorIndex].mData;
}
}
const PxHashMap<ActorShape, ActorShapeData>::Entry* e = mDatabase.find(ActorShape(actor, shape));
PX_ASSERT(e);
return e->second;
}
| 4,580 | C++ | 31.260563 | 110 | 0.731878 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuGeometryChecks.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_GEOMETRY_CHECKS_H
#define GU_GEOMETRY_CHECKS_H
#include "geometry/PxBoxGeometry.h"
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxCapsuleGeometry.h"
#include "geometry/PxPlaneGeometry.h"
#include "geometry/PxConvexMeshGeometry.h"
#include "geometry/PxParticleSystemGeometry.h"
#include "geometry/PxTetrahedronMeshGeometry.h"
#include "geometry/PxTriangleMeshGeometry.h"
#include "geometry/PxHeightFieldGeometry.h"
#include "geometry/PxHairSystemGeometry.h"
#include "geometry/PxCustomGeometry.h"
namespace physx
{
// We sometimes overload capsule code for spheres, so every sphere should have
// valid capsule data (height = 0). This is preferable to a typedef so that we
// can maintain traits separately for a sphere, but some care is required to deal
// with the fact that when a reference to a capsule is extracted, it may have its
// type field set to eSPHERE
template <typename T>
struct PxcGeometryTraits
{
enum {TypeID = PxGeometryType::eINVALID };
};
template <typename T> struct PxcGeometryTraits<const T> { enum { TypeID = PxcGeometryTraits<T>::TypeID }; };
template <> struct PxcGeometryTraits<PxBoxGeometry> { enum { TypeID = PxGeometryType::eBOX }; };
template <> struct PxcGeometryTraits<PxSphereGeometry> { enum { TypeID = PxGeometryType::eSPHERE }; };
template <> struct PxcGeometryTraits<PxCapsuleGeometry> { enum { TypeID = PxGeometryType::eCAPSULE }; };
template <> struct PxcGeometryTraits<PxPlaneGeometry> { enum { TypeID = PxGeometryType::ePLANE }; };
template <> struct PxcGeometryTraits<PxParticleSystemGeometry> { enum { TypeID = PxGeometryType::ePARTICLESYSTEM}; };
template <> struct PxcGeometryTraits<PxConvexMeshGeometry> { enum { TypeID = PxGeometryType::eCONVEXMESH }; };
template <> struct PxcGeometryTraits<PxTriangleMeshGeometry> { enum { TypeID = PxGeometryType::eTRIANGLEMESH }; };
template <> struct PxcGeometryTraits<PxTetrahedronMeshGeometry> { enum { TypeID = PxGeometryType::eTETRAHEDRONMESH }; };
template <> struct PxcGeometryTraits<PxHeightFieldGeometry> { enum { TypeID = PxGeometryType::eHEIGHTFIELD }; };
template <> struct PxcGeometryTraits<PxHairSystemGeometry> { enum { TypeID = PxGeometryType::eHAIRSYSTEM }; };
template <> struct PxcGeometryTraits<PxCustomGeometry> { enum { TypeID = PxGeometryType::eCUSTOM }; };
template<class T> PX_CUDA_CALLABLE PX_FORCE_INLINE void checkType(const PxGeometry& geometry)
{
PX_ASSERT(PxU32(geometry.getType()) == PxU32(PxcGeometryTraits<T>::TypeID));
PX_UNUSED(geometry);
}
template<> PX_CUDA_CALLABLE PX_FORCE_INLINE void checkType<PxCapsuleGeometry>(const PxGeometry& geometry)
{
PX_ASSERT(geometry.getType() == PxGeometryType::eCAPSULE || geometry.getType() == PxGeometryType::eSPHERE);
PX_UNUSED(geometry);
}
template<> PX_CUDA_CALLABLE PX_FORCE_INLINE void checkType<const PxCapsuleGeometry>(const PxGeometry& geometry)
{
PX_ASSERT(geometry.getType()== PxGeometryType::eCAPSULE || geometry.getType() == PxGeometryType::eSPHERE);
PX_UNUSED(geometry);
}
}
#if !defined(__CUDACC__)
// the shape structure relies on punning capsules and spheres
PX_COMPILE_TIME_ASSERT(PX_OFFSET_OF(physx::PxCapsuleGeometry, radius) == PX_OFFSET_OF(physx::PxSphereGeometry, radius));
#endif
#endif
| 4,973 | C | 50.27835 | 122 | 0.760708 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuSecondaryPruner.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_SECONDARY_PRUNER_H
#define GU_SECONDARY_PRUNER_H
#include "common/PxPhysXCommonConfig.h"
#include "GuPruner.h"
namespace physx
{
class PxRenderOutput;
namespace Gu
{
class PruningPool;
class CompanionPruner : public PxUserAllocated
{
public:
CompanionPruner() {}
virtual ~CompanionPruner() {}
virtual bool addObject(const PrunerPayload& object, PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform, PxU32 timeStamp, PoolIndex poolIndex) = 0;
virtual bool updateObject(const PrunerPayload& object, PrunerHandle handle, const PxBounds3& worldAABB, const PxTransform& transform, PoolIndex poolIndex) = 0;
virtual bool removeObject(const PrunerPayload& object, PrunerHandle handle, PxU32 objectIndex, PxU32 swapObjectIndex) = 0;
virtual void swapIndex(PxU32 objectIndex, PxU32 swapObjectIndex) = 0;
virtual PxU32 removeMarkedObjects(PxU32 timeStamp) = 0;
virtual void shiftOrigin(const PxVec3& shift) = 0;
virtual void timeStampChange() = 0;
virtual void build() = 0;
virtual PxU32 getNbObjects() const = 0;
virtual void release() = 0;
virtual void visualize(PxRenderOutput& out, PxU32 color) const = 0;
virtual bool raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& prunerCallback) const = 0;
virtual bool overlap(const ShapeData& queryVolume, PrunerOverlapCallback& prunerCallback) const = 0;
virtual bool sweep(const ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& prunerCallback) const = 0;
virtual void getGlobalBounds(PxBounds3&) const = 0;
};
CompanionPruner* createCompanionPruner(PxU64 contextID, CompanionPrunerType type, const PruningPool* pool);
}
}
#endif
| 3,775 | C | 52.183098 | 175 | 0.705166 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBTreeNode.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_AABBTREE_NODE_H
#define GU_AABBTREE_NODE_H
#include "common/PxPhysXCommonConfig.h"
#include "foundation/PxBounds3.h"
#include "foundation/PxVecMath.h"
#include "foundation/PxUserAllocated.h"
namespace physx
{
using namespace aos;
namespace Gu
{
struct BVHNode : public PxUserAllocated
{
public:
PX_FORCE_INLINE BVHNode() {}
PX_FORCE_INLINE ~BVHNode() {}
PX_FORCE_INLINE PxU32 isLeaf() const { return mData&1; }
PX_FORCE_INLINE const PxU32* getPrimitives(const PxU32* base) const { return base + (mData>>5); }
PX_FORCE_INLINE PxU32* getPrimitives(PxU32* base) { return base + (mData>>5); }
PX_FORCE_INLINE PxU32 getPrimitiveIndex() const { return mData>>5; }
PX_FORCE_INLINE PxU32 getNbPrimitives() const { return (mData>>1)&15; }
PX_FORCE_INLINE PxU32 getPosIndex() const { return mData>>1; }
PX_FORCE_INLINE PxU32 getNegIndex() const { return (mData>>1) + 1; }
PX_FORCE_INLINE const BVHNode* getPos(const BVHNode* base) const { return base + (mData>>1); }
PX_FORCE_INLINE const BVHNode* getNeg(const BVHNode* base) const { const BVHNode* P = getPos(base); return P ? P+1 : NULL; }
PX_FORCE_INLINE BVHNode* getPos(BVHNode* base) { return base + (mData >> 1); }
PX_FORCE_INLINE BVHNode* getNeg(BVHNode* base) { BVHNode* P = getPos(base); return P ? P + 1 : NULL; }
PX_FORCE_INLINE PxU32 getNbRuntimePrimitives() const { return (mData>>1)&15; }
PX_FORCE_INLINE void setNbRunTimePrimitives(PxU32 val)
{
PX_ASSERT(val<16);
PxU32 data = mData & ~(15<<1);
data |= val<<1;
mData = data;
}
PX_FORCE_INLINE void getAABBCenterExtentsV(Vec3V* center, Vec3V* extents) const
{
const Vec4V minV = V4LoadU(&mBV.minimum.x);
const Vec4V maxV = V4LoadU(&mBV.maximum.x);
const float half = 0.5f;
const FloatV halfV = FLoad(half);
*extents = Vec3V_From_Vec4V(V4Scale(V4Sub(maxV, minV), halfV));
*center = Vec3V_From_Vec4V(V4Scale(V4Add(maxV, minV), halfV));
}
PX_FORCE_INLINE void getAABBCenterExtentsV2(Vec3V* center, Vec3V* extents) const
{
const Vec4V minV = V4LoadU(&mBV.minimum.x);
const Vec4V maxV = V4LoadU(&mBV.maximum.x);
*extents = Vec3V_From_Vec4V(V4Sub(maxV, minV));
*center = Vec3V_From_Vec4V(V4Add(maxV, minV));
}
PxBounds3 mBV; // Global bounding-volume enclosing all the node-related primitives
PxU32 mData; // 27 bits node or prim index|4 bits #prims|1 bit leaf
};
} // namespace Gu
}
#endif // GU_AABBTREE_NODE_H
| 4,429 | C | 43.747474 | 129 | 0.67487 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuCCTSweepTests.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "geometry/PxSphereGeometry.h"
#include "GuSweepTests.h"
#include "GuHeightFieldUtil.h"
#include "GuEntityReport.h"
#include "GuDistanceSegmentBox.h"
#include "GuDistancePointBox.h"
#include "GuSweepBoxSphere.h"
#include "GuSweepCapsuleBox.h"
#include "GuSweepBoxBox.h"
#include "GuSweepBoxTriangle_SAT.h"
#include "GuSweepTriangleUtils.h"
#include "GuInternal.h"
#include "foundation/PxVecMath.h"
using namespace physx;
using namespace Gu;
using namespace Cm;
using namespace aos;
static const bool gValidateBoxRadiusComputation = false;
///////////////////////////////////////////
bool sweepCapsule_BoxGeom_Precise(GU_CAPSULE_SWEEP_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eBOX);
PX_UNUSED(threadContext);
PX_UNUSED(inflation);
PX_UNUSED(capsulePose_);
PX_UNUSED(capsuleGeom_);
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
if (lss.p0 == lss.p1) // The capsule is actually a sphere
{
//TODO: Check if this is really faster than using a "sphere-aware" version of sweepCapsuleBox
Box box; buildFrom(box, pose.p, boxGeom.halfExtents, pose.q);
if(!sweepBoxSphere(box, lss.radius, lss.p0, unitDir, distance, sweepHit.distance, sweepHit.normal, hitFlags))
return false;
sweepHit.normal = -sweepHit.normal;
sweepHit.flags = PxHitFlag::eNORMAL;
if(hitFlags & PxHitFlag::ePOSITION && sweepHit.distance!=0.0f)
{
// The sweep test doesn't compute the impact point automatically, so we have to do it here.
const PxVec3 newSphereCenter = lss.p0 + unitDir * sweepHit.distance;
PxVec3 closest;
const PxReal d = distancePointBoxSquared(newSphereCenter, box.center, box.extents, box.rot, &closest);
PX_UNUSED(d);
// Compute point on the box, after sweep
closest = box.rotate(closest);
sweepHit.position = closest + box.center;
sweepHit.flags |= PxHitFlag::ePOSITION;
}
}
else
{
if(!sweepCapsuleBox(lss, pose, boxGeom.halfExtents, unitDir, distance, sweepHit.position, sweepHit.distance, sweepHit.normal, hitFlags))
return false;
sweepHit.flags = PxHitFlag::eNORMAL;
if((hitFlags & PxHitFlag::ePOSITION) && sweepHit.distance!=0.0f)
{
// The sweep test doesn't compute the impact point automatically, so we have to do it here.
Capsule movedCaps = lss;
movedCaps.p0 += unitDir * sweepHit.distance;
movedCaps.p1 += unitDir * sweepHit.distance;
Box box;
buildFrom(box, pose.p, boxGeom.halfExtents, pose.q);
PxVec3 closest;
const PxReal d = distanceSegmentBoxSquared(movedCaps, box, NULL, &closest);
PX_UNUSED(d);
// Compute point on the box, after sweep
closest = pose.q.rotate(closest);
sweepHit.position = closest + pose.p;
sweepHit.flags |= PxHitFlag::ePOSITION;
}
}
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool sweepBox_SphereGeom_Precise(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_UNUSED(threadContext);
PX_UNUSED(boxPose_);
PX_UNUSED(boxGeom_);
PX_ASSERT(geom.getType() == PxGeometryType::eSPHERE);
const PxSphereGeometry& sphereGeom = static_cast<const PxSphereGeometry&>(geom);
// PT: move to relative space
const Box relBox(box.center - pose.p, box.extents, box.rot);
const PxReal sphereRadius = sphereGeom.radius + inflation;
if(!sweepBoxSphere(relBox, sphereRadius, PxVec3(0), -unitDir, distance, sweepHit.distance, sweepHit.normal, hitFlags))
return false;
sweepHit.flags = PxHitFlag::eNORMAL;
if((hitFlags & PxHitFlag::ePOSITION) && sweepHit.distance!=0.0f)
{
// The sweep test doesn't compute the impact point automatically, so we have to do it here.
const PxVec3 motion = sweepHit.distance * unitDir;
const PxVec3 newSphereCenter = - motion;
PxVec3 closest;
const PxReal d = distancePointBoxSquared(newSphereCenter, relBox.center, relBox.extents, relBox.rot, &closest);
PX_UNUSED(d);
// Compute point on the box, after sweep
sweepHit.position = relBox.rotate(closest) + box.center + motion; // PT: undo move to local space here
sweepHit.flags |= PxHitFlag::ePOSITION;
}
return true;
}
bool sweepBox_CapsuleGeom_Precise(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eCAPSULE);
PX_UNUSED(inflation);
PX_UNUSED(boxGeom_);
PX_UNUSED(threadContext);
const PxCapsuleGeometry& capsuleGeom = static_cast<const PxCapsuleGeometry&>(geom);
// PT: move to relative space
const PxVec3 delta = box.center - pose.p;
Box relBox(delta, box.extents, box.rot);
Capsule capsule;
const PxVec3 halfHeightVector = getCapsuleHalfHeightVector(pose, capsuleGeom);
capsule.p0 = halfHeightVector;
capsule.p1 = -halfHeightVector;
capsule.radius = capsuleGeom.radius;
// PT: TODO: remove this. We convert to PxTansform here but inside sweepCapsuleBox we convert back to a matrix.
const PxTransform boxWorldPose(delta, boxPose_.q);
PxVec3 n;
if(!sweepCapsuleBox(capsule, boxWorldPose, relBox.extents, -unitDir, distance, sweepHit.position, sweepHit.distance, n, hitFlags))
return false;
sweepHit.normal = -n;
sweepHit.flags = PxHitFlag::eNORMAL;
if((hitFlags & PxHitFlag::ePOSITION) && sweepHit.distance!=0.0f)
{
// The sweep test doesn't compute the impact point automatically, so we have to do it here.
relBox.center += (unitDir * sweepHit.distance);
PxVec3 closest;
const PxReal d = distanceSegmentBoxSquared(capsule, relBox, NULL, &closest);
PX_UNUSED(d);
// Compute point on the box, after sweep
sweepHit.position = relBox.transform(closest) + pose.p; // PT: undo move to local space here
sweepHit.flags |= PxHitFlag::ePOSITION;
}
return true;
}
bool sweepBox_BoxGeom_Precise(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eBOX);
PX_UNUSED(threadContext);
PX_UNUSED(inflation);
PX_UNUSED(boxPose_);
PX_UNUSED(boxGeom_);
const PxBoxGeometry& boxGeom = static_cast<const PxBoxGeometry&>(geom);
// PT: move to local space
const Box relBox(box.center - pose.p, box.extents, box.rot);
Box staticBox; buildFrom(staticBox, PxVec3(0), boxGeom.halfExtents, pose.q);
if(!sweepBoxBox(relBox, staticBox, unitDir, distance, hitFlags, sweepHit))
return false;
if(sweepHit.distance!=0.0f)
sweepHit.position += pose.p; // PT: undo move to local space
return true;
}
// PT: test: new version for CCT, based on code for general sweeps. Just to check it works or not with rotations
// TODO: refactor this and the similar code in sweptBox for box-vs-mesh. Not so easy though.
static bool sweepBoxVsTriangles(PxU32 nbTris, const PxTriangle* triangles, const Box& box, const PxVec3& unitDir, const PxReal distance, PxGeomSweepHit& sweepHit,
PxHitFlags hitFlags, bool isDoubleSided, const PxU32* cachedIndex)
{
if(!nbTris)
return false;
const bool meshBothSides = hitFlags & PxHitFlag::eMESH_BOTH_SIDES;
const bool doBackfaceCulling = !isDoubleSided && !meshBothSides;
// Move to AABB space
PxMat34 worldToBox;
computeWorldToBoxMatrix(worldToBox, box);
const PxVec3 localDir = worldToBox.rotate(unitDir);
const PxVec3 localMotion = localDir * distance;
bool status = false;
sweepHit.distance = distance; //was PX_MAX_F32, but that may trigger an assert in the caller!
const PxVec3 oneOverMotion(
localDir.x!=0.0f ? 1.0f/localMotion.x : 0.0f,
localDir.y!=0.0f ? 1.0f/localMotion.y : 0.0f,
localDir.z!=0.0f ? 1.0f/localMotion.z : 0.0f);
// PT: experimental code, don't clean up before I test it more and validate it
// Project box
/*float boxRadius0 =
PxAbs(dir.x) * box.extents.x
+ PxAbs(dir.y) * box.extents.y
+ PxAbs(dir.z) * box.extents.z;*/
float boxRadius =
PxAbs(localDir.x) * box.extents.x
+ PxAbs(localDir.y) * box.extents.y
+ PxAbs(localDir.z) * box.extents.z;
if(gValidateBoxRadiusComputation) // PT: run this to check the box radius is correctly computed
{
PxVec3 boxVertices2[8];
box.computeBoxPoints(boxVertices2);
float dpmin = FLT_MAX;
float dpmax = -FLT_MAX;
for(int i=0;i<8;i++)
{
const float dp = boxVertices2[i].dot(unitDir);
if(dp<dpmin) dpmin = dp;
if(dp>dpmax) dpmax = dp;
}
const float goodRadius = (dpmax-dpmin)/2.0f;
PX_UNUSED(goodRadius);
}
const float dpc0 = box.center.dot(unitDir);
float localMinDist = 1.0f;
#if PX_DEBUG
PxU32 totalTestsExpected = nbTris;
PxU32 totalTestsReal = 0;
PX_UNUSED(totalTestsExpected);
PX_UNUSED(totalTestsReal);
#endif
const PxU32 idx = cachedIndex ? *cachedIndex : 0;
PxVec3 bestTriNormal(0.0f);
for(PxU32 ii=0;ii<nbTris;ii++)
{
const PxU32 triangleIndex = getTriangleIndex(ii, idx);
const PxTriangle& tri = triangles[triangleIndex];
if(!cullTriangle(tri.verts, unitDir, boxRadius, localMinDist*distance, dpc0))
continue;
#if PX_DEBUG
totalTestsReal++;
#endif
// Move to box space
const PxTriangle currentTriangle(
worldToBox.transform(tri.verts[0]),
worldToBox.transform(tri.verts[1]),
worldToBox.transform(tri.verts[2]));
PxF32 t = PX_MAX_F32; // could be better!
if(triBoxSweepTestBoxSpace(currentTriangle, box.extents, localMotion, oneOverMotion, localMinDist, t, doBackfaceCulling))
{
if(t < localMinDist)
{
// PT: test if shapes initially overlap
if(t==0.0f)
return setInitialOverlapResults(sweepHit, unitDir, triangleIndex);
localMinDist = t;
sweepHit.distance = t * distance;
sweepHit.faceIndex = triangleIndex;
status = true;
// PT: TODO: optimize this.... already computed in triBoxSweepTestBoxSpace...
currentTriangle.denormalizedNormal(bestTriNormal);
if(hitFlags & PxHitFlag::eMESH_ANY)
break;
}
}
}
if(status)
{
sweepHit.flags = PxHitFlag::eFACE_INDEX;
// PT: TODO: refactor with computeBoxLocalImpact (TA34704)
if(hitFlags & (PxHitFlag::eNORMAL|PxHitFlag::ePOSITION))
{
const PxTriangle& tri = triangles[sweepHit.faceIndex];
// Move to box space
const PxTriangle currentTriangle(
worldToBox.transform(tri.verts[0]),
worldToBox.transform(tri.verts[1]),
worldToBox.transform(tri.verts[2]));
computeBoxTriImpactData(sweepHit.position, sweepHit.normal, box.extents, localDir, currentTriangle, sweepHit.distance);
if(hitFlags & PxHitFlag::eNORMAL)
{
PxVec3 localNormal = sweepHit.normal; // PT: both local space & local variable
localNormal.normalize();
if(shouldFlipNormal(localNormal, meshBothSides, isDoubleSided, bestTriNormal, localDir))
localNormal = -localNormal;
sweepHit.normal = box.rotate(localNormal);
sweepHit.flags |= PxHitFlag::eNORMAL;
}
if(hitFlags & PxHitFlag::ePOSITION)
{
sweepHit.position = box.rotate(sweepHit.position) + box.center;
sweepHit.flags |= PxHitFlag::ePOSITION;
}
}
}
return status;
}
bool sweepBox_HeightFieldGeom_Precise(GU_BOX_SWEEP_FUNC_PARAMS)
{
PX_ASSERT(geom.getType() == PxGeometryType::eHEIGHTFIELD);
PX_UNUSED(threadContext);
PX_UNUSED(inflation);
PX_UNUSED(boxPose_);
PX_UNUSED(boxGeom_);
const PxHeightFieldGeometry& heightFieldGeom = static_cast<const PxHeightFieldGeometry&>(geom);
// Compute swept box
Box sweptBox;
computeSweptBox(sweptBox, box.extents, box.center, box.rot, unitDir, distance);
//### Temp hack until we can directly collide the OBB against the HF
const PxTransform sweptBoxTR = sweptBox.getTransform();
const PxBounds3 bounds = PxBounds3::poseExtent(sweptBoxTR, sweptBox.extents);
sweepHit.distance = PX_MAX_F32;
struct LocalReport : OverlapReport
{
virtual bool reportTouchedTris(PxU32 nb, const PxU32* indices)
{
for(PxU32 i=0; i<nb; i++)
{
const PxU32 triangleIndex = indices[i];
PxTriangle currentTriangle; // in world space
mHFUtil->getTriangle(*mPose, currentTriangle, NULL, NULL, triangleIndex, true, true);
PxGeomSweepHit sweepHit_;
const bool b = sweepBoxVsTriangles(1, ¤tTriangle, mBox, mDir, mDist, sweepHit_, mHitFlags, mIsDoubleSided, NULL);
if(b && sweepHit_.distance<mHit->distance)
{
*mHit = sweepHit_;
mHit->faceIndex = triangleIndex;
mStatus = true;
}
}
return true;
}
const HeightFieldUtil* mHFUtil;
const PxTransform* mPose;
PxGeomSweepHit* mHit;
bool mStatus;
Box mBox;
PxVec3 mDir;
float mDist;
PxHitFlags mHitFlags;
bool mIsDoubleSided;
} myReport;
HeightFieldUtil hfUtil(heightFieldGeom);
myReport.mBox = box;
myReport.mDir = unitDir;
myReport.mDist = distance;
myReport.mHitFlags = hitFlags;
myReport.mHFUtil = &hfUtil;
myReport.mStatus = false;
myReport.mPose = &pose;
myReport.mHit = &sweepHit;
const PxU32 meshBothSides = hitFlags & PxHitFlag::eMESH_BOTH_SIDES;
myReport.mIsDoubleSided = (heightFieldGeom.heightFieldFlags & PxMeshGeometryFlag::eDOUBLE_SIDED) || meshBothSides;
hfUtil.overlapAABBTriangles(pose, bounds, myReport);
return myReport.mStatus;
}
bool Gu::sweepBoxTriangles_Precise(GU_SWEEP_TRIANGLES_FUNC_PARAMS(PxBoxGeometry))
{
PX_UNUSED(inflation);
Box box;
buildFrom(box, pose.p, geom.halfExtents, pose.q);
return sweepBoxVsTriangles(nbTris, triangles, box, unitDir, distance, hit, hitFlags, doubleSided, cachedIndex);
}
| 14,727 | C++ | 32.096629 | 162 | 0.723705 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuSweepMTD.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "geometry/PxConvexMeshGeometry.h"
#include "GuHeightFieldUtil.h"
#include "GuEntityReport.h"
#include "GuConvexMesh.h"
#include "GuSweepSharedTests.h"
#include "GuConvexUtilsInternal.h"
#include "GuTriangleMesh.h"
#include "GuVecBox.h"
#include "GuVecTriangle.h"
#include "GuVecConvexHullNoScale.h"
#include "GuMidphaseInterface.h"
#include "GuPCMContactConvexCommon.h"
#include "GuSweepMTD.h"
#include "GuPCMShapeConvex.h"
#include "GuDistanceSegmentSegment.h"
#include "GuDistancePointSegment.h"
#include "GuInternal.h"
#include "GuConvexEdgeFlags.h"
#include "GuMTD.h"
#include "CmMatrix34.h"
using namespace physx;
using namespace Gu;
using namespace Cm;
using namespace aos;
#define BATCH_TRIANGLE_NUMBER 32u
struct MTDTriangle : public PxTriangle
{
public:
PxU8 extraTriData;//active edge flag data
};
struct MeshMTDGenerationCallback : MeshHitCallback<PxGeomRaycastHit>
{
public:
PxArray<PxU32>& container;
MeshMTDGenerationCallback(PxArray<PxU32>& tempContainer)
: MeshHitCallback<PxGeomRaycastHit>(CallbackMode::eMULTIPLE), container(tempContainer)
{
}
virtual PxAgain processHit(
const PxGeomRaycastHit& hit, const PxVec3&, const PxVec3&, const PxVec3&, PxReal&, const PxU32*)
{
container.pushBack(hit.faceIndex);
return true;
}
void operator=(const MeshMTDGenerationCallback&) {}
};
static bool getMTDPerTriangle(const MeshPersistentContact* manifoldContacts, const PxU32 numContacts, const PxU32 triangleIndex, Vec3V& normal, Vec3V& closestA, Vec3V& closestB, PxU32& faceIndex, FloatV& deepestPen)
{
FloatV deepest = V4GetW(manifoldContacts[0].mLocalNormalPen);
PxU32 index = 0;
for(PxU32 k=1; k<numContacts; ++k)
{
const FloatV pen = V4GetW(manifoldContacts[k].mLocalNormalPen);
if(FAllGrtr(deepest, pen))
{
deepest = pen;
index = k;
}
}
if(FAllGrtr(deepestPen, deepest))
{
PX_ASSERT(triangleIndex == manifoldContacts[index].mFaceIndex);
faceIndex = triangleIndex;
deepestPen = deepest;
normal = Vec3V_From_Vec4V(manifoldContacts[index].mLocalNormalPen);
closestA = manifoldContacts[index].mLocalPointB;
closestB = manifoldContacts[index].mLocalPointA;
return true;
}
return false;
}
static void midPhaseQuery(const PxTriangleMeshGeometry& meshGeom, const PxTransform& pose, const Box& bound, PxArray<PxU32>& tempContainer)
{
TriangleMesh* meshData = static_cast<TriangleMesh*>(meshGeom.triangleMesh);
Box vertexSpaceBox;
computeVertexSpaceOBB(vertexSpaceBox, bound, pose, meshGeom.scale);
MeshMTDGenerationCallback callback(tempContainer);
Midphase::intersectOBB(meshData, vertexSpaceBox, callback, true);
}
// PT: TODO: refactor with EntityReportContainerCallback
struct MidPhaseQueryLocalReport : OverlapReport
{
MidPhaseQueryLocalReport(PxArray<PxU32>& _container) : container(_container)
{
}
virtual bool reportTouchedTris(PxU32 nb, const PxU32* indices)
{
for(PxU32 i=0; i<nb; i++)
container.pushBack(indices[i]);
return true;
}
PxArray<PxU32>& container;
private:
MidPhaseQueryLocalReport operator=(MidPhaseQueryLocalReport& report);
};
static void midPhaseQuery(const HeightFieldUtil& hfUtil, const PxTransform& pose, const PxBounds3& bounds, PxArray<PxU32>& tempContainer)
{
MidPhaseQueryLocalReport localReport(tempContainer);
hfUtil.overlapAABBTriangles(pose, bounds, localReport);
}
static bool calculateMTD( const CapsuleV& capsuleV, const FloatVArg inflatedRadiusV, const bool isDoubleSide, const MTDTriangle* triangles, const PxU32 nbTriangles, const PxU32 startIndex, MeshPersistentContact* manifoldContacts,
PxU32& numContacts, Vec3V& normal, Vec3V& closestA, Vec3V& closestB, PxU32& faceIndex, FloatV& mtd)
{
const FloatV zero = FZero();
bool hadContacts = false;
FloatV deepestPen = mtd;
for(PxU32 j=0; j<nbTriangles; ++j)
{
numContacts = 0;
const MTDTriangle& curTri = triangles[j];
TriangleV triangleV;
triangleV.verts[0] = V3LoadU(curTri.verts[0]);
triangleV.verts[1] = V3LoadU(curTri.verts[1]);
triangleV.verts[2] = V3LoadU(curTri.verts[2]);
const PxU8 triFlag = curTri.extraTriData;
const Vec3V triangleNormal = triangleV.normal();
const Vec3V v = V3Sub(capsuleV.getCenter(), triangleV.verts[0]);
const FloatV dotV = V3Dot(triangleNormal, v);
// Backface culling
const bool culled = !isDoubleSide && (FAllGrtr(zero, dotV));
if(culled)
continue;
PCMCapsuleVsMeshContactGeneration::processTriangle(triangleV, j+startIndex, capsuleV, inflatedRadiusV, triFlag, manifoldContacts, numContacts);
if(numContacts ==0)
continue;
hadContacts = true;
getMTDPerTriangle(manifoldContacts, numContacts, j + startIndex, normal, closestA, closestB, faceIndex, deepestPen);
}
mtd = deepestPen;
return hadContacts;
}
static PX_FORCE_INLINE bool finalizeMTD(PxGeomSweepHit& hit, const Vec3VArg translationV, const Vec3VArg posV, PxU32 triangleIndex, bool foundInitial)
{
if(foundInitial)
{
const FloatV translationF = V3Length(translationV);
const FloatV distV = FNeg(translationF);
const BoolV con = FIsGrtr(translationF, FZero());
const Vec3V nrm = V3Sel(con, V3ScaleInv(translationV, translationF), V3Zero());
FStore(distV, &hit.distance);
V3StoreU(posV, hit.position);
V3StoreU(nrm, hit.normal);
hit.faceIndex = triangleIndex;
}
return foundInitial;
}
bool physx::Gu::computeCapsule_TriangleMeshMTD( const PxTriangleMeshGeometry& triMeshGeom, const PxTransform& pose, CapsuleV& capsuleV, PxReal inflatedRadius,
bool isDoubleSided, PxGeomSweepHit& hit)
{
TriangleMesh* triMesh = static_cast<TriangleMesh*>(triMeshGeom.triangleMesh);
const PxU8* extraTrigData = triMesh->getExtraTrigData();
const bool flipsNormal = triMeshGeom.scale.hasNegativeDeterminant();
//inflated the capsule by 15% in case of some disagreement between sweep and mtd calculation. If sweep said initial overlap, but mtd has a positive separation,
//we are still be able to return a valid normal but we should zero the distance.
const FloatV inflatedRadiusV = FLoad(inflatedRadius*1.15f);
const PxMat34 vertexToWorldSkew = pose * triMeshGeom.scale;
const Vec3V zeroV = V3Zero();
Vec3V closestA = zeroV, closestB = zeroV, normal = zeroV;
/////
MeshPersistentContact manifoldContacts[64];
PxU32 numContacts = 0;
PxArray<PxU32> tempContainer;
tempContainer.reserve(128);
PxU32 triangleIndex = 0xfffffff;
Vec3V translation = zeroV;
bool foundInitial = false;
const PxU32 iterations = 4;
/////
for(PxU32 i=0; i<iterations; ++i)
{
tempContainer.forceSize_Unsafe(0);
{
Capsule inflatedCapsule;
V3StoreU(capsuleV.p0, inflatedCapsule.p0);
V3StoreU(capsuleV.p1, inflatedCapsule.p1);
inflatedCapsule.radius = inflatedRadius;
Box capsuleBox;
computeBoxAroundCapsule(inflatedCapsule, capsuleBox);
midPhaseQuery(triMeshGeom, pose, capsuleBox, tempContainer);
}
// Get results
const PxU32 nbTriangles = tempContainer.size();
if(!nbTriangles)
break;
FloatV mtd;
{
bool hadContacts = false;
const PxU32 nbBatches = (nbTriangles + BATCH_TRIANGLE_NUMBER - 1)/BATCH_TRIANGLE_NUMBER;
mtd = FMax();
MTDTriangle triangles[BATCH_TRIANGLE_NUMBER];
for(PxU32 a = 0; a < nbBatches; ++a)
{
const PxU32 startIndex = a * BATCH_TRIANGLE_NUMBER;
const PxU32 nbTrigs = PxMin(nbTriangles - startIndex, BATCH_TRIANGLE_NUMBER);
for(PxU32 k=0; k<nbTrigs; k++)
{
//triangle world space
const PxU32 currentTriangleIndex = tempContainer[startIndex+k];
triMesh->computeWorldTriangle(triangles[k], currentTriangleIndex, vertexToWorldSkew, flipsNormal);
triangles[k].extraTriData = getConvexEdgeFlags(extraTrigData, currentTriangleIndex);
}
//ML: mtd has back face culling, so if the capsule's center is below the triangle, we won't generate any contacts
hadContacts = calculateMTD(capsuleV, inflatedRadiusV, isDoubleSided, triangles, nbTrigs, startIndex, manifoldContacts, numContacts, normal, closestA, closestB, triangleIndex, mtd) || hadContacts;
}
if(!hadContacts)
break;
triangleIndex = tempContainer[triangleIndex];
foundInitial = true;
}
//move the capsule to depenetrate it
const FloatV distV = FSub(mtd, capsuleV.radius);
if(FAllGrtr(FZero(), distV))
{
Vec3V center = capsuleV.getCenter();
const Vec3V t = V3Scale(normal, distV);
translation = V3Sub(translation, t);
center = V3Sub(center, t);
capsuleV.setCenter(center);
}
else
{
if(i == 0)
{
//First iteration so keep this normal
hit.distance = 0.0f;
V3StoreU(closestA, hit.position);
V3StoreU(normal, hit.normal);
hit.faceIndex = triangleIndex;
return true;
}
break;
}
}
return finalizeMTD(hit, translation, closestA, triangleIndex, foundInitial);
}
bool physx::Gu::computeCapsule_HeightFieldMTD(const PxHeightFieldGeometry& heightFieldGeom, const PxTransform& pose, CapsuleV& capsuleV, PxReal inflatedRadius, bool isDoubleSided, PxGeomSweepHit& hit)
{
//inflated the capsule by 1% in case of some disagreement between sweep and mtd calculation.If sweep said initial overlap, but mtd has a positive separation,
//we are still be able to return a valid normal but we should zero the distance.
const FloatV inflatedRadiusV = FLoad(inflatedRadius*1.01f);
const HeightFieldUtil hfUtil(heightFieldGeom);
const Vec3V zeroV = V3Zero();
Vec3V closestA = zeroV, closestB = zeroV, normal = zeroV;
/////
MeshPersistentContact manifoldContacts[64];
PxU32 numContacts = 0;
PxArray<PxU32> tempContainer;
tempContainer.reserve(128);
PxU32 triangleIndex = 0xfffffff;
Vec3V translation = zeroV;
bool foundInitial = false;
const PxU32 iterations = 4;
/////
for(PxU32 i=0; i<iterations; ++i)
{
tempContainer.forceSize_Unsafe(0);
{
Capsule inflatedCapsule;
V3StoreU(capsuleV.p0, inflatedCapsule.p0);
V3StoreU(capsuleV.p1, inflatedCapsule.p1);
inflatedCapsule.radius = inflatedRadius;
Box capsuleBox;
computeBoxAroundCapsule(inflatedCapsule, capsuleBox);
const PxTransform capsuleBoxTransform = capsuleBox.getTransform();
const PxBounds3 bounds = PxBounds3::poseExtent(capsuleBoxTransform, capsuleBox.extents);
midPhaseQuery(hfUtil, pose, bounds, tempContainer);
}
// Get results
const PxU32 nbTriangles = tempContainer.size();
if(!nbTriangles)
break;
FloatV mtd;
{
bool hadContacts = false;
const PxU32 nbBatches = (nbTriangles + BATCH_TRIANGLE_NUMBER - 1)/BATCH_TRIANGLE_NUMBER;
mtd = FMax();
MTDTriangle triangles[BATCH_TRIANGLE_NUMBER];
for(PxU32 a = 0; a < nbBatches; ++a)
{
const PxU32 startIndex = a * BATCH_TRIANGLE_NUMBER;
const PxU32 nbTrigs = PxMin(nbTriangles - startIndex, BATCH_TRIANGLE_NUMBER);
for(PxU32 k=0; k<nbTrigs; k++)
{
//triangle vertex space
const PxU32 currentTriangleIndex = tempContainer[startIndex+k];
hfUtil.getTriangle(pose, triangles[k], NULL, NULL, currentTriangleIndex, true);
triangles[k].extraTriData = ETD_CONVEX_EDGE_ALL;
}
//ML: mtd has back face culling, so if the capsule's center is below the triangle, we won't generate any contacts
hadContacts = calculateMTD(capsuleV, inflatedRadiusV, isDoubleSided, triangles, nbTrigs, startIndex, manifoldContacts, numContacts, normal, closestA, closestB, triangleIndex, mtd) || hadContacts;
}
if(!hadContacts)
break;
triangleIndex = tempContainer[triangleIndex];
foundInitial = true;
}
const FloatV distV = FSub(mtd, capsuleV.radius);
if(FAllGrtr(FZero(), distV))
{
//move the capsule to depenetrate it
Vec3V center = capsuleV.getCenter();
const Vec3V t = V3Scale(normal, distV);
translation = V3Sub(translation, t);
center = V3Sub(center, t);
capsuleV.setCenter(center);
}
else
{
if(i == 0)
{
//First iteration so keep this normal
hit.distance = 0.0f;
V3StoreU(closestA, hit.position);
V3StoreU(normal, hit.normal);
hit.faceIndex = triangleIndex;
return true;
}
break;
}
}
return finalizeMTD(hit, translation, closestA, triangleIndex, foundInitial);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static bool calculateMTD( const PolygonalData& polyData, const SupportLocal* polyMap, const PxTransformV& convexTransform, const PxMatTransformV& meshToConvex, bool isDoubleSided, const FloatVArg inflation, const MTDTriangle* triangles, PxU32 nbTriangles, PxU32 startIndex,
MeshPersistentContact* manifoldContacts, PxU32& numContacts, Vec3V& normal, Vec3V& closestA, Vec3V& closestB, PxU32& faceIndex, FloatV& mtd)
{
bool hadContacts = false;
FloatV deepestPen = mtd;
for(PxU32 j=0; j<nbTriangles; ++j)
{
numContacts = 0;
const MTDTriangle& curTri = triangles[j];
const PxU8 triFlag = curTri.extraTriData;
PCMConvexVsMeshContactGeneration::processTriangle(polyData, polyMap, curTri.verts, j+startIndex, triFlag, inflation, isDoubleSided, convexTransform, meshToConvex, manifoldContacts, numContacts);
if(numContacts ==0)
continue;
hadContacts = true;
getMTDPerTriangle(manifoldContacts, numContacts, j+startIndex, normal, closestA, closestB, faceIndex, deepestPen);
}
mtd = deepestPen;
return hadContacts;
}
bool physx::Gu::computeBox_TriangleMeshMTD(const PxTriangleMeshGeometry& triMeshGeom, const PxTransform& pose, const Box& _box, const PxTransform& boxTransform, PxReal inflation, bool isDoubleSided, PxGeomSweepHit& hit)
{
TriangleMesh* triMesh = static_cast<TriangleMesh*>(triMeshGeom.triangleMesh);
const PxU8* extraTrigData = triMesh->getExtraTrigData();
const bool flipsNormal = triMeshGeom.scale.hasNegativeDeterminant();
const Vec3V zeroV = V3Zero();
Vec3V closestA = zeroV, closestB = zeroV, normal = zeroV;
Vec3V worldNormal = zeroV, worldContactA = zeroV;//, worldContactB = zeroV;
Box box = _box;
const QuatV q0 = QuatVLoadU(&boxTransform.q.x);
const Vec3V p0 = V3LoadU(&boxTransform.p.x);
const Vec3V boxExtents = V3LoadU(box.extents);
const FloatV minMargin = CalculateMTDBoxMargin(boxExtents);
const FloatV inflationV = FAdd(FLoad(inflation), minMargin);
PxReal boundInflation;
FStore(inflationV, &boundInflation);
box.extents += PxVec3(boundInflation);
const BoxV boxV(zeroV, boxExtents);
Vec3V boxCenter = V3LoadU(box.center);
//create the polyData based on the original data
PolygonalData polyData;
const PCMPolygonalBox polyBox(_box.extents);
polyBox.getPolygonalData(&polyData);
const Mat33V identity = M33Identity();
const PxMat34 meshToWorldSkew = pose * triMeshGeom.scale;
PxTransformV boxTransformV(p0, q0);//box
/////
MeshPersistentContact manifoldContacts[64];
PxU32 numContacts = 0;
PxArray<PxU32> tempContainer;
tempContainer.reserve(128);
PxU32 triangleIndex = 0xfffffff;
Vec3V translation = zeroV;
bool foundInitial = false;
const PxU32 iterations = 4;
/////
for(PxU32 i=0; i<iterations; ++i)
{
tempContainer.forceSize_Unsafe(0);
{
midPhaseQuery(triMeshGeom, pose, box, tempContainer);
}
// Get results
const PxU32 nbTriangles = tempContainer.size();
if(!nbTriangles)
break;
boxTransformV.p = boxCenter;
SupportLocalImpl<BoxV> boxMap(boxV, boxTransformV, identity, identity, true);
boxMap.setShapeSpaceCenterofMass(zeroV);
// Move to AABB space
PxMat34 WorldToBox;
computeWorldToBoxMatrix(WorldToBox, box);
const PxMat34 meshToBox = WorldToBox*meshToWorldSkew;
const Mat33V rot(V3LoadU(meshToBox.m.column0), V3LoadU(meshToBox.m.column1), V3LoadU(meshToBox.m.column2));
const PxMatTransformV meshToConvex(V3LoadU(meshToBox.p), rot);
FloatV mtd;
{
bool hadContacts = false;
const PxU32 nbBatches = (nbTriangles + BATCH_TRIANGLE_NUMBER - 1)/BATCH_TRIANGLE_NUMBER;
mtd = FMax();
MTDTriangle triangles[BATCH_TRIANGLE_NUMBER];
for(PxU32 a = 0; a < nbBatches; ++a)
{
const PxU32 startIndex = a * BATCH_TRIANGLE_NUMBER;
const PxU32 nbTrigs = PxMin(nbTriangles - startIndex, BATCH_TRIANGLE_NUMBER);
for(PxU32 k=0; k<nbTrigs; k++)
{
//triangle vertex space
const PxU32 currentTriangleIndex = tempContainer[startIndex+k];
triMesh->getLocalTriangle(triangles[k], currentTriangleIndex, flipsNormal);
triangles[k].extraTriData = getConvexEdgeFlags(extraTrigData, currentTriangleIndex);
}
//ML: mtd has back face culling, so if the capsule's center is below the triangle, we won't generate any contacts
hadContacts = calculateMTD(polyData, &boxMap, boxTransformV, meshToConvex, isDoubleSided, inflationV, triangles, nbTrigs, startIndex, manifoldContacts, numContacts, normal, closestA, closestB, triangleIndex, mtd) || hadContacts;
}
if(!hadContacts)
break;
triangleIndex = tempContainer[triangleIndex];
foundInitial = true;
}
const FloatV distV = mtd;
worldNormal = boxTransformV.rotate(normal);
worldContactA = boxTransformV.transform(closestA);
if(FAllGrtr(FZero(), distV))
{
const Vec3V t = V3Scale(worldNormal, mtd);
translation = V3Sub(translation, t);
boxCenter = V3Sub(boxCenter, t);
V3StoreU(boxCenter, box.center);
}
else
{
if(i == 0)
{
//First iteration so keep this normal
hit.distance = 0.0f;
V3StoreU(worldContactA, hit.position);
V3StoreU(worldNormal, hit.normal);
hit.faceIndex = triangleIndex;
return true;
}
break;
}
}
return finalizeMTD(hit, translation, worldContactA, triangleIndex, foundInitial);
}
bool physx::Gu::computeBox_HeightFieldMTD(const PxHeightFieldGeometry& heightFieldGeom, const PxTransform& pose, const Box& _box, const PxTransform& boxTransform, PxReal inflation, bool isDoubleSided, PxGeomSweepHit& hit)
{
const HeightFieldUtil hfUtil(heightFieldGeom);
const Vec3V zeroV = V3Zero();
Vec3V closestA = zeroV, closestB = zeroV, normal = zeroV;
Vec3V worldNormal = zeroV, worldContactA = zeroV;//, worldContactB = zeroV;
Box box = _box;
const QuatV q0 = QuatVLoadU(&boxTransform.q.x);
const Vec3V p0 = V3LoadU(&boxTransform.p.x);
const Vec3V boxExtents = V3LoadU(box.extents);
const FloatV minMargin = CalculateMTDBoxMargin(boxExtents);
const FloatV inflationV = FAdd(FLoad(inflation), minMargin);
//const FloatV inflationV = FLoad(inflation);
PxReal boundInflation;
FStore(inflationV, &boundInflation);
box.extents += PxVec3(boundInflation);
const BoxV boxV(zeroV, boxExtents);
Vec3V boxCenter = V3LoadU(box.center);
//create the polyData based on the original box
PolygonalData polyData;
const PCMPolygonalBox polyBox(_box.extents);
polyBox.getPolygonalData(&polyData);
const Mat33V identity = M33Identity();
const Matrix34FromTransform meshToWorldSkew(pose);
PxTransformV boxTransformV(p0, q0);//box
/////
MeshPersistentContact manifoldContacts[64];
PxU32 numContacts = 0;
PxArray<PxU32> tempContainer;
tempContainer.reserve(128);
PxU32 triangleIndex = 0xfffffff;
Vec3V translation = zeroV;
bool foundInitial = false;
const PxU32 iterations = 4;
/////
for(PxU32 i=0; i<iterations; ++i)
{
tempContainer.forceSize_Unsafe(0);
{
const PxBounds3 bounds = PxBounds3::poseExtent(box.getTransform(), box.extents);
midPhaseQuery(hfUtil, pose, bounds, tempContainer);
}
// Get results
const PxU32 nbTriangles = tempContainer.size();
if(!nbTriangles)
break;
boxTransformV.p = boxCenter;
SupportLocalImpl<BoxV> boxMap(boxV, boxTransformV, identity, identity, true);
boxMap.setShapeSpaceCenterofMass(zeroV);
// Move to AABB space
PxMat34 WorldToBox;
computeWorldToBoxMatrix(WorldToBox, box);
const PxMat34 meshToBox = WorldToBox*meshToWorldSkew;
const Mat33V rot(V3LoadU(meshToBox.m.column0), V3LoadU(meshToBox.m.column1), V3LoadU(meshToBox.m.column2));
const PxMatTransformV meshToConvex(V3LoadU(meshToBox.p), rot);
FloatV mtd;
{
bool hadContacts = false;
const PxU32 nbBatches = (nbTriangles + BATCH_TRIANGLE_NUMBER - 1)/BATCH_TRIANGLE_NUMBER;
mtd = FMax();
MTDTriangle triangles[BATCH_TRIANGLE_NUMBER];
for(PxU32 a = 0; a < nbBatches; ++a)
{
const PxU32 startIndex = a * BATCH_TRIANGLE_NUMBER;
const PxU32 nbTrigs = PxMin(nbTriangles - startIndex, BATCH_TRIANGLE_NUMBER);
for(PxU32 k=0; k<nbTrigs; k++)
{
//triangle vertex space
const PxU32 currentTriangleIndex = tempContainer[startIndex+k];
hfUtil.getTriangle(pose, triangles[k], NULL, NULL, currentTriangleIndex, false, false);
triangles[k].extraTriData = ETD_CONVEX_EDGE_ALL;
}
//ML: mtd has back face culling, so if the box's center is below the triangle, we won't generate any contacts
hadContacts = calculateMTD(polyData, &boxMap, boxTransformV, meshToConvex, isDoubleSided, inflationV, triangles, nbTrigs, startIndex, manifoldContacts, numContacts, normal, closestA, closestB, triangleIndex, mtd) || hadContacts;
}
if(!hadContacts)
break;
triangleIndex = tempContainer[triangleIndex];
foundInitial = true;
}
const FloatV distV = mtd;
worldNormal = boxTransformV.rotate(normal);
worldContactA = boxTransformV.transform(closestA);
if(FAllGrtr(FZero(), distV))
{
//worldContactB = boxTransformV.transform(closestB);
const Vec3V t = V3Scale(worldNormal, mtd);
translation = V3Sub(translation, t);
boxCenter = V3Sub(boxCenter, t);
V3StoreU(boxCenter, box.center);
}
else
{
if(i == 0)
{
//First iteration so keep this normal
hit.distance = 0.0f;
V3StoreU(worldContactA, hit.position);
V3StoreU(worldNormal, hit.normal);
hit.faceIndex = triangleIndex;
return true;
}
break;
}
}
return finalizeMTD(hit, translation, worldContactA, triangleIndex, foundInitial);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computeConvex_TriangleMeshMTD( const PxTriangleMeshGeometry& triMeshGeom, const PxTransform& pose, const PxConvexMeshGeometry& convexGeom, const PxTransform& convexPose, PxReal inflation,
bool isDoubleSided, PxGeomSweepHit& hit)
{
const Vec3V zeroV = V3Zero();
TriangleMesh* triMesh = static_cast<TriangleMesh*>(triMeshGeom.triangleMesh);
ConvexMesh* cm = static_cast<ConvexMesh*>(convexGeom.convexMesh);
const PxU8* extraTrigData = triMesh->getExtraTrigData();
const bool flipsNormal = triMeshGeom.scale.hasNegativeDeterminant();
ConvexHullData* hullData = &cm->getHull();
const bool idtScaleConvex = convexGeom.scale.isIdentity();
FastVertex2ShapeScaling convexScaling;
if(!idtScaleConvex)
convexScaling.init(convexGeom.scale);
const PxVec3 _shapeSpaceCenterOfMass = convexScaling * hullData->mCenterOfMass;
const Vec3V shapeSpaceCenterOfMass = V3LoadU(_shapeSpaceCenterOfMass);
const QuatV q0 = QuatVLoadU(&convexPose.q.x);
const Vec3V p0 = V3LoadU(&convexPose.p.x);
PxTransformV convexTransformV(p0, q0);
const Vec3V vScale = V3LoadU_SafeReadW(convexGeom.scale.scale); // PT: safe because 'rotation' follows 'scale' in PxMeshScale
const QuatV vQuat = QuatVLoadU(&convexGeom.scale.rotation.x);
const ConvexHullV convexHull(hullData, V3Zero(), vScale, vQuat, idtScaleConvex);
PX_ALIGN(16, PxU8 convexBuff[sizeof(SupportLocalImpl<ConvexHullV>)]);
const FloatV convexMargin = CalculateMTDConvexMargin(hullData, vScale);
const FloatV inflationV = FAdd(FLoad(inflation), convexMargin);
PxReal boundInflation;
FStore(inflationV, &boundInflation);
Vec3V closestA = zeroV, closestB = zeroV, normal = zeroV;
const PxMat34 meshToWorldSkew = pose * triMeshGeom.scale;
PolygonalData polyData;
getPCMConvexData(convexHull, idtScaleConvex, polyData);
Vec3V center = p0;
PxTransform tempConvexPose = convexPose;
Vec3V worldNormal = zeroV, worldContactA = zeroV;//, worldContactB = zeroV;
/////
MeshPersistentContact manifoldContacts[64];
PxU32 numContacts = 0;
PxArray<PxU32> tempContainer;
tempContainer.reserve(128);
PxU32 triangleIndex = 0xfffffff;
Vec3V translation = zeroV;
bool foundInitial = false;
const PxU32 iterations = 2; // PT: TODO: why 2 here instead of 4?
/////
for(PxU32 i=0; i<iterations; ++i)
{
tempContainer.forceSize_Unsafe(0);
SupportLocal* convexMap;
{
//ML:: construct convex hull data
V3StoreU(center, tempConvexPose.p);
convexTransformV.p = center;
convexMap = idtScaleConvex ? static_cast<SupportLocal*>(PX_PLACEMENT_NEW(convexBuff, SupportLocalImpl<ConvexHullNoScaleV>)(static_cast<const ConvexHullNoScaleV&>(convexHull), convexTransformV, convexHull.vertex2Shape, convexHull.shape2Vertex, idtScaleConvex)) :
static_cast<SupportLocal*>(PX_PLACEMENT_NEW(convexBuff, SupportLocalImpl<ConvexHullV>)(convexHull, convexTransformV, convexHull.vertex2Shape, convexHull.shape2Vertex, idtScaleConvex));
convexMap->setShapeSpaceCenterofMass(shapeSpaceCenterOfMass);
Box hullOBB;
computeOBBAroundConvex(hullOBB, convexGeom, cm, tempConvexPose);
hullOBB.extents += PxVec3(boundInflation);
midPhaseQuery(triMeshGeom, pose, hullOBB, tempContainer);
}
// Get results
const PxU32 nbTriangles = tempContainer.size();
if(!nbTriangles)
break;
// Move to AABB space
const Matrix34FromTransform worldToConvex(tempConvexPose.getInverse());
const PxMat34 meshToConvex = worldToConvex*meshToWorldSkew;
const Mat33V rot(V3LoadU(meshToConvex.m.column0), V3LoadU(meshToConvex.m.column1), V3LoadU(meshToConvex.m.column2));
const PxMatTransformV meshToConvexV(V3LoadU(meshToConvex.p), rot);
FloatV mtd;
{
bool hadContacts = false;
const PxU32 nbBatches = (nbTriangles + BATCH_TRIANGLE_NUMBER - 1)/BATCH_TRIANGLE_NUMBER;
mtd = FMax();
MTDTriangle triangles[BATCH_TRIANGLE_NUMBER];
for(PxU32 a = 0; a < nbBatches; ++a)
{
const PxU32 startIndex = a * BATCH_TRIANGLE_NUMBER;
const PxU32 nbTrigs = PxMin(nbTriangles - startIndex, BATCH_TRIANGLE_NUMBER);
for(PxU32 k=0; k<nbTrigs; k++)
{
//triangle vertex space
const PxU32 currentTriangleIndex = tempContainer[startIndex+k];
triMesh->getLocalTriangle(triangles[k], currentTriangleIndex, flipsNormal);
triangles[k].extraTriData = getConvexEdgeFlags(extraTrigData, currentTriangleIndex);
}
//ML: mtd has back face culling, so if the capsule's center is below the triangle, we won't generate any contacts
hadContacts = calculateMTD(polyData, convexMap, convexTransformV, meshToConvexV, isDoubleSided, inflationV, triangles, nbTrigs, startIndex, manifoldContacts, numContacts, normal, closestA, closestB, triangleIndex, mtd) || hadContacts;
}
if(!hadContacts)
break;
triangleIndex = tempContainer[triangleIndex];
foundInitial = true;
}
const FloatV distV = mtd;
worldNormal = convexTransformV.rotate(normal);
worldContactA = convexTransformV.transform(closestA);
if(FAllGrtr(FZero(), distV))
{
const Vec3V t = V3Scale(worldNormal, mtd);
translation = V3Sub(translation, t);
center = V3Sub(center, t);
}
else
{
if(i == 0)
{
//First iteration so keep this normal
hit.distance = 0.0f;
V3StoreU(worldContactA, hit.position);
V3StoreU(worldNormal, hit.normal);
hit.faceIndex = triangleIndex;
return true;
}
break;
}
}
return finalizeMTD(hit, translation, worldContactA, triangleIndex, foundInitial);
}
bool physx::Gu::computeConvex_HeightFieldMTD(const PxHeightFieldGeometry& heightFieldGeom, const PxTransform& pose, const PxConvexMeshGeometry& convexGeom, const PxTransform& convexPose, PxReal inflation, bool isDoubleSided, PxGeomSweepHit& hit)
{
const HeightFieldUtil hfUtil(heightFieldGeom);
const Vec3V zeroV = V3Zero();
ConvexMesh* cm = static_cast<ConvexMesh*>(convexGeom.convexMesh);
ConvexHullData* hullData = &cm->getHull();
const bool idtScaleConvex = convexGeom.scale.isIdentity();
FastVertex2ShapeScaling convexScaling;
if(!idtScaleConvex)
convexScaling.init(convexGeom.scale);
const PxVec3 _shapeSpaceCenterOfMass = convexScaling * hullData->mCenterOfMass;
const Vec3V shapeSpaceCenterOfMass = V3LoadU(_shapeSpaceCenterOfMass);
const QuatV q0 = QuatVLoadU(&convexPose.q.x);
const Vec3V p0 = V3LoadU(&convexPose.p.x);
PxTransformV convexTransformV(p0, q0);
const Vec3V vScale = V3LoadU_SafeReadW(convexGeom.scale.scale); // PT: safe because 'rotation' follows 'scale' in PxMeshScale
const QuatV vQuat = QuatVLoadU(&convexGeom.scale.rotation.x);
const ConvexHullV convexHull(hullData, zeroV, vScale, vQuat, idtScaleConvex);
PX_ALIGN(16, PxU8 convexBuff[sizeof(SupportLocalImpl<ConvexHullV>)]);
const FloatV convexMargin = CalculateMTDConvexMargin(hullData, vScale);
const FloatV inflationV = FAdd(FLoad(inflation), convexMargin);
PxReal boundInflation;
FStore(inflationV, &boundInflation);
Vec3V closestA = zeroV, closestB = zeroV, normal = zeroV;
Vec3V worldNormal = zeroV, worldContactA = zeroV;//, worldContactB = zeroV;
PolygonalData polyData;
getPCMConvexData(convexHull, idtScaleConvex, polyData);
Vec3V center = p0;
PxTransform tempConvexPose = convexPose;
const Matrix34FromTransform meshToWorldSkew(pose);
/////
MeshPersistentContact manifoldContacts[64];
PxU32 numContacts = 0;
PxArray<PxU32> tempContainer;
tempContainer.reserve(128);
PxU32 triangleIndex = 0xfffffff;
Vec3V translation = zeroV;
bool foundInitial = false;
const PxU32 iterations = 2; // PT: TODO: why 2 here instead of 4?
/////
for(PxU32 i=0; i<iterations; ++i)
{
tempContainer.forceSize_Unsafe(0);
SupportLocal* convexMap;
{
//ML:: construct convex hull data
V3StoreU(center, tempConvexPose.p);
convexTransformV.p = center;
convexMap = idtScaleConvex ? static_cast<SupportLocal*>(PX_PLACEMENT_NEW(convexBuff, SupportLocalImpl<ConvexHullNoScaleV>)(static_cast<const ConvexHullNoScaleV&>(convexHull), convexTransformV, convexHull.vertex2Shape, convexHull.shape2Vertex, idtScaleConvex)) :
static_cast<SupportLocal*>(PX_PLACEMENT_NEW(convexBuff, SupportLocalImpl<ConvexHullV>)(convexHull, convexTransformV, convexHull.vertex2Shape, convexHull.shape2Vertex, idtScaleConvex));
convexMap->setShapeSpaceCenterofMass(shapeSpaceCenterOfMass);
Box hullOBB;
computeOBBAroundConvex(hullOBB, convexGeom, cm, tempConvexPose);
hullOBB.extents += PxVec3(boundInflation);
const PxBounds3 bounds = PxBounds3::basisExtent(hullOBB.center, hullOBB.rot, hullOBB.extents);
midPhaseQuery(hfUtil, pose, bounds, tempContainer);
}
// Get results
const PxU32 nbTriangles = tempContainer.size();
if(!nbTriangles)
break;
// Move to AABB space
const Matrix34FromTransform worldToConvex(tempConvexPose.getInverse());
const PxMat34 meshToConvex = worldToConvex*meshToWorldSkew;
const Mat33V rot(V3LoadU(meshToConvex.m.column0), V3LoadU(meshToConvex.m.column1), V3LoadU(meshToConvex.m.column2));
const PxMatTransformV meshToConvexV(V3LoadU(meshToConvex.p), rot);
FloatV mtd;
{
bool hadContacts = false;
const PxU32 nbBatches = (nbTriangles + BATCH_TRIANGLE_NUMBER - 1)/BATCH_TRIANGLE_NUMBER;
mtd = FMax();
MTDTriangle triangles[BATCH_TRIANGLE_NUMBER];
for(PxU32 a = 0; a < nbBatches; ++a)
{
const PxU32 startIndex = a * BATCH_TRIANGLE_NUMBER;
const PxU32 nbTrigs = PxMin(nbTriangles - startIndex, BATCH_TRIANGLE_NUMBER);
for(PxU32 k=0; k<nbTrigs; k++)
{
//triangle vertex space
const PxU32 currentTriangleIndex = tempContainer[startIndex+k];
hfUtil.getTriangle(pose, triangles[k], NULL, NULL, currentTriangleIndex, false, false);
triangles[k].extraTriData = ETD_CONVEX_EDGE_ALL;
}
//ML: mtd has back face culling, so if the capsule's center is below the triangle, we won't generate any contacts
hadContacts = calculateMTD(polyData, convexMap, convexTransformV, meshToConvexV, isDoubleSided, inflationV, triangles, nbTrigs, startIndex, manifoldContacts, numContacts, normal, closestA, closestB, triangleIndex, mtd) || hadContacts;
}
if(!hadContacts)
break;
triangleIndex = tempContainer[triangleIndex];
foundInitial = true;
}
const FloatV distV = mtd;
worldNormal = convexTransformV.rotate(normal);
worldContactA = convexTransformV.transform(closestA);
if(FAllGrtr(FZero(), distV))
{
const Vec3V t = V3Scale(worldNormal, mtd);
translation = V3Sub(translation, t);
center = V3Sub(center, t);
}
else
{
if(i == 0)
{
//First iteration so keep this normal
hit.distance = 0.0f;
V3StoreU(worldContactA, hit.position);
V3StoreU(worldNormal, hit.normal);
hit.faceIndex = triangleIndex;
return true;
}
break;
}
}
return finalizeMTD(hit, translation, worldContactA, triangleIndex, foundInitial);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computeSphere_SphereMTD(const Sphere& sphere0, const Sphere& sphere1, PxGeomSweepHit& hit)
{
const PxVec3 delta = sphere1.center - sphere0.center;
const PxReal d2 = delta.magnitudeSquared();
const PxReal radiusSum = sphere0.radius + sphere1.radius;
const PxReal d = manualNormalize(hit.normal, delta, d2);
hit.distance = d - radiusSum;
hit.position = sphere0.center + hit.normal * sphere0.radius;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computeSphere_CapsuleMTD( const Sphere& sphere, const Capsule& capsule, PxGeomSweepHit& hit)
{
const PxReal radiusSum = sphere.radius + capsule.radius;
PxReal u;
distancePointSegmentSquared(capsule, sphere.center, &u);
const PxVec3 normal = capsule.getPointAt(u) - sphere.center;
const PxReal lenSq = normal.magnitudeSquared();
const PxF32 d = manualNormalize(hit.normal, normal, lenSq);
hit.distance = d - radiusSum;
hit.position = sphere.center + hit.normal * sphere.radius;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computeCapsule_CapsuleMTD(const Capsule& capsule0, const Capsule& capsule1, PxGeomSweepHit& hit)
{
PxReal s,t;
distanceSegmentSegmentSquared(capsule0, capsule1, &s, &t);
const PxReal radiusSum = capsule0.radius + capsule1.radius;
const PxVec3 pointAtCapsule0 = capsule0.getPointAt(s);
const PxVec3 pointAtCapsule1 = capsule1.getPointAt(t);
const PxVec3 normal = pointAtCapsule0 - pointAtCapsule1;
const PxReal lenSq = normal.magnitudeSquared();
const PxF32 len = manualNormalize(hit.normal, normal, lenSq);
hit.distance = len - radiusSum;
hit.position = pointAtCapsule1 + hit.normal * capsule1.radius;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computePlane_CapsuleMTD(const PxPlane& plane, const Capsule& capsule, PxGeomSweepHit& hit)
{
const PxReal d0 = plane.distance(capsule.p0);
const PxReal d1 = plane.distance(capsule.p1);
PxReal dmin;
PxVec3 point;
if(d0 < d1)
{
dmin = d0;
point = capsule.p0;
}
else
{
dmin = d1;
point = capsule.p1;
}
hit.normal = plane.n;
hit.distance = dmin - capsule.radius;
hit.position = point - hit.normal * dmin;
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computePlane_BoxMTD(const PxPlane& plane, const Box& box, PxGeomSweepHit& hit)
{
PxVec3 pts[8];
box.computeBoxPoints(pts);
PxReal dmin = plane.distance(pts[0]);
PxU32 index = 0;
for(PxU32 i=1;i<8;i++)
{
const PxReal d = plane.distance(pts[i]);
if(dmin > d)
{
index = i;
dmin = d;
}
}
hit.normal = plane.n;
hit.distance = dmin;
hit.position = pts[index] - plane.n*dmin;
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool physx::Gu::computePlane_ConvexMTD(const PxPlane& plane, const PxConvexMeshGeometry& convexGeom, const PxTransform& convexPose, PxGeomSweepHit& hit)
{
const ConvexMesh* convexMesh = static_cast<const ConvexMesh*>(convexGeom.convexMesh);
const FastVertex2ShapeScaling convexScaling(convexGeom.scale);
PxU32 nbVerts = convexMesh->getNbVerts();
const PxVec3* PX_RESTRICT verts = convexMesh->getVerts();
PxVec3 worldPointMin = convexPose.transform(convexScaling * verts[0]);
PxReal dmin = plane.distance(worldPointMin);
for(PxU32 i=1;i<nbVerts;i++)
{
const PxVec3 worldPoint = convexPose.transform(convexScaling * verts[i]);
const PxReal d = plane.distance(worldPoint);
if(dmin > d)
{
dmin = d;
worldPointMin = worldPoint;
}
}
hit.normal = plane.n;
hit.distance = dmin;
hit.position = worldPointMin - plane.n * dmin;
return true;
}
| 38,568 | C++ | 32.480035 | 274 | 0.718601 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuGjkQuery.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "geometry/PxGjkQuery.h"
#include "GuInternal.h"
#include "GuOverlapTests.h"
#include "GuSweepTests.h"
#include "GuRaycastTests.h"
#include "GuBoxConversion.h"
#include "GuTriangleMesh.h"
#include "GuMTD.h"
#include "GuBounds.h"
#include "GuDistancePointSegment.h"
#include "GuConvexMesh.h"
#include "GuDistancePointBox.h"
#include "GuMidphaseInterface.h"
#include "foundation/PxFPU.h"
using namespace physx;
using namespace Gu;
#include "GuGJK.h"
#include "GuGJKPenetration.h"
#include "GuGJKRaycast.h"
#include "GuEPA.h"
#include "geomutils/PxContactBuffer.h"
using namespace aos;
static PX_SUPPORT_INLINE PxVec3 Vec3V_To_PxVec3(const Vec3V& a)
{
PxVec3 v;
V3StoreU(a, v);
return v;
}
static PX_SUPPORT_INLINE PxReal FloatV_To_PxReal(const FloatV& a)
{
PxF32 f;
FStore(a, &f);
return f;
}
struct CustomConvexV : ConvexV
{
const PxGjkQuery::Support* s;
PxReal supportScale;
CustomConvexV(const PxGjkQuery::Support& _s) : ConvexV(Gu::ConvexType::eCUSTOM), s(&_s), supportScale(1.0f)
{
setMinMargin(FLoad(0.001f));
setSweepMargin(FLoad(0.001f));
}
PX_SUPPORT_INLINE Vec3V supportPoint(const PxI32 /*index*/) const
{
return supportLocal(V3LoadU(PxVec3(1, 0, 0)));
}
PX_SUPPORT_INLINE Vec3V supportLocal(const Vec3V& dir) const
{
return V3Scale(V3LoadU(s->supportLocal(Vec3V_To_PxVec3(dir))), FLoad(supportScale));
}
PX_SUPPORT_INLINE Vec3V supportLocal(const Vec3V& dir, PxI32& index) const
{
index = 0;
return supportLocal(dir);
}
PX_SUPPORT_INLINE Vec3V supportRelative(const Vec3V& dir, const PxMatTransformV& aTob, const PxMatTransformV& aTobT) const
{
const Vec3V _dir = aTobT.rotate(dir);
const Vec3V p = supportLocal(_dir);
return aTob.transform(p);
}
PX_SUPPORT_INLINE Vec3V supportRelative(const Vec3V& dir, const PxMatTransformV& aTob, const PxMatTransformV& aTobT, PxI32& index) const
{
index = 0;
return supportRelative(dir, aTob, aTobT);
}
};
bool PxGjkQuery::proximityInfo(const Support& a, const Support& b, const PxTransform& poseA, const PxTransform& poseB, PxReal contactDistance, PxReal toleranceLength, PxVec3& pointA, PxVec3& pointB, PxVec3& separatingAxis, PxReal& separation)
{
const PxTransformV transf0 = loadTransformU(poseA);
const PxTransformV transf1 = loadTransformU(poseB);
const PxTransformV curRTrans(transf1.transformInv(transf0));
const PxMatTransformV aToB(curRTrans);
const PxReal degenerateScale = 0.001f;
CustomConvexV supportA(a);
CustomConvexV supportB(b);
const RelativeConvex<CustomConvexV> convexA(supportA, aToB);
const LocalConvex<CustomConvexV> convexB(supportB);
Vec3V initialSearchDir = aToB.p;
FloatV contactDist = FLoad((a.getMargin() + b.getMargin()) + contactDistance);
Vec3V aPoints[4];
Vec3V bPoints[4];
PxU8 size = 0;
GjkOutput output;
GjkStatus status = gjkPenetration(convexA, convexB, initialSearchDir, contactDist, true, aPoints, bPoints, size, output);
if (status == GJK_DEGENERATE)
{
supportA.supportScale = supportB.supportScale = 1.0f - degenerateScale;
status = gjkPenetration(convexA, convexB, initialSearchDir, contactDist, true, aPoints, bPoints, size, output);
supportA.supportScale = supportB.supportScale = 1.0f;
}
if (status == GJK_CONTACT || status == GJK_DEGENERATE)
{
separatingAxis = poseB.rotate(Vec3V_To_PxVec3(output.normal).getNormalized());
pointA = poseB.transform(Vec3V_To_PxVec3(output.closestA)) - separatingAxis * a.getMargin();
pointB = poseB.transform(Vec3V_To_PxVec3(output.closestB)) + separatingAxis * b.getMargin();
separation = (pointA - pointB).dot(separatingAxis);
return true;
}
if (status == EPA_CONTACT)
{
status = epaPenetration(convexA, convexB, aPoints, bPoints, size, true, FLoad(toleranceLength), output);
if (status == EPA_CONTACT || status == EPA_DEGENERATE)
{
separatingAxis = poseB.rotate(Vec3V_To_PxVec3(output.normal).getNormalized());
pointA = poseB.transform(Vec3V_To_PxVec3(output.closestA)) - separatingAxis * a.getMargin();
pointB = poseB.transform(Vec3V_To_PxVec3(output.closestB)) + separatingAxis * b.getMargin();
separation = (pointA - pointB).dot(separatingAxis);
return true;
}
}
return false;
}
struct PointConvexV : ConvexV
{
Vec3V zero;
PointConvexV() : ConvexV(Gu::ConvexType::eCUSTOM)
{
zero = V3Zero();
setMinMargin(FLoad(0.001f));
setSweepMargin(FLoad(0.001f));
}
PX_SUPPORT_INLINE Vec3V supportPoint(const PxI32 /*index*/) const
{
return zero;
}
PX_SUPPORT_INLINE Vec3V supportLocal(const Vec3V& /*dir*/) const
{
return zero;
}
PX_SUPPORT_INLINE Vec3V supportLocal(const Vec3V& dir, PxI32& index) const
{
index = 0;
return supportLocal(dir);
}
PX_SUPPORT_INLINE Vec3V supportRelative(const Vec3V& dir, const PxMatTransformV& aTob, const PxMatTransformV& aTobT) const
{
const Vec3V _dir = aTobT.rotate(dir);
const Vec3V p = supportLocal(_dir);
return aTob.transform(p);
}
PX_SUPPORT_INLINE Vec3V supportRelative(const Vec3V& dir, const PxMatTransformV& aTob, const PxMatTransformV& aTobT, PxI32& index) const
{
index = 0;
return supportRelative(dir, aTob, aTobT);
}
};
bool PxGjkQuery::raycast(const Support& shape, const PxTransform& pose, const PxVec3& rayStart, const PxVec3& unitDir, PxReal maxDist, PxReal& t, PxVec3& n, PxVec3& p)
{
const PxTransformV transf0 = loadTransformU(pose);
const PxTransformV transf1 = PxTransformV(V3LoadU(rayStart));
const PxTransformV curRTrans(transf1.transformInv(transf0));
const PxMatTransformV aToB(curRTrans);
CustomConvexV supportA(shape);
PointConvexV supportB;
const RelativeConvex<CustomConvexV> convexA(supportA, aToB);
const LocalConvex<PointConvexV> convexB(supportB);
Vec3V initialDir = aToB.p;
FloatV initialLambda = FLoad(0);
Vec3V s = V3Zero();
Vec3V r = V3LoadU(unitDir * maxDist);
FloatV lambda;
Vec3V normal, closestA;
if (gjkRaycast(convexA, convexB, initialDir, initialLambda, s, r, lambda, normal, closestA, shape.getMargin()))
{
t = FloatV_To_PxReal(lambda) * maxDist;
n = -Vec3V_To_PxVec3(normal).getNormalized();
p = Vec3V_To_PxVec3(closestA) + n * shape.getMargin() + rayStart;
return true;
}
return false;
}
bool PxGjkQuery::overlap(const Support& a, const Support& b, const PxTransform& poseA, const PxTransform& poseB)
{
const PxTransformV transf0 = loadTransformU(poseA);
const PxTransformV transf1 = loadTransformU(poseB);
const PxTransformV curRTrans(transf1.transformInv(transf0));
const PxMatTransformV aToB(curRTrans);
CustomConvexV supportA(a);
CustomConvexV supportB(b);
const RelativeConvex<CustomConvexV> convexA(supportA, aToB);
const LocalConvex<CustomConvexV> convexB(supportB);
Vec3V initialSearchDir = aToB.p;
FloatV contactDist = FLoad(a.getMargin() + b.getMargin());
Vec3V closestA, closestB, normal;
FloatV distance;
GjkStatus status = gjk(convexA, convexB, initialSearchDir, contactDist, closestA, closestB, normal, distance);
return status == GJK_CLOSE || status == GJK_CONTACT;
}
bool PxGjkQuery::sweep(const Support& a, const Support& b, const PxTransform& poseA, const PxTransform& poseB, const PxVec3& unitDir, PxReal maxDist, PxReal& t, PxVec3& n, PxVec3& p)
{
const PxTransformV transf0 = loadTransformU(poseA);
const PxTransformV transf1 = loadTransformU(poseB);
const PxTransformV curRTrans(transf1.transformInv(transf0));
const PxMatTransformV aToB(curRTrans);
CustomConvexV supportA(a);
CustomConvexV supportB(b);
const RelativeConvex<CustomConvexV> convexA(supportA, aToB);
const LocalConvex<CustomConvexV> convexB(supportB);
Vec3V initialDir = aToB.p;
FloatV initialLambda = FLoad(0);
Vec3V s = V3Zero();
Vec3V r = V3LoadU(poseB.rotateInv(unitDir * maxDist));
FloatV lambda;
Vec3V normal, closestA;
if (gjkRaycast(convexA, convexB, initialDir, initialLambda, s, r, lambda, normal, closestA, a.getMargin() + b.getMargin()))
{
t = FloatV_To_PxReal(lambda) * maxDist;
n = poseB.rotate(-(Vec3V_To_PxVec3(normal)).getNormalized());
p = poseB.transform(Vec3V_To_PxVec3(closestA)) + n * a.getMargin();
return true;
}
return false;
}
| 9,711 | C++ | 33.935252 | 242 | 0.748739 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuAABBPruner.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "common/PxProfileZone.h"
#include "foundation/PxIntrinsics.h"
#include "foundation/PxUserAllocated.h"
#include "foundation/PxBitUtils.h"
#include "GuAABBPruner.h"
#include "GuPrunerMergeData.h"
#include "GuCallbackAdapter.h"
#include "GuSphere.h"
#include "GuBox.h"
#include "GuCapsule.h"
#include "GuAABBTreeQuery.h"
#include "GuAABBTreeNode.h"
#include "GuQuery.h"
#include "CmVisualization.h"
using namespace physx;
using namespace Gu;
using namespace Cm;
// PT: TODO: this is copied from SqBounds.h, should be either moved to Gu and shared or passed as a user parameter
#define SQ_PRUNER_EPSILON 0.005f
#define SQ_PRUNER_INFLATION (1.0f + SQ_PRUNER_EPSILON) // pruner test shape inflation (not narrow phase shape)
AABBPruner::AABBPruner(bool incrementalRebuild, PxU64 contextID, CompanionPrunerType cpType, BVHBuildStrategy buildStrategy, PxU32 nbObjectsPerNode) :
mAABBTree (NULL),
mNewTree (NULL),
mNbCachedBoxes (0),
mNbCalls (0),
mTimeStamp (0),
mBucketPruner (contextID, cpType, &mPool),
mProgress (BUILD_NOT_STARTED),
mRebuildRateHint (100),
mAdaptiveRebuildTerm(0),
mNbObjectsPerNode (nbObjectsPerNode),
mBuildStrategy (buildStrategy),
mPool (contextID, TRANSFORM_CACHE_GLOBAL),
mIncrementalRebuild (incrementalRebuild),
mUncommittedChanges (false),
mNeedsNewTree (false),
mNewTreeFixups ("AABBPruner::mNewTreeFixups")
{
PX_ASSERT(nbObjectsPerNode<16);
}
AABBPruner::~AABBPruner()
{
release();
}
bool AABBPruner::addObjects(PrunerHandle* results, const PxBounds3* bounds, const PrunerPayload* data, const PxTransform* transforms, PxU32 count, bool hasPruningStructure)
{
PX_PROFILE_ZONE("SceneQuery.prunerAddObjects", mPool.mContextID);
if(!count)
return true;
// no need to do refitMarked for added objects since they are not in the tree
// if we have provided pruning structure, we will merge it, the changes will be applied after the objects has been addded
if(!hasPruningStructure || !mAABBTree)
mUncommittedChanges = true;
// PT: TODO: 'addObjects' for bucket pruner too. Not urgent since we always call the function with count=1 at the moment
const PxU32 valid = mPool.addObjects(results, bounds, data, transforms, count);
// Bucket pruner is only used while the dynamic pruner is rebuilding
// For the static pruner a full rebuild will happen in commit() every time we modify something, this is not true if
// pruning structure was provided. The objects tree will be merged directly into the static tree. No rebuild will be triggered.
if(mIncrementalRebuild && mAABBTree)
{
PX_PROFILE_ZONE("SceneQuery.bucketPrunerAddObjects", mPool.mContextID);
mNeedsNewTree = true; // each add forces a tree rebuild
// if a pruner structure is provided, we dont move the new objects into bucket pruner
// the pruning structure will be merged into the bucket pruner
if(!hasPruningStructure)
{
for(PxU32 i=0;i<valid;i++)
{
// PT: poolIndex fetched in vain for bucket pruner companion...
// Since the incremental tree references the same pool we could just retrieve the poolIndex there, from the handle...
const PrunerHandle handle = results[i];
const PoolIndex poolIndex = mPool.getIndex(handle);
mBucketPruner.addObject(data[i], handle, bounds[i], transforms[i], mTimeStamp, poolIndex);
}
}
}
return valid==count;
}
void AABBPruner::updateObjects(const PrunerHandle* handles, PxU32 count, float inflation, const PxU32* boundsIndices, const PxBounds3* newBounds, const PxTransform32* newTransforms)
{
PX_PROFILE_ZONE("SceneQuery.prunerUpdateObjects", mPool.mContextID);
if(!count)
return;
mUncommittedChanges = true;
if(handles && boundsIndices && newBounds)
mPool.updateAndInflateBounds(handles, boundsIndices, newBounds, newTransforms, count, inflation);
if(mIncrementalRebuild && mAABBTree)
{
mNeedsNewTree = true; // each update forces a tree rebuild
const PxBounds3* currentBounds = mPool.getCurrentWorldBoxes();
const PxTransform* currentTransforms = mPool.getTransforms();
const PrunerPayload* data = mPool.getObjects();
const bool addToRefit = mProgress == BUILD_NEW_MAPPING || mProgress == BUILD_FULL_REFIT || mProgress==BUILD_LAST_FRAME;
for(PxU32 i=0; i<count; i++)
{
const PrunerHandle handle = handles[i];
const PoolIndex poolIndex = mPool.getIndex(handle);
const TreeNodeIndex treeNodeIndex = mTreeMap[poolIndex];
if(treeNodeIndex != INVALID_NODE_ID) // this means it's in the current tree still and hasn't been removed
mAABBTree->markNodeForRefit(treeNodeIndex);
else // otherwise it means it should be in the bucket pruner
{
PX_ASSERT(&data[poolIndex]==&mPool.getPayloadData(handle));
bool found = mBucketPruner.updateObject(currentBounds[poolIndex], currentTransforms[poolIndex], data[poolIndex], handle, poolIndex);
PX_UNUSED(found); PX_ASSERT(found);
}
if(addToRefit)
mToRefit.pushBack(poolIndex);
}
}
}
void AABBPruner::removeObjects(const PrunerHandle* handles, PxU32 count, PrunerPayloadRemovalCallback* removalCallback)
{
PX_PROFILE_ZONE("SceneQuery.prunerRemoveObjects", mPool.mContextID);
if(!count)
return;
mUncommittedChanges = true;
for(PxU32 i=0; i<count; i++)
{
const PrunerHandle h = handles[i];
// copy the payload/userdata before removing it since we need to know the payload/userdata to remove it from the bucket pruner
const PrunerPayload removedData = mPool.getPayloadData(h);
const PoolIndex poolIndex = mPool.getIndex(h); // save the pool index for removed object
const PoolIndex poolRelocatedLastIndex = mPool.removeObject(h, removalCallback); // save the lastIndex returned by removeObject
if(mIncrementalRebuild && mAABBTree)
{
mNeedsNewTree = true;
const TreeNodeIndex treeNodeIndex = mTreeMap[poolIndex]; // already removed from pool but still in tree map
const PrunerPayload swappedData = mPool.getObjects()[poolIndex];
if(treeNodeIndex!=INVALID_NODE_ID) // can be invalid if removed
{
mAABBTree->markNodeForRefit(treeNodeIndex); // mark the spot as blank
mBucketPruner.swapIndex(poolIndex, swappedData, poolRelocatedLastIndex); // if swapped index is in bucket pruner
}
else
{
bool status = mBucketPruner.removeObject(removedData, h, poolIndex, swappedData, poolRelocatedLastIndex);
// PT: removed assert to avoid crashing all UTs
//PX_ASSERT(status);
PX_UNUSED(status);
}
mTreeMap.invalidate(poolIndex, poolRelocatedLastIndex, *mAABBTree);
if(mNewTree)
mNewTreeFixups.pushBack(NewTreeFixup(poolIndex, poolRelocatedLastIndex));
}
}
if (mPool.getNbActiveObjects()==0)
{
// this is just to make sure we release all the internal data once all the objects are out of the pruner
// since this is the only place we know that and we don't want to keep memory reserved
release();
// Pruner API requires a commit before the next query, even if we ended up removing the entire tree here. This
// forces that to happen.
mUncommittedChanges = true;
}
}
bool AABBPruner::overlap(const ShapeData& queryVolume, PrunerOverlapCallback& pcbArgName) const
{
PX_ASSERT(!mUncommittedChanges);
bool again = true;
if(mAABBTree)
{
OverlapCallbackAdapter pcb(pcbArgName, mPool);
switch(queryVolume.getType())
{
case PxGeometryType::eBOX:
{
if(queryVolume.isOBB())
{
const DefaultOBBAABBTest test(queryVolume);
again = AABBTreeOverlap<true, OBBAABBTest, AABBTree, BVHNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
else
{
const DefaultAABBAABBTest test(queryVolume);
again = AABBTreeOverlap<true, AABBAABBTest, AABBTree, BVHNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
}
break;
case PxGeometryType::eCAPSULE:
{
const DefaultCapsuleAABBTest test(queryVolume, SQ_PRUNER_INFLATION);
again = AABBTreeOverlap<true, CapsuleAABBTest, AABBTree, BVHNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
break;
case PxGeometryType::eSPHERE:
{
const DefaultSphereAABBTest test(queryVolume);
again = AABBTreeOverlap<true, SphereAABBTest, AABBTree, BVHNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
break;
case PxGeometryType::eCONVEXMESH:
{
const DefaultOBBAABBTest test(queryVolume);
again = AABBTreeOverlap<true, OBBAABBTest, AABBTree, BVHNode, OverlapCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, test, pcb);
}
break;
default:
PX_ALWAYS_ASSERT_MESSAGE("unsupported overlap query volume geometry type");
}
}
if(again && mIncrementalRebuild && mBucketPruner.getNbObjects())
again = mBucketPruner.overlap(queryVolume, pcbArgName);
return again;
}
bool AABBPruner::sweep(const ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& pcbArgName) const
{
PX_ASSERT(!mUncommittedChanges);
bool again = true;
if(mAABBTree)
{
RaycastCallbackAdapter pcb(pcbArgName, mPool);
const PxBounds3& aabb = queryVolume.getPrunerInflatedWorldAABB();
again = AABBTreeRaycast<true, true, AABBTree, BVHNode, RaycastCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, aabb.getCenter(), unitDir, inOutDistance, aabb.getExtents(), pcb);
}
if(again && mIncrementalRebuild && mBucketPruner.getNbObjects())
again = mBucketPruner.sweep(queryVolume, unitDir, inOutDistance, pcbArgName);
return again;
}
bool AABBPruner::raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& pcbArgName) const
{
PX_ASSERT(!mUncommittedChanges);
bool again = true;
if(mAABBTree)
{
RaycastCallbackAdapter pcb(pcbArgName, mPool);
again = AABBTreeRaycast<false, true, AABBTree, BVHNode, RaycastCallbackAdapter>()(mPool.getCurrentAABBTreeBounds(), *mAABBTree, origin, unitDir, inOutDistance, PxVec3(0.0f), pcb);
}
if(again && mIncrementalRebuild && mBucketPruner.getNbObjects())
again = mBucketPruner.raycast(origin, unitDir, inOutDistance, pcbArgName);
return again;
}
// This isn't part of the pruner virtual interface, but it is part of the public interface
// of AABBPruner - it gets called by SqManager to force a rebuild, and requires a commit() before
// queries can take place
void AABBPruner::purge()
{
release();
mUncommittedChanges = true; // this ensures a commit() must happen before any query
}
void AABBPruner::setRebuildRateHint(PxU32 nbStepsForRebuild)
{
PX_ASSERT(nbStepsForRebuild > 3);
mRebuildRateHint = (nbStepsForRebuild-3); // looks like a magic number to account for the rebuild pipeline latency
mAdaptiveRebuildTerm = 0;
}
// Commit either performs a refit if background rebuild is not yet finished
// or swaps the current tree for the second tree rebuilt in the background
void AABBPruner::commit()
{
PX_PROFILE_ZONE("SceneQuery.prunerCommit", mPool.mContextID);
if(!mUncommittedChanges && (mProgress != BUILD_FINISHED))
// Q: seems like this is both for refit and finalization so is this is correct?
// i.e. in a situation when we started rebuilding a tree and didn't add anything since
// who is going to set mUncommittedChanges to true?
// A: it's set in buildStep at final stage, so that finalization is forced.
// Seems a bit difficult to follow and verify correctness.
return;
mUncommittedChanges = false;
if(!mAABBTree || !mIncrementalRebuild)
{
if(!mIncrementalRebuild && mAABBTree)
PxGetFoundation().error(PxErrorCode::ePERF_WARNING, PX_FL, "SceneQuery static AABB Tree rebuilt, because a shape attached to a static actor was added, removed or moved, and PxSceneQueryDesc::staticStructure is set to eSTATIC_AABB_TREE.");
fullRebuildAABBTree();
return;
}
// Note: it is not safe to call AABBPruner::build() here
// because the first thread will perform one step of the incremental update,
// continue raycasting, while the second thread performs the next step in
// the incremental update
// Calling Refit() below is safe. It will call
// StaticPruner::build() when necessary. Both will early
// exit if the tree is already up to date, if it is not already, then we
// must be the first thread performing raycasts on a dirty tree and other
// scene query threads will be locked out by the write lock in
// PrunerManager::flushUpdates()
if (mProgress != BUILD_FINISHED)
{
// Calling refit because the second tree is not ready to be swapped in (mProgress != BUILD_FINISHED)
// Generally speaking as long as things keep moving the second build will never catch up with true state
refitUpdatedAndRemoved();
}
else
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeFinalize", mPool.mContextID);
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeSwitch", mPool.mContextID);
PX_DELETE(mAABBTree); // delete the old tree
mCachedBoxes.release();
mProgress = BUILD_NOT_STARTED; // reset the build state to initial
// Adjust adaptive term to get closer to specified rebuild rate.
// perform an even division correction to make sure the rebuild rate adds up
if (mNbCalls > mRebuildRateHint)
mAdaptiveRebuildTerm++;
else if (mNbCalls < mRebuildRateHint)
mAdaptiveRebuildTerm--;
// Switch trees
#if PX_DEBUG
mNewTree->validate();
#endif
mAABBTree = mNewTree; // set current tree to progressively rebuilt tree
mNewTree = NULL; // clear out the progressively rebuild tree pointer
mNodeAllocator.release();
}
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeMapping", mPool.mContextID);
// rebuild the tree map to match the current (newly built) tree
mTreeMap.initMap(PxMax(mPool.getNbActiveObjects(), mNbCachedBoxes), *mAABBTree);
// The new mapping has been computed using only indices stored in the new tree. Those indices map the pruning pool
// we had when starting to build the tree. We need to re-apply recorded moves to fix the tree that finished rebuilding.
// AP: the problem here is while we are rebuilding the tree there are ongoing modifications to the current tree
// but the background build has a cached copy of all the AABBs at the time it was started
// (and will produce indices referencing those)
// Things that can happen in the meantime: update, remove, add, commit
for(NewTreeFixup* r = mNewTreeFixups.begin(); r < mNewTreeFixups.end(); r++)
{
// PT: we're not doing a full refit after this point anymore, so the remaining deleted objects must be manually marked for
// refit (otherwise their AABB in the tree would remain valid, leading to crashes when the corresponding index is 0xffffffff).
// We must do this before invalidating the corresponding tree nodes in the map, obviously (otherwise we'd be reading node
// indices that we already invalidated).
const PoolIndex poolIndex = r->removedIndex;
const TreeNodeIndex treeNodeIndex = mTreeMap[poolIndex];
if(treeNodeIndex!=INVALID_NODE_ID)
mAABBTree->markNodeForRefit(treeNodeIndex);
mTreeMap.invalidate(r->removedIndex, r->relocatedLastIndex, *mAABBTree);
}
mNewTreeFixups.clear(); // clear out the fixups since we just applied them all
}
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeFinalRefit", mPool.mContextID);
const PxU32 size = mToRefit.size();
for(PxU32 i=0;i<size;i++)
{
const PoolIndex poolIndex = mToRefit[i];
const TreeNodeIndex treeNodeIndex = mTreeMap[poolIndex];
if(treeNodeIndex!=INVALID_NODE_ID)
mAABBTree->markNodeForRefit(treeNodeIndex);
}
mToRefit.clear();
refitUpdatedAndRemoved();
}
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeRemoveObjects", mPool.mContextID);
PxU32 nbRemovedPairs = mBucketPruner.removeMarkedObjects(mTimeStamp-1);
PX_UNUSED(nbRemovedPairs);
mNeedsNewTree = mBucketPruner.getNbObjects()>0;
}
}
updateBucketPruner();
}
void AABBPruner::shiftOrigin(const PxVec3& shift)
{
mPool.shiftOrigin(shift);
if(mAABBTree)
mAABBTree->shiftOrigin(shift);
if(mIncrementalRebuild)
mBucketPruner.shiftOrigin(shift);
if(mNewTree)
mNewTree->shiftOrigin(shift);
}
void AABBPruner::visualize(PxRenderOutput& out, PxU32 primaryColor, PxU32 secondaryColor) const
{
// getAABBTree() asserts when pruner is dirty. NpScene::visualization() does not enforce flushUpdate. see DE7834
visualizeTree(out, primaryColor, mAABBTree);
// Render added objects not yet in the tree
out << PxTransform(PxIdentity);
out << PxU32(PxDebugColor::eARGB_WHITE);
if(mIncrementalRebuild && mBucketPruner.getNbObjects())
mBucketPruner.visualize(out, secondaryColor);
}
bool AABBPruner::buildStep(bool synchronousCall)
{
PX_PROFILE_ZONE("SceneQuery.prunerBuildStep", mPool.mContextID);
PX_ASSERT(mIncrementalRebuild);
if(mNeedsNewTree)
{
if(mProgress==BUILD_NOT_STARTED)
{
if(!synchronousCall || !prepareBuild())
return false;
}
else if(mProgress==BUILD_INIT)
{
mNewTree->progressiveBuild(mBuilder, mNodeAllocator, mBuildStats, 0, 0);
mProgress = BUILD_IN_PROGRESS;
mNbCalls = 0;
// Use a heuristic to estimate the number of work units needed for rebuilding the tree.
// The general idea is to use the number of work units of the previous tree to build the new tree.
// This works fine as long as the number of leaves remains more or less the same for the old and the
// new tree. If that is not the case, this estimate can be way off and the work units per step will
// be either much too small or too large. Hence, in that case we will try to estimate the number of work
// units based on the number of leaves of the new tree as follows:
//
// - Assume new tree with n leaves is perfectly-balanced
// - Compute the depth of perfectly-balanced tree with n leaves
// - Estimate number of working units for the new tree
const PxU32 depth = PxILog2(mBuilder.mNbPrimitives); // Note: This is the depth without counting the leaf layer
const PxU32 estimatedNbWorkUnits = depth * mBuilder.mNbPrimitives; // Estimated number of work units for new tree
const PxU32 estimatedNbWorkUnitsOld = mAABBTree ? mAABBTree->getTotalPrims() : 0;
if ((estimatedNbWorkUnits <= (estimatedNbWorkUnitsOld << 1)) && (estimatedNbWorkUnits >= (estimatedNbWorkUnitsOld >> 1)))
// The two estimates do not differ by more than a factor 2
mTotalWorkUnits = estimatedNbWorkUnitsOld;
else
{
mAdaptiveRebuildTerm = 0;
mTotalWorkUnits = estimatedNbWorkUnits;
}
const PxI32 totalWorkUnits = PxI32(mTotalWorkUnits + (mAdaptiveRebuildTerm * mBuilder.mNbPrimitives));
mTotalWorkUnits = PxU32(PxMax(totalWorkUnits, 0));
}
else if(mProgress==BUILD_IN_PROGRESS)
{
mNbCalls++;
const PxU32 Limit = 1 + (mTotalWorkUnits / mRebuildRateHint);
// looks like progressiveRebuild returns 0 when finished
if(!mNewTree->progressiveBuild(mBuilder, mNodeAllocator, mBuildStats, 1, Limit))
{
// Done
mProgress = BUILD_NEW_MAPPING;
#if PX_DEBUG
mNewTree->validate();
#endif
}
}
else if(mProgress==BUILD_NEW_MAPPING)
{
mNbCalls++;
mProgress = BUILD_FULL_REFIT;
// PT: we can't call fullRefit without creating the new mapping first: the refit function will fetch boxes from
// the pool using "primitive indices" captured in the tree. But some of these indices may have been invalidated
// if objects got removed while the tree was built. So we need to invalidate the corresponding nodes before refit,
// that way the #prims will be zero and the code won't fetch a wrong box (which may now below to a different object).
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeMapping", mPool.mContextID);
if(mNewTreeFixups.size())
{
mNewTreeMap.initMap(PxMax(mPool.getNbActiveObjects(), mNbCachedBoxes), *mNewTree);
// The new mapping has been computed using only indices stored in the new tree. Those indices map the pruning pool
// we had when starting to build the tree. We need to re-apply recorded moves to fix the tree.
for(NewTreeFixup* r = mNewTreeFixups.begin(); r < mNewTreeFixups.end(); r++)
mNewTreeMap.invalidate(r->removedIndex, r->relocatedLastIndex, *mNewTree);
mNewTreeFixups.clear();
#if PX_DEBUG
mNewTree->validate();
#endif
}
}
}
else if(mProgress==BUILD_FULL_REFIT)
{
mNbCalls++;
mProgress = BUILD_LAST_FRAME;
{
PX_PROFILE_ZONE("SceneQuery.prunerNewTreeFullRefit", mPool.mContextID);
// We need to refit the new tree because objects may have moved while we were building it.
mNewTree->fullRefit(mPool.getCurrentWorldBoxes());
}
}
else if(mProgress==BUILD_LAST_FRAME)
{
mProgress = BUILD_FINISHED;
}
// This is required to be set because commit handles both refit and a portion of build finalization (why?)
// This is overly conservative also only necessary in case there were no updates at all to the tree since the last tree swap
// It also overly conservative in a sense that it could be set only if mProgress was just set to BUILD_FINISHED
// If run asynchronously from a different thread, we touched just the new AABB build phase, we should not mark the main tree as dirty
if(synchronousCall)
mUncommittedChanges = true;
return mProgress==BUILD_FINISHED;
}
return false;
}
bool AABBPruner::prepareBuild()
{
PX_PROFILE_ZONE("SceneQuery.prepareBuild", mPool.mContextID);
PX_ASSERT(mIncrementalRebuild);
if(mNeedsNewTree)
{
if(mProgress==BUILD_NOT_STARTED)
{
const PxU32 nbObjects = mPool.getNbActiveObjects();
if(!nbObjects)
return false;
mNodeAllocator.release();
PX_DELETE(mNewTree);
mNewTree = PX_NEW(AABBTree);
mNbCachedBoxes = nbObjects;
mCachedBoxes.init(nbObjects, mPool.getCurrentWorldBoxes());
// PT: objects currently in the bucket pruner will be in the new tree. They are marked with the
// current timestamp (mTimeStamp). However more objects can get added while we compute the new tree,
// and those ones will not be part of it. These new objects will be marked with the new timestamp
// value (mTimeStamp+1), and we can use these different values to remove the proper objects from
// the bucket pruner (when switching to the new tree).
mTimeStamp++;
// notify the incremental pruner to swap trees (for incremental pruner companion)
mBucketPruner.timeStampChange();
mBuilder.reset();
mBuilder.mNbPrimitives = mNbCachedBoxes;
mBuilder.mBounds = &mCachedBoxes;
mBuilder.mLimit = mNbObjectsPerNode;
mBuilder.mBuildStrategy = mBuildStrategy;
mBuildStats.reset();
// start recording modifications to the tree made during rebuild to reapply (fix the new tree) eventually
PX_ASSERT(mNewTreeFixups.size()==0);
mProgress = BUILD_INIT;
}
}
else
return false;
return true;
}
/**
* Builds an AABB-tree for objects in the pruning pool.
* \return true if success
*/
bool AABBPruner::fullRebuildAABBTree()
{
PX_PROFILE_ZONE("SceneQuery.prunerFullRebuildAABBTree", mPool.mContextID);
// Release possibly already existing tree
PX_DELETE(mAABBTree);
// Don't bother building an AABB-tree if there isn't a single static object
const PxU32 nbObjects = mPool.getNbActiveObjects();
if(!nbObjects)
return true;
bool Status;
{
// Create a new tree
mAABBTree = PX_NEW(AABBTree);
Status = mAABBTree->build(AABBTreeBuildParams(mNbObjectsPerNode, nbObjects, &mPool.getCurrentAABBTreeBounds(), mBuildStrategy), mNodeAllocator);
}
// No need for the tree map for static pruner
if(mIncrementalRebuild)
mTreeMap.initMap(PxMax(nbObjects, mNbCachedBoxes), *mAABBTree);
return Status;
}
// called in the end of commit(), but only if mIncrementalRebuild is true
void AABBPruner::updateBucketPruner()
{
PX_PROFILE_ZONE("SceneQuery.prunerUpdateBucketPruner", mPool.mContextID);
PX_ASSERT(mIncrementalRebuild);
mBucketPruner.build();
}
void AABBPruner::release() // this can be called from purge()
{
mBucketPruner.release();
mTimeStamp = 0;
mTreeMap.release();
mNewTreeMap.release();
mCachedBoxes.release();
mBuilder.reset();
mNodeAllocator.release();
PX_DELETE(mNewTree);
PX_DELETE(mAABBTree);
mNbCachedBoxes = 0;
mProgress = BUILD_NOT_STARTED;
mNewTreeFixups.clear();
mUncommittedChanges = false;
}
// Refit current tree
void AABBPruner::refitUpdatedAndRemoved()
{
PX_PROFILE_ZONE("SceneQuery.prunerRefitUpdatedAndRemoved", mPool.mContextID);
PX_ASSERT(mIncrementalRebuild);
AABBTree* tree = getAABBTree();
if(!tree)
return;
#if PX_DEBUG
tree->validate();
#endif
//### missing a way to skip work if not needed
const PxU32 nbObjects = mPool.getNbActiveObjects();
// At this point there still can be objects in the tree that are blanked out so it's an optimization shortcut (not required)
if(!nbObjects)
return;
mBucketPruner.refitMarkedNodes(mPool.getCurrentWorldBoxes());
tree->refitMarkedNodes(mPool.getCurrentWorldBoxes());
}
void AABBPruner::merge(const void* mergeParams)
{
const AABBPrunerMergeData& pruningStructure = *reinterpret_cast<const AABBPrunerMergeData*> (mergeParams);
if(!pruningStructure.mAABBTreeNodes)
return;
if(mAABBTree)
{
// index in pruning pool, where new objects were added
const PxU32 pruningPoolIndex = mPool.getNbActiveObjects() - pruningStructure.mNbObjects;
// create tree from given nodes and indices
AABBTreeMergeData aabbTreeMergeParams(pruningStructure.mNbNodes, pruningStructure.mAABBTreeNodes,
pruningStructure.mNbObjects, pruningStructure.mAABBTreeIndices, pruningPoolIndex);
if(!mIncrementalRebuild)
{
// merge tree directly
mAABBTree->mergeTree(aabbTreeMergeParams);
}
else
{
mBucketPruner.addTree(aabbTreeMergeParams, mTimeStamp);
}
}
}
void AABBPruner::getGlobalBounds(PxBounds3& bounds) const
{
if(mAABBTree && mAABBTree->getNodes())
bounds = mAABBTree->getNodes()->mBV;
else
bounds.setEmpty();
if(mIncrementalRebuild && mBucketPruner.getNbObjects())
{
PxBounds3 extBounds;
mBucketPruner.getGlobalBounds(extBounds);
bounds.include(extBounds);
}
}
| 27,670 | C++ | 34.843264 | 241 | 0.744742 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuSDF.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuSDF.h"
#include "GuAABBTreeNode.h"
#include "GuAABBTree.h"
#include "GuAABBTreeBounds.h"
#include "GuWindingNumber.h"
#include "GuAABBTreeNode.h"
#include "GuDistancePointBox.h"
#include "GuDistancePointTriangle.h"
#include "GuAABBTreeQuery.h"
#include "GuIntersectionRayTriangle.h"
#include "GuIntersectionRayBox.h"
#include "foundation/PxAtomic.h"
#include "foundation/PxThread.h"
#include "common/GuMeshAnalysis.h"
#include "GuMeshAnalysis.h"
#include "PxSDFBuilder.h"
#include "GuDistancePointSegment.h"
#include "common/PxSerialFramework.h"
#define EXTENDED_DEBUG 0
namespace physx
{
namespace Gu
{
SDF::~SDF()
{
if(mOwnsMemory)
{
PX_FREE(mSdf);
PX_FREE(mSubgridStartSlots);
PX_FREE(mSubgridSdf);
}
}
PxReal* SDF::allocateSdfs(const PxVec3& meshLower, const PxReal& spacing, const PxU32 dimX, const PxU32 dimY, const PxU32 dimZ,
const PxU32 subgridSize, const PxU32 sdfSubgrids3DTexBlockDimX, const PxU32 sdfSubgrids3DTexBlockDimY, const PxU32 sdfSubgrids3DTexBlockDimZ,
PxReal minSdfValueSubgrids, PxReal maxSdfValueSubgrids, PxU32 sparsePixelNumBytes)
{
PX_ASSERT(!mSdf);
PX_ASSERT(!mSubgridStartSlots);
PX_ASSERT(!mSubgridSdf);
mMeshLower = meshLower;
mSpacing = spacing;
mDims.x = dimX;
mDims.y = dimY;
mDims.z = dimZ;
mSubgridSize = subgridSize;
mSdfSubgrids3DTexBlockDim.x = sdfSubgrids3DTexBlockDimX;
mSdfSubgrids3DTexBlockDim.y = sdfSubgrids3DTexBlockDimY;
mSdfSubgrids3DTexBlockDim.z = sdfSubgrids3DTexBlockDimZ;
mSubgridsMinSdfValue = minSdfValueSubgrids;
mSubgridsMaxSdfValue = maxSdfValueSubgrids;
mBytesPerSparsePixel = sparsePixelNumBytes;
if (subgridSize > 0)
{
//Sparse sdf
PX_ASSERT(dimX % subgridSize == 0);
PX_ASSERT(dimY % subgridSize == 0);
PX_ASSERT(dimZ % subgridSize == 0);
PxU32 x = dimX / subgridSize;
PxU32 y = dimY / subgridSize;
PxU32 z = dimZ / subgridSize;
mNumSdfs = (x + 1) * (y + 1) * (z + 1);
mNumSubgridSdfs = mBytesPerSparsePixel * sdfSubgrids3DTexBlockDimX * (subgridSize + 1) * sdfSubgrids3DTexBlockDimY * (subgridSize + 1) * sdfSubgrids3DTexBlockDimZ * (subgridSize + 1);
mNumStartSlots = x * y * z;
mSubgridSdf = PX_ALLOCATE(PxU8, mNumSubgridSdfs, "PxU8");
mSubgridStartSlots = PX_ALLOCATE(PxU32, mNumStartSlots, "PxU32");
mSdf = PX_ALLOCATE(PxReal, mNumSdfs, "PxReal");
}
else
{
//Dense sdf - no sparse grid data required
mSubgridStartSlots = NULL;
mSubgridSdf = NULL;
mNumSdfs = dimX * dimY*dimZ;
mNumSubgridSdfs = 0;
mNumStartSlots = 0;
mSdf = PX_ALLOCATE(PxReal, mNumSdfs, "PxReal");
}
return mSdf;
}
void SDF::exportExtraData(PxSerializationContext& context)
{
if (mSdf)
{
context.alignData(PX_SERIAL_ALIGN);
context.writeData(mSdf, mNumSdfs * sizeof(PxReal));
}
if (mNumStartSlots)
{
context.alignData(PX_SERIAL_ALIGN);
context.writeData(mSubgridStartSlots, mNumStartSlots * sizeof(PxU32));
}
if (mSubgridSdf)
{
context.alignData(PX_SERIAL_ALIGN);
context.writeData(mSubgridSdf, mNumSubgridSdfs * sizeof(PxU8));
}
}
void SDF::importExtraData(PxDeserializationContext& context)
{
if (mSdf)
mSdf = context.readExtraData<PxReal, PX_SERIAL_ALIGN>(mNumSdfs);
if (mSubgridStartSlots)
mSubgridStartSlots = context.readExtraData<PxU32, PX_SERIAL_ALIGN>(mNumStartSlots);
if (mSubgridSdf)
mSubgridSdf = context.readExtraData<PxU8, PX_SERIAL_ALIGN>(mNumSubgridSdfs);
}
void buildTree(const PxU32* triangles, const PxU32 numTriangles, const PxVec3* points, PxArray<Gu::BVHNode>& tree, PxF32 enlargement = 1e-4f)
{
//Computes a bounding box for every triangle in triangles
Gu::AABBTreeBounds boxes;
boxes.init(numTriangles);
for (PxU32 i = 0; i < numTriangles; ++i)
{
const PxU32* tri = &triangles[3 * i];
PxBounds3 box = PxBounds3::empty();
box.include(points[tri[0]]);
box.include(points[tri[1]]);
box.include(points[tri[2]]);
box.fattenFast(enlargement);
boxes.getBounds()[i] = box;
}
Gu::buildAABBTree(numTriangles, boxes, tree);
}
class LineSegmentTrimeshIntersectionTraversalController
{
private:
const PxU32* mTriangles;
const PxVec3* mPoints;
PxVec3 mSegmentStart;
PxVec3 mSegmentEnd;
PxVec3 mDirection;
bool mIntersects;
public:
LineSegmentTrimeshIntersectionTraversalController(const PxU32* triangles, const PxVec3* points, PxVec3 segmentStart, PxVec3 segmentEnd)
: mTriangles(triangles), mPoints(points), mSegmentStart(segmentStart), mSegmentEnd(segmentEnd), mDirection(segmentEnd - segmentStart), mIntersects(false)
{
}
void reset(PxVec3 segmentStart, PxVec3 segmentEnd)
{
mSegmentStart = segmentStart;
mSegmentEnd = segmentEnd;
mDirection = segmentEnd - segmentStart;
mIntersects = false;
}
bool intersectionDetected() const
{
return mIntersects;
}
PX_FORCE_INLINE Gu::TraversalControl::Enum analyze(const Gu::BVHNode& node, PxI32)
{
if (node.isLeaf())
{
PxI32 j = node.getPrimitiveIndex();
const PxU32* tri = &mTriangles[3 * j];
PxReal at, au, av;
if (Gu::intersectRayTriangle(mSegmentStart, mDirection, mPoints[tri[0]], mPoints[tri[1]], mPoints[tri[2]], at, au, av, false, 1e-4f) && at >= 0.0f && at <= 1.0f)
{
mIntersects = true;
return TraversalControl::eAbort;
}
return TraversalControl::eDontGoDeeper;
}
PxReal tnear, tfar;
if (Gu::intersectRayAABB(node.mBV.minimum, node.mBV.maximum, mSegmentStart, mDirection, tnear, tfar) >= 0 && ((tnear >= 0.0f && tnear <= 1.0f) || (tfar >= 0.0f && tfar <= 1.0f) || node.mBV.contains(mSegmentStart)))
return TraversalControl::eGoDeeper;
return TraversalControl::eDontGoDeeper;
}
private:
PX_NOCOPY(LineSegmentTrimeshIntersectionTraversalController)
};
class ClosestDistanceToTrimeshTraversalController
{
private:
PxReal mClosestDistanceSquared;
const PxU32* mTriangles;
const PxVec3* mPoints;
const Gu::BVHNode* mNodes;
PxVec3 mQueryPoint;
PxVec3 mClosestPoint;
PxI32 mClosestTriId;
public:
PX_FORCE_INLINE ClosestDistanceToTrimeshTraversalController(){}
PX_FORCE_INLINE ClosestDistanceToTrimeshTraversalController(const PxU32* triangles, const PxVec3* points, Gu::BVHNode* nodes) :
mTriangles(triangles), mPoints(points), mNodes(nodes), mQueryPoint(0.0f), mClosestPoint(0.0f), mClosestTriId(-1)
{
initialize(triangles, points, nodes);
}
void initialize(const PxU32* triangles, const PxVec3* points, Gu::BVHNode* nodes)
{
mTriangles = triangles;
mPoints = points;
mNodes = nodes;
mQueryPoint = PxVec3(0.0f);
mClosestPoint = PxVec3(0.0f);
mClosestTriId = -1;
mClosestDistanceSquared = PX_MAX_F32;
}
PX_FORCE_INLINE void setQueryPoint(const PxVec3& queryPoint)
{
this->mQueryPoint = queryPoint;
mClosestDistanceSquared = FLT_MAX;
mClosestPoint = PxVec3(0.0f);
mClosestTriId = -1;
}
PX_FORCE_INLINE const PxVec3& getClosestPoint() const
{
return mClosestPoint;
}
PX_FORCE_INLINE PxReal distancePointBoxSquared(const PxBounds3& box, const PxVec3& point)
{
PxVec3 closestPt = box.minimum.maximum(box.maximum.minimum(point));
return (closestPt - point).magnitudeSquared();
}
PX_FORCE_INLINE Gu::TraversalControl::Enum analyze(const Gu::BVHNode& node, PxI32)
{
if (distancePointBoxSquared(node.mBV, mQueryPoint) >= mClosestDistanceSquared)
return Gu::TraversalControl::eDontGoDeeper;
if (node.isLeaf())
{
const PxI32 j = node.getPrimitiveIndex();
const PxU32* tri = &mTriangles[3 * j];
aos::FloatV t1, t2;
aos::Vec3V q = V3LoadU(mQueryPoint);
aos::Vec3V a = V3LoadU(mPoints[tri[0]]);
aos::Vec3V b = V3LoadU(mPoints[tri[1]]);
aos::Vec3V c = V3LoadU(mPoints[tri[2]]);
aos::Vec3V cp;
aos::FloatV d = Gu::distancePointTriangleSquared2UnitBox(q, a, b, c, t1, t2, cp);
PxReal d2;
FStore(d, &d2);
PxVec3 closest;
V3StoreU(cp, closest);
//const PxVec3 closest = closestPtPointTriangle2UnitBox(mQueryPoint, mPoints[tri[0]], mPoints[tri[1]], mPoints[tri[2]]);
//PxReal d2 = (closest - mQueryPoint).magnitudeSquared();
if (d2 < mClosestDistanceSquared)
{
mClosestDistanceSquared = d2;
mClosestTriId = j;
mClosestPoint = closest;
}
return Gu::TraversalControl::eDontGoDeeper;
}
const Gu::BVHNode& nodePos = mNodes[node.getPosIndex()];
const PxReal distSquaredPos = distancePointBoxSquared(nodePos.mBV, mQueryPoint);
const Gu::BVHNode& nodeNeg = mNodes[node.getNegIndex()];
const PxReal distSquaredNeg = distancePointBoxSquared(nodeNeg.mBV, mQueryPoint);
if (distSquaredPos < distSquaredNeg)
{
if (distSquaredPos < mClosestDistanceSquared)
return Gu::TraversalControl::eGoDeeper;
}
else
{
if (distSquaredNeg < mClosestDistanceSquared)
return Gu::TraversalControl::eGoDeeperNegFirst;
}
return Gu::TraversalControl::eDontGoDeeper;
}
PxI32 getClosestTriId() const { return mClosestTriId; }
void setClosestStart(const PxReal closestDistanceSquared, PxI32 closestTriangle, const PxVec3& closestPoint)
{
mClosestDistanceSquared = closestDistanceSquared;
mClosestTriId = closestTriangle;
mClosestPoint = closestPoint;
}
private:
PX_NOCOPY(ClosestDistanceToTrimeshTraversalController)
};
class PointOntoTriangleMeshProjector : public PxPointOntoTriangleMeshProjector, public PxUserAllocated
{
PxArray<Gu::BVHNode> mNodes;
ClosestDistanceToTrimeshTraversalController mEvaluator;
public:
PointOntoTriangleMeshProjector(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangles)
{
buildTree(indices, numTriangles, vertices, mNodes);
mEvaluator.initialize(indices, vertices, mNodes.begin());
}
virtual PxVec3 projectPoint(const PxVec3& point) PX_OVERRIDE
{
mEvaluator.setQueryPoint(point);
Gu::traverseBVH(mNodes.begin(), mEvaluator);
PxVec3 closestPoint = mEvaluator.getClosestPoint();
return closestPoint;
}
virtual PxVec3 projectPoint(const PxVec3& point, PxU32& closetTriangleIndex) PX_OVERRIDE
{
mEvaluator.setQueryPoint(point);
Gu::traverseBVH(mNodes.begin(), mEvaluator);
PxVec3 closestPoint = mEvaluator.getClosestPoint();
closetTriangleIndex = mEvaluator.getClosestTriId();
return closestPoint;
}
virtual void release() PX_OVERRIDE
{
mNodes.reset();
PX_FREE_THIS;
}
};
PxPointOntoTriangleMeshProjector* PxCreatePointOntoTriangleMeshProjector(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices)
{
return PX_NEW(PointOntoTriangleMeshProjector)(vertices, indices, numTriangleIndices);
}
void windingNumbers(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
PxReal* windingNumbers, PxVec3 min, PxVec3 max, PxVec3* sampleLocations)
{
const PxVec3 extents(max - min);
const PxVec3 delta(extents.x / width, extents.y / height, extents.z / depth);
const PxVec3 offset = min + PxVec3(0.5f * delta.x, 0.5f * delta.y, 0.5f * delta.z);
PxArray<Gu::BVHNode> tree;
buildTree(indices, numTriangleIndices / 3, vertices, tree);
PxHashMap<PxU32, Gu::ClusterApproximation> clusters;
Gu::precomputeClusterInformation(tree.begin(), indices, numTriangleIndices / 3, vertices, clusters);
for (PxU32 x = 0; x < width; ++x)
{
for (PxU32 y = 0; y < height; ++y)
{
for (PxU32 z = 0; z < depth; ++z)
{
PxVec3 queryPoint(x * delta.x + offset.x, y * delta.y + offset.y, z * delta.z + offset.z);
PxReal windingNumber = Gu::computeWindingNumber(tree.begin(), queryPoint, clusters, indices, vertices);
windingNumbers[z * width * height + y * width + x] = windingNumber; // > 0.5f ? PxU32(-1) : 0;
if (sampleLocations)
sampleLocations[z * width * height + y * width + x] = queryPoint;
}
}
}
}
struct Range
{
PxI32 mStart;
PxI32 mEnd;
bool mInsideStart;
bool mInsideEnd;
Range(PxI32 start, PxI32 end, bool insideStart, bool insideEnd) : mStart(start), mEnd(end), mInsideStart(insideStart), mInsideEnd(insideEnd) { }
};
struct SDFCalculationData
{
const PxVec3* vertices;
const PxU32* indices;
PxU32 numTriangleIndices;
PxU32 width;
PxU32 height;
PxU32 depth;
PxReal* sdf;
PxVec3* sampleLocations;
GridQueryPointSampler* pointSampler;
PxArray<Gu::BVHNode>* tree;
PxHashMap<PxU32, Gu::ClusterApproximation>* clusters;
PxI32 batchSize = 32;
PxI32 end;
PxI32* progress;
bool optimizeInsideOutsideCalculation; //Toggle to enable an additional optimization for faster inside/outside classification
bool signOnly;
};
void windingNumbersInsideCheck(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
bool* insideResult, PxVec3 min, PxVec3 max, PxVec3* sampleLocations)
{
#if PX_DEBUG
PxBounds3 bounds(min, max);
for (PxU32 i = 0; i < numTriangleIndices; ++i)
PX_ASSERT(bounds.contains(vertices[indices[i]]));
#endif
const PxVec3 extents(max - min);
const PxVec3 delta(extents.x / width, extents.y / height, extents.z / depth);
const PxVec3 offset = min + PxVec3(0.5f * delta.x, 0.5f * delta.y, -0.5f * delta.z);
PxArray<Gu::BVHNode> tree;
buildTree(indices, numTriangleIndices / 3, vertices, tree);
PxHashMap<PxU32, Gu::ClusterApproximation> clusters;
Gu::precomputeClusterInformation(tree.begin(), indices, numTriangleIndices / 3, vertices, clusters);
LineSegmentTrimeshIntersectionTraversalController intersector(indices, vertices, PxVec3(0.0f), PxVec3(0.0f));
PxArray<Range> stack;
for (PxU32 x = 0; x < width; ++x)
{
for (PxU32 y = 0; y < height; ++y)
{
stack.pushBack(Range(0, depth+2, false, false));
while (stack.size() > 0)
{
Range r = stack.popBack();
PxI32 center = (r.mStart + r.mEnd) / 2;
if (center == r.mStart)
{
if (r.mStart > 0 && r.mStart <= PxI32(depth))
{
insideResult[(r.mStart - 1) * width * height + y * width + x] = r.mInsideStart;
if (sampleLocations)
sampleLocations[(r.mStart - 1) * width * height + y * width + x] = PxVec3(x * delta.x + offset.x, y * delta.y + offset.y, r.mStart * delta.z + offset.z);
}
continue;
}
PxVec3 queryPoint = PxVec3(x * delta.x + offset.x, y * delta.y + offset.y, center * delta.z + offset.z);
bool inside = Gu::computeWindingNumber(tree.begin(), queryPoint, clusters, indices, vertices) > 0.5f;
if (inside != r.mInsideStart)
stack.pushBack(Range(r.mStart, center, r.mInsideStart, inside));
else
{
PxVec3 p = PxVec3(x * delta.x + offset.x, y * delta.y + offset.y, r.mStart * delta.z + offset.z);
intersector.reset(p, queryPoint);
Gu::traverseBVH(tree.begin(), intersector);
if (!intersector.intersectionDetected())
{
PxI32 e = PxMin(center, PxI32(depth) + 1);
for (PxI32 z = PxMax(1, r.mStart); z < e; ++z)
{
insideResult[(z - 1) * width * height + y * width + x] = inside;
if (sampleLocations)
sampleLocations[(z - 1) * width * height + y * width + x] = queryPoint;
}
}
else
stack.pushBack(Range(r.mStart, center, r.mInsideStart, inside));
}
if (inside != r.mInsideEnd)
stack.pushBack(Range(center, r.mEnd, inside, r.mInsideEnd));
else
{
PxVec3 p = PxVec3(x * delta.x + offset.x, y * delta.y + offset.y, r.mEnd * delta.z + offset.z);
intersector.reset(queryPoint, p);
Gu::traverseBVH(tree.begin(), intersector);
if (!intersector.intersectionDetected())
{
PxI32 e = PxMin(r.mEnd, PxI32(depth) + 1);
for (PxI32 z = PxMax(1, center); z < e; ++z)
{
insideResult[(z - 1) * width * height + y * width + x] = inside;
if (sampleLocations)
sampleLocations[(z - 1) * width * height + y * width + x] = queryPoint;
}
}
else
stack.pushBack(Range(center, r.mEnd, inside, r.mInsideEnd));
}
}
}
}
}
void idToXY(PxU32 id, PxU32 sizeX, PxU32& xi, PxU32& yi)
{
xi = id % sizeX;
yi = id / sizeX;
}
void* computeSDFThreadJob(void* data)
{
SDFCalculationData& d = *reinterpret_cast<SDFCalculationData*>(data);
PxI32 lastTriangle = -1;
PxArray<Range> stack;
LineSegmentTrimeshIntersectionTraversalController intersector(d.indices, d.vertices, PxVec3(0.0f), PxVec3(0.0f));
PxI32 start = physx::PxAtomicAdd(d.progress, d.batchSize) - d.batchSize;
while (start < d.end)
{
PxI32 end = PxMin(d.end, start + d.batchSize);
PxU32 yStart, zStart;
idToXY(start, d.height, yStart, zStart);
for (PxI32 id = start; id < end; ++id)
{
PxU32 y, z;
idToXY(id, d.height, y, z);
if (y < yStart)
yStart = 0;
if (d.optimizeInsideOutsideCalculation)
{
stack.pushBack(Range(0, d.width + 2, false, false));
while (stack.size() > 0)
{
Range r = stack.popBack();
PxI32 center = (r.mStart + r.mEnd) / 2;
if (center == r.mStart)
{
if (r.mStart > 0 && r.mStart <= PxI32(d.width))
{
if (r.mInsideStart)
d.sdf[z * d.width * d.height + y * d.width + (r.mStart - 1)] *= -1.0f;
}
continue;
}
PxVec3 queryPoint = d.pointSampler->getPoint(center - 1, y, z);
bool inside = false;
bool computeWinding = true;
if (id > start && y > yStart)
{
PxReal s = d.sdf[z * d.width * d.height + (y - 1) * d.width + (center - 1)];
if (PxAbs(s) > d.pointSampler->getActiveCellSize().y)
{
inside = s < 0.0f;
computeWinding = false;
}
}
if (computeWinding)
inside = Gu::computeWindingNumber(d.tree->begin(), queryPoint, *d.clusters, d.indices, d.vertices) > 0.5f;
if (inside != r.mInsideStart)
stack.pushBack(Range(r.mStart, center, r.mInsideStart, inside));
else
{
PxVec3 p = d.pointSampler->getPoint(r.mStart - 1, y, z);
intersector.reset(p, queryPoint);
Gu::traverseBVH(d.tree->begin(), intersector);
if (!intersector.intersectionDetected())
{
PxI32 e = PxMin(center, PxI32(d.width) + 1);
for (PxI32 x = PxMax(1, r.mStart); x < e; ++x)
{
if (inside)
d.sdf[z * d.width * d.height + y * d.width + (x - 1)] *= -1.0f;
}
}
else
stack.pushBack(Range(r.mStart, center, r.mInsideStart, inside));
}
if (inside != r.mInsideEnd)
stack.pushBack(Range(center, r.mEnd, inside, r.mInsideEnd));
else
{
PxVec3 p = d.pointSampler->getPoint(r.mEnd - 1, y, z);
intersector.reset(queryPoint, p);
Gu::traverseBVH(d.tree->begin(), intersector);
if (!intersector.intersectionDetected())
{
PxI32 e = PxMin(r.mEnd, PxI32(d.width) + 1);
for (PxI32 x = PxMax(1, center); x < e; ++x)
{
if (inside)
d.sdf[z * d.width * d.height + y * d.width + (x - 1)] *= -1.0f;
}
}
else
stack.pushBack(Range(center, r.mEnd, inside, r.mInsideEnd));
}
}
}
if (!d.signOnly)
{
for (PxU32 x = 0; x < d.width; ++x)
{
const PxU32 index = z * d.width * d.height + y * d.width + x;
PxVec3 queryPoint = d.pointSampler->getPoint(x, y, z);
ClosestDistanceToTrimeshTraversalController cd(d.indices, d.vertices, d.tree->begin());
cd.setQueryPoint(queryPoint);
if (lastTriangle != -1)
{
//Warm-start the query with a lower-bound distance based on the triangle found by the previous query.
//This helps to cull the tree traversal more effectively in the closest point query.
PxU32 i0 = d.indices[3 * lastTriangle];
PxU32 i1 = d.indices[3 * lastTriangle + 1];
PxU32 i2 = d.indices[3 * lastTriangle + 2];
//const PxVec3 closest = Gu::closestPtPointTriangle2UnitBox(queryPoint, d.vertices[i0], d.vertices[i1], d.vertices[i2]);
//PxReal d2 = (closest - queryPoint).magnitudeSquared();
aos::FloatV t1, t2;
aos::Vec3V q = aos::V3LoadU(queryPoint);
aos::Vec3V a = aos::V3LoadU(d.vertices[i0]);
aos::Vec3V b = aos::V3LoadU(d.vertices[i1]);
aos::Vec3V c = aos::V3LoadU(d.vertices[i2]);
aos::Vec3V cp;
aos::FloatV dist2 = Gu::distancePointTriangleSquared2UnitBox(q, a, b, c, t1, t2, cp);
PxReal d2;
aos::FStore(dist2, &d2);
PxVec3 closest;
aos::V3StoreU(cp, closest);
cd.setClosestStart(d2, lastTriangle, closest);
}
Gu::traverseBVH(d.tree->begin(), cd);
PxVec3 closestPoint = cd.getClosestPoint();
PxReal closestDistance = (closestPoint - queryPoint).magnitude();
lastTriangle = cd.getClosestTriId();
PxReal sign = 1.f;
if (!d.optimizeInsideOutsideCalculation)
{
PxReal windingNumber = Gu::computeWindingNumber(d.tree->begin(), queryPoint, *d.clusters, d.indices, d.vertices);
sign = windingNumber > 0.5f ? -1.f : 1.f;
}
d.sdf[index] *= closestDistance * sign;
if (d.sampleLocations)
d.sampleLocations[index] = queryPoint;
}
}
}
start = physx::PxAtomicAdd(d.progress, d.batchSize) - d.batchSize;
}
return NULL;
}
struct PxI32x3
{
PxI32x3(PxI32 x_, PxI32 y_, PxI32 z_) : x(x_), y(y_), z(z_)
{}
PxI32 x;
PxI32 y;
PxI32 z;
};
//Applies per pixel operations similar to the one uses by the fast marching methods to build SDFs out of binary image bitmaps
//This allows to fill in correct distance values in regions where meshes habe holes
struct PixelProcessor
{
PxVec3 mCellSize;
PxI32 mWidth;
PxI32 mHeight;
PxI32 mDepth;
PixelProcessor(PxVec3 cellSize, PxI32 width, PxI32 height, PxI32 depth) :
mCellSize(cellSize), mWidth(width), mHeight(height), mDepth(depth)
{
}
//Estimates distance values near at mesh holes by estimating the location of the mesh surface. This can be done by analyzing
//the sign change of the imperfect SDF. The signs are computed using winding numbers which are immune to meshes with holes.
bool init(PxI32x3 p, const PxReal* sdf, PxReal& newValue) const
{
PxReal initialValue = sdf[idx3D(p.x, p.y, p.z, mWidth, mHeight)];
newValue = PxAbs(initialValue);
for (PxI32 z = PxMax(0, p.z - 1); z <= PxMin(mDepth - 1, p.z + 1); ++z)
for (PxI32 y = PxMax(0, p.y - 1); y <= PxMin(mHeight - 1, p.y + 1); ++y)
for (PxI32 x = PxMax(0, p.x - 1); x <= PxMin(mWidth - 1, p.x + 1); ++x)
{
if (x == p.x && y == p.y && z == p.z)
continue;
PxReal value = sdf[idx3D(x, y, z, mWidth, mHeight)];
if (PxSign(initialValue) != PxSign(value))
{
PxReal distance = 0;
if (x != p.x)
distance += mCellSize.x*mCellSize.x;
if (y != p.y)
distance += mCellSize.y*mCellSize.y;
if (z != p.z)
distance += mCellSize.z*mCellSize.z;
distance = PxSqrt(distance);
PxReal delta = PxAbs(value - initialValue);
if (0.99f * delta > distance)
{
PxReal scaling = distance / delta;
PxReal v = 0.99f * scaling * initialValue;
newValue = PxMin(newValue, PxAbs(v));
}
}
}
if (initialValue < 0)
newValue = -newValue;
if (newValue !=initialValue)
return true;
return false;
}
//Processes a pixel in a 3D sdf by applying the rule from the fast marching method. Only works on pixels with the same sign.
bool process(PxI32x3 p, PxReal* sdf, PxReal& newValue) const
{
PxReal initialValue = sdf[idx3D(p.x, p.y, p.z, mWidth, mHeight)];
if (initialValue == 0.0f)
return false;
PxReal sign = PxSign(initialValue);
newValue = PxAbs(initialValue);
for (PxI32 z = PxMax(0, p.z - 1); z <= PxMin(mDepth - 1, p.z + 1); ++z)
for (PxI32 y = PxMax(0, p.y - 1); y <= PxMin(mHeight - 1, p.y + 1); ++y)
for (PxI32 x = PxMax(0, p.x - 1); x <= PxMin(mWidth - 1, p.x + 1); ++x)
{
if (x == p.x && y == p.y && z == p.z)
continue;
PxReal value = sdf[idx3D(x, y, z, mWidth, mHeight)];
if (sign == PxSign(value))
{
PxReal distance = 0;
if (x != p.x)
distance += mCellSize.x*mCellSize.x;
if (y != p.y)
distance += mCellSize.y*mCellSize.y;
if (z != p.z)
distance += mCellSize.z*mCellSize.z;
distance = PxSqrt(distance);
PxReal absValue = PxAbs(value);
if(absValue + 1.01f*distance < newValue)
newValue = absValue + distance;
}
}
newValue = sign * newValue;
if (newValue != initialValue)
{
sdf[idx3D(p.x, p.y, p.z, mWidth, mHeight)] = newValue;
return true;
}
return false;
}
};
//Allows to store the new value of a SDF pixel to apply the change later. This avoids the need of double buffering the SDF data.
struct Mutation
{
PxI32x3 mIndex;
PxReal mNewValue;
Mutation(const PxI32x3& index, PxReal newValue) : mIndex(index), mNewValue(newValue)
{
}
};
void applyMutations(PxArray<Mutation>& mutations, PxU32 start, PxU32 end, PxReal* sdfs, PxU32 width, PxU32 height)
{
for (PxU32 i = start; i < end; ++i)
{
Mutation m = mutations[i];
sdfs[idx3D(m.mIndex.x, m.mIndex.y, m.mIndex.z, width, height)] = m.mNewValue;
}
}
//Approximates the solution of an Eikonal equation on a dense grid
void fixSdfForNonClosedGeometry(PxU32 width, PxU32 height, PxU32 depth,
PxReal* sdf, const PxVec3& cellSize)
{
PxArray<Mutation> mutations;
PixelProcessor processor(cellSize, width, height, depth);
for (PxU32 z = 0; z < depth; ++z)
for (PxU32 y = 0; y < height; ++y)
for (PxU32 x = 0; x < width; ++x)
{
//Process only cells where a sign change occurs
PxReal newValue;
if (processor.init(PxI32x3(x, y, z), sdf, newValue))
mutations.pushBack(Mutation(PxI32x3(x, y, z), newValue));
}
//printf("numMutations: %i\n", mutations.size());
applyMutations(mutations, 0, mutations.size(), sdf, width, height);
PxU32 maxMutationLoops = 1000;
PxU32 counter = 0;
while (mutations.size() > 0 && counter < maxMutationLoops)
{
PxU32 size = mutations.size();
for (PxU32 i = 0; i < size; ++i)
{
PxI32x3 p = mutations[i].mIndex;
//Process neighbors of item on stack
for (PxI32 z = PxMax(0, p.z - 1); z <= PxMin(PxI32(depth) - 1, p.z + 1); ++z)
for (PxI32 y = PxMax(0, p.y - 1); y <= PxMin(PxI32(height) - 1, p.y + 1); ++y)
for (PxI32 x = PxMax(0, p.x - 1); x <= PxMin(PxI32(width) - 1, p.x + 1); ++x)
{
if (x == p.x && y == p.y && z == p.z)
continue;
PxReal newValue;
if (processor.process(PxI32x3(x, y, z), sdf, newValue))
mutations.pushBack(Mutation(PxI32x3(x, y, z), newValue));
}
}
mutations.removeRange(0, size);
++counter;
}
//For safety reasons: Check all cells again
for (PxU32 z = 0; z < depth; ++z)
for (PxU32 y = 0; y < height; ++y)
for (PxU32 x = 0; x < width; ++x)
{
//Look at all neighbors
PxReal newValue;
if (processor.init(PxI32x3(x, y, z), sdf, newValue))
mutations.pushBack(Mutation(PxI32x3(x, y, z), newValue));
}
counter = 0;
while (mutations.size() > 0 && counter < maxMutationLoops)
{
PxU32 size = mutations.size();
for (PxU32 i = 0; i < size; ++i)
{
PxI32x3 p = mutations[i].mIndex;
//Process neighbors of item on stack
for (PxI32 z = PxMax(0, p.z - 1); z <= PxMin(PxI32(depth) - 1, p.z + 1); ++z)
for (PxI32 y = PxMax(0, p.y - 1); y <= PxMin(PxI32(height) - 1, p.y + 1); ++y)
for (PxI32 x = PxMax(0, p.x - 1); x <= PxMin(PxI32(width) - 1, p.x + 1); ++x)
{
if (x == p.x && y == p.y && z == p.z)
continue;
PxReal newValue;
if (processor.process(PxI32x3(x, y, z), sdf, newValue))
mutations.pushBack(Mutation(PxI32x3(x, y, z), newValue));
}
}
mutations.removeRange(0, size);
++counter;
}
}
void SDFUsingWindingNumbers(PxArray<Gu::BVHNode>& tree, PxHashMap<PxU32, Gu::ClusterApproximation>& clusters, const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
PxReal* sdf, GridQueryPointSampler& sampler, PxVec3* sampleLocations, PxU32 numThreads, bool isWatertight, bool allVerticesInsideSamplingBox)
{
bool optimizeInsideOutsideCalculation = allVerticesInsideSamplingBox && isWatertight;
numThreads = PxMax(numThreads, 1u);
PxI32 progress = 0;
PxArray<PxThread*> threads;
PxArray<SDFCalculationData> perThreadData;
for (PxU32 i = 0; i < numThreads; ++i)
{
perThreadData.pushBack(SDFCalculationData());
SDFCalculationData& d = perThreadData[i];
d.vertices = vertices;
d.indices = indices;
d.numTriangleIndices = numTriangleIndices;
d.width = width;
d.height = height;
d.depth = depth;
d.sdf = sdf;
d.sampleLocations = sampleLocations;
d.optimizeInsideOutsideCalculation = optimizeInsideOutsideCalculation;
d.pointSampler = &sampler;
d.progress = &progress;
d.tree = &tree;
d.clusters = &clusters;
d.end = depth * height;
d.signOnly = false;
}
PxU32 l = width * height * depth;
for (PxU32 i = 0; i < l; ++i)
sdf[i] = 1.0f;
for (PxU32 i = 0; i < numThreads; ++i)
{
if (perThreadData.size() == 1)
computeSDFThreadJob(&perThreadData[i]);
else
{
threads.pushBack(PX_NEW(PxThread)(computeSDFThreadJob, &perThreadData[i], "thread"));
threads[i]->start();
}
}
for (PxU32 i = 0; i < threads.size(); ++i)
{
threads[i]->waitForQuit();
}
for (PxU32 i = 0; i < threads.size(); ++i)
{
threads[i]->~PxThreadT();
PX_FREE(threads[i]);
}
if (!isWatertight)
fixSdfForNonClosedGeometry(width, height, depth, sdf, sampler.getActiveCellSize());
}
//Helper class to extract surface triangles from a tetmesh
struct SortedTriangle
{
public:
PxI32 mA;
PxI32 mB;
PxI32 mC;
bool mFlipped;
PX_FORCE_INLINE SortedTriangle(PxI32 a, PxI32 b, PxI32 c)
{
mA = a; mB = b; mC = c; mFlipped = false;
if (mA > mB) { PxSwap(mA, mB); mFlipped = !mFlipped; }
if (mB > mC) { PxSwap(mB, mC); mFlipped = !mFlipped; }
if (mA > mB) { PxSwap(mA, mB); mFlipped = !mFlipped; }
}
};
struct TriangleHash
{
PX_FORCE_INLINE std::size_t operator()(const SortedTriangle& k) const
{
return k.mA ^ k.mB ^ k.mC;
}
PX_FORCE_INLINE bool equal(const SortedTriangle& first, const SortedTriangle& second) const
{
return first.mA == second.mA && first.mB == second.mB && first.mC == second.mC;
}
};
PxReal signedVolume(const PxVec3* points, const PxU32* triangles, PxU32 numTriangles, const PxU32* triangleSubset = NULL, PxU32 setLength = 0)
{
PxReal signedVolume = 0;
const PxU32 l = triangleSubset ? setLength : numTriangles;
for (PxU32 j = 0; j < l; ++j)
{
const PxU32 i = triangleSubset ? triangleSubset[j] : j;
const PxU32* tri = &triangles[3 * i];
PxVec3 a = points[tri[0]];
PxVec3 b = points[tri[1]];
PxVec3 c = points[tri[2]];
PxReal y = a.dot(b.cross(c));
signedVolume += y;
}
signedVolume *= (1.0f / 6.0f);
return signedVolume;
}
void analyzeAndFixMesh(const PxVec3* vertices, const PxU32* indicesOrig, PxU32 numTriangleIndices, PxArray<PxU32>& repairedIndices)
{
const PxU32* indices = indicesOrig;
PxI32 numVertices = -1;
for (PxU32 i = 0; i < numTriangleIndices; ++i)
numVertices = PxMax(numVertices, PxI32(indices[i]));
++numVertices;
//Check for duplicate vertices
PxArray<PxI32> map;
MeshAnalyzer::mapDuplicatePoints<PxVec3, PxReal>(vertices, PxU32(numVertices), map, 0.0f);
bool hasDuplicateVertices = false;
for (PxU32 i = 0; i < map.size(); ++i)
{
if (map[i] != PxI32(i))
{
hasDuplicateVertices = true;
break;
}
}
if (hasDuplicateVertices)
{
repairedIndices.resize(numTriangleIndices);
for (PxU32 i = 0; i < numTriangleIndices; ++i)
repairedIndices[i] = map[indices[i]];
indices = repairedIndices.begin();
}
//Check for duplicate triangles
PxHashMap<SortedTriangle, PxI32, TriangleHash> tris;
bool hasDuplicateTriangles = false;
for (PxU32 i = 0; i < numTriangleIndices; i += 3)
{
SortedTriangle tri(indices[i], indices[i + 1], indices[i + 2]);
if (const PxPair<const SortedTriangle, PxI32>* ptr = tris.find(tri))
{
tris[tri] = ptr->second + 1;
hasDuplicateTriangles = true;
}
else
tris.insert(tri, 1);
}
if (hasDuplicateTriangles)
{
repairedIndices.clear();
for (PxHashMap<SortedTriangle, PxI32, TriangleHash>::Iterator iter = tris.getIterator(); !iter.done(); ++iter)
{
repairedIndices.pushBack(iter->first.mA);
if (iter->first.mFlipped)
{
repairedIndices.pushBack(iter->first.mC);
repairedIndices.pushBack(iter->first.mB);
}
else
{
repairedIndices.pushBack(iter->first.mB);
repairedIndices.pushBack(iter->first.mC);
}
}
}
else
{
if (!hasDuplicateVertices) //reqairedIndices is already initialized if hasDuplicateVertices is true
{
repairedIndices.resize(numTriangleIndices);
for (PxU32 i = 0; i < numTriangleIndices; ++i)
repairedIndices[i] = indices[i];
}
}
PxHashMap<PxU64, PxI32> edges;
PxArray<bool> flipTriangle;
PxArray<PxArray<PxU32>> connectedTriangleGroups;
Triangle* triangles = reinterpret_cast<Triangle*>(repairedIndices.begin());
bool success = MeshAnalyzer::buildConsistentTriangleOrientationMap(triangles, repairedIndices.size() / 3, flipTriangle, edges, connectedTriangleGroups);
bool meshIsWatertight = true;
for (PxHashMap<PxU64, PxI32>::Iterator iter = edges.getIterator(); !iter.done(); ++iter)
{
if (iter->second != -1)
{
meshIsWatertight = false;
break;
}
}
if (success)
{
if (hasDuplicateTriangles && meshIsWatertight && connectedTriangleGroups.size() == 1)
{
for (PxU32 i = 0; i < flipTriangle.size(); ++i)
{
Triangle& t = triangles[i];
if (flipTriangle[i])
PxSwap(t[0], t[1]);
}
if (signedVolume(vertices, repairedIndices.begin(), repairedIndices.size() / 3) < 0.0f)
{
PxU32 numTriangles = repairedIndices.size() / 3;
for (PxU32 j = 0; j < numTriangles; ++j)
{
PxU32* tri = &repairedIndices[j * 3];
PxSwap(tri[1], tri[2]);
}
}
}
}
else
{
//Here it is not possible to guarantee that the mesh fixing can succeed
PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "SDF creation: Mesh is not suitable for SDF (non-manifold, not watertight, duplicated triangles, ...) and automatic repair failed. The computed SDF might not work as expected. If collisions are not good, try to improve the mesh structure e.g., by applying remeshing.");
//connectedTriangleGroups won't have any elements, so return
return;
}
if (!meshIsWatertight)
{
PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "SDF creation: Input mesh is not watertight. The SDF will try to close the holes.");
}
}
void SDFUsingWindingNumbers(const PxVec3* vertices, const PxU32* indicesOrig, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
PxReal* sdf, PxVec3 minExtents, PxVec3 maxExtents, PxVec3* sampleLocations, bool cellCenteredSamples, PxU32 numThreads, PxSDFBuilder* sdfBuilder)
{
PxArray<PxU32> repairedIndices;
//Analyze the mesh to catch and fix some special cases
//There are meshes where every triangle is present once with cw and once with ccw orientation. Try to filter out only one set
analyzeAndFixMesh(vertices, indicesOrig, numTriangleIndices, repairedIndices);
const PxU32* indices = repairedIndices.size() > 0 ? repairedIndices.begin() : indicesOrig;
if (repairedIndices.size() > 0)
numTriangleIndices = repairedIndices.size();
if (sdfBuilder)
{
PxI32 numVertices = -1;
for (PxU32 i = 0; i < numTriangleIndices; ++i)
numVertices = PxMax(numVertices, PxI32(indices[i]));
++numVertices;
sdfBuilder->buildSDF(vertices, PxU32(numVertices), indices, numTriangleIndices, width, height, depth, minExtents, maxExtents, cellCenteredSamples, sdf);
}
else
{
PxArray<Gu::BVHNode> tree;
buildTree(indices, numTriangleIndices / 3, vertices, tree);
PxHashMap<PxU32, Gu::ClusterApproximation> clusters;
Gu::precomputeClusterInformation(tree.begin(), indices, numTriangleIndices / 3, vertices, clusters);
const PxVec3 extents(maxExtents - minExtents);
GridQueryPointSampler sampler(minExtents, PxVec3(extents.x / width, extents.y / height, extents.z / depth), cellCenteredSamples);
bool isWatertight = MeshAnalyzer::checkMeshWatertightness(reinterpret_cast<const Triangle*>(indices), numTriangleIndices / 3);
bool allSamplesInsideBox = true;
PxBounds3 box(minExtents, maxExtents);
for (PxU32 i = 0; i < numTriangleIndices; ++i)
{
PxVec3 v = vertices[indices[i]];
if (!box.contains(v))
{
allSamplesInsideBox = false;
break;
}
}
SDFUsingWindingNumbers(tree, clusters, vertices, indices, numTriangleIndices, width, height, depth, sdf, sampler, sampleLocations, numThreads, isWatertight, allSamplesInsideBox);
}
#if EXTENDED_DEBUG
bool debug = false;
if (debug && sdfBuilder)
{
PX_UNUSED(sdfBuilder);
PxArray<PxReal> sdf2;
sdf2.resize(width * height * depth);
PxI32 numVertices = -1;
for (PxU32 i = 0; i < numTriangleIndices; ++i)
numVertices = PxMax(numVertices, PxI32(indices[i]));
++numVertices;
sdfBuilder->buildSDF(vertices, PxU32(numVertices), indices, numTriangleIndices, width, height, depth, minExtents, maxExtents, cellCenteredSamples, sdf2.begin());
for (PxU32 i = 0; i < sdf2.size(); ++i)
{
PxReal diff = sdf[i] - sdf2[i];
//PxReal diffOfAbs = PxAbs(sdf[i]) - PxAbs(sdf2[i]);
if(PxAbs(diff) > 1e-3f)
PxGetFoundation().error(physx::PxErrorCode::eDEBUG_WARNING, PX_FL, "SDFs don't match %f %f", PxF64(sdf[i]), PxF64(sdf2[i]));
}
}
#endif
}
void convertSparseSDFTo3DTextureLayout(PxU32 width, PxU32 height, PxU32 depth, PxU32 cellsPerSubgrid,
PxU32* sdfFineStartSlots, const PxReal* sdfFineSubgridsIn, PxU32 sparseSDFNumEntries, PxArray<PxReal>& subgrids3DTexFormat,
PxU32& numSubgridsX, PxU32& numSubgridsY, PxU32& numSubgridsZ)
{
PxU32 valuesPerSubgrid = (cellsPerSubgrid + 1)*(cellsPerSubgrid + 1)*(cellsPerSubgrid + 1);
PX_ASSERT(sparseSDFNumEntries % valuesPerSubgrid == 0);
PxU32 numSubgrids = sparseSDFNumEntries / valuesPerSubgrid;
PxReal cubicRoot = PxPow(PxReal(numSubgrids), 1.0f / 3.0f);
PxU32 up = PxMax(1u, PxU32(PxCeil(cubicRoot)));
PxU32 debug = numSubgrids;
//Arrange numSubgrids in a 3d layout
PxU32 n = numSubgrids;
numSubgridsX = PxMin(up, n);
n = (n + up - 1) / up;
numSubgridsY = PxMin(up, n);
n = (n + up - 1) / up;
numSubgridsZ = PxMin(up, n);
PxU32 debug2 = numSubgridsX * numSubgridsY * numSubgridsZ;
PX_ASSERT(debug2 >= debug);
PX_UNUSED(debug);
PX_UNUSED(debug2);
PxU32 size = valuesPerSubgrid * numSubgridsX * numSubgridsY * numSubgridsZ;
PxReal placeholder = 1234567;
subgrids3DTexFormat.resize(size, placeholder);
PxU32 w = width / cellsPerSubgrid;
PxU32 h = height / cellsPerSubgrid;
PxU32 d = depth / cellsPerSubgrid;
PxU32 l = (w)*(h)*(d);
for (PxU32 i = 0; i < l; ++i)
{
PxU32 startSlot = sdfFineStartSlots[i];
if (startSlot != 0xFFFFFFFF)
{
PxU32 baseIndex = startSlot * (cellsPerSubgrid + 1) * (cellsPerSubgrid + 1) * (cellsPerSubgrid + 1);
const PxReal* sdfFine = &sdfFineSubgridsIn[baseIndex];
PxU32 startSlotX, startSlotY, startSlotZ;
idToXYZ(startSlot, numSubgridsX, numSubgridsY, startSlotX, startSlotY, startSlotZ);
sdfFineStartSlots[i] = encodeTriple(startSlotX, startSlotY, startSlotZ);
for (PxU32 zLocal = 0; zLocal <= cellsPerSubgrid; ++zLocal)
{
for (PxU32 yLocal = 0; yLocal <= cellsPerSubgrid; ++yLocal)
{
for (PxU32 xLocal = 0; xLocal <= cellsPerSubgrid; ++xLocal)
{
PxReal sdfValue = sdfFine[idx3D(xLocal, yLocal, zLocal, cellsPerSubgrid+1, cellsPerSubgrid+1)];
PxU32 index = idx3D(xLocal + startSlotX * (cellsPerSubgrid + 1), yLocal + startSlotY * (cellsPerSubgrid + 1), zLocal + startSlotZ * (cellsPerSubgrid + 1),
numSubgridsX * (cellsPerSubgrid + 1), numSubgridsY * (cellsPerSubgrid + 1));
PX_ASSERT(subgrids3DTexFormat[index] == placeholder);
subgrids3DTexFormat[index] = sdfValue;
PX_ASSERT(PxIsFinite(sdfValue));
}
}
}
}
}
}
struct Interval
{
PxReal min;
PxReal max;
PX_CUDA_CALLABLE Interval() : min(FLT_MAX), max(-FLT_MAX)
{}
PX_CUDA_CALLABLE Interval(PxReal min_, PxReal max_) : min(min_), max(max_)
{}
PX_FORCE_INLINE PX_CUDA_CALLABLE bool overlaps(const Interval& i)
{
return !(min > i.max || i.min > max);
}
};
void SDFUsingWindingNumbersSparse(const PxVec3* vertices, const PxU32* indices, PxU32 numTriangleIndices, PxU32 width, PxU32 height, PxU32 depth,
const PxVec3& minExtents, const PxVec3& maxExtents, PxReal narrowBandThickness, PxU32 cellsPerSubgrid,
PxArray<PxReal>& sdfCoarse, PxArray<PxU32>& sdfFineStartSlots, PxArray<PxReal>& subgridData, PxArray<PxReal>& denseSdf,
PxReal& subgridsMinSdfValue, PxReal& subgridsMaxSdfValue, PxU32 numThreads, PxSDFBuilder* sdfBuilder)
{
PX_ASSERT(width % cellsPerSubgrid == 0);
PX_ASSERT(height % cellsPerSubgrid == 0);
PX_ASSERT(depth % cellsPerSubgrid == 0);
const PxVec3 extents(maxExtents - minExtents);
const PxVec3 delta(extents.x / width, extents.y / height, extents.z / depth);
const PxU32 w = width / cellsPerSubgrid;
const PxU32 h = height / cellsPerSubgrid;
const PxU32 d = depth / cellsPerSubgrid;
denseSdf.resize((width + 1) * (height + 1) * (depth + 1));
SDFUsingWindingNumbers(vertices, indices, numTriangleIndices, width + 1, height + 1, depth + 1, denseSdf.begin(), minExtents, maxExtents + delta, NULL, false, numThreads, sdfBuilder);
sdfCoarse.clear();
sdfFineStartSlots.clear();
subgridData.clear();
sdfCoarse.reserve((w + 1) * (h + 1) * (d + 1));
sdfFineStartSlots.reserve(w * h * d);
for (PxU32 zBlock = 0; zBlock < d; ++zBlock)
for (PxU32 yBlock = 0; yBlock < h; ++yBlock)
for (PxU32 xBlock = 0; xBlock < w; ++xBlock)
{
sdfFineStartSlots.pushBack(0xFFFFFFFF);
}
for (PxU32 zBlock = 0; zBlock <= d; ++zBlock)
for (PxU32 yBlock = 0; yBlock <= h; ++yBlock)
for (PxU32 xBlock = 0; xBlock <= w; ++xBlock)
{
PxU32 x = xBlock * cellsPerSubgrid;
PxU32 y = yBlock * cellsPerSubgrid;
PxU32 z = zBlock * cellsPerSubgrid;
const PxU32 index = idx3D(x, y, z, width+1, height+1);
PX_ASSERT(index < denseSdf.size());
PxReal sdfValue = denseSdf[index];
sdfCoarse.pushBack(sdfValue);
}
#if DEBUG
for (PxU32 zBlock = 0; zBlock <= d; ++zBlock)
for (PxU32 yBlock = 0; yBlock <= h; ++yBlock)
for (PxU32 xBlock = 0; xBlock <= w; ++xBlock)
{
PxU32 x = xBlock * cellsPerSubgrid;
PxU32 y = yBlock * cellsPerSubgrid;
PxU32 z = zBlock * cellsPerSubgrid;
const PxU32 index = idx3D(x, y, z, width+1, height+1);
const PxU32 indexCoarse = idx3D(xBlock, yBlock, zBlock, w+1, h+1);
PX_ASSERT(sdfCoarse[indexCoarse] == denseSdf[index]);
PX_UNUSED(indexCoarse);
PX_UNUSED(index);
}
#endif
Interval narrowBandInterval(-narrowBandThickness, narrowBandThickness);
DenseSDF coarseEval(w + 1, h + 1, d + 1, sdfCoarse.begin());
PxReal s = 1.0f / cellsPerSubgrid;
const PxReal errorThreshold = 1e-6f * extents.magnitude();
PxU32 subgridIndexer = 0;
subgridsMaxSdfValue = -FLT_MAX;
subgridsMinSdfValue = FLT_MAX;
for (PxU32 zBlock = 0; zBlock < d; ++zBlock)
{
for (PxU32 yBlock = 0; yBlock < h; ++yBlock)
{
for (PxU32 xBlock = 0; xBlock < w; ++xBlock)
{
bool subgridRequired = false;
Interval inverval;
PxReal maxAbsError = 0.0f;
for (PxU32 zLocal = 0; zLocal <= cellsPerSubgrid; ++zLocal)
{
for (PxU32 yLocal = 0; yLocal <= cellsPerSubgrid; ++yLocal)
{
for (PxU32 xLocal = 0; xLocal <= cellsPerSubgrid; ++xLocal)
{
PxU32 x = xBlock * cellsPerSubgrid + xLocal;
PxU32 y = yBlock * cellsPerSubgrid + yLocal;
PxU32 z = zBlock * cellsPerSubgrid + zLocal;
const PxU32 index = idx3D(x, y, z, width+1, height+1);
PxReal sdfValue = denseSdf[index];
inverval.max = PxMax(inverval.max, sdfValue);
inverval.min = PxMin(inverval.min, sdfValue);
maxAbsError = PxMax(maxAbsError, PxAbs(sdfValue - coarseEval.sampleSDFDirect(PxVec3(xBlock + xLocal * s, yBlock + yLocal * s, zBlock + zLocal * s))));
}
}
}
subgridRequired = narrowBandInterval.overlaps(inverval);
if (maxAbsError < errorThreshold)
subgridRequired = false; //No need for a subgrid if the coarse SDF is already almost exact
if (subgridRequired)
{
subgridsMaxSdfValue = PxMax(subgridsMaxSdfValue, inverval.max);
subgridsMinSdfValue = PxMin(subgridsMinSdfValue, inverval.min);
for (PxU32 zLocal = 0; zLocal <= cellsPerSubgrid; ++zLocal)
{
for (PxU32 yLocal = 0; yLocal <= cellsPerSubgrid; ++yLocal)
{
for (PxU32 xLocal = 0; xLocal <= cellsPerSubgrid; ++xLocal)
{
PxU32 x = xBlock * cellsPerSubgrid + xLocal;
PxU32 y = yBlock * cellsPerSubgrid + yLocal;
PxU32 z = zBlock * cellsPerSubgrid + zLocal;
const PxU32 index = z * (width + 1) * (height + 1) + y * (width + 1) + x;
PxReal sdfValue = denseSdf[index];
subgridData.pushBack(sdfValue);
}
}
}
sdfFineStartSlots[idx3D(xBlock, yBlock, zBlock, w, h)] = subgridIndexer;
++subgridIndexer;
}
}
}
}
}
PX_INLINE PxReal decodeSparse2(const SDF& sdf, PxI32 xx, PxI32 yy, PxI32 zz)
{
if (xx < 0 || yy < 0 || zz < 0 || xx > PxI32(sdf.mDims.x) || yy > PxI32(sdf.mDims.y) || zz > PxI32(sdf.mDims.z))
return 1.0f; //Return a value >0 that counts as outside
const PxU32 nbX = sdf.mDims.x / sdf.mSubgridSize;
const PxU32 nbY = sdf.mDims.y / sdf.mSubgridSize;
const PxU32 nbZ = sdf.mDims.z / sdf.mSubgridSize;
PxU32 xBase = xx / sdf.mSubgridSize;
PxU32 yBase = yy / sdf.mSubgridSize;
PxU32 zBase = zz / sdf.mSubgridSize;
PxU32 x = xx % sdf.mSubgridSize;
PxU32 y = yy % sdf.mSubgridSize;
PxU32 z = zz % sdf.mSubgridSize;
if (xBase == nbX)
{
--xBase;
x = sdf.mSubgridSize;
}
if (yBase == nbY)
{
--yBase;
y = sdf.mSubgridSize;
}
if (zBase == nbZ)
{
--zBase;
z = sdf.mSubgridSize;
}
PxU32 startId = sdf.mSubgridStartSlots[zBase * (nbX) * (nbY)+yBase * (nbX)+xBase];
if (startId != 0xFFFFFFFFu)
{
SDF::decodeTriple(startId, xBase, yBase, zBase);
/*if (xBase >= mSdfSubgrids3DTexBlockDim.x || yBase >= mSdfSubgrids3DTexBlockDim.y || zBase >= mSdfSubgrids3DTexBlockDim.z)
{
PxGetFoundation().error(::physx::PxErrorCode::eINTERNAL_ERROR, PX_FL, "Out of bounds subgrid index\n");
//printf("%i %i %i %i\n", PxI32(startId), PxI32(xBase), PxI32(yBase), PxI32(zBase));
}*/
xBase *= (sdf.mSubgridSize + 1);
yBase *= (sdf.mSubgridSize + 1);
zBase *= (sdf.mSubgridSize + 1);
const PxU32 w = sdf.mSdfSubgrids3DTexBlockDim.x * (sdf.mSubgridSize + 1);
const PxU32 h = sdf.mSdfSubgrids3DTexBlockDim.y * (sdf.mSubgridSize + 1);
const PxU32 index = idx3D(xBase + x, yBase + y, zBase + z, w, h);
//if (mBytesPerSparsePixel * index >= mNumSubgridSdfs)
// PxGetFoundation().error(::physx::PxErrorCode::eINTERNAL_ERROR, PX_FL, "Out of bounds sdf subgrid access\n");
return SDF::decodeSample(sdf.mSubgridSdf, index,
sdf.mBytesPerSparsePixel, sdf.mSubgridsMinSdfValue, sdf.mSubgridsMaxSdfValue);
}
else
{
DenseSDF coarseEval(nbX + 1, nbY + 1, nbZ + 1, sdf.mSdf);
PxReal s = 1.0f / sdf.mSubgridSize;
PxReal result = coarseEval.sampleSDFDirect(PxVec3(xBase + x * s, yBase + y * s, zBase + z * s));
return result;
}
}
PxReal SDF::decodeSparse(PxI32 xx, PxI32 yy, PxI32 zz) const
{
return decodeSparse2(*this, xx, yy, zz);
}
PX_FORCE_INLINE PxU64 key(PxI32 xId, PxI32 yId, PxI32 zId)
{
const PxI32 offset = 1 << 19;
return (PxU64(zId + offset) << 42) | (PxU64(yId + offset) << 21) | (PxU64(xId + offset) << 0);
}
const PxI32 offsets[3][3][3] = { { {0,-1,0}, {0,-1,-1}, {0,0,-1} },
{ {0,0,-1}, {-1,0,-1}, {-1,0,0} } ,
{ {-1,0,0}, {-1,-1,0}, {0,-1,0} } };
const PxI32 projections[3][2] = { {1, 2}, {2, 0}, {0, 1} };
PX_FORCE_INLINE PxReal dirSign(PxI32 principalDirection, const PxVec3& start, const PxVec3& middle, const PxVec3& end)
{
PxReal a0 = middle[projections[principalDirection][0]] - start[projections[principalDirection][0]];
PxReal a1 = middle[projections[principalDirection][1]] - start[projections[principalDirection][1]];
PxReal b0 = end[projections[principalDirection][0]] - middle[projections[principalDirection][0]];
PxReal b1 = end[projections[principalDirection][1]] - middle[projections[principalDirection][1]];
return a0 * b1 - a1 * b0;
}
PX_FORCE_INLINE PxI32 indexOfMostConcaveCorner(PxI32 principalDirection, const PxVec3& a, const PxVec3& b, const PxVec3& c, const PxVec3& d)
{
PxReal minimum = 0;
PxI32 result = -1;
PxReal s = dirSign(principalDirection, a, b, c);
if (s <= minimum)
{
minimum = s;
result = 1;
}
s = dirSign(principalDirection, b, c, d);
if (s <= minimum)
{
minimum = s;
result = 2;
}
s = dirSign(principalDirection, c, d, a);
if (s <= minimum)
{
minimum = s;
result = 3;
}
s = dirSign(principalDirection, d, a, b);
if (s <= minimum)
{
minimum = s;
result = 0;
}
return result;
}
bool generatePointInCell(const Gu::SDF& sdf, PxI32 x, PxI32 y, PxI32 z, PxVec3& point, PxReal corners[2][2][2])
{
const PxReal threshold = 0.0f;
PxU32 positiveCounter = 0;
PxU32 negativeCounter = 0;
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
PxReal v = corners[xx][yy][zz];
if (v > 0)
++positiveCounter;
if (v < 0)
++negativeCounter;
}
PxBounds3 box;
box.minimum = sdf.mMeshLower + PxVec3(x * sdf.mSpacing, y * sdf.mSpacing, z * sdf.mSpacing);
box.maximum = box.minimum + PxVec3(sdf.mSpacing);
if (positiveCounter == 8 || negativeCounter == 8)
{
//Nothing to do because surface does not cross the current cell
}
else
{
//If point is not completely inside or outside, then find a point inside the cube that divides it into 8 cuboids
PxU32 counter = 0;
PxVec3 sum(0.0f);
for (PxI32 a = 0; a <= 1; ++a) for (PxI32 b = 0; b <= 1; ++b)
{
PxReal p = corners[a][b][0];
PxReal q = corners[a][b][1];
if ((p <= threshold && q >= threshold) || (q <= threshold && p >= threshold))
{
PxReal t = (q != p) ? PxClamp((threshold - p) / (q - p), 0.0f, 1.0f) : 0.5f;
sum += PxVec3(PxReal(a), PxReal(b), t);
++counter;
}
}
for (PxI32 a = 0; a <= 1; ++a) for (PxI32 b = 0; b <= 1; ++b)
{
PxReal p = corners[b][0][a];
PxReal q = corners[b][1][a];
if ((p <= threshold && q >= threshold) || (q <= threshold && p >= threshold))
{
PxReal t = (q != p) ? PxClamp((threshold - p) / (q - p), 0.0f, 1.0f) : 0.5f;
sum += PxVec3(PxReal(b), t, PxReal(a));
++counter;
}
}
for (PxI32 a = 0; a <= 1; ++a) for (PxI32 b = 0; b <= 1; ++b)
{
PxReal p = corners[0][a][b];
PxReal q = corners[1][a][b];
if ((p <= threshold && q >= threshold) || (q <= threshold && p >= threshold))
{
PxReal t = (q != p) ? PxClamp((threshold - p) / (q - p), 0.0f, 1.0f) : 0.5f;
sum += PxVec3(t, PxReal(a), PxReal(b));
++counter;
}
}
if (counter > 0)
{
point = box.minimum + sum * (sdf.mSpacing / counter);
return true;
}
}
return false;
}
PX_FORCE_INLINE bool generatePointInCell(const Gu::SDF& sdf, PxI32 x, PxI32 y, PxI32 z, PxVec3& point)
{
PxReal corners[2][2][2];
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
PxReal v = sdf.decodeSparse(x + xx, y + yy, z + zz);
corners[xx][yy][zz] = v;
}
return generatePointInCell(sdf, x, y, z, point, corners);
}
PX_FORCE_INLINE bool generatePointInCellUsingCache(const Gu::SDF& sdf, PxI32 xBase, PxI32 yBase, PxI32 zBase, PxI32 x, PxI32 y, PxI32 z, PxVec3& point, const PxArray<PxReal>& cache)
{
const PxU32 s = sdf.mSubgridSize + 1;
PxReal corners[2][2][2];
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
PxReal v = cache[idx3D(x + xx, y + yy, z + zz, s, s)];
corners[xx][yy][zz] = v;
}
return generatePointInCell(sdf, xBase * sdf.mSubgridSize + x, yBase * sdf.mSubgridSize + y, zBase * sdf.mSubgridSize + z, point, corners);
}
PxReal SDF::decodeDense(PxI32 x, PxI32 y, PxI32 z) const
{
if (x < 0 || y < 0 || z < 0 || x >= PxI32(mDims.x) || y >= PxI32(mDims.y) || z >= PxI32(mDims.z))
return 1.0; //Return a value >0 that counts as outside
return mSdf[idx3D(x, y, z, mDims.x, mDims.y)];
}
PX_FORCE_INLINE bool generatePointInCellDense(const Gu::SDF& sdf, PxI32 x, PxI32 y, PxI32 z, PxVec3& point)
{
PxReal corners[2][2][2];
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
PxReal v = sdf.decodeDense(x + xx, y + yy, z + zz);
corners[xx][yy][zz] = v;
}
return generatePointInCell(sdf, x, y, z, point, corners);
}
PX_FORCE_INLINE bool canSkipSubgrid(const Gu::SDF& sdf, PxI32 i, PxI32 j, PxI32 k)
{
const PxReal t = 0.1f * sdf.mSpacing;
const PxI32 nbX = sdf.mDims.x / sdf.mSubgridSize;
const PxI32 nbY = sdf.mDims.y / sdf.mSubgridSize;
const PxI32 nbZ = sdf.mDims.z / sdf.mSubgridSize;
if (i < 0 || j < 0 || k < 0 || i >= nbX || j >= nbY || k >= nbZ)
return false;
if (sdf.mSubgridStartSlots[k * (nbX) * (nbY)+j * (nbX)+i] == 0xFFFFFFFFu)
{
PxU32 positiveCounter = 0;
PxU32 negativeCounter = 0;
for (PxI32 xx = 0; xx <= 1; ++xx) for (PxI32 yy = 0; yy <= 1; ++yy) for (PxI32 zz = 0; zz <= 1; ++zz)
{
PxReal v = decodeSparse2(sdf, (i + xx)* sdf.mSubgridSize, (j + yy) * sdf.mSubgridSize, (k + zz) * sdf.mSubgridSize);
if (v > t)
++positiveCounter;
if (v < t)
++negativeCounter;
}
if (positiveCounter == 8 || negativeCounter == 8)
return true;
}
return false;
}
struct Map : public PxHashMap<PxU64, PxU32>, public PxUserAllocated
{
Map()
{
}
};
struct CellToPoint
{
PxArray<Map*> cellToPoint;
CellToPoint(PxU32 numThreads)
{
cellToPoint.resize(numThreads);
for (PxU32 i = 0; i < cellToPoint.size(); ++i)
cellToPoint[i] = PX_NEW(Map);
}
~CellToPoint()
{
for (PxU32 i = 0; i < cellToPoint.size(); ++i)
{
PX_DELETE(cellToPoint[i]);
}
}
const PxPair<const PxU64, PxU32>* find(PxI32 xId, PxI32 yId, PxI32 zId) const
{
PxU64 k = key(xId, yId, zId);
for (PxU32 i = 0; i < cellToPoint.size(); ++i)
{
const PxPair<const PxU64, PxU32>* f = cellToPoint[i]->find(k);
if (f)
return f;
}
return NULL;
}
void insert(PxI32 threadId, PxI32 xId, PxI32 yId, PxI32 zId, PxU32 value)
{
cellToPoint[threadId]->insert(key(xId, yId, zId), value);
}
};
PX_INLINE void createTriangles(PxI32 xId, PxI32 yId, PxI32 zId, PxReal d0, PxReal ds[3],
const CellToPoint& cellToPoint, const PxArray<PxVec3>& points, PxArray<PxU32>& triangleIndices)
{
bool flipTriangleOrientation = false;
const PxReal threshold = 0.0f;
PxI32 num = 0;
for (PxI32 dim = 0; dim < 3; dim++)
{
PxReal d = ds[dim];
if ((d0 <= threshold && d >= threshold) || (d <= threshold && d0 >= threshold))
num++;
}
if (num == 0)
return;
PxI32 buffer[4];
const PxPair<const PxU64, PxU32>* f = cellToPoint.find(xId, yId, zId);
if (!f)
return;
buffer[0] = f->second;
PxVec3 v0 = points[buffer[0]];
for (PxI32 dim = 0; dim < 3; dim++)
{
PxReal d = ds[dim];
bool b1 = d0 <= threshold && d >= threshold;
bool b2 = d <= threshold && d0 >= threshold;
if (b1 || b2)
{
bool flip = flipTriangleOrientation == b1;
bool skip = false;
for (PxI32 ii = 0; ii < 3; ++ii)
{
f = cellToPoint.find(xId + offsets[dim][ii][0], yId + offsets[dim][ii][1], zId + offsets[dim][ii][2]);
if (f)
buffer[ii + 1] = f->second;
else
skip = true;
}
if (skip)
continue;
PxI32 shift = PxMax(0, indexOfMostConcaveCorner(dim, v0, points[buffer[1]], points[buffer[2]], points[buffer[3]])) % 2;
//Split the quad into two triangles
for (PxI32 ii = 0; ii < 2; ++ii)
{
triangleIndices.pushBack(buffer[shift]);
if (flip)
{
for (PxI32 jj = 2; jj >= 1; --jj)
triangleIndices.pushBack(buffer[(ii + jj + shift) % 4]);
}
else
{
for (PxI32 jj = 1; jj < 3; ++jj)
triangleIndices.pushBack(buffer[(ii + jj + shift) % 4]);
}
}
}
}
}
PX_INLINE void populateSubgridCache(const Gu::SDF& sdf, PxArray<PxReal>& sdfCache, PxI32 i, PxI32 j, PxI32 k)
{
const PxU32 s = sdf.mSubgridSize + 1;
for (PxU32 z = 0; z <= sdf.mSubgridSize; ++z)
for (PxU32 y = 0; y <= sdf.mSubgridSize; ++y)
for (PxU32 x = 0; x <= sdf.mSubgridSize; ++x)
{
sdfCache[idx3D(x, y, z, s, s)] =
decodeSparse2(sdf, i * PxI32(sdf.mSubgridSize) + PxI32(x),
j * PxI32(sdf.mSubgridSize) + PxI32(y),
k * PxI32(sdf.mSubgridSize) + PxI32(z));
}
}
struct IsosurfaceThreadData
{
const Gu::SDF& sdf;
PxArray<PxVec3> isosurfaceVertices;
const PxArray<PxVec3>& allIsosurfaceVertices;
PxArray<PxU32> isosurfaceTriangleIndices;
PxArray<PxReal> sdfCache;
CellToPoint& cellToPoint;
PxU32 startIndex;
PxU32 endIndex;
PxU32 threadIndex;
PxI32 nbX;
PxI32 nbY;
PxI32 nbZ;
IsosurfaceThreadData(const Gu::SDF& sdf_, CellToPoint& cellToPoint_, const PxArray<PxVec3>& allIsosurfaceVertices_) :
sdf(sdf_), allIsosurfaceVertices(allIsosurfaceVertices_), cellToPoint(cellToPoint_)
{ }
};
void* computeIsosurfaceVerticesThreadJob(void* data)
{
IsosurfaceThreadData & d = *reinterpret_cast<IsosurfaceThreadData*>(data);
for (PxU32 indexer = d.startIndex; indexer < d.endIndex; ++indexer)
{
PxU32 ii, jj, kk;
idToXYZ(indexer, d.nbX, d.nbY, ii, jj, kk);
PxI32 i = PxI32(ii) - 1;
PxI32 j = PxI32(jj) - 1;
PxI32 k = PxI32(kk) - 1;
if (canSkipSubgrid(d.sdf, i, j, k))
continue;
populateSubgridCache(d.sdf, d.sdfCache, i, j, k);
//Process the subgrid
for (PxU32 z = 0; z < d.sdf.mSubgridSize; ++z)
{
for (PxU32 y = 0; y < d.sdf.mSubgridSize; ++y)
{
for (PxU32 x = 0; x < d.sdf.mSubgridSize; ++x)
{
PxVec3 p;
if (generatePointInCellUsingCache(d.sdf, i, j, k, x, y, z, p, d.sdfCache))
{
PxU32 xId = i * d.sdf.mSubgridSize + x;
PxU32 yId = j * d.sdf.mSubgridSize + y;
PxU32 zId = k * d.sdf.mSubgridSize + z;
d.cellToPoint.insert(d.threadIndex, xId, yId, zId, d.isosurfaceVertices.size());
d.isosurfaceVertices.pushBack(p);
}
}
}
}
}
return NULL;
}
void* computeIsosurfaceTrianglesThreadJob(void* data)
{
IsosurfaceThreadData & d = *reinterpret_cast<IsosurfaceThreadData*>(data);
const PxU32 s = d.sdf.mSubgridSize + 1;
for (PxU32 indexer = d.startIndex; indexer < d.endIndex; ++indexer)
{
PxU32 ii, jj, kk;
idToXYZ(indexer, d.nbX, d.nbY, ii, jj, kk);
PxI32 i = PxI32(ii) - 1;
PxI32 j = PxI32(jj) - 1;
PxI32 k = PxI32(kk) - 1;
if (canSkipSubgrid(d.sdf, i, j, k))
continue;
populateSubgridCache(d.sdf, d.sdfCache, i, j, k);
PxReal ds[3];
//Process the subgrid
for (PxU32 z = 0; z < d.sdf.mSubgridSize; ++z)
{
for (PxU32 y = 0; y < d.sdf.mSubgridSize; ++y)
{
for (PxU32 x = 0; x < d.sdf.mSubgridSize; ++x)
{
PxReal d0 = d.sdfCache[idx3D(x, y, z, s, s)];
ds[0] = d.sdfCache[idx3D(x + 1, y, z, s, s)];
ds[1] = d.sdfCache[idx3D(x, y + 1, z, s, s)];
ds[2] = d.sdfCache[idx3D(x, y, z + 1, s, s)];
createTriangles(x + i * d.sdf.mSubgridSize, y + j * d.sdf.mSubgridSize, z + k * d.sdf.mSubgridSize, d0, ds,
d.cellToPoint, d.allIsosurfaceVertices, d.isosurfaceTriangleIndices);
}
}
}
}
return NULL;
}
void extractIsosurfaceFromSDFSerial(const Gu::SDF& sdf, PxArray<PxVec3>& isosurfaceVertices, PxArray<PxU32>& isosurfaceTriangleIndices)
{
isosurfaceVertices.clear();
isosurfaceTriangleIndices.clear();
const PxI32 nbX = sdf.mDims.x / PxMax(1u, sdf.mSubgridSize);
const PxI32 nbY = sdf.mDims.y / PxMax(1u, sdf.mSubgridSize);
const PxI32 nbZ = sdf.mDims.z / PxMax(1u, sdf.mSubgridSize);
PxU32 sizeEstimate = PxU32(PxSqrt(PxReal(nbX*nbY * nbZ)));
CellToPoint cellToPoint(1);
isosurfaceVertices.reserve(sizeEstimate);
isosurfaceTriangleIndices.reserve(sizeEstimate);
PxArray<PxReal> sdfCache;
sdfCache.resize((sdf.mSubgridSize + 1) * (sdf.mSubgridSize + 1) * (sdf.mSubgridSize + 1));
if (sdf.mSubgridSize == 0)
{
//Dense SDF
for (PxI32 k = -1; k <= nbZ; ++k)
for (PxI32 j = -1; j <= nbY; ++j)
for (PxI32 i = -1; i <= nbX; ++i)
{
PxVec3 p;
if (generatePointInCellDense(sdf, i, j, k, p))
{
cellToPoint.insert(0, i, j, k, isosurfaceVertices.size());
isosurfaceVertices.pushBack(p);
}
}
}
else
{
for (PxI32 k = -1; k <= nbZ; ++k)
{
for (PxI32 j = -1; j <= nbY; ++j)
{
for (PxI32 i = -1; i <= nbX; ++i)
{
if (canSkipSubgrid(sdf, i, j, k))
continue;
populateSubgridCache(sdf, sdfCache, i, j, k);
//Process the subgrid
for (PxU32 z = 0; z < sdf.mSubgridSize; ++z)
{
for (PxU32 y = 0; y < sdf.mSubgridSize; ++y)
{
for (PxU32 x = 0; x < sdf.mSubgridSize; ++x)
{
PxVec3 p;
if (generatePointInCellUsingCache(sdf, i, j, k, x, y, z, p, sdfCache))
{
PxU32 xId = i * sdf.mSubgridSize + x;
PxU32 yId = j * sdf.mSubgridSize + y;
PxU32 zId = k * sdf.mSubgridSize + z;
cellToPoint.insert(0, xId, yId, zId, isosurfaceVertices.size());
isosurfaceVertices.pushBack(p);
}
}
}
}
}
}
}
}
if (sdf.mSubgridSize == 0)
{
for (PxI32 k = -1; k <= nbZ; ++k)
for (PxI32 j = -1; j <= nbY; ++j)
for (PxI32 i = -1; i <= nbX; ++i)
{
PxReal d0 = sdf.decodeDense(i, j, k);
PxReal ds[3];
ds[0] = sdf.decodeDense(i + 1, j, k);
ds[1] = sdf.decodeDense(i, j + 1, k);
ds[2] = sdf.decodeDense(i, j, k + 1);
createTriangles(i, j, k, d0, ds, cellToPoint, isosurfaceVertices, isosurfaceTriangleIndices);
}
}
else
{
const PxU32 s = sdf.mSubgridSize + 1;
for (PxI32 k = -1; k <= nbZ; ++k)
{
for (PxI32 j = -1; j <= nbY; ++j)
{
for (PxI32 i = -1; i <= nbX; ++i)
{
if (canSkipSubgrid(sdf, i, j, k))
continue;
populateSubgridCache(sdf, sdfCache, i, j, k);
PxReal ds[3];
//Process the subgrid
for (PxU32 z = 0; z < sdf.mSubgridSize; ++z)
{
for (PxU32 y = 0; y < sdf.mSubgridSize; ++y)
{
for (PxU32 x = 0; x < sdf.mSubgridSize; ++x)
{
PxReal d0 = sdfCache[idx3D(x, y, z, s, s)];
ds[0] = sdfCache[idx3D(x + 1, y, z, s, s)];
ds[1] = sdfCache[idx3D(x, y + 1, z, s, s)];
ds[2] = sdfCache[idx3D(x, y, z + 1, s, s)];
createTriangles(x + i * sdf.mSubgridSize, y + j * sdf.mSubgridSize, z + k * sdf.mSubgridSize, d0, ds,
cellToPoint, isosurfaceVertices, isosurfaceTriangleIndices);
}
}
}
}
}
}
}
}
void extractIsosurfaceFromSDF(const Gu::SDF& sdf, PxArray<PxVec3>& isosurfaceVertices, PxArray<PxU32>& isosurfaceTriangleIndices, PxU32 numThreads)
{
if (sdf.mSubgridSize == 0)
{
//Handle dense SDFs using the serial fallback
extractIsosurfaceFromSDFSerial(sdf, isosurfaceVertices, isosurfaceTriangleIndices);
return;
}
numThreads = PxMax(1u, numThreads);
PxArray<PxThread*> threads;
PxArray<IsosurfaceThreadData> perThreadData;
CellToPoint cellToPoint(numThreads);
const PxI32 nbX = sdf.mDims.x / PxMax(1u, sdf.mSubgridSize);
const PxI32 nbY = sdf.mDims.y / PxMax(1u, sdf.mSubgridSize);
const PxI32 nbZ = sdf.mDims.z / PxMax(1u, sdf.mSubgridSize);
PxU32 l = (nbX + 2) * (nbY + 2) * (nbZ + 2);
PxU32 range = l / numThreads;
for (PxU32 i = 0; i < numThreads; ++i)
{
perThreadData.pushBack(IsosurfaceThreadData(sdf, cellToPoint, isosurfaceVertices));
IsosurfaceThreadData& d = perThreadData[i];
d.startIndex = i * range;
d.endIndex = (i + 1) * range;
if (i == numThreads - 1)
d.endIndex = l;
d.nbX = nbX + 2;
d.nbY = nbY + 2;
d.nbZ = nbZ + 2;
d.sdfCache.resize((sdf.mSubgridSize + 1) * (sdf.mSubgridSize + 1) * (sdf.mSubgridSize + 1));
d.threadIndex = i;
}
for (PxU32 i = 0; i < numThreads; ++i)
{
if (perThreadData.size() == 1)
computeIsosurfaceVerticesThreadJob(&perThreadData[i]);
else
{
threads.pushBack(PX_NEW(PxThread)(computeIsosurfaceVerticesThreadJob, &perThreadData[i], "thread"));
threads[i]->start();
}
}
for (PxU32 i = 0; i < threads.size(); ++i)
{
threads[i]->waitForQuit();
}
for (PxU32 i = 0; i < threads.size(); ++i)
{
threads[i]->~PxThreadT();
PX_FREE(threads[i]);
}
//Collect vertices
PxU32 sum = 0;
for (PxU32 i = 0; i < perThreadData.size(); ++i)
{
IsosurfaceThreadData& d = perThreadData[i];
if (sum > 0)
{
for (PxHashMap<PxU64, PxU32>::Iterator iter = cellToPoint.cellToPoint[i]->getIterator(); !iter.done(); ++iter)
iter->second += sum;
}
sum += d.isosurfaceVertices.size();
}
isosurfaceVertices.reserve(sum);
for (PxU32 i = 0; i < perThreadData.size(); ++i)
{
IsosurfaceThreadData& d = perThreadData[i];
for (PxU32 j = 0; j < d.isosurfaceVertices.size(); ++j)
isosurfaceVertices.pushBack(d.isosurfaceVertices[j]);
d.isosurfaceTriangleIndices.reset(); //Release memory that is not needed anymore
}
threads.clear();
for (PxU32 i = 0; i < numThreads; ++i)
{
if (perThreadData.size() == 1)
computeIsosurfaceTrianglesThreadJob(&perThreadData[i]);
else
{
threads.pushBack(PX_NEW(PxThread)(computeIsosurfaceTrianglesThreadJob, &perThreadData[i], "thread"));
threads[i]->start();
}
}
for (PxU32 i = 0; i < threads.size(); ++i)
{
threads[i]->waitForQuit();
}
for (PxU32 i = 0; i < threads.size(); ++i)
{
threads[i]->~PxThreadT();
PX_FREE(threads[i]);
}
//Collect triangles
sum = 0;
for (PxU32 i = 0; i < perThreadData.size(); ++i)
sum += perThreadData[i].isosurfaceTriangleIndices.size();
isosurfaceTriangleIndices.resize(sum);
for (PxU32 i = 0; i < perThreadData.size(); ++i)
{
IsosurfaceThreadData& d = perThreadData[i];
for (PxU32 j = 0; j < d.isosurfaceTriangleIndices.size(); ++j)
isosurfaceTriangleIndices.pushBack(d.isosurfaceTriangleIndices[j]);
}
}
}
}
| 68,852 | C++ | 29.931267 | 332 | 0.639008 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuExtendedBucketPruner.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxBitMap.h"
#include "GuExtendedBucketPruner.h"
#include "GuAABBTree.h"
#include "GuAABBTreeQuery.h"
#include "GuQuery.h"
#include "GuCallbackAdapter.h"
#include "GuSqInternal.h"
using namespace physx;
using namespace Gu;
#define EXT_NB_OBJECTS_PER_NODE 4
// PT: TODO: this is copied from SqBounds.h, should be either moved to Gu and shared or passed as a user parameter
#define SQ_PRUNER_EPSILON 0.005f
#define SQ_PRUNER_INFLATION (1.0f + SQ_PRUNER_EPSILON) // pruner test shape inflation (not narrow phase shape)
ExtendedBucketPruner::ExtendedBucketPruner(PxU64 contextID, CompanionPrunerType type, const PruningPool* pool) :
mCompanion (createCompanionPruner(contextID, type, pool)),
mPruningPool (pool),
mMainTree (NULL),
mMergedTrees (NULL),
mCurrentTreeIndex (0),
mTreesDirty (false)
{
// preallocated size for bounds, trees
mCurrentTreeCapacity = 32;
mBounds.init(mCurrentTreeCapacity);
mMergedTrees = PX_ALLOCATE(MergedTree, mCurrentTreeCapacity, "AABB trees");
mExtendedBucketPrunerMap.reserve(mCurrentTreeCapacity);
// create empty main tree
mMainTree = PX_NEW(AABBTree);
// create empty merge trees
for (PxU32 i = 0; i < mCurrentTreeCapacity; i++)
{
mMergedTrees[i].mTimeStamp = 0;
mMergedTrees[i].mTree = PX_NEW(AABBTree);
}
}
//////////////////////////////////////////////////////////////////////////
ExtendedBucketPruner::~ExtendedBucketPruner()
{
// release main tree
PX_DELETE(mMainTree);
// release merged trees
for (PxU32 i = 0; i < mCurrentTreeCapacity; i++)
{
AABBTree* aabbTree = mMergedTrees[i].mTree;
PX_DELETE(aabbTree);
}
mBounds.release();
PX_FREE(mMergedTrees);
PX_DELETE(mCompanion);
}
//////////////////////////////////////////////////////////////////////////
// release all objects in bucket pruner
void ExtendedBucketPruner::release()
{
if(mCompanion)
mCompanion->release();
mMainTreeUpdateMap.release();
mMergeTreeUpdateMap.release();
// release all objecs from the map
mExtendedBucketPrunerMap.clear();
// release all merged trees
for (PxU32 i = 0; i < mCurrentTreeCapacity; i++)
{
mMergedTrees[i].mTimeStamp = 0;
mMergedTrees[i].mTree->release();
}
// reset current tree index
mCurrentTreeIndex = 0;
}
//////////////////////////////////////////////////////////////////////////
// Add a tree from a pruning structure
// 1. get new tree index
// 2. initialize merged tree, bounds
// 3. create update map for the merged tree
// 4. build new tree of trees from given trees bounds
// 5. add new objects into extended bucket pruner map
// 6. shift indices in the merged tree
void ExtendedBucketPruner::addTree(const AABBTreeMergeData& mergeData, PxU32 timeStamp)
{
// check if we have to resize
if(mCurrentTreeIndex == mCurrentTreeCapacity)
{
resize(mCurrentTreeCapacity*2);
}
// get current merge tree index
const PxU32 mergeTreeIndex = mCurrentTreeIndex++;
// get payloads/userdata pointers - the pointers start at mIndicesOffset, thats where all
// objects were added before merge was called
const PrunerPayload* data = &mPruningPool->getObjects()[mergeData.mIndicesOffset];
// setup merged tree with the merge data and timestamp
mMergedTrees[mergeTreeIndex].mTimeStamp = timeStamp;
AABBTree& mergedTree = *mMergedTrees[mergeTreeIndex].mTree;
mergedTree.initTree(mergeData);
// set bounds
mBounds.getBounds()[mergeTreeIndex] = mergeData.getRootNode().mBV;
// update temporally update map for the current merge tree, map is used to setup the base extended bucket pruner map
mMergeTreeUpdateMap.initMap(mergeData.mNbIndices, mergedTree);
// create new base tree of trees
buildMainAABBTree();
// Add each object into extended bucket pruner hash map
for (PxU32 i = 0; i < mergeData.mNbIndices; i++)
{
ExtendedBucketPrunerData mapData;
mapData.mMergeIndex = mergeTreeIndex;
mapData.mTimeStamp = timeStamp;
PX_ASSERT(mMergeTreeUpdateMap[i] < mergedTree.getNbNodes());
// get node information from the merge tree update map
mapData.mSubTreeNode = mMergeTreeUpdateMap[i];
mExtendedBucketPrunerMap.insert(data[i], mapData);
}
// merged tree indices needs to be shifted now, we cannot shift it in init - the update map
// could not be constructed otherwise, as the indices wont start from 0. The indices
// needs to be shifted by offset from the pruning pool, where the new objects were added into the pruning pool.
mergedTree.shiftIndices(mergeData.mIndicesOffset);
#if PX_DEBUG
checkValidity();
#endif // PX_DEBUG
}
//////////////////////////////////////////////////////////////////////////
// Builds the new main AABB tree with given current active merged trees and its bounds
void ExtendedBucketPruner::buildMainAABBTree()
{
// create the AABB tree from given merged trees bounds
NodeAllocator nodeAllocator;
bool status = mMainTree->build(AABBTreeBuildParams(EXT_NB_OBJECTS_PER_NODE, mCurrentTreeIndex, &mBounds), nodeAllocator);
PX_UNUSED(status);
PX_ASSERT(status);
// Init main tree update map for the new main tree
mMainTreeUpdateMap.initMap(mCurrentTreeIndex, *mMainTree);
}
//////////////////////////////////////////////////////////////////////////
// resize internal memory, buffers
void ExtendedBucketPruner::resize(PxU32 size)
{
PX_ASSERT(size > mCurrentTreeCapacity);
mBounds.resize(size, mCurrentTreeCapacity);
// allocate new merged trees
MergedTree* newMergeTrees = PX_ALLOCATE(MergedTree, size, "AABB trees");
// copy previous merged trees
PxMemCopy(newMergeTrees, mMergedTrees, sizeof(MergedTree)*mCurrentTreeCapacity);
PX_FREE(mMergedTrees);
mMergedTrees = newMergeTrees;
// allocate new trees for merged trees
for (PxU32 i = mCurrentTreeCapacity; i < size; i++)
{
mMergedTrees[i].mTimeStamp = 0;
mMergedTrees[i].mTree = PX_NEW(AABBTree);
}
mCurrentTreeCapacity = size;
}
//////////////////////////////////////////////////////////////////////////
// Update object
bool ExtendedBucketPruner::updateObject(const PxBounds3& worldAABB, const PxTransform& transform, const PrunerPayload& object, PrunerHandle handle, const PoolIndex poolIndex)
{
const ExtendedBucketPrunerMap::Entry* extendedPrunerEntry = mExtendedBucketPrunerMap.find(object);
// if object is not in tree of trees, it is in bucket pruner core
if(!extendedPrunerEntry)
{
if(mCompanion)
mCompanion->updateObject(object, handle, worldAABB, transform, poolIndex);
}
else
{
const ExtendedBucketPrunerData& data = extendedPrunerEntry->second;
PX_ASSERT(data.mMergeIndex < mCurrentTreeIndex);
// update tree where objects belongs to
AABBTree& tree = *mMergedTrees[data.mMergeIndex].mTree;
PX_ASSERT(data.mSubTreeNode < tree.getNbNodes());
// mark for refit node in merged tree
tree.markNodeForRefit(data.mSubTreeNode);
PX_ASSERT(mMainTreeUpdateMap[data.mMergeIndex] < mMainTree->getNbNodes());
// mark for refit node in main aabb tree
mMainTree->markNodeForRefit(mMainTreeUpdateMap[data.mMergeIndex]);
mTreesDirty = true;
}
return true;
}
//////////////////////////////////////////////////////////////////////////
// refit merged nodes
// 1. refit nodes in merged trees
// 2. check if after refit root node is valid - might happen edge case
// where all objects were released - the root node is then invalid
// in this edge case we need to compact the merged trees array
// and create new main AABB tree
// 3. If all merged trees bounds are valid - refit main tree
// 4. If bounds are invalid create new main AABB tree
void ExtendedBucketPruner::refitMarkedNodes(const PxBounds3* boxes)
{
// if no tree needs update early exit
if(!mTreesDirty)
return;
// refit trees and update bounds for main tree
PxU32 nbValidTrees = 0;
for (PxU32 i = mCurrentTreeIndex; i--; )
{
AABBTree& tree = *mMergedTrees[i].mTree;
tree.refitMarkedNodes(boxes);
const PxBounds3& bounds = tree.getNodes()[0].mBV;
// check if bounds are valid, if all objects of the tree were released, the bounds
// will be invalid, in that case we cannot use this tree anymore.
if(bounds.isValid())
{
nbValidTrees++;
}
mBounds.getBounds()[i] = bounds;
}
if(nbValidTrees == mCurrentTreeIndex)
{
// no tree has been removed refit main tree
mMainTree->refitMarkedNodes(mBounds.getBounds());
}
else
{
// edge case path, tree does not have a valid root node bounds - all objects from the tree were released
// we might even fire perf warning
// compact the tree array - no holes in the array, remember the swap position
PxU32* swapMap = PX_ALLOCATE(PxU32, (mCurrentTreeIndex + 1), "Swap Map");
PxU32 writeIndex = 0;
for (PxU32 i = 0; i < mCurrentTreeIndex; i++)
{
AABBTree& tree = *mMergedTrees[i].mTree;
if(tree.getNodes()[0].mBV.isValid())
{
// we have to store the tree into an empty location
if(i != writeIndex)
{
PX_ASSERT(writeIndex < i);
AABBTree* ptr = mMergedTrees[writeIndex].mTree;
mMergedTrees[writeIndex] = mMergedTrees[i];
mMergedTrees[i].mTree = ptr;
mBounds.getBounds()[writeIndex] = mBounds.getBounds()[i];
}
// remember the swap location
swapMap[i] = writeIndex;
writeIndex++;
}
else
{
// tree is not valid, release it
tree.release();
mMergedTrees[i].mTimeStamp = 0;
}
// remember the swap
swapMap[mCurrentTreeIndex] = i;
}
PX_ASSERT(writeIndex == nbValidTrees);
// new merged trees size
mCurrentTreeIndex = nbValidTrees;
if(mCurrentTreeIndex)
{
// trees have changed, we need to rebuild the main tree
buildMainAABBTree();
// fixup the object entries, the merge index has changed
for (ExtendedBucketPrunerMap::Iterator iter = mExtendedBucketPrunerMap.getIterator(); !iter.done(); ++iter)
{
ExtendedBucketPrunerData& data = iter->second;
PX_ASSERT(swapMap[data.mMergeIndex] < nbValidTrees);
data.mMergeIndex = swapMap[data.mMergeIndex];
}
}
else
{
// if there is no tree release the main tree
mMainTree->release();
}
PX_FREE(swapMap);
}
#if PX_DEBUG
checkValidity();
#endif
mTreesDirty = false;
}
//////////////////////////////////////////////////////////////////////////
// remove object
bool ExtendedBucketPruner::removeObject(const PrunerPayload& object, PrunerHandle handle, PxU32 objectIndex, const PrunerPayload& swapObject, PxU32 swapObjectIndex)
{
ExtendedBucketPrunerMap::Entry dataEntry;
// if object is not in tree of trees, it is in bucket pruner core
if (!mExtendedBucketPrunerMap.erase(object, dataEntry))
{
// we need to call invalidateObjects, it might happen that the swapped object
// does belong to the extended bucket pruner, in that case the objects index
// needs to be swapped.
// do not call additional bucket pruner swap, that does happen during remove
swapIndex(objectIndex, swapObject, swapObjectIndex, false);
return mCompanion ? mCompanion->removeObject(object, handle, objectIndex, swapObjectIndex) : true;
}
else
{
const ExtendedBucketPrunerData& data = dataEntry.second;
// mark tree nodes where objects belongs to
AABBTree& tree = *mMergedTrees[data.mMergeIndex].mTree;
PX_ASSERT(data.mSubTreeNode < tree.getNbNodes());
// mark the merged tree for refit
tree.markNodeForRefit(data.mSubTreeNode);
PX_ASSERT(mMainTreeUpdateMap[data.mMergeIndex] < mMainTree->getNbNodes());
// mark the main tree for refit
mMainTree->markNodeForRefit(mMainTreeUpdateMap[data.mMergeIndex]);
// call invalidate object to swap the object indices in the merged trees
invalidateObject(data, objectIndex, swapObject, swapObjectIndex);
mTreesDirty = true;
}
#if PX_DEBUG
checkValidity();
#endif // PX_DEBUG
return true;
}
//////////////////////////////////////////////////////////////////////////
// invalidate object
// remove the objectIndex from the merged tree
void ExtendedBucketPruner::invalidateObject(const ExtendedBucketPrunerData& data, PxU32 objectIndex, const PrunerPayload& swapObject, PxU32 swapObjectIndex)
{
// get the merged tree
AABBTree& tree = *mMergedTrees[data.mMergeIndex].mTree;
PX_ASSERT(data.mSubTreeNode < tree.getNbNodes());
PX_ASSERT(tree.getNodes()[data.mSubTreeNode].isLeaf());
// get merged tree node
BVHNode& node0 = tree.getNodes()[data.mSubTreeNode];
const PxU32 nbPrims = node0.getNbRuntimePrimitives();
PX_ASSERT(nbPrims <= EXT_NB_OBJECTS_PER_NODE);
// retrieve the primitives pointer
PxU32* primitives = node0.getPrimitives(tree.getIndices());
PX_ASSERT(primitives);
// Look for desired pool index in the leaf
bool foundIt = false;
for (PxU32 i = 0; i < nbPrims; i++)
{
if (objectIndex == primitives[i])
{
foundIt = true;
const PxU32 last = nbPrims - 1;
node0.setNbRunTimePrimitives(last);
primitives[i] = INVALID_POOL_ID; // Mark primitive index as invalid in the node
// Swap within the leaf node. No need to update the mapping since they should all point
// to the same tree node anyway.
if (last != i)
PxSwap(primitives[i], primitives[last]);
break;
}
}
PX_ASSERT(foundIt);
PX_UNUSED(foundIt);
swapIndex(objectIndex, swapObject, swapObjectIndex);
}
// Swap object index
// if swapObject is in a merged tree its index needs to be swapped with objectIndex
void ExtendedBucketPruner::swapIndex(PxU32 objectIndex, const PrunerPayload& swapObject, PxU32 swapObjectIndex, bool corePrunerIncluded)
{
PX_UNUSED(corePrunerIncluded);
if (objectIndex == swapObjectIndex)
return;
const ExtendedBucketPrunerMap::Entry* extendedPrunerSwapEntry = mExtendedBucketPrunerMap.find(swapObject);
// if swapped object index is in extended pruner, we have to fix the primitives index
if (extendedPrunerSwapEntry)
{
const ExtendedBucketPrunerData& swapData = extendedPrunerSwapEntry->second;
AABBTree& swapTree = *mMergedTrees[swapData.mMergeIndex].mTree;
// With multiple primitives per leaf, tree nodes may very well be the same for different pool indices.
// However the pool indices may be the same when a swap has been skipped in the pruning pool, in which
// case there is nothing to do.
PX_ASSERT(swapData.mSubTreeNode < swapTree.getNbNodes());
PX_ASSERT(swapTree.getNodes()[swapData.mSubTreeNode].isLeaf());
BVHNode* node1 = swapTree.getNodes() + swapData.mSubTreeNode;
const PxU32 nbPrims = node1->getNbRuntimePrimitives();
PX_ASSERT(nbPrims <= EXT_NB_OBJECTS_PER_NODE);
// retrieve the primitives pointer
PxU32* primitives = node1->getPrimitives(swapTree.getIndices());
PX_ASSERT(primitives);
// look for desired pool index in the leaf
bool foundIt = false;
for (PxU32 i = 0; i < nbPrims; i++)
{
if (swapObjectIndex == primitives[i])
{
foundIt = true;
primitives[i] = objectIndex; // point node to the pool object moved to
break;
}
}
PX_ASSERT(foundIt);
PX_UNUSED(foundIt);
}
else
{
if(corePrunerIncluded)
if(mCompanion)
mCompanion->swapIndex(objectIndex, swapObjectIndex);
}
}
//////////////////////////////////////////////////////////////////////////
// Optimized removal of timestamped objects from the extended bucket pruner
PxU32 ExtendedBucketPruner::removeMarkedObjects(PxU32 timeStamp)
{
// remove objects from the core bucket pruner
PxU32 retVal = mCompanion ? mCompanion->removeMarkedObjects(timeStamp) : 0;
// nothing to be removed
if(!mCurrentTreeIndex)
return retVal;
// if last merged tree is the timeStamp to remove, we can clear all
// this is safe as the merged trees array is time ordered, never shifted
if(mMergedTrees[mCurrentTreeIndex - 1].mTimeStamp == timeStamp)
{
retVal += mExtendedBucketPrunerMap.size();
cleanTrees();
return retVal;
}
// get the highest index in the merged trees array, where timeStamp match
// we release than all trees till the index
PxU32 highestTreeIndex = 0xFFFFFFFF;
for (PxU32 i = 0; i < mCurrentTreeIndex; i++)
{
if(mMergedTrees[i].mTimeStamp == timeStamp)
highestTreeIndex = i;
else
break;
}
// if no timestamp found early exit
if(highestTreeIndex == 0xFFFFFFFF)
return retVal;
PX_ASSERT(highestTreeIndex < mCurrentTreeIndex);
// get offset, where valid trees start
const PxU32 mergeTreeOffset = highestTreeIndex + 1;
// shrink the array to merged trees with a valid timeStamp
mCurrentTreeIndex = mCurrentTreeIndex - mergeTreeOffset;
// go over trees and swap released trees with valid trees from the back (valid trees are at the back)
for (PxU32 i = 0; i < mCurrentTreeIndex; i++)
{
// store bounds, timestamp
mBounds.getBounds()[i] = mMergedTrees[mergeTreeOffset + i].mTree->getNodes()[0].mBV;
mMergedTrees[i].mTimeStamp = mMergedTrees[mergeTreeOffset + i].mTimeStamp;
// release the tree with timestamp
AABBTree* ptr = mMergedTrees[i].mTree;
ptr->release();
// store the valid tree
mMergedTrees[i].mTree = mMergedTrees[mergeTreeOffset + i].mTree;
// store the release tree at the offset
mMergedTrees[mergeTreeOffset + i].mTree = ptr;
mMergedTrees[mergeTreeOffset + i].mTimeStamp = 0;
}
// release the rest of the trees with not valid timestamp
for (PxU32 i = mCurrentTreeIndex; i <= highestTreeIndex; i++)
{
mMergedTrees[i].mTree->release();
mMergedTrees[i].mTimeStamp = 0;
}
// build new main AABB tree with only trees with valid valid timeStamp
buildMainAABBTree();
// remove all unnecessary trees and map entries
bool removeEntry = false;
PxU32 numRemovedEntries = 0;
ExtendedBucketPrunerMap::EraseIterator eraseIterator = mExtendedBucketPrunerMap.getEraseIterator();
ExtendedBucketPrunerMap::Entry* entry = eraseIterator.eraseCurrentGetNext(removeEntry);
while (entry)
{
ExtendedBucketPrunerData& data = entry->second;
// data to be removed
if (data.mTimeStamp == timeStamp)
{
removeEntry = true;
numRemovedEntries++;
}
else
{
// update the merge index and main tree node index
PX_ASSERT(highestTreeIndex < data.mMergeIndex);
data.mMergeIndex -= mergeTreeOffset;
removeEntry = false;
}
entry = eraseIterator.eraseCurrentGetNext(removeEntry);
}
#if PX_DEBUG
checkValidity();
#endif // PX_DEBUG
// return the number of removed objects
return retVal + numRemovedEntries;
}
//////////////////////////////////////////////////////////////////////////
// clean all trees, all objects have been released
void ExtendedBucketPruner::cleanTrees()
{
for (PxU32 i = 0; i < mCurrentTreeIndex; i++)
{
mMergedTrees[i].mTree->release();
mMergedTrees[i].mTimeStamp = 0;
}
mExtendedBucketPrunerMap.clear();
mCurrentTreeIndex = 0;
mMainTree->release();
}
//////////////////////////////////////////////////////////////////////////
// shift origin
void ExtendedBucketPruner::shiftOrigin(const PxVec3& shift)
{
mMainTree->shiftOrigin(shift);
for(PxU32 i=0; i<mCurrentTreeIndex; i++)
mMergedTrees[i].mTree->shiftOrigin(shift);
if(mCompanion)
mCompanion->shiftOrigin(shift);
}
//////////////////////////////////////////////////////////////////////////
// Queries implementation
//////////////////////////////////////////////////////////////////////////
// Raycast/sweeps callback for main AABB tree
template<const bool tInflate>
struct MainTreeRaycastPrunerCallback
{
MainTreeRaycastPrunerCallback(const PxVec3& origin, const PxVec3& unitDir, const PxVec3& extent, PrunerRaycastCallback& prunerCallback, const PruningPool* pool, const MergedTree* mergedTrees)
: mOrigin(origin), mUnitDir(unitDir), mExtent(extent), mPrunerCallback(prunerCallback), mPruningPool(pool), mMergedTrees(mergedTrees)
{
}
bool invoke(PxReal& distance, PxU32 primIndex)
{
const AABBTree* aabbTree = mMergedTrees[primIndex].mTree;
// raycast the merged tree
RaycastCallbackAdapter pcb(mPrunerCallback, *mPruningPool);
return AABBTreeRaycast<tInflate, true, AABBTree, BVHNode, RaycastCallbackAdapter>()(mPruningPool->getCurrentAABBTreeBounds(), *aabbTree, mOrigin, mUnitDir, distance, mExtent, pcb);
}
PX_NOCOPY(MainTreeRaycastPrunerCallback)
private:
const PxVec3& mOrigin;
const PxVec3& mUnitDir;
const PxVec3& mExtent;
PrunerRaycastCallback& mPrunerCallback;
const PruningPool* mPruningPool;
const MergedTree* mMergedTrees;
};
//////////////////////////////////////////////////////////////////////////
// raycast against the extended bucket pruner
bool ExtendedBucketPruner::raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& prunerCallback) const
{
bool again = mCompanion ? mCompanion->raycast(origin, unitDir, inOutDistance, prunerCallback) : true;
if(again && mExtendedBucketPrunerMap.size())
{
const PxVec3 extent(0.0f);
// main tree callback
MainTreeRaycastPrunerCallback<false> pcb(origin, unitDir, extent, prunerCallback, mPruningPool, mMergedTrees);
// traverse the main tree
again = AABBTreeRaycast<false, true, AABBTree, BVHNode, MainTreeRaycastPrunerCallback<false>>()(mBounds, *mMainTree, origin, unitDir, inOutDistance, extent, pcb);
}
return again;
}
//////////////////////////////////////////////////////////////////////////
// overlap main tree callback
template<typename Test>
struct MainTreeOverlapPrunerCallback
{
MainTreeOverlapPrunerCallback(const Test& test, PrunerOverlapCallback& prunerCallback, const PruningPool* pool, const MergedTree* mergedTrees)
: mTest(test), mPrunerCallback(prunerCallback), mPruningPool(pool), mMergedTrees(mergedTrees)
{
}
bool invoke(PxU32 primIndex)
{
const AABBTree* aabbTree = mMergedTrees[primIndex].mTree;
// overlap the merged tree
OverlapCallbackAdapter pcb(mPrunerCallback, *mPruningPool);
return AABBTreeOverlap<true, Test, AABBTree, BVHNode, OverlapCallbackAdapter>()(mPruningPool->getCurrentAABBTreeBounds(), *aabbTree, mTest, pcb);
}
PX_NOCOPY(MainTreeOverlapPrunerCallback)
private:
const Test& mTest;
PrunerOverlapCallback& mPrunerCallback;
const PruningPool* mPruningPool;
const MergedTree* mMergedTrees;
};
//////////////////////////////////////////////////////////////////////////
// overlap implementation
bool ExtendedBucketPruner::overlap(const ShapeData& queryVolume, PrunerOverlapCallback& prunerCallback) const
{
bool again = mCompanion ? mCompanion->overlap(queryVolume, prunerCallback) : true;
if(again && mExtendedBucketPrunerMap.size())
{
switch (queryVolume.getType())
{
case PxGeometryType::eBOX:
{
if (queryVolume.isOBB())
{
const DefaultOBBAABBTest test(queryVolume);
MainTreeOverlapPrunerCallback<OBBAABBTest> pcb(test, prunerCallback, mPruningPool, mMergedTrees);
again = AABBTreeOverlap<true, OBBAABBTest, AABBTree, BVHNode, MainTreeOverlapPrunerCallback<OBBAABBTest>>()(mBounds, *mMainTree, test, pcb);
}
else
{
const DefaultAABBAABBTest test(queryVolume);
MainTreeOverlapPrunerCallback<AABBAABBTest> pcb(test, prunerCallback, mPruningPool, mMergedTrees);
again = AABBTreeOverlap<true, AABBAABBTest, AABBTree, BVHNode, MainTreeOverlapPrunerCallback<AABBAABBTest>>()(mBounds, *mMainTree, test, pcb);
}
}
break;
case PxGeometryType::eCAPSULE:
{
const DefaultCapsuleAABBTest test(queryVolume, SQ_PRUNER_INFLATION);
MainTreeOverlapPrunerCallback<CapsuleAABBTest> pcb(test, prunerCallback, mPruningPool, mMergedTrees);
again = AABBTreeOverlap<true, CapsuleAABBTest, AABBTree, BVHNode, MainTreeOverlapPrunerCallback<CapsuleAABBTest>>()(mBounds, *mMainTree, test, pcb);
}
break;
case PxGeometryType::eSPHERE:
{
const DefaultSphereAABBTest test(queryVolume);
MainTreeOverlapPrunerCallback<SphereAABBTest> pcb(test, prunerCallback, mPruningPool, mMergedTrees);
again = AABBTreeOverlap<true, SphereAABBTest, AABBTree, BVHNode, MainTreeOverlapPrunerCallback<SphereAABBTest>>()(mBounds, *mMainTree, test, pcb);
}
break;
case PxGeometryType::eCONVEXMESH:
{
const DefaultOBBAABBTest test(queryVolume);
MainTreeOverlapPrunerCallback<OBBAABBTest> pcb(test, prunerCallback, mPruningPool, mMergedTrees);
again = AABBTreeOverlap<true, OBBAABBTest, AABBTree, BVHNode, MainTreeOverlapPrunerCallback<OBBAABBTest>>()(mBounds, *mMainTree, test, pcb);
}
break;
default:
PX_ALWAYS_ASSERT_MESSAGE("unsupported overlap query volume geometry type");
}
}
return again;
}
//////////////////////////////////////////////////////////////////////////
// sweep implementation
bool ExtendedBucketPruner::sweep(const ShapeData& queryVolume, const PxVec3& unitDir, PxReal& inOutDistance, PrunerRaycastCallback& prunerCallback) const
{
bool again = mCompanion ? mCompanion->sweep(queryVolume, unitDir, inOutDistance, prunerCallback) : true;
if(again && mExtendedBucketPrunerMap.size())
{
const PxBounds3& aabb = queryVolume.getPrunerInflatedWorldAABB();
const PxVec3 extents = aabb.getExtents();
const PxVec3 center = aabb.getCenter();
MainTreeRaycastPrunerCallback<true> pcb(center, unitDir, extents, prunerCallback, mPruningPool, mMergedTrees);
again = AABBTreeRaycast<true, true, AABBTree, BVHNode, MainTreeRaycastPrunerCallback<true>>()(mBounds, *mMainTree, center, unitDir, inOutDistance, extents, pcb);
}
return again;
}
//////////////////////////////////////////////////////////////////////////
void ExtendedBucketPruner::getGlobalBounds(PxBounds3& bounds) const
{
if(mCompanion)
mCompanion->getGlobalBounds(bounds);
else
bounds.setEmpty();
if(mExtendedBucketPrunerMap.size() && mMainTree && mMainTree->getNodes())
bounds.include(mMainTree->getNodes()->mBV);
}
//////////////////////////////////////////////////////////////////////////
void ExtendedBucketPruner::visualize(PxRenderOutput& out, PxU32 color) const
{
visualizeTree(out, color, mMainTree);
for(PxU32 i=0; i<mCurrentTreeIndex; i++)
visualizeTree(out, color, mMergedTrees[i].mTree);
if(mCompanion)
mCompanion->visualize(out, color);
}
//////////////////////////////////////////////////////////////////////////
#if PX_DEBUG
// extended bucket pruner validity check
bool ExtendedBucketPruner::checkValidity()
{
PxBitMap testBitmap;
testBitmap.resizeAndClear(mCurrentTreeIndex);
for (PxU32 i = 0; i < mMainTree->getNbNodes(); i++)
{
const BVHNode& node = mMainTree->getNodes()[i];
if(node.isLeaf())
{
const PxU32 nbPrims = node.getNbRuntimePrimitives();
PX_ASSERT(nbPrims <= EXT_NB_OBJECTS_PER_NODE);
const PxU32* primitives = node.getPrimitives(mMainTree->getIndices());
for (PxU32 j = 0; j < nbPrims; j++)
{
const PxU32 index = primitives[j];
// check if index is correct
PX_ASSERT(index < mCurrentTreeIndex);
// mark the index in the test bitmap, must be once set only, all merged trees must be in the main tree
PX_ASSERT(testBitmap.test(index) == PxIntFalse);
testBitmap.set(index);
}
}
}
PxBitMap mergeTreeTestBitmap;
mergeTreeTestBitmap.resizeAndClear(mPruningPool->getNbActiveObjects());
for (PxU32 i = 0; i < mCurrentTreeIndex; i++)
{
// check if bounds are the same as the merged tree root bounds
PX_ASSERT(mBounds.getBounds()[i].maximum.x == mMergedTrees[i].mTree->getNodes()[0].mBV.maximum.x);
PX_ASSERT(mBounds.getBounds()[i].maximum.y == mMergedTrees[i].mTree->getNodes()[0].mBV.maximum.y);
PX_ASSERT(mBounds.getBounds()[i].maximum.z == mMergedTrees[i].mTree->getNodes()[0].mBV.maximum.z);
PX_ASSERT(mBounds.getBounds()[i].minimum.x == mMergedTrees[i].mTree->getNodes()[0].mBV.minimum.x);
PX_ASSERT(mBounds.getBounds()[i].minimum.y == mMergedTrees[i].mTree->getNodes()[0].mBV.minimum.y);
PX_ASSERT(mBounds.getBounds()[i].minimum.z == mMergedTrees[i].mTree->getNodes()[0].mBV.minimum.z);
// check each tree
const AABBTree& mergedTree = *mMergedTrees[i].mTree;
for (PxU32 j = 0; j < mergedTree.getNbNodes(); j++)
{
const BVHNode& node = mergedTree.getNodes()[j];
if (node.isLeaf())
{
const PxU32 nbPrims = node.getNbRuntimePrimitives();
PX_ASSERT(nbPrims <= EXT_NB_OBJECTS_PER_NODE);
const PxU32* primitives = node.getPrimitives(mergedTree.getIndices());
for (PxU32 k = 0; k < nbPrims; k++)
{
const PxU32 index = primitives[k];
// check if index is correct
PX_ASSERT(index < mPruningPool->getNbActiveObjects());
// mark the index in the test bitmap, must be once set only, all merged trees must be in the main tree
PX_ASSERT(mergeTreeTestBitmap.test(index) == PxIntFalse);
mergeTreeTestBitmap.set(index);
const PrunerPayload& payload = mPruningPool->getObjects()[index];
const ExtendedBucketPrunerMap::Entry* extendedPrunerSwapEntry = mExtendedBucketPrunerMap.find(payload);
PX_ASSERT(extendedPrunerSwapEntry);
const ExtendedBucketPrunerData& data = extendedPrunerSwapEntry->second;
PX_ASSERT(data.mMergeIndex == i);
PX_ASSERT(data.mSubTreeNode == j);
}
}
}
}
for (PxU32 i = mCurrentTreeIndex; i < mCurrentTreeCapacity; i++)
{
PX_ASSERT(mMergedTrees[i].mTree->getIndices() == NULL);
PX_ASSERT(mMergedTrees[i].mTree->getNodes() == NULL);
}
for (ExtendedBucketPrunerMap::Iterator iter = mExtendedBucketPrunerMap.getIterator(); !iter.done(); ++iter)
{
const ExtendedBucketPrunerData& data = iter->second;
PX_ASSERT(mMainTreeUpdateMap[data.mMergeIndex] < mMainTree->getNbNodes());
PX_ASSERT(data.mMergeIndex < mCurrentTreeIndex);
PX_ASSERT(data.mSubTreeNode < mMergedTrees[data.mMergeIndex].mTree->getNbNodes());
}
return true;
}
#endif
| 30,845 | C++ | 34.577855 | 192 | 0.70462 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuBounds.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "GuBounds.h"
#include "geometry/PxBoxGeometry.h"
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxPlaneGeometry.h"
#include "geometry/PxConvexMeshGeometry.h"
#include "geometry/PxTetrahedronMeshGeometry.h"
#include "geometry/PxTriangleMeshGeometry.h"
#include "geometry/PxHeightFieldGeometry.h"
#include "geometry/PxCustomGeometry.h"
#include "GuInternal.h"
#include "CmUtils.h"
#include "GuConvexMesh.h"
#include "GuConvexMeshData.h"
#include "GuTriangleMesh.h"
#include "GuTetrahedronMesh.h"
#include "GuHeightFieldData.h"
#include "GuHeightField.h"
#include "GuConvexUtilsInternal.h"
#include "GuBoxConversion.h"
using namespace physx;
using namespace Gu;
using namespace aos;
// Compute global box for current node. The box is stored in mBV.
void Gu::computeGlobalBox(PxBounds3& bounds, PxU32 nbPrims, const PxBounds3* PX_RESTRICT boxes, const PxU32* PX_RESTRICT primitives)
{
PX_ASSERT(boxes);
PX_ASSERT(primitives);
PX_ASSERT(nbPrims);
Vec4V minV = V4LoadU(&boxes[primitives[0]].minimum.x);
Vec4V maxV = V4LoadU(&boxes[primitives[0]].maximum.x);
for (PxU32 i=1; i<nbPrims; i++)
{
const PxU32 index = primitives[i];
minV = V4Min(minV, V4LoadU(&boxes[index].minimum.x));
maxV = V4Max(maxV, V4LoadU(&boxes[index].maximum.x));
}
StoreBounds(bounds, minV, maxV);
}
void Gu::computeBoundsAroundVertices(PxBounds3& bounds, PxU32 nbVerts, const PxVec3* PX_RESTRICT verts)
{
// PT: we can safely V4LoadU the first N-1 vertices. We must V3LoadU the last vertex, to make sure we don't read
// invalid memory. Since we have to special-case that last vertex anyway, we reuse that code to also initialize
// the minV/maxV values (bypassing the need for a 'setEmpty()' initialization).
if(!nbVerts)
{
bounds.setEmpty();
return;
}
PxU32 nbSafe = nbVerts-1;
// PT: read last (unsafe) vertex using V3LoadU, initialize minV/maxV
const Vec4V lastVertexV = Vec4V_From_Vec3V(V3LoadU(&verts[nbSafe].x));
Vec4V minV = lastVertexV;
Vec4V maxV = lastVertexV;
// PT: read N-1 first (safe) vertices using V4LoadU
while(nbSafe--)
{
const Vec4V vertexV = V4LoadU(&verts->x);
verts++;
minV = V4Min(minV, vertexV);
maxV = V4Max(maxV, vertexV);
}
StoreBounds(bounds, minV, maxV);
}
void Gu::computeLocalBoundsAndGeomEpsilon(const PxVec3* vertices, PxU32 nbVerties, PxBounds3& localBounds, PxReal& geomEpsilon)
{
computeBoundsAroundVertices(localBounds, nbVerties, vertices);
// Derive a good geometric epsilon from local bounds. We must do this before bounds extrusion for heightfields.
//
// From Charles Bloom:
// "Epsilon must be big enough so that the consistency condition abs(D(Hit))
// <= Epsilon is satisfied for all queries. You want the smallest epsilon
// you can have that meets that constraint. Normal floats have a 24 bit
// mantissa. When you do any float addition, you may have round-off error
// that makes the result off by roughly 2^-24 * result. Our result is
// scaled by the position values. If our world is strictly required to be
// in a box of world size W (each coordinate in -W to W), then the maximum
// error is 2^-24 * W. Thus Epsilon must be at least >= 2^-24 * W. If
// you're doing coordinate transforms, that may scale your error up by some
// amount, so you'll need a bigger epsilon. In general something like
// 2^-22*W is reasonable. If you allow scaled transforms, it needs to be
// something like 2^-22*W*MAX_SCALE."
// PT: TODO: runtime checkings for this
PxReal eps = 0.0f;
for (PxU32 i = 0; i < 3; i++)
eps = PxMax(eps, PxMax(PxAbs(localBounds.maximum[i]), PxAbs(localBounds.minimum[i])));
eps *= powf(2.0f, -22.0f);
geomEpsilon = eps;
}
static PX_FORCE_INLINE void transformNoEmptyTest(PxVec3p& c, PxVec3p& ext, const PxMat33& rot, const PxVec3& pos, const CenterExtentsPadded& bounds)
{
c = rot.transform(bounds.mCenter) + pos;
ext = Cm::basisExtent(rot.column0, rot.column1, rot.column2, bounds.mExtents);
}
// PT: this one may have duplicates in GuBV4_BoxSweep_Internal.h & GuBV4_Raycast.cpp
static PX_FORCE_INLINE Vec4V multiply3x3V(const Vec4V p, const PxMat33Padded& mat_Padded)
{
Vec4V ResV = V4Scale(V4LoadU(&mat_Padded.column0.x), V4GetX(p));
ResV = V4Add(ResV, V4Scale(V4LoadU(&mat_Padded.column1.x), V4GetY(p)));
ResV = V4Add(ResV, V4Scale(V4LoadU(&mat_Padded.column2.x), V4GetZ(p)));
return ResV;
}
static PX_FORCE_INLINE void transformNoEmptyTestV(PxVec3p& c, PxVec3p& ext, const PxMat33Padded& rot, const PxVec3& pos, const CenterExtentsPadded& bounds)
{
const Vec4V boundsCenterV = V4LoadU(&bounds.mCenter.x); // PT: this load is safe since extents follow center in the class
// PT: unfortunately we can't V4LoadU 'pos' directly (it can come directly from users!). So we have to live with this for now:
const Vec4V posV = Vec4V_From_Vec3V(V3LoadU(&pos.x));
// PT: but eventually we'd like to use the "unsafe" version (e.g. by switching p&q in PxTransform), which would save 6 instructions on Win32
const Vec4V cV = V4Add(multiply3x3V(boundsCenterV, rot), posV);
// const Vec4V cV = V4Add(multiply3x3V(boundsCenterV, rot), V4LoadU(&pos.x)); // ### unsafe
V4StoreU(cV, &c.x);
// extended basis vectors
const Vec4V boundsExtentsV = V4LoadU(&bounds.mExtents.x); // PT: this load is safe since bounds are padded
const Vec4V c0V = V4Scale(V4LoadU(&rot.column0.x), V4GetX(boundsExtentsV));
const Vec4V c1V = V4Scale(V4LoadU(&rot.column1.x), V4GetY(boundsExtentsV));
const Vec4V c2V = V4Scale(V4LoadU(&rot.column2.x), V4GetZ(boundsExtentsV));
// find combination of base vectors that produces max. distance for each component = sum of abs()
Vec4V extentsV = V4Add(V4Abs(c0V), V4Abs(c1V));
extentsV = V4Add(extentsV, V4Abs(c2V));
V4StoreU(extentsV, &ext.x);
}
static PX_FORCE_INLINE PxU32 isNonIdentity(const PxVec3& scale)
{
#define IEEE_1_0 0x3f800000 //!< integer representation of 1.0
const PxU32* binary = reinterpret_cast<const PxU32*>(&scale.x);
return (binary[0] - IEEE_1_0)|(binary[1] - IEEE_1_0)|(binary[2] - IEEE_1_0);
}
// PT: please don't inline this one - 300+ lines of rarely used code
static void computeScaledMatrix(PxMat33Padded& rot, const PxMeshScale& scale)
{
rot = rot * Cm::toMat33(scale);
}
static PX_FORCE_INLINE void transformNoEmptyTest(PxVec3p& c, PxVec3p& ext, const PxTransform& transform, const PxMeshScale& scale, const CenterExtentsPadded& bounds)
{
PxMat33Padded rot(transform.q);
if(isNonIdentity(scale.scale))
computeScaledMatrix(rot, scale);
transformNoEmptyTestV(c, ext, rot, transform.p, bounds);
}
static PX_FORCE_INLINE void transformNoEmptyTest(PxVec3p& c, PxVec3p& ext, const PxVec3& pos, const PxMat33Padded& rot, const PxMeshScale& scale, const CenterExtentsPadded& bounds)
{
if(scale.isIdentity())
transformNoEmptyTest(c, ext, rot, pos, bounds);
else
transformNoEmptyTest(c, ext, rot * Cm::toMat33(scale), pos, bounds);
}
static void computeMeshBounds(const PxTransform& pose, const CenterExtentsPadded* PX_RESTRICT localSpaceBounds, const PxMeshScale& meshScale, PxVec3p& origin, PxVec3p& extent)
{
transformNoEmptyTest(origin, extent, pose, meshScale, *localSpaceBounds);
}
static void computePlaneBounds(PxBounds3& bounds, const PxTransform& pose, float contactOffset, float inflation)
{
// PT: A plane is infinite, so usually the bounding box covers the whole world.
// Now, in particular cases when the plane is axis-aligned, we can take
// advantage of this to compute a smaller bounding box anyway.
// PT: we use PX_MAX_BOUNDS_EXTENTS to be compatible with PxBounds3::setMaximal,
// and to make sure that the value doesn't collide with the BP's sentinels.
const PxF32 bigValue = PX_MAX_BOUNDS_EXTENTS;
// const PxF32 bigValue = 1000000.0f;
PxVec3 minPt = PxVec3(-bigValue, -bigValue, -bigValue);
PxVec3 maxPt = PxVec3(bigValue, bigValue, bigValue);
const PxVec3 planeNormal = pose.q.getBasisVector0();
const PxPlane plane(pose.p, planeNormal);
const float nx = PxAbs(planeNormal.x);
const float ny = PxAbs(planeNormal.y);
const float nz = PxAbs(planeNormal.z);
const float epsilon = 1e-6f;
const float oneMinusEpsilon = 1.0f - epsilon;
if(nx>oneMinusEpsilon && ny<epsilon && nz<epsilon)
{
if(planeNormal.x>0.0f) maxPt.x = -plane.d + contactOffset;
else minPt.x = plane.d - contactOffset;
}
else if(nx<epsilon && ny>oneMinusEpsilon && nz<epsilon)
{
if(planeNormal.y>0.0f) maxPt.y = -plane.d + contactOffset;
else minPt.y = plane.d - contactOffset;
}
else if(nx<epsilon && ny<epsilon && nz>oneMinusEpsilon)
{
if(planeNormal.z>0.0f) maxPt.z = -plane.d + contactOffset;
else minPt.z = plane.d - contactOffset;
}
// PT: it is important to compute the min/max form directly without going through the
// center/extents intermediate form. With PX_MAX_BOUNDS_EXTENTS, those back-and-forth
// computations destroy accuracy.
// PT: inflation actually destroys the bounds really. We keep it to please UTs but this is broken (DE10595).
// (e.g. for SQ 1% of PX_MAX_BOUNDS_EXTENTS is still a huge number, effectively making the AABB infinite and defeating the point of the above computation)
if(inflation!=1.0f)
{
const PxVec3 c = (maxPt + minPt)*0.5f;
const PxVec3 e = (maxPt - minPt)*0.5f*inflation;
minPt = c - e;
maxPt = c + e;
}
bounds.minimum = minPt;
bounds.maximum = maxPt;
}
static PX_FORCE_INLINE void inflateBounds(PxBounds3& bounds, const PxVec3p& origin, const PxVec3p& extents, float contactOffset, float inflation)
{
Vec4V extentsV = V4LoadU(&extents.x);
extentsV = V4Add(extentsV, V4Load(contactOffset));
extentsV = V4Scale(extentsV, FLoad(inflation));
const Vec4V originV = V4LoadU(&origin.x);
const Vec4V minV = V4Sub(originV, extentsV);
const Vec4V maxV = V4Add(originV, extentsV);
StoreBounds(bounds, minV, maxV);
}
static PX_FORCE_INLINE Vec4V basisExtentV(const PxMat33Padded& basis, const PxVec3& extent, float offset, float inflation)
{
// extended basis vectors
const Vec4V c0V = V4Scale(V4LoadU(&basis.column0.x), FLoad(extent.x));
const Vec4V c1V = V4Scale(V4LoadU(&basis.column1.x), FLoad(extent.y));
const Vec4V c2V = V4Scale(V4LoadU(&basis.column2.x), FLoad(extent.z));
// find combination of base vectors that produces max. distance for each component = sum of abs()
Vec4V extentsV = V4Add(V4Abs(c0V), V4Abs(c1V));
extentsV = V4Add(extentsV, V4Abs(c2V));
extentsV = V4Add(extentsV, V4Load(offset));
extentsV = V4Scale(extentsV, FLoad(inflation));
return extentsV;
}
static PX_FORCE_INLINE void computeMeshBounds(PxBounds3& bounds, float contactOffset, float inflation, const PxTransform& pose, const CenterExtentsPadded* PX_RESTRICT localSpaceBounds, const PxMeshScale& scale)
{
PxVec3p origin, extents;
computeMeshBounds(pose, localSpaceBounds, scale, origin, extents);
::inflateBounds(bounds, origin, extents, contactOffset, inflation);
}
void Gu::computeTightBounds(PxBounds3& bounds, PxU32 nb, const PxVec3* PX_RESTRICT v, const PxTransform& pose, const PxMeshScale& scale, float contactOffset, float inflation)
{
if(!nb)
{
bounds.setEmpty();
return;
}
PxMat33Padded rot(pose.q);
if(isNonIdentity(scale.scale))
computeScaledMatrix(rot, scale);
// PT: we can safely V4LoadU the first N-1 vertices. We must V3LoadU the last vertex, to make sure we don't read
// invalid memory. Since we have to special-case that last vertex anyway, we reuse that code to also initialize
// the minV/maxV values (bypassing the need for a 'setEmpty()' initialization).
PxU32 nbSafe = nb-1;
// PT: read last (unsafe) vertex using V3LoadU, initialize minV/maxV
const Vec4V lastVertexV = multiply3x3V(Vec4V_From_Vec3V(V3LoadU(&v[nbSafe].x)), rot);
Vec4V minV = lastVertexV;
Vec4V maxV = lastVertexV;
// PT: read N-1 first (safe) vertices using V4LoadU
while(nbSafe--)
{
const Vec4V vertexV = multiply3x3V(V4LoadU(&v->x), rot);
v++;
minV = V4Min(minV, vertexV);
maxV = V4Max(maxV, vertexV);
}
const Vec4V offsetV = V4Load(contactOffset);
minV = V4Sub(minV, offsetV);
maxV = V4Add(maxV, offsetV);
const Vec4V posV = Vec4V_From_Vec3V(V3LoadU(&pose.p.x));
maxV = V4Add(maxV, posV);
minV = V4Add(minV, posV);
// Inflation
{
const Vec4V centerV = V4Scale(V4Add(maxV, minV), FLoad(0.5f));
const Vec4V extentsV = V4Scale(V4Sub(maxV, minV), FLoad(0.5f*inflation));
maxV = V4Add(centerV, extentsV);
minV = V4Sub(centerV, extentsV);
}
StoreBounds(bounds, minV, maxV);
}
void Gu::computeBounds(PxBounds3& bounds, const PxGeometry& geometry, const PxTransform& pose, float contactOffset, float inflation)
{
// Box, Convex, Mesh and HeightField will compute local bounds and pose to world space.
// Sphere, Capsule & Plane will compute world space bounds directly.
switch(geometry.getType())
{
case PxGeometryType::eSPHERE:
{
const PxSphereGeometry& shape = static_cast<const PxSphereGeometry&>(geometry);
const PxVec3 extents((shape.radius+contactOffset)*inflation);
bounds.minimum = pose.p - extents;
bounds.maximum = pose.p + extents;
}
break;
case PxGeometryType::ePLANE:
{
computePlaneBounds(bounds, pose, contactOffset, inflation);
}
break;
case PxGeometryType::eCAPSULE:
{
computeCapsuleBounds(bounds, static_cast<const PxCapsuleGeometry&>(geometry), pose, contactOffset, inflation);
}
break;
case PxGeometryType::eBOX:
{
const PxBoxGeometry& shape = static_cast<const PxBoxGeometry&>(geometry);
const PxVec3p origin(pose.p);
const PxMat33Padded basis(pose.q);
const Vec4V extentsV = basisExtentV(basis, shape.halfExtents, contactOffset, inflation);
const Vec4V originV = V4LoadU(&origin.x);
const Vec4V minV = V4Sub(originV, extentsV);
const Vec4V maxV = V4Add(originV, extentsV);
StoreBounds(bounds, minV, maxV);
}
break;
case PxGeometryType::eCONVEXMESH:
{
const PxConvexMeshGeometry& shape = static_cast<const PxConvexMeshGeometry&>(geometry);
const Gu::ConvexHullData& hullData = static_cast<const Gu::ConvexMesh*>(shape.convexMesh)->getHull();
const bool useTightBounds = shape.meshFlags & PxConvexMeshGeometryFlag::eTIGHT_BOUNDS;
if(useTightBounds)
computeTightBounds(bounds, hullData.mNbHullVertices, hullData.getHullVertices(), pose, shape.scale, contactOffset, inflation);
else
computeMeshBounds(bounds, contactOffset, inflation, pose, &hullData.getPaddedBounds(), shape.scale);
}
break;
case PxGeometryType::eTRIANGLEMESH:
{
const PxTriangleMeshGeometry& shape = static_cast<const PxTriangleMeshGeometry&>(geometry);
const TriangleMesh* triangleMesh = static_cast<const TriangleMesh*>(shape.triangleMesh);
const bool useTightBounds = shape.meshFlags & PxMeshGeometryFlag::eTIGHT_BOUNDS;
if(useTightBounds)
computeTightBounds(bounds, triangleMesh->getNbVerticesFast(), triangleMesh->getVerticesFast(), pose, shape.scale, contactOffset, inflation);
else
computeMeshBounds(bounds, contactOffset, inflation, pose, &triangleMesh->getPaddedBounds(), shape.scale);
}
break;
case PxGeometryType::eHEIGHTFIELD:
{
const PxHeightFieldGeometry& shape = static_cast<const PxHeightFieldGeometry&>(geometry);
computeMeshBounds(bounds, contactOffset, inflation, pose, &static_cast<const Gu::HeightField*>(shape.heightField)->getData().getPaddedBounds(), PxMeshScale(PxVec3(shape.rowScale, shape.heightScale, shape.columnScale)));
}
break;
case PxGeometryType::eTETRAHEDRONMESH:
{
const PxTetrahedronMeshGeometry& shape = static_cast<const PxTetrahedronMeshGeometry&>(geometry);
computeMeshBounds(bounds, contactOffset, inflation, pose, &static_cast<const Gu::TetrahedronMesh*>(shape.tetrahedronMesh)->getPaddedBounds(), PxMeshScale());
}
break;
case PxGeometryType::ePARTICLESYSTEM:
{
// implement!
PX_ASSERT(0);
}
break;
case PxGeometryType::eHAIRSYSTEM:
{
// jcarius: Hairsystem bounds only available on GPU
bounds.setEmpty();
}
break;
case PxGeometryType::eCUSTOM:
{
const PxCustomGeometry& shape = static_cast<const PxCustomGeometry&>(geometry);
PxVec3p centre(0), extents(0);
if (shape.callbacks)
{
const PxBounds3 b = shape.callbacks->getLocalBounds(shape);
centre = b.getCenter(); extents = b.getExtents();
}
const PxVec3p origin(pose.transform(centre));
const PxMat33Padded basis(pose.q);
const Vec4V extentsV = basisExtentV(basis, extents, contactOffset, inflation);
const Vec4V originV = V4LoadU(&origin.x);
const Vec4V minV = V4Sub(originV, extentsV);
const Vec4V maxV = V4Add(originV, extentsV);
StoreBounds(bounds, minV, maxV);
}
break;
default:
{
PX_ASSERT(0);
PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "Gu::computeBounds: Unknown shape type.");
}
}
}
static PX_FORCE_INLINE void computeBoxExtentsAroundCapsule(PxVec3& extents, const PxCapsuleGeometry& capsuleGeom, float inflation)
{
extents.x = (capsuleGeom.radius + capsuleGeom.halfHeight) * inflation;
extents.y = capsuleGeom.radius * inflation;
extents.z = capsuleGeom.radius * inflation;
}
static const PxReal SQ_PRUNER_INFLATION = 1.01f; // pruner test shape inflation (not narrow phase shape)
static void computeMeshBounds(const PxVec3& pos, const PxMat33Padded& rot, const CenterExtentsPadded* PX_RESTRICT localSpaceBounds, const PxMeshScale& meshScale, PxVec3p& origin, PxVec3p& extent)
{
PxPrefetchLine(localSpaceBounds); // PT: this one helps reducing L2 misses in transformNoEmptyTest
transformNoEmptyTest(origin, extent, pos, rot, meshScale, *localSpaceBounds);
}
// PT: warning: this writes 4 bytes after the end of 'bounds'. Calling code must ensure it is safe to do so.
static PX_FORCE_INLINE void computeMinMaxBounds(PxBounds3* PX_RESTRICT bounds, const PxVec3p& c, const PxVec3p& e, float prunerInflation, float offset)
{
const Vec4V extentsV = V4Scale(V4Add(V4LoadU(&e.x), V4Load(offset)), FLoad(prunerInflation));
const Vec4V centerV = V4LoadU(&c.x);
const Vec4V minV = V4Sub(centerV, extentsV);
const Vec4V maxV = V4Add(centerV, extentsV);
V4StoreU(minV, &bounds->minimum.x);
V4StoreU(maxV, &bounds->maximum.x);
}
ShapeData::ShapeData(const PxGeometry& g, const PxTransform& t, PxReal inflation)
{
using namespace physx::aos;
// PT: this cast to matrix is already done in GeometryUnion::computeBounds (e.g. for boxes). So we do it first,
// then we'll pass the matrix directly to computeBoundsShapeData, to avoid the double conversion.
const bool isOBB = PxAbs(t.q.w) < 0.999999f;
if(isOBB)
{
// PT: writes 4 bytes after 'rot' but it's safe since we then write 'center' just afterwards
buildFrom(mGuBox, t.q);
}
else
{
mGuBox.rot = PxMat33(PxIdentity);
}
// PT: can't use V4Load here since there's no guarantee on 't.p'
// PT: must store 'center' after 'rot' now
mGuBox.center = t.p;
// Compute AABB, used by the BucketPruner as cullBox
switch(g.getType())
{
case PxGeometryType::eSPHERE:
{
const PxSphereGeometry& shape = static_cast<const PxSphereGeometry&>(g);
computeMinMaxBounds(&mPrunerInflatedAABB, mGuBox.center, PxVec3(0.0f), SQ_PRUNER_INFLATION, shape.radius+inflation);
//
reinterpret_cast<Sphere&>(mGuSphere) = Sphere(t.p, shape.radius);
}
break;
case PxGeometryType::eCAPSULE:
{
const PxCapsuleGeometry& shape = static_cast<const PxCapsuleGeometry&>(g);
const PxVec3p extents = mGuBox.rot.column0.abs() * shape.halfHeight;
computeMinMaxBounds(&mPrunerInflatedAABB, mGuBox.center, extents, SQ_PRUNER_INFLATION, shape.radius+inflation);
//
Capsule& dstWorldCapsule = reinterpret_cast<Capsule&>(mGuCapsule); // store a narrow phase version copy
getCapsule(dstWorldCapsule, shape, t);
mGuBox.extents.x = shape.halfHeight;
// compute PxBoxGeometry pruner geom around input capsule geom; transform remains unchanged
computeBoxExtentsAroundCapsule(mPrunerBoxGeomExtents, shape, SQ_PRUNER_INFLATION);
}
break;
case PxGeometryType::eBOX:
{
const PxBoxGeometry& shape = static_cast<const PxBoxGeometry&>(g);
// PT: cast is safe because 'rot' followed by other members
Vec4V extentsV = basisExtentV(static_cast<const PxMat33Padded&>(mGuBox.rot), shape.halfExtents, inflation, SQ_PRUNER_INFLATION);
// PT: c/e-to-m/M conversion
const Vec4V centerV = V4LoadU(&mGuBox.center.x);
const Vec4V minV = V4Sub(centerV, extentsV);
const Vec4V maxV = V4Add(centerV, extentsV);
V4StoreU(minV, &mPrunerInflatedAABB.minimum.x);
V4StoreU(maxV, &mPrunerInflatedAABB.maximum.x); // PT: WARNING: writes past end of class
//
mGuBox.extents = shape.halfExtents; // PT: TODO: use SIMD
mPrunerBoxGeomExtents = shape.halfExtents*SQ_PRUNER_INFLATION;
}
break;
case PxGeometryType::eCONVEXMESH:
{
const PxConvexMeshGeometry& shape = static_cast<const PxConvexMeshGeometry&>(g);
const ConvexMesh* cm = static_cast<const ConvexMesh*>(shape.convexMesh);
const ConvexHullData* hullData = &cm->getHull();
// PT: cast is safe since 'rot' is followed by other members of the box
PxVec3p center, extents;
computeMeshBounds(mGuBox.center, static_cast<const PxMat33Padded&>(mGuBox.rot), &hullData->getPaddedBounds(), shape.scale, center, extents);
computeMinMaxBounds(&mPrunerInflatedAABB, center, extents, SQ_PRUNER_INFLATION, inflation);
//
Box prunerBox;
computeOBBAroundConvex(prunerBox, shape, cm, t);
mGuBox.rot = prunerBox.rot; // PT: TODO: optimize this copy
// AP: pruners are now responsible for growing the OBB by 1% for overlap/sweep/GJK accuracy
mPrunerBoxGeomExtents = prunerBox.extents*SQ_PRUNER_INFLATION;
mGuBox.center = prunerBox.center;
}
break;
default:
PX_ALWAYS_ASSERT_MESSAGE("PhysX internal error: Invalid shape in ShapeData contructor.");
}
// PT: WARNING: these writes must stay after the above code
mIsOBB = PxU32(isOBB);
mType = PxU16(g.getType());
}
| 23,441 | C++ | 36.932039 | 222 | 0.738194 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuMeshFactory.cpp | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "common/PxInsertionCallback.h"
#include "GuCooking.h"
#include "GuMeshFactory.h"
#include "GuTriangleMeshBV4.h"
#include "GuTriangleMeshRTree.h"
#include "GuTetrahedronMesh.h"
#include "GuConvexMesh.h"
#include "GuBVH.h"
#include "GuHeightField.h"
#if PX_SUPPORT_OMNI_PVD
# define OMNI_PVD_NOTIFY_ADD(OBJECT) notifyListenersAdd(OBJECT)
# define OMNI_PVD_NOTIFY_REMOVE(OBJECT) notifyListenersRemove(OBJECT)
#else
# define OMNI_PVD_NOTIFY_ADD(OBJECT)
# define OMNI_PVD_NOTIFY_REMOVE(OBJECT)
#endif
using namespace physx;
using namespace Gu;
using namespace Cm;
///////////////////////////////////////////////////////////////////////////////
PX_IMPLEMENT_OUTPUT_ERROR
///////////////////////////////////////////////////////////////////////////////
// PT: TODO: refactor all this with a dedicated container
MeshFactory::MeshFactory() :
mTriangleMeshes ("mesh factory triangle mesh hash"),
mConvexMeshes ("mesh factory convex mesh hash"),
mHeightFields ("mesh factory height field hash"),
mBVHs ("BVH factory hash"),
mFactoryListeners ("FactoryListeners")
{
}
MeshFactory::~MeshFactory()
{
}
///////////////////////////////////////////////////////////////////////////////
template<class T>
static void releaseObjects(PxCoalescedHashSet<T*>& objects)
{
while(objects.size())
{
T* object = objects.getEntries()[0];
PX_ASSERT(RefCountable_getRefCount(*object)==1);
object->release();
}
}
// PT: needed because Gu::BVH is not a PxRefCounted object, although it derives from RefCountable
static void releaseObjects(PxCoalescedHashSet<Gu::BVH*>& objects)
{
while(objects.size())
{
Gu::BVH* object = objects.getEntries()[0];
PX_ASSERT(object->getRefCount()==1);
object->release();
}
}
void MeshFactory::release()
{
// Release all objects in case the user didn't do it
releaseObjects(mTriangleMeshes);
releaseObjects(mTetrahedronMeshes);
releaseObjects(mSoftBodyMeshes);
releaseObjects(mConvexMeshes);
releaseObjects(mHeightFields);
releaseObjects(mBVHs);
PX_DELETE_THIS;
}
template <typename T>
static void addToHash(PxCoalescedHashSet<T*>& hash, T* element, PxMutex* mutex)
{
if(!element)
return;
if(mutex)
mutex->lock();
hash.insert(element);
if(mutex)
mutex->unlock();
}
///////////////////////////////////////////////////////////////////////////////
static void read8BitIndices(PxInputStream& stream, void* tris, PxU32 nbIndices, const bool has16BitIndices)
{
PxU8 x;
if(has16BitIndices)
{
PxU16* tris16 = reinterpret_cast<PxU16*>(tris);
for(PxU32 i=0;i<nbIndices;i++)
{
stream.read(&x, sizeof(PxU8));
*tris16++ = x;
}
}
else
{
PxU32* tris32 = reinterpret_cast<PxU32*>(tris);
for(PxU32 i=0;i<nbIndices;i++)
{
stream.read(&x, sizeof(PxU8));
*tris32++ = x;
}
}
}
static void read16BitIndices(PxInputStream& stream, void* tris, PxU32 nbIndices, const bool has16BitIndices, const bool mismatch)
{
if(has16BitIndices)
{
PxU16* tris16 = reinterpret_cast<PxU16*>(tris);
stream.read(tris16, nbIndices*sizeof(PxU16));
if(mismatch)
{
for(PxU32 i=0;i<nbIndices;i++)
flip(tris16[i]);
}
}
else
{
PxU32* tris32 = reinterpret_cast<PxU32*>(tris);
PxU16 x;
for(PxU32 i=0;i<nbIndices;i++)
{
stream.read(&x, sizeof(PxU16));
if(mismatch)
flip(x);
*tris32++ = x;
}
}
}
static void read32BitIndices(PxInputStream& stream, void* tris, PxU32 nbIndices, const bool has16BitIndices, const bool mismatch)
{
if(has16BitIndices)
{
PxU32 x;
PxU16* tris16 = reinterpret_cast<PxU16*>(tris);
for(PxU32 i=0;i<nbIndices;i++)
{
stream.read(&x, sizeof(PxU32));
if(mismatch)
flip(x);
*tris16++ = PxTo16(x);
}
}
else
{
PxU32* tris32 = reinterpret_cast<PxU32*>(tris);
stream.read(tris32, nbIndices*sizeof(PxU32));
if(mismatch)
{
for(PxU32 i=0;i<nbIndices;i++)
flip(tris32[i]);
}
}
}
static TriangleMeshData* loadMeshData(PxInputStream& stream)
{
// Import header
PxU32 version;
bool mismatch;
if(!readHeader('M', 'E', 'S', 'H', version, mismatch, stream))
return NULL;
PxU32 midphaseID = PxMeshMidPhase::eBVH33; // Default before version 14
if(version>=14) // this refers to PX_MESH_VERSION
midphaseID = readDword(mismatch, stream);
// Check if old (incompatible) mesh format is loaded
if (version <= 9) // this refers to PX_MESH_VERSION
{
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "Loading triangle mesh failed: "
"Deprecated mesh cooking format. Please recook your mesh in a new cooking format.");
PX_ALWAYS_ASSERT_MESSAGE("Obsolete cooked mesh found. Mesh version has been updated, please recook your meshes.");
return NULL;
}
// Import serialization flags
const PxU32 serialFlags = readDword(mismatch, stream);
// Import misc values
if (version <= 12) // this refers to PX_MESH_VERSION
{
// convexEdgeThreshold was removed in 3.4.0
readFloat(mismatch, stream);
}
TriangleMeshData* data;
if(midphaseID==PxMeshMidPhase::eBVH33)
data = PX_NEW(RTreeTriangleData);
else if(midphaseID==PxMeshMidPhase::eBVH34)
data = PX_NEW(BV4TriangleData);
else return NULL;
// Import mesh
PxVec3* verts = data->allocateVertices(readDword(mismatch, stream));
const PxU32 nbTris = readDword(mismatch, stream);
const bool force32 = (serialFlags & (IMSF_8BIT_INDICES|IMSF_16BIT_INDICES)) == 0;
//ML: this will allocate CPU triangle indices and GPU triangle indices if we have GRB data built
void* tris = data->allocateTriangles(nbTris, force32, serialFlags & IMSF_GRB_DATA);
stream.read(verts, sizeof(PxVec3)*data->mNbVertices);
if(mismatch)
{
for(PxU32 i=0;i<data->mNbVertices;i++)
{
flip(verts[i].x);
flip(verts[i].y);
flip(verts[i].z);
}
}
//TODO: stop support for format conversion on load!!
const PxU32 nbIndices = 3*data->mNbTriangles;
if(serialFlags & IMSF_8BIT_INDICES)
read8BitIndices(stream, tris, nbIndices, data->has16BitIndices());
else if(serialFlags & IMSF_16BIT_INDICES)
read16BitIndices(stream, tris, nbIndices, data->has16BitIndices(), mismatch);
else
read32BitIndices(stream, tris, nbIndices, data->has16BitIndices(), mismatch);
if(serialFlags & IMSF_MATERIALS)
{
PxU16* materials = data->allocateMaterials();
stream.read(materials, sizeof(PxU16)*data->mNbTriangles);
if(mismatch)
{
for(PxU32 i=0;i<data->mNbTriangles;i++)
flip(materials[i]);
}
}
if(serialFlags & IMSF_FACE_REMAP)
{
PxU32* remap = data->allocateFaceRemap();
readIndices(readDword(mismatch, stream), data->mNbTriangles, remap, stream, mismatch);
}
if(serialFlags & IMSF_ADJACENCIES)
{
PxU32* adj = data->allocateAdjacencies();
stream.read(adj, sizeof(PxU32)*data->mNbTriangles*3);
if(mismatch)
{
for(PxU32 i=0;i<data->mNbTriangles*3;i++)
flip(adj[i]);
}
}
// PT: TODO better
if(midphaseID==PxMeshMidPhase::eBVH33)
{
if(!static_cast<RTreeTriangleData*>(data)->mRTree.load(stream, version, mismatch))
{
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "RTree binary image load error.");
PX_DELETE(data);
return NULL;
}
}
else if(midphaseID==PxMeshMidPhase::eBVH34)
{
BV4TriangleData* bv4data = static_cast<BV4TriangleData*>(data);
if(!bv4data->mBV4Tree.load(stream, mismatch))
{
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "BV4 binary image load error.");
PX_DELETE(data);
return NULL;
}
bv4data->mMeshInterface.setNbTriangles(nbTris);
bv4data->mMeshInterface.setNbVertices(data->mNbVertices);
if(data->has16BitIndices())
bv4data->mMeshInterface.setPointers(NULL, reinterpret_cast<IndTri16*>(tris), verts);
else
bv4data->mMeshInterface.setPointers(reinterpret_cast<IndTri32*>(tris), NULL, verts);
bv4data->mBV4Tree.mMeshInterface = &bv4data->mMeshInterface;
}
else PX_ASSERT(0);
// Import local bounds
data->mGeomEpsilon = readFloat(mismatch, stream);
readFloatBuffer(&data->mAABB.minimum.x, 6, mismatch, stream);
PxU32 nb = readDword(mismatch, stream);
if(nb)
{
PX_ASSERT(nb==data->mNbTriangles);
data->allocateExtraTrigData();
// No need to convert those bytes
stream.read(data->mExtraTrigData, nb*sizeof(PxU8));
}
if(serialFlags & IMSF_GRB_DATA)
{
PxU32 GRB_meshAdjVerticiesTotal = 0;
if(version < 15)
GRB_meshAdjVerticiesTotal = readDword(mismatch, stream);
//read grb triangle indices
PX_ASSERT(data->mGRB_primIndices);
if(serialFlags & IMSF_8BIT_INDICES)
read8BitIndices(stream, data->mGRB_primIndices, nbIndices, data->has16BitIndices());
else if(serialFlags & IMSF_16BIT_INDICES)
read16BitIndices(stream, data->mGRB_primIndices, nbIndices, data->has16BitIndices(), mismatch);
else
read32BitIndices(stream, data->mGRB_primIndices, nbIndices, data->has16BitIndices(), mismatch);
data->mGRB_primAdjacencies = PX_ALLOCATE(PxU32, data->mNbTriangles*4, "mGRB_primAdjacencies");
data->mGRB_faceRemap = PX_ALLOCATE(PxU32, data->mNbTriangles, "mGRB_faceRemap");
if(serialFlags & IMSF_GRB_INV_REMAP)
data->mGRB_faceRemapInverse = PX_ALLOCATE(PxU32, data->mNbTriangles, "mGRB_faceRemapInverse");
stream.read(data->mGRB_primAdjacencies, sizeof(PxU32)*data->mNbTriangles*4);
if (version < 15)
{
//stream.read(data->mGRB_vertValency, sizeof(PxU32)*data->mNbVertices);
for (PxU32 i = 0; i < data->mNbVertices; ++i)
readDword(mismatch, stream);
//stream.read(data->mGRB_adjVertStart, sizeof(PxU32)*data->mNbVertices);
for (PxU32 i = 0; i < data->mNbVertices; ++i)
readDword(mismatch, stream);
//stream.read(data->mGRB_adjVertices, sizeof(PxU32)*GRB_meshAdjVerticiesTotal);
for (PxU32 i = 0; i < GRB_meshAdjVerticiesTotal; ++i)
readDword(mismatch, stream);
}
stream.read(data->mGRB_faceRemap, sizeof(PxU32)*data->mNbTriangles);
if(data->mGRB_faceRemapInverse)
stream.read(data->mGRB_faceRemapInverse, sizeof(PxU32)*data->mNbTriangles);
if(mismatch)
{
for(PxU32 i=0;i<data->mNbTriangles*4;i++)
flip(reinterpret_cast<PxU32 *>(data->mGRB_primIndices)[i]);
for(PxU32 i=0;i<data->mNbTriangles*4;i++)
flip(reinterpret_cast<PxU32 *>(data->mGRB_primAdjacencies)[i]);
}
//read BV32
data->mGRB_BV32Tree = PX_NEW(BV32Tree);
if (!data->mGRB_BV32Tree->load(stream, mismatch))
{
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "BV32 binary image load error.");
PX_DELETE(data);
return NULL;
}
if (serialFlags & IMSF_VERT_MAPPING)
{
//import vertex mapping data
data->mNbTrianglesReferences = readDword(mismatch, stream);
data->mAccumulatedTrianglesRef = PX_ALLOCATE(PxU32, data->mNbVertices, "mAccumulatedTrianglesRef");
data->mTrianglesReferences = PX_ALLOCATE(PxU32, data->mNbTrianglesReferences, "mTrianglesReferences");
stream.read(data->mAccumulatedTrianglesRef, data->mNbVertices * sizeof(PxU32));
stream.read(data->mTrianglesReferences, data->mNbTrianglesReferences * sizeof(PxU32));
}
}
if (serialFlags & IMSF_SDF)
{
// Import sdf
SDF& sdfData = data->mSdfData;
sdfData.mMeshLower.x = readFloat(mismatch, stream);
sdfData.mMeshLower.y = readFloat(mismatch, stream);
sdfData.mMeshLower.z = readFloat(mismatch, stream);
sdfData.mSpacing = readFloat(mismatch, stream);
sdfData.mDims.x = readDword(mismatch, stream);
sdfData.mDims.y = readDword(mismatch, stream);
sdfData.mDims.z = readDword(mismatch, stream);
sdfData.mNumSdfs = readDword(mismatch, stream);
sdfData.mNumSubgridSdfs = readDword(mismatch, stream);
sdfData.mNumStartSlots = readDword(mismatch, stream);
sdfData.mSubgridSize = readDword(mismatch, stream);
sdfData.mSdfSubgrids3DTexBlockDim.x = readDword(mismatch, stream);
sdfData.mSdfSubgrids3DTexBlockDim.y = readDword(mismatch, stream);
sdfData.mSdfSubgrids3DTexBlockDim.z = readDword(mismatch, stream);
sdfData.mSubgridsMinSdfValue = readFloat(mismatch, stream);
sdfData.mSubgridsMaxSdfValue = readFloat(mismatch, stream);
sdfData.mBytesPerSparsePixel = readDword(mismatch, stream);
PxReal* sdf = sdfData.allocateSdfs(sdfData.mMeshLower, sdfData.mSpacing, sdfData.mDims.x, sdfData.mDims.y, sdfData.mDims.z,
sdfData.mSubgridSize, sdfData.mSdfSubgrids3DTexBlockDim.x, sdfData.mSdfSubgrids3DTexBlockDim.y, sdfData.mSdfSubgrids3DTexBlockDim.z,
sdfData.mSubgridsMinSdfValue, sdfData.mSubgridsMaxSdfValue, sdfData.mBytesPerSparsePixel);
stream.read(sdf, sizeof(PxReal) * sdfData.mNumSdfs);
readByteBuffer(sdfData.mSubgridSdf, sdfData.mNumSubgridSdfs, stream);
readIntBuffer(sdfData.mSubgridStartSlots, sdfData.mNumStartSlots, mismatch, stream);
}
if (serialFlags & IMSF_INERTIA)
{
// Import inertia
stream.read(&data->mMass, sizeof(PxReal));
readFloatBuffer(&data->mInertia(0, 0), 9, mismatch, stream);
readFloatBuffer(&data->mLocalCenterOfMass.x, 3, mismatch, stream);
}
return data;
}
static void readIndices(const PxU32 serialFlags, void* indices, const PxU32 nbIndices,
const bool has16BitIndices, const bool mismatch, PxInputStream& stream)
{
if(serialFlags & IMSF_8BIT_INDICES)
read8BitIndices(stream, indices, nbIndices, has16BitIndices);
else if(serialFlags & IMSF_16BIT_INDICES)
read16BitIndices(stream, indices, nbIndices, has16BitIndices, mismatch);
else
read32BitIndices(stream, indices, nbIndices, has16BitIndices, mismatch);
}
void MeshFactory::addTriangleMesh(TriangleMesh* np, bool lock)
{
addToHash(mTriangleMeshes, np, lock ? &mTrackingMutex : NULL);
OMNI_PVD_NOTIFY_ADD(np);
}
PxTriangleMesh* MeshFactory::createTriangleMesh(TriangleMeshData& data)
{
TriangleMesh* np;
if(data.mType==PxMeshMidPhase::eBVH33)
{
PX_NEW_SERIALIZED(np, RTreeTriangleMesh)(this, data);
}
else if(data.mType==PxMeshMidPhase::eBVH34)
{
PX_NEW_SERIALIZED(np, BV4TriangleMesh)(this, data);
}
else return NULL;
if(np)
addTriangleMesh(np);
return np;
}
// data injected by cooking lib for runtime cooking
PxTriangleMesh* MeshFactory::createTriangleMesh(void* data)
{
return createTriangleMesh(*reinterpret_cast<TriangleMeshData*>(data));
}
PxTriangleMesh* MeshFactory::createTriangleMesh(PxInputStream& desc)
{
TriangleMeshData* data = ::loadMeshData(desc);
if(!data)
return NULL;
PxTriangleMesh* m = createTriangleMesh(*data);
PX_DELETE(data);
return m;
}
bool MeshFactory::removeTriangleMesh(PxTriangleMesh& m)
{
TriangleMesh* gu = static_cast<TriangleMesh*>(&m);
OMNI_PVD_NOTIFY_REMOVE(gu);
PxMutex::ScopedLock lock(mTrackingMutex);
bool found = mTriangleMeshes.erase(gu);
return found;
}
PxU32 MeshFactory::getNbTriangleMeshes() const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return mTriangleMeshes.size();
}
PxU32 MeshFactory::getTriangleMeshes(PxTriangleMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return getArrayOfPointers(userBuffer, bufferSize, startIndex, mTriangleMeshes.getEntries(), mTriangleMeshes.size());
}
///////////////////////////////////////////////////////////////////////////////
static TetrahedronMeshData* loadTetrahedronMeshData(PxInputStream& stream)
{
// Import header
PxU32 version;
bool mismatch;
if (!readHeader('T', 'E', 'M', 'E', version, mismatch, stream))
return NULL;
// Import serialization flags
const PxU32 serialFlags = readDword(mismatch, stream);
TetrahedronMeshData* data = PX_NEW(TetrahedronMeshData);
// Import mesh
const PxU32 nbVerts = readDword(mismatch, stream);
PxVec3* verts = data->allocateVertices(nbVerts);
//const PxU32 nbSurfaceTriangles = readDword(mismatch, stream);
const PxU32 nbTetrahedrons = readDword(mismatch, stream);
//ML: this will allocate CPU tetrahedron indices and GPU tetrahedron indices and other GPU data if we have GRB data built
//void* tets = data->allocateTetrahedrons(nbTetrahedrons, serialFlags & IMSF_GRB_DATA);
data->allocateTetrahedrons(nbTetrahedrons, 1);
void* tets = data->mTetrahedrons;
stream.read(verts, sizeof(PxVec3)*data->mNbVertices);
//stream.read(restPoses, sizeof(PxMat33) * data->mNbTetrahedrons);
if (mismatch)
{
for (PxU32 i = 0; i < data->mNbVertices; i++)
{
flip(verts[i].x);
flip(verts[i].y);
flip(verts[i].z);
}
}
//TODO: stop support for format conversion on load!!
const PxU32 nbTetIndices = 4 * data->mNbTetrahedrons;
readIndices(serialFlags, tets, nbTetIndices, data->has16BitIndices(), mismatch, stream);
// Import local bounds
data->mGeomEpsilon = readFloat(mismatch, stream);
readFloatBuffer(&data->mAABB.minimum.x, 6, mismatch, stream);
return data;
}
static bool loadSoftBodyMeshData(PxInputStream& stream, SoftBodyMeshData& data)
{
// Import header
PxU32 version;
bool mismatch;
if (!readHeader('S', 'O', 'M', 'E', version, mismatch, stream))
return false;
// Import serialization flags
const PxU32 serialFlags = readDword(mismatch, stream);
// Import mesh
const PxU32 nbVerts = readDword(mismatch, stream);
PxVec3* verts = data.mCollisionMesh.allocateVertices(nbVerts);
//const PxU32 nbSurfaceTriangles = readDword(mismatch, stream);
const PxU32 nbTetrahedrons= readDword(mismatch, stream);
//ML: this will allocate CPU tetrahedron indices and GPU tetrahedron indices and other GPU data if we have GRB data built
//void* tets = data.allocateTetrahedrons(nbTetrahedrons, serialFlags & IMSF_GRB_DATA);
data.mCollisionMesh.allocateTetrahedrons(nbTetrahedrons, 1);
if (serialFlags & IMSF_GRB_DATA)
data.mCollisionData.allocateCollisionData(nbTetrahedrons);
void* tets = data.mCollisionMesh.mTetrahedrons;
//void* surfaceTriangles = data.mCollisionData.allocateSurfaceTriangles(nbSurfaceTriangles);
//void* restPoses = data.mTetraRestPoses;
stream.read(verts, sizeof(PxVec3)*nbVerts);
//stream.read(restPoses, sizeof(PxMat33) * data.mNbTetrahedrons);
if (mismatch)
{
for (PxU32 i = 0; i< nbVerts; i++)
{
flip(verts[i].x);
flip(verts[i].y);
flip(verts[i].z);
}
}
//TODO: stop support for format conversion on load!!
const PxU32 nbTetIndices = 4 * nbTetrahedrons;
readIndices(serialFlags, tets, nbTetIndices, data.mCollisionMesh.has16BitIndices(), mismatch, stream);
//const PxU32 nbSurfaceTriangleIndices = 3 * nbSurfaceTriangles;
//readIndices(serialFlags, surfaceTriangles, nbSurfaceTriangleIndices, data.mCollisionMesh.has16BitIndices(), mismatch, stream);
////using IMSF_ADJACENCIES for tetMesh tetrahedron surface hint
//if (serialFlags & IMSF_ADJACENCIES)
//{
// PxU8* surfaceHints = reinterpret_cast<PxU8*>(data.mTetraSurfaceHint);
// stream.read(surfaceHints, sizeof(PxU8)*data.mNbTetrahedrons);
//}
if (serialFlags & IMSF_MATERIALS)
{
PxU16* materials = data.mCollisionMesh.allocateMaterials();
stream.read(materials, sizeof(PxU16)*nbTetrahedrons);
if (mismatch)
{
for (PxU32 i = 0; i < nbTetrahedrons; i++)
flip(materials[i]);
}
}
if (serialFlags & IMSF_FACE_REMAP)
{
PxU32* remap = data.mCollisionData.allocateFaceRemap(nbTetrahedrons);
readIndices(readDword(mismatch, stream), nbTetrahedrons, remap, stream, mismatch);
}
/*if (serialFlags & IMSF_ADJACENCIES)
{
PxU32* adj = data.allocateAdjacencies();
stream.read(adj, sizeof(PxU32)*data.mNbTetrahedrons * 4);
if (mismatch)
{
for (PxU32 i = 0; i<data.mNbTetrahedrons * 4; i++)
flip(adj[i]);
}
}*/
SoftBodyMeshData* bv4data = &data;
if (!bv4data->mCollisionData.mBV4Tree.load(stream, mismatch))
{
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "BV4 binary image load error.");
//PX_DELETE(data);
return false;
}
bv4data->mCollisionData.mMeshInterface.setNbTetrahedrons(nbTetrahedrons);
bv4data->mCollisionData.mMeshInterface.setNbVertices(nbVerts);
if (data.mCollisionMesh.has16BitIndices())
bv4data->mCollisionData.mMeshInterface.setPointers(NULL, reinterpret_cast<IndTetrahedron16*>(tets), verts);
else
bv4data->mCollisionData.mMeshInterface.setPointers(reinterpret_cast<IndTetrahedron32*>(tets), NULL, verts);
bv4data->mCollisionData.mBV4Tree.mMeshInterface = &bv4data->mCollisionData.mMeshInterface;
// Import local bounds
data.mCollisionMesh.mGeomEpsilon = readFloat(mismatch, stream);
readFloatBuffer(&data.mCollisionMesh.mAABB.minimum.x, 6, mismatch, stream);
if (serialFlags & IMSF_GRB_DATA)
{
/*PxU32 GRB_meshAdjVerticiesTotal = 0;
if (version < 15)
GRB_meshAdjVerticiesTotal = readDword(mismatch, stream);*/
//read grb tetrahedron indices
PX_ASSERT(data.mCollisionData.mGRB_primIndices);
//read tetrahedron indices
readIndices(serialFlags, data.mCollisionData.mGRB_primIndices, nbTetIndices, data.mCollisionMesh.has16BitIndices(), mismatch, stream);
//data.mGRB_primAdjacencies = static_cast<void *>(PX_NEW(PxU32)[data.mNbTetrahedrons * 4]);
//data.mGRB_surfaceTriIndices = static_cast<void *>(PX_NEW(PxU32)[data.mNbTriangles * 3]);
data.mCollisionData.mGRB_faceRemap = PX_ALLOCATE(PxU32, data.mCollisionMesh.mNbTetrahedrons, "mGRB_faceRemap");
data.mCollisionData.mGRB_faceRemapInverse = PX_ALLOCATE(PxU32, data.mCollisionMesh.mNbTetrahedrons, "mGRB_faceRemapInverse");
//data.mGRB_surfaceTriangleIndice = PX_NEW(PxU32)[data.mNbSurfaceTriangles * 3];
//stream.read(data.mGRB_primAdjacencies, sizeof(PxU32)*data.mNbTetrahedrons * 4);
stream.read(data.mCollisionData.mGRB_tetraSurfaceHint, sizeof(PxU8) * data.mCollisionMesh.mNbTetrahedrons);
stream.read(data.mCollisionData.mGRB_faceRemap, sizeof(PxU32) * data.mCollisionMesh.mNbTetrahedrons);
stream.read(data.mCollisionData.mGRB_faceRemapInverse, sizeof(PxU32) * data.mCollisionMesh.mNbTetrahedrons);
//stream.read(data.mGRB_surfaceTriangleIndice, sizeof(PxU32) * data.mNbSurfaceTriangles * 3);
stream.read(data.mCollisionData.mTetraRestPoses, sizeof(PxMat33) * nbTetrahedrons);
if (mismatch)
{
for (PxU32 i = 0; i<data.mCollisionMesh.mNbTetrahedrons * 4; i++)
flip(reinterpret_cast<PxU32 *>(data.mCollisionData.mGRB_primIndices)[i]);
}
//read BV32
data.mCollisionData.mGRB_BV32Tree = PX_NEW(BV32Tree);
if (!data.mCollisionData.mGRB_BV32Tree->load(stream, mismatch))
{
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "BV32 binary image load error.");
//PX_DELETE(data);
return false;
}
const PxU32 nbGridModelTetrahedrons = readDword(mismatch, stream);
const PxU32 nbGridModelVertices = readDword(mismatch, stream);
const PxU32 nbGridModelPartitions = readDword(mismatch, stream);
const PxU32 nbGMMaxTetsPerPartition = readDword(mismatch, stream);
const PxU32 nbGMRemapOutputSize = readDword(mismatch, stream);
PxU32 numTetsPerElement = 1;
if(version >= 2)
numTetsPerElement = readDword(mismatch, stream);
const PxU32 nbGMTotalTetReferenceCount = readDword(mismatch, stream);
const PxU32 nbTetRemapSize = readDword(mismatch, stream);
const PxU32 numVertsPerElement = (numTetsPerElement == 5 || numTetsPerElement == 6) ? 8 : 4;
const PxU32 numSimElements = nbGridModelTetrahedrons / numTetsPerElement;
data.mSimulationData.mGridModelMaxTetsPerPartitions = nbGMMaxTetsPerPartition;
data.mSimulationData.mNumTetsPerElement = numTetsPerElement;
data.mMappingData.mTetsRemapSize = nbTetRemapSize;
/*data.allocateGridModelData(nbGridModelTetrahedrons, nbGridModelVertices,
data.mCollisionMesh.mNbVertices, nbGridModelPartitions, nbGMRemapOutputSize,
nbGMTotalTetReferenceCount, nbTetRemapSize, data.mCollisionMesh.mNbTetrahedrons,
serialFlags & IMSF_GRB_DATA);*/
data.mSimulationMesh.allocateTetrahedrons(nbGridModelTetrahedrons, serialFlags & IMSF_GRB_DATA);
data.mSimulationMesh.allocateVertices(nbGridModelVertices, serialFlags & IMSF_GRB_DATA);
data.mSimulationData.allocateGridModelData(nbGridModelTetrahedrons, nbGridModelVertices,
data.mCollisionMesh.mNbVertices, nbGridModelPartitions, nbGMRemapOutputSize, numTetsPerElement, serialFlags & IMSF_GRB_DATA);
data.mMappingData.allocatemappingData(data.mCollisionMesh.mNbVertices, nbTetRemapSize, data.mCollisionMesh.mNbTetrahedrons, serialFlags & IMSF_GRB_DATA);
data.mMappingData.allocateTetRefData(nbGMTotalTetReferenceCount, data.mCollisionMesh.mNbVertices, serialFlags & IMSF_GRB_DATA);
const PxU32 nbGridModelIndices = 4 * nbGridModelTetrahedrons;
readIndices(serialFlags, data.mSimulationMesh.mTetrahedrons, nbGridModelIndices, data.mSimulationMesh.has16BitIndices(), mismatch, stream);
//stream.read(data.mGridModelVerticesInvMass, sizeof(PxVec4) * nbGridModelVertices);
stream.read(data.mSimulationMesh.mVertices, sizeof(PxVec3) * nbGridModelVertices);
if (serialFlags & IMSF_MATERIALS)
{
PxU16* materials = data.mSimulationMesh.allocateMaterials();
stream.read(materials, sizeof(PxU16)*nbGridModelTetrahedrons);
if (mismatch)
{
for (PxU32 i = 0; i < nbTetrahedrons; i++)
flip(materials[i]);
}
}
stream.read(data.mSimulationData.mGridModelInvMass, sizeof(PxReal) * nbGridModelVertices);
stream.read(data.mSimulationData.mGridModelTetraRestPoses, sizeof(PxMat33) * nbGridModelTetrahedrons);
stream.read(data.mSimulationData.mGridModelOrderedTetrahedrons, sizeof(PxU32) * numSimElements);
stream.read(data.mSimulationData.mGMRemapOutputCP, sizeof(PxU32) * numSimElements * numVertsPerElement);
stream.read(data.mSimulationData.mGMAccumulatedPartitionsCP, sizeof(PxU32) * nbGridModelPartitions);
stream.read(data.mSimulationData.mGMAccumulatedCopiesCP, sizeof(PxU32) * data.mSimulationMesh.mNbVertices);
stream.read(data.mMappingData.mCollisionAccumulatedTetrahedronsRef, sizeof(PxU32) * data.mCollisionMesh.mNbVertices);
stream.read(data.mMappingData.mCollisionTetrahedronsReferences, sizeof(PxU32) * data.mMappingData.mCollisionNbTetrahedronsReferences);
stream.read(data.mMappingData.mCollisionSurfaceVertsHint, sizeof(PxU8) * data.mCollisionMesh.mNbVertices);
stream.read(data.mMappingData.mCollisionSurfaceVertToTetRemap, sizeof(PxU32) * data.mCollisionMesh.mNbVertices);
//stream.read(data->mVertsBarycentricInGridModel, sizeof(PxReal) * 4 * data->mNbVertices);
stream.read(data.mSimulationData.mGMPullIndices, sizeof(PxU32) * numSimElements * numVertsPerElement);
//stream.read(data->mVertsBarycentricInGridModel, sizeof(PxReal) * 4 * data->mNbVertices);
stream.read(data.mMappingData.mVertsBarycentricInGridModel, sizeof(PxReal) * 4 * data.mCollisionMesh.mNbVertices);
stream.read(data.mMappingData.mVertsRemapInGridModel, sizeof(PxU32) * data.mCollisionMesh.mNbVertices);
stream.read(data.mMappingData.mTetsRemapColToSim, sizeof(PxU32) *nbTetRemapSize);
stream.read(data.mMappingData.mTetsAccumulatedRemapColToSim, sizeof(PxU32) * data.mCollisionMesh.mNbTetrahedrons);
}
return true;
}
void MeshFactory::addTetrahedronMesh(TetrahedronMesh* np, bool lock)
{
addToHash(mTetrahedronMeshes, np, lock ? &mTrackingMutex : NULL);
OMNI_PVD_NOTIFY_ADD(np);
}
void MeshFactory::addSoftBodyMesh(SoftBodyMesh* np, bool lock)
{
addToHash(mSoftBodyMeshes, np, lock ? &mTrackingMutex : NULL);
OMNI_PVD_NOTIFY_ADD(np);
}
PxSoftBodyMesh* MeshFactory::createSoftBodyMesh(PxInputStream& desc)
{
TetrahedronMeshData mSimulationMesh;
SoftBodySimulationData mSimulationData;
TetrahedronMeshData mCollisionMesh;
SoftBodyCollisionData mCollisionData;
CollisionMeshMappingData mMappingData;
SoftBodyMeshData data(mSimulationMesh, mSimulationData, mCollisionMesh, mCollisionData, mMappingData);
if (!::loadSoftBodyMeshData(desc, data))
return NULL;
PxSoftBodyMesh* m = createSoftBodyMesh(data);
return m;
}
PxTetrahedronMesh* MeshFactory::createTetrahedronMesh(PxInputStream& desc)
{
TetrahedronMeshData* data = ::loadTetrahedronMeshData(desc);
if (!data)
return NULL;
PxTetrahedronMesh* m = createTetrahedronMesh(*data);
PX_DELETE(data);
return m;
}
PxTetrahedronMesh* MeshFactory::createTetrahedronMesh(TetrahedronMeshData& data)
{
TetrahedronMesh* np = NULL;
PX_NEW_SERIALIZED(np, TetrahedronMesh)(this, data);
if (np)
addTetrahedronMesh(np);
return np;
}
// data injected by cooking lib for runtime cooking
PxTetrahedronMesh* MeshFactory::createTetrahedronMesh(void* data)
{
return createTetrahedronMesh(*reinterpret_cast<TetrahedronMeshData*>(data));
}
PxSoftBodyMesh* MeshFactory::createSoftBodyMesh(Gu::SoftBodyMeshData& data)
{
SoftBodyMesh* np = NULL;
PX_NEW_SERIALIZED(np, SoftBodyMesh)(this, data);
if (np)
addSoftBodyMesh(np);
return np;
}
// data injected by cooking lib for runtime cooking
PxSoftBodyMesh* MeshFactory::createSoftBodyMesh(void* data)
{
return createSoftBodyMesh(*reinterpret_cast<SoftBodyMeshData*>(data));
}
bool MeshFactory::removeSoftBodyMesh(PxSoftBodyMesh& tetMesh)
{
SoftBodyMesh* gu = static_cast<SoftBodyMesh*>(&tetMesh);
OMNI_PVD_NOTIFY_REMOVE(gu);
PxMutex::ScopedLock lock(mTrackingMutex);
bool found = mSoftBodyMeshes.erase(gu);
return found;
}
bool MeshFactory::removeTetrahedronMesh(PxTetrahedronMesh& tetMesh)
{
TetrahedronMesh* gu = static_cast<TetrahedronMesh*>(&tetMesh);
OMNI_PVD_NOTIFY_REMOVE(gu);
PxMutex::ScopedLock lock(mTrackingMutex);
bool found = mTetrahedronMeshes.erase(gu);
return found;
}
PxU32 MeshFactory::getNbSoftBodyMeshes() const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return mSoftBodyMeshes.size();
}
PxU32 MeshFactory::getNbTetrahedronMeshes() const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return mTetrahedronMeshes.size();
}
PxU32 MeshFactory::getTetrahedronMeshes(PxTetrahedronMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return getArrayOfPointers(userBuffer, bufferSize, startIndex, mTetrahedronMeshes.getEntries(), mTetrahedronMeshes.size());
}
PxU32 MeshFactory::getSoftBodyMeshes(PxSoftBodyMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return getArrayOfPointers(userBuffer, bufferSize, startIndex, mSoftBodyMeshes.getEntries(), mSoftBodyMeshes.size());
}
///////////////////////////////////////////////////////////////////////////////
void MeshFactory::addConvexMesh(ConvexMesh* np, bool lock)
{
addToHash(mConvexMeshes, np, lock ? &mTrackingMutex : NULL);
OMNI_PVD_NOTIFY_ADD(np);
}
// data injected by cooking lib for runtime cooking
PxConvexMesh* MeshFactory::createConvexMesh(void* data)
{
return createConvexMesh(*reinterpret_cast<ConvexHullInitData*>(data));
}
PxConvexMesh* MeshFactory::createConvexMesh(ConvexHullInitData& data)
{
ConvexMesh* np;
PX_NEW_SERIALIZED(np, ConvexMesh)(this, data);
if (np)
addConvexMesh(np);
return np;
}
PxConvexMesh* MeshFactory::createConvexMesh(PxInputStream& desc)
{
ConvexMesh* np;
PX_NEW_SERIALIZED(np, ConvexMesh)(this);
if(!np)
return NULL;
if(!np->load(desc))
{
Cm::deletePxBase(np);
return NULL;
}
addConvexMesh(np);
return np;
}
bool MeshFactory::removeConvexMesh(PxConvexMesh& m)
{
ConvexMesh* gu = static_cast<ConvexMesh*>(&m);
OMNI_PVD_NOTIFY_REMOVE(gu);
PxMutex::ScopedLock lock(mTrackingMutex);
bool found = mConvexMeshes.erase(gu);
return found;
}
PxU32 MeshFactory::getNbConvexMeshes() const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return mConvexMeshes.size();
}
PxU32 MeshFactory::getConvexMeshes(PxConvexMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return getArrayOfPointers(userBuffer, bufferSize, startIndex, mConvexMeshes.getEntries(), mConvexMeshes.size());
}
///////////////////////////////////////////////////////////////////////////////
void MeshFactory::addHeightField(HeightField* np, bool lock)
{
addToHash(mHeightFields, np, lock ? &mTrackingMutex : NULL);
OMNI_PVD_NOTIFY_ADD(np);
}
PxHeightField* MeshFactory::createHeightField(void* heightFieldMeshData)
{
HeightField* np;
PX_NEW_SERIALIZED(np, HeightField)(this, *reinterpret_cast<HeightFieldData*>(heightFieldMeshData));
if(np)
addHeightField(np);
return np;
}
PxHeightField* MeshFactory::createHeightField(PxInputStream& stream)
{
HeightField* np;
PX_NEW_SERIALIZED(np, HeightField)(this);
if(!np)
return NULL;
if(!np->load(stream))
{
Cm::deletePxBase(np);
return NULL;
}
addHeightField(np);
return np;
}
bool MeshFactory::removeHeightField(PxHeightField& hf)
{
HeightField* gu = static_cast<HeightField*>(&hf);
OMNI_PVD_NOTIFY_REMOVE(gu);
PxMutex::ScopedLock lock(mTrackingMutex);
bool found = mHeightFields.erase(gu);
return found;
}
PxU32 MeshFactory::getNbHeightFields() const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return mHeightFields.size();
}
PxU32 MeshFactory::getHeightFields(PxHeightField** userBuffer, PxU32 bufferSize, PxU32 startIndex) const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return getArrayOfPointers(userBuffer, bufferSize, startIndex, mHeightFields.getEntries(), mHeightFields.size());
}
///////////////////////////////////////////////////////////////////////////////
void MeshFactory::addFactoryListener(Gu::MeshFactoryListener& listener )
{
PxMutex::ScopedLock lock(mTrackingMutex);
mFactoryListeners.pushBack( &listener );
}
void MeshFactory::removeFactoryListener(Gu::MeshFactoryListener& listener )
{
PxMutex::ScopedLock lock(mTrackingMutex);
for ( PxU32 idx = 0; idx < mFactoryListeners.size(); ++idx )
{
if ( mFactoryListeners[idx] == &listener )
{
mFactoryListeners.replaceWithLast( idx );
--idx;
}
}
}
void MeshFactory::notifyFactoryListener(const PxBase* base, PxType typeID)
{
const PxU32 nbListeners = mFactoryListeners.size();
for(PxU32 i=0; i<nbListeners; i++)
mFactoryListeners[i]->onMeshFactoryBufferRelease(base, typeID);
}
#if PX_SUPPORT_OMNI_PVD
void MeshFactory::notifyListenersAdd(const PxBase* base)
{
for (PxU32 i = 0; i < mFactoryListeners.size(); i++)
mFactoryListeners[i]->onObjectAdd(base);
}
void MeshFactory::notifyListenersRemove(const PxBase* base)
{
for (PxU32 i = 0; i < mFactoryListeners.size(); i++)
mFactoryListeners[i]->onObjectRemove(base);
}
#endif
///////////////////////////////////////////////////////////////////////////////
void MeshFactory::addBVH(BVH* np, bool lock)
{
addToHash(mBVHs, np, lock ? &mTrackingMutex : NULL);
OMNI_PVD_NOTIFY_ADD(np);
}
// data injected by cooking lib for runtime cooking
PxBVH* MeshFactory::createBVH(void* data)
{
return createBVH(*reinterpret_cast<BVHData*>(data));
}
PxBVH* MeshFactory::createBVH(BVHData& data)
{
BVH* np;
PX_NEW_SERIALIZED(np, BVH)(this, data);
if (np)
addBVH(np);
return np;
}
PxBVH* MeshFactory::createBVH(PxInputStream& desc)
{
BVH* np;
PX_NEW_SERIALIZED(np, BVH)(this);
if(!np)
return NULL;
if(!np->load(desc))
{
Cm::deletePxBase(np);
return NULL;
}
addBVH(np);
return np;
}
bool MeshFactory::removeBVH(PxBVH& m)
{
BVH* gu = static_cast<BVH*>(&m);
OMNI_PVD_NOTIFY_REMOVE(gu);
PxMutex::ScopedLock lock(mTrackingMutex);
bool found = mBVHs.erase(gu);
return found;
}
PxU32 MeshFactory::getNbBVHs() const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return mBVHs.size();
}
PxU32 MeshFactory::getBVHs(PxBVH** userBuffer, PxU32 bufferSize, PxU32 startIndex) const
{
PxMutex::ScopedLock lock(mTrackingMutex);
return getArrayOfPointers(userBuffer, bufferSize, startIndex, mBVHs.getEntries(), mBVHs.size());
}
///////////////////////////////////////////////////////////////////////////////
bool MeshFactory::remove(PxBase& obj)
{
const PxType type = obj.getConcreteType();
if(type==PxConcreteType::eHEIGHTFIELD)
return removeHeightField(static_cast<PxHeightField&>(obj));
else if(type==PxConcreteType::eCONVEX_MESH)
return removeConvexMesh(static_cast<PxConvexMesh&>(obj));
else if(type==PxConcreteType::eTRIANGLE_MESH_BVH33 || type==PxConcreteType::eTRIANGLE_MESH_BVH34)
return removeTriangleMesh(static_cast<PxTriangleMesh&>(obj));
else if(type==PxConcreteType::eTETRAHEDRON_MESH)
return removeTetrahedronMesh(static_cast<PxTetrahedronMesh&>(obj));
else if (type == PxConcreteType::eSOFTBODY_MESH)
return removeSoftBodyMesh(static_cast<PxSoftBodyMesh&>(obj));
else if(type==PxConcreteType::eBVH)
return removeBVH(static_cast<PxBVH&>(obj));
return false;
}
///////////////////////////////////////////////////////////////////////////////
namespace
{
class StandaloneInsertionCallback : public PxInsertionCallback
{
public:
StandaloneInsertionCallback() {}
virtual PxBase* buildObjectFromData(PxConcreteType::Enum type, void* data)
{
if(type == PxConcreteType::eTRIANGLE_MESH_BVH33)
{
TriangleMesh* np;
PX_NEW_SERIALIZED(np, RTreeTriangleMesh)(NULL, *reinterpret_cast<TriangleMeshData*>(data));
return np;
}
if(type == PxConcreteType::eTRIANGLE_MESH_BVH34)
{
TriangleMesh* np;
PX_NEW_SERIALIZED(np, BV4TriangleMesh)(NULL, *reinterpret_cast<TriangleMeshData*>(data));
return np;
}
if(type == PxConcreteType::eCONVEX_MESH)
{
ConvexMesh* np;
PX_NEW_SERIALIZED(np, ConvexMesh)(NULL, *reinterpret_cast<ConvexHullInitData*>(data));
return np;
}
if(type == PxConcreteType::eHEIGHTFIELD)
{
HeightField* np;
PX_NEW_SERIALIZED(np, HeightField)(NULL, *reinterpret_cast<HeightFieldData*>(data));
return np;
}
if(type == PxConcreteType::eBVH)
{
BVH* np;
PX_NEW_SERIALIZED(np, BVH)(NULL, *reinterpret_cast<BVHData*>(data));
return np;
}
if (type == PxConcreteType::eTETRAHEDRON_MESH)
{
TetrahedronMesh* np;
PX_NEW_SERIALIZED(np, TetrahedronMesh)(NULL, *reinterpret_cast<TetrahedronMeshData*>(data));
return np;
}
if (type == PxConcreteType::eSOFTBODY_MESH)
{
SoftBodyMesh* np;
PX_NEW_SERIALIZED(np, SoftBodyMesh)(NULL, *reinterpret_cast<SoftBodyMeshData*>(data));
return np;
}
outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "Inserting object failed: "
"Object type not supported for buildObjectFromData.");
return NULL;
}
}gSAIC;
}
PxInsertionCallback* physx::immediateCooking::getInsertionCallback()
{
return &gSAIC;
}
| 39,213 | C++ | 30.752227 | 155 | 0.731339 |
NVIDIA-Omniverse/PhysX/physx/source/geomutils/src/GuBVH.h | // Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef GU_BVH_H
#define GU_BVH_H
/** \addtogroup geomutils
@{
*/
#include "geometry/PxBVH.h"
#include "CmRefCountable.h"
#include "foundation/PxVecMath.h"
#include "foundation/PxUserAllocated.h"
#include "GuAABBTreeBounds.h"
#include "GuAABBTree.h"
namespace physx
{
struct PxBVHInternalData;
namespace Gu
{
class MeshFactory;
struct BVHNode;
class ShapeData;
class BVHData : public BVHPartialRefitData
{
public:
BVHData() {}
BVHData(BVHData& other)
{
mNbIndices = other.mNbIndices;
mNbNodes = other.mNbNodes;
mIndices = other.mIndices;
mNodes = other.mNodes;
mBounds.moveFrom(other.mBounds);
other.mIndices = NULL;
other.mNodes = NULL;
}
~BVHData()
{
if(mBounds.ownsMemory())
{
mBounds.release();
PX_FREE(mIndices);
PX_FREE(mNodes); // PT: TODO: fix this, unify with AABBTree version
}
mNbNodes = 0;
mNbIndices = 0;
}
PX_PHYSX_COMMON_API bool build(PxU32 nbBounds, const void* boundsData, PxU32 boundsStride, float enlargement, PxU32 numPrimsPerLeaf, BVHBuildStrategy bs);
PX_PHYSX_COMMON_API bool save(PxOutputStream& stream, bool endian) const;
AABBTreeBounds mBounds;
};
/**
\brief Represents a BVH.
*/
class BVH : public PxBVH, public PxUserAllocated, public Cm::RefCountable
{
public:
// PT: TODO: revisit these PX_PHYSX_COMMON_API calls. At the end of the day the issue is that things like PxUserAllocated aren't exported.
PX_PHYSX_COMMON_API BVH(MeshFactory* factory);
PX_PHYSX_COMMON_API BVH(MeshFactory* factory, BVHData& data);
PX_PHYSX_COMMON_API BVH(const PxBVHInternalData& data);
virtual ~BVH();
PX_PHYSX_COMMON_API bool init(PxU32 nbPrims, AABBTreeBounds* bounds, const void* boundsData, PxU32 stride, BVHBuildStrategy bs, PxU32 nbPrimsPerLeaf, float enlargement);
bool load(PxInputStream& desc);
void release();
// PxBVH
virtual bool raycast(const PxVec3& origin, const PxVec3& unitDir, float distance, RaycastCallback& cb, PxGeometryQueryFlags flags) const PX_OVERRIDE;
virtual bool overlap(const PxGeometry& geom, const PxTransform& pose, OverlapCallback& cb, PxGeometryQueryFlags flags) const PX_OVERRIDE;
virtual bool sweep(const PxGeometry& geom, const PxTransform& pose, const PxVec3& unitDir, float distance, RaycastCallback& cb, PxGeometryQueryFlags flags) const PX_OVERRIDE;
virtual bool cull(PxU32 nbPlanes, const PxPlane* planes, OverlapCallback& cb, PxGeometryQueryFlags flags) const PX_OVERRIDE;
virtual PxU32 getNbBounds() const PX_OVERRIDE { return mData.mNbIndices; }
virtual const PxBounds3* getBounds() const PX_OVERRIDE { return mData.mBounds.getBounds(); }
virtual void refit() PX_OVERRIDE;
virtual bool updateBounds(PxU32 boundsIndex, const PxBounds3& newBounds) PX_OVERRIDE;
virtual void partialRefit() PX_OVERRIDE;
virtual bool traverse(TraversalCallback& cb) const PX_OVERRIDE;
//~PxBVH
// Cm::RefCountable
virtual void onRefCountZero() PX_OVERRIDE;
//~Cm::RefCountable
PX_FORCE_INLINE const BVHNode* getNodes() const { return mData.mNodes; }
PX_FORCE_INLINE const PxU32* getIndices() const { return mData.mIndices; }
PX_FORCE_INLINE const BVHData& getData() const { return mData; }
bool getInternalData(PxBVHInternalData&, bool) const;
bool updateBoundsInternal(PxU32 localIndex, const PxBounds3& bounds);
// PT: alternative implementations directly working on shape data
bool overlap(const ShapeData& shapeData, OverlapCallback& cb, PxGeometryQueryFlags flags) const;
bool sweep(const ShapeData& shapeData, const PxVec3& unitDir, float distance, RaycastCallback& cb, PxGeometryQueryFlags flags) const;
private:
MeshFactory* mMeshFactory;
BVHData mData;
};
}
}
/** @} */
#endif
| 5,708 | C | 38.645833 | 182 | 0.710757 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.