aboutsummaryrefslogtreecommitdiff
path: root/NvCloth/src/ps
diff options
context:
space:
mode:
authorMarijn Tamis <[email protected]>2019-04-29 16:21:42 +0200
committerMarijn Tamis <[email protected]>2019-04-29 16:21:42 +0200
commit90963f4c0a38c705fe85101f2be5fdd09911b10f (patch)
tree34ca6c9e642ce4998612e3ee5bf3264a57c21277 /NvCloth/src/ps
parent1.1.6 Release. (diff)
downloadnvcloth-90963f4c0a38c705fe85101f2be5fdd09911b10f.tar.xz
nvcloth-90963f4c0a38c705fe85101f2be5fdd09911b10f.zip
Fix potential namespace issues when using NvCloth together with PhysX.
Diffstat (limited to 'NvCloth/src/ps')
-rw-r--r--NvCloth/src/ps/PsAlloca.h16
-rw-r--r--NvCloth/src/ps/PsFPU.h18
-rw-r--r--NvCloth/src/ps/PsSort.h18
-rw-r--r--NvCloth/src/ps/PsSortInternals.h16
-rw-r--r--NvCloth/src/ps/PsUtilities.h54
-rw-r--r--NvCloth/src/ps/unix/PsUnixAtomic.cpp14
-rw-r--r--NvCloth/src/ps/unix/PsUnixFPU.h4
-rw-r--r--NvCloth/src/ps/unix/PsUnixMutex.cpp14
-rw-r--r--NvCloth/src/ps/windows/PsWindowsAtomic.cpp13
-rw-r--r--NvCloth/src/ps/windows/PsWindowsFPU.h4
10 files changed, 106 insertions, 65 deletions
diff --git a/NvCloth/src/ps/PsAlloca.h b/NvCloth/src/ps/PsAlloca.h
index 75a7bb2..538defb 100644
--- a/NvCloth/src/ps/PsAlloca.h
+++ b/NvCloth/src/ps/PsAlloca.h
@@ -32,10 +32,15 @@
#include "NvCloth/Allocator.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
{
+namespace ps
+{
+
template <typename T, typename Unused = void>
class ScopedPointer
{
@@ -55,15 +60,16 @@ class ScopedPointer
bool mOwned;
};
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
/*! Stack allocation for \c count instances of \c type. Falling back to temp allocator if using more than 1kB. */
#ifdef __SPU__
#define PX_ALLOCA(var, type, count) type* var = reinterpret_cast<type*>(PxAlloca(sizeof(type) * (count)))
#else
#define PX_ALLOCA(var, type, count) \
- physx::shdfnd::ScopedPointer<type> var; \
+ nv::cloth::ps::ScopedPointer<type> var; \
{ \
uint32_t size = sizeof(type) * (count); \
var.mOwned = size > 1024; \
diff --git a/NvCloth/src/ps/PsFPU.h b/NvCloth/src/ps/PsFPU.h
index 82b7ff2..1cb45c0 100644
--- a/NvCloth/src/ps/PsFPU.h
+++ b/NvCloth/src/ps/PsFPU.h
@@ -48,10 +48,15 @@
#define PX_SUPPORT_GUARDS (PX_WINDOWS_FAMILY || PX_XBOXONE || (PX_LINUX && (PX_X86 || PX_X64)) || PX_PS4 || PX_OSX)
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
{
+namespace ps
+{
+
// sets the default SDK state for scalar and SIMD units
class NV_CLOTH_IMPORT FPUGuard
{
@@ -84,18 +89,19 @@ NV_CLOTH_IMPORT void enableFPExceptions();
*/
NV_CLOTH_IMPORT void disableFPExceptions();
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#if PX_WINDOWS_FAMILY || PX_XBOXONE
#include "windows/PsWindowsFPU.h"
#elif (PX_LINUX && PX_SSE2) || PX_PS4 || PX_OSX
#include "unix/PsUnixFPU.h"
#else
-PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard()
+PX_INLINE nv::cloth::ps::SIMDGuard::SIMDGuard()
{
}
-PX_INLINE physx::shdfnd::SIMDGuard::~SIMDGuard()
+PX_INLINE nv::cloth::ps::SIMDGuard::~SIMDGuard()
{
}
#endif
diff --git a/NvCloth/src/ps/PsSort.h b/NvCloth/src/ps/PsSort.h
index 8667244..c2c238a 100644
--- a/NvCloth/src/ps/PsSort.h
+++ b/NvCloth/src/ps/PsSort.h
@@ -52,10 +52,15 @@ that the predicate implements the < operator:
// this was intentional.
#endif
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
{
+namespace ps
+{
+
template <class T, class Predicate, class Allocator>
void sort(T* elements, uint32_t count, const Predicate& compare, const Allocator& inAllocator,
const uint32_t initialStackSize = 32)
@@ -111,17 +116,18 @@ void sort(T* elements, uint32_t count, const Predicate& compare, const Allocator
template <class T, class Predicate>
void sort(T* elements, uint32_t count, const Predicate& compare)
{
- sort(elements, count, compare, typename shdfnd::AllocatorTraits<T>::Type());
+ sort(elements, count, compare, typename ps::AllocatorTraits<T>::Type());
}
template <class T>
void sort(T* elements, uint32_t count)
{
- sort(elements, count, shdfnd::Less<T>(), typename shdfnd::AllocatorTraits<T>::Type());
+ sort(elements, count, ps::Less<T>(), typename ps::AllocatorTraits<T>::Type());
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#if PX_VC
#pragma warning(pop)
diff --git a/NvCloth/src/ps/PsSortInternals.h b/NvCloth/src/ps/PsSortInternals.h
index c7a7703..a7931d3 100644
--- a/NvCloth/src/ps/PsSortInternals.h
+++ b/NvCloth/src/ps/PsSortInternals.h
@@ -38,9 +38,13 @@
#include "NvCloth/ps/PsBasicTemplates.h"
#include "NvCloth/ps/PsUserAllocated.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
namespace internal
{
@@ -152,7 +156,7 @@ class Stack
mCapacity *= 2;
int32_t* newMem =
reinterpret_cast<int32_t*>(mAllocator.allocate(sizeof(int32_t) * mCapacity, __FILE__, __LINE__));
- intrinsics::memCopy(newMem, mMemory, mSize * sizeof(int32_t));
+ physx::intrinsics::memCopy(newMem, mMemory, mSize * sizeof(int32_t));
if(mRealloc)
mAllocator.deallocate(mMemory);
mRealloc = true;
@@ -180,8 +184,8 @@ class Stack
}
};
} // namespace internal
-
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSSORTINTERNALS_H
diff --git a/NvCloth/src/ps/PsUtilities.h b/NvCloth/src/ps/PsUtilities.h
index 4e59ddc..111242a 100644
--- a/NvCloth/src/ps/PsUtilities.h
+++ b/NvCloth/src/ps/PsUtilities.h
@@ -36,10 +36,15 @@
#include "NvCloth/ps/PsBasicTemplates.h"
#include "NvCloth/Callbacks.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
{
+namespace ps
+{
+
PX_INLINE char littleEndian()
{
int i = 1;
@@ -47,36 +52,36 @@ PX_INLINE char littleEndian()
}
// PT: checked casts
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 to32(PxU64 value)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU32 to32(physx::PxU64 value)
{
NV_CLOTH_ASSERT(value <= 0xffffffff);
- return PxU32(value);
+ return physx::PxU32(value);
}
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU16 to16(PxU32 value)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU16 to16(physx::PxU32 value)
{
NV_CLOTH_ASSERT(value <= 0xffff);
- return PxU16(value);
+ return physx::PxU16(value);
}
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 to8(PxU16 value)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU8 to8(physx::PxU16 value)
{
NV_CLOTH_ASSERT(value <= 0xff);
- return PxU8(value);
+ return physx::PxU8(value);
}
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 to8(PxU32 value)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU8 to8(physx::PxU32 value)
{
NV_CLOTH_ASSERT(value <= 0xff);
- return PxU8(value);
+ return physx::PxU8(value);
}
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU8 to8(PxI32 value)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU8 to8(physx::PxI32 value)
{
NV_CLOTH_ASSERT(value <= 0xff);
NV_CLOTH_ASSERT(value >= 0);
- return PxU8(value);
+ return physx::PxU8(value);
}
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxI8 toI8(PxU32 value)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxI8 toI8(physx::PxU32 value)
{
NV_CLOTH_ASSERT(value <= 0x7f);
- return PxI8(value);
+ return physx::PxI8(value);
}
/*!
@@ -84,7 +89,7 @@ Get number of elements in array
*/
template <typename T, size_t N>
char (&ArraySizeHelper(T (&array)[N]))[N];
-#define PX_ARRAY_SIZE(_array) (sizeof(physx::shdfnd::ArraySizeHelper(_array)))
+#define PX_ARRAY_SIZE(_array) (sizeof(nv::cloth::ps::ArraySizeHelper(_array)))
/*!
Sort two elements using operator<
@@ -100,10 +105,10 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE void order(T& x, T& y)
// most architectures can do predication on real comparisons, and on VMX, it matters
-PX_CUDA_CALLABLE PX_FORCE_INLINE void order(PxReal& x, PxReal& y)
+PX_CUDA_CALLABLE PX_FORCE_INLINE void order(physx::PxReal& x, physx::PxReal& y)
{
- PxReal newX = PxMin(x, y);
- PxReal newY = PxMax(x, y);
+ physx::PxReal newX = physx::PxMin(x, y);
+ physx::PxReal newY = physx::PxMax(x, y);
x = newX;
y = newY;
}
@@ -145,10 +150,10 @@ __attribute__((noreturn))
}
bool checkValid(const float&);
-bool checkValid(const PxVec3&);
-bool checkValid(const PxQuat&);
-bool checkValid(const PxMat33&);
-bool checkValid(const PxTransform&);
+bool checkValid(const physx::PxVec3&);
+bool checkValid(const physx::PxQuat&);
+bool checkValid(const physx::PxMat33&);
+bool checkValid(const physx::PxTransform&);
bool checkValid(const char*);
// equivalent to std::max_element
@@ -163,7 +168,8 @@ inline const T* maxElement(const T* first, const T* last)
return m;
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif
diff --git a/NvCloth/src/ps/unix/PsUnixAtomic.cpp b/NvCloth/src/ps/unix/PsUnixAtomic.cpp
index 376f795..19167cd 100644
--- a/NvCloth/src/ps/unix/PsUnixAtomic.cpp
+++ b/NvCloth/src/ps/unix/PsUnixAtomic.cpp
@@ -35,9 +35,13 @@
#define PAUSE()
#endif
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
void* atomicCompareExchangePointer(volatile void** dest, void* exch, void* comp)
@@ -97,6 +101,6 @@ int32_t atomicExchange(volatile int32_t* val, int32_t val2)
return oldVal;
}
-
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
diff --git a/NvCloth/src/ps/unix/PsUnixFPU.h b/NvCloth/src/ps/unix/PsUnixFPU.h
index edd5522..3f98a69 100644
--- a/NvCloth/src/ps/unix/PsUnixFPU.h
+++ b/NvCloth/src/ps/unix/PsUnixFPU.h
@@ -44,7 +44,7 @@
#endif
-PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard()
+PX_INLINE nv::cloth::ps::SIMDGuard::SIMDGuard()
{
#if !PX_EMSCRIPTEN && (PX_X86 || PX_X64)
mControlWord = _mm_getcsr();
@@ -53,7 +53,7 @@ PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard()
#endif
}
-PX_INLINE physx::shdfnd::SIMDGuard::~SIMDGuard()
+PX_INLINE nv::cloth::ps::SIMDGuard::~SIMDGuard()
{
#if !PX_EMSCRIPTEN && (PX_X86 || PX_X64)
// restore control word and clear exception flags
diff --git a/NvCloth/src/ps/unix/PsUnixMutex.cpp b/NvCloth/src/ps/unix/PsUnixMutex.cpp
index 23b6549..f40d294 100644
--- a/NvCloth/src/ps/unix/PsUnixMutex.cpp
+++ b/NvCloth/src/ps/unix/PsUnixMutex.cpp
@@ -39,9 +39,13 @@
#include <pthread.h>
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
namespace
@@ -165,6 +169,6 @@ void ReadWriteLock::unlockWriter()
{
mImpl->mutex.unlock();
}
-
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
diff --git a/NvCloth/src/ps/windows/PsWindowsAtomic.cpp b/NvCloth/src/ps/windows/PsWindowsAtomic.cpp
index c78728f..fa9c115 100644
--- a/NvCloth/src/ps/windows/PsWindowsAtomic.cpp
+++ b/NvCloth/src/ps/windows/PsWindowsAtomic.cpp
@@ -30,9 +30,13 @@
#include "PsWindowsInclude.h"
#include "NvCloth/ps/PsAtomic.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
int32_t atomicExchange(volatile int32_t* val, int32_t val2)
@@ -92,5 +96,6 @@ int32_t atomicMax(volatile int32_t* val, int32_t val2)
return newValue;
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
diff --git a/NvCloth/src/ps/windows/PsWindowsFPU.h b/NvCloth/src/ps/windows/PsWindowsFPU.h
index d85e531..dc8b90e 100644
--- a/NvCloth/src/ps/windows/PsWindowsFPU.h
+++ b/NvCloth/src/ps/windows/PsWindowsFPU.h
@@ -30,7 +30,7 @@
#ifndef PSFOUNDATION_PSWINDOWSFPU_H
#define PSFOUNDATION_PSWINDOWSFPU_H
-PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard()
+PX_INLINE nv::cloth::ps::SIMDGuard::SIMDGuard()
{
#if !PX_ARM
mControlWord = _mm_getcsr();
@@ -39,7 +39,7 @@ PX_INLINE physx::shdfnd::SIMDGuard::SIMDGuard()
#endif
}
-PX_INLINE physx::shdfnd::SIMDGuard::~SIMDGuard()
+PX_INLINE nv::cloth::ps::SIMDGuard::~SIMDGuard()
{
#if !PX_ARM
// restore control word and clear any exception flags