aboutsummaryrefslogtreecommitdiff
path: root/NvCloth/include
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/include
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/include')
-rw-r--r--NvCloth/include/NvCloth/Allocator.h32
-rw-r--r--NvCloth/include/NvCloth/Callbacks.h13
-rw-r--r--NvCloth/include/NvCloth/Fabric.h4
-rw-r--r--NvCloth/include/NvCloth/ps/Ps.h13
-rw-r--r--NvCloth/include/NvCloth/ps/PsAlignedMalloc.h13
-rw-r--r--NvCloth/include/NvCloth/ps/PsAllocator.cpp14
-rw-r--r--NvCloth/include/NvCloth/ps/PsAllocator.h42
-rw-r--r--NvCloth/include/NvCloth/ps/PsArray.h21
-rw-r--r--NvCloth/include/NvCloth/ps/PsAtomic.h13
-rw-r--r--NvCloth/include/NvCloth/ps/PsBasicTemplates.h15
-rw-r--r--NvCloth/include/NvCloth/ps/PsBitUtils.h13
-rw-r--r--NvCloth/include/NvCloth/ps/PsHash.h13
-rw-r--r--NvCloth/include/NvCloth/ps/PsHashInternals.h19
-rw-r--r--NvCloth/include/NvCloth/ps/PsHashMap.h13
-rw-r--r--NvCloth/include/NvCloth/ps/PsMathUtils.h292
-rw-r--r--NvCloth/include/NvCloth/ps/PsUserAllocated.h13
-rw-r--r--NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h15
-rw-r--r--NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h13
18 files changed, 313 insertions, 258 deletions
diff --git a/NvCloth/include/NvCloth/Allocator.h b/NvCloth/include/NvCloth/Allocator.h
index e66f34a..8b1c9fa 100644
--- a/NvCloth/include/NvCloth/Allocator.h
+++ b/NvCloth/include/NvCloth/Allocator.h
@@ -48,41 +48,25 @@ namespace cloth
void* allocate(size_t);
void deallocate(void*);
-class NonTrackingAllocator
-{
-public:
- PX_FORCE_INLINE NonTrackingAllocator(const char* = 0)
- {
- }
- PX_FORCE_INLINE void* allocate(size_t size, const char* file, int line)
- {
- return !size ? 0 : GetNvClothAllocator()->allocate(size, "NonTrackedAlloc", file, line);
- }
- PX_FORCE_INLINE void deallocate(void* ptr)
- {
- if (ptr)
- GetNvClothAllocator()->deallocate(ptr);
- }
-};
/* templated typedefs for convenience */
template <typename T>
struct Vector
{
- typedef physx::shdfnd::Array<T, NonTrackingAllocator> Type;
+ typedef ps::Array<T, ps::NonTrackingAllocator> Type;
};
template <typename T, size_t alignment>
struct AlignedVector
{
- typedef physx::shdfnd::Array<T, physx::shdfnd::AlignedAllocator<alignment, NonTrackingAllocator> > Type;
+ typedef ps::Array<T, ps::AlignedAllocator<alignment, ps::NonTrackingAllocator> > Type;
};
-template <class Key, class Value, class HashFn = physx::shdfnd::Hash<Key> >
+template <class Key, class Value, class HashFn = ps::Hash<Key> >
struct HashMap
{
- typedef physx::shdfnd::HashMap<Key, Value, HashFn, NonTrackingAllocator> Type;
+ typedef ps::HashMap<Key, Value, HashFn, ps::NonTrackingAllocator> Type;
};
struct NvClothOverload{};
@@ -97,7 +81,7 @@ struct NvClothOverload{};
//new/delete operators need to be declared in global scope
template <typename T>
PX_INLINE void* operator new(size_t size, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
{
PX_UNUSED(overload);
return GetNvClothAllocator()->allocate(size, "<TypeName Unknown>", fileName, line);
@@ -105,7 +89,7 @@ PX_INLINE void* operator new(size_t size, const char* fileName,
template <typename T>
PX_INLINE void* operator new [](size_t size, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
{
PX_UNUSED(overload);
return GetNvClothAllocator()->allocate(size, "<TypeName Unknown>", fileName, line);
@@ -114,7 +98,7 @@ PX_INLINE void* operator new [](size_t size, const char* fileName,
// If construction after placement new throws, this placement delete is being called.
template <typename T>
PX_INLINE void operator delete(void* ptr, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
{
PX_UNUSED(fileName);
PX_UNUSED(line);
@@ -126,7 +110,7 @@ PX_INLINE void operator delete(void* ptr, const char* fileName,
// If construction after placement new throws, this placement delete is being called.
template <typename T>
PX_INLINE void operator delete [](void* ptr, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line, nv::cloth::NvClothOverload overload)
{
PX_UNUSED(fileName);
PX_UNUSED(line);
diff --git a/NvCloth/include/NvCloth/Callbacks.h b/NvCloth/include/NvCloth/Callbacks.h
index f5b54a9..10039a9 100644
--- a/NvCloth/include/NvCloth/Callbacks.h
+++ b/NvCloth/include/NvCloth/Callbacks.h
@@ -47,13 +47,7 @@
#define NV_CLOTH_CALL_CONV PX_CALL_CONV
#define NV_CLOTH_API(ret_type) NV_CLOTH_LINKAGE ret_type NV_CLOTH_CALL_CONV
-namespace physx
-{
- class PxAllocatorCallback;
- class PxErrorCallback;
- class PxProfilerCallback;
- class PxAssertHandler;
-}
+
/** \brief NVidia namespace */
namespace nv
@@ -61,6 +55,11 @@ namespace nv
/** \brief nvcloth namespace */
namespace cloth
{
+ class PxAllocatorCallback;
+ class PxErrorCallback;
+ class PxProfilerCallback;
+ class PxAssertHandler;
+
/** \brief Initialize the library by passing in callback functions.
This needs to be called before using any other part of the library.
@param allocatorCallback Callback interface for memory allocations. Needs to return 16 byte aligned memory.
diff --git a/NvCloth/include/NvCloth/Fabric.h b/NvCloth/include/NvCloth/Fabric.h
index eb0fc5e..1f966da 100644
--- a/NvCloth/include/NvCloth/Fabric.h
+++ b/NvCloth/include/NvCloth/Fabric.h
@@ -105,7 +105,7 @@ public:
void incRefCount()
{
- physx::shdfnd::atomicIncrement(&mRefCount);
+ ps::atomicIncrement(&mRefCount);
NV_CLOTH_ASSERT(mRefCount > 0);
}
@@ -113,7 +113,7 @@ public:
bool decRefCount()
{
NV_CLOTH_ASSERT(mRefCount > 0);
- int result = physx::shdfnd::atomicDecrement(&mRefCount);
+ int result = ps::atomicDecrement(&mRefCount);
if (result == 0)
{
delete this;
diff --git a/NvCloth/include/NvCloth/ps/Ps.h b/NvCloth/include/NvCloth/ps/Ps.h
index 89fc9c7..b8e722f 100644
--- a/NvCloth/include/NvCloth/ps/Ps.h
+++ b/NvCloth/include/NvCloth/ps/Ps.h
@@ -55,16 +55,21 @@ Platform specific defines
#define PX_SIGN_BITMASK 0x80000000
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
// Int-as-bool type - has some uses for efficiency and with SIMD
typedef int IntBool;
static const IntBool IntFalse = 0;
static const IntBool IntTrue = 1;
-}
-} // namespace physx
+}
+}
+}
#endif // #ifndef PSFOUNDATION_PS_H
diff --git a/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h b/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h
index 4be8409..0794aa2 100644
--- a/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h
+++ b/NvCloth/include/NvCloth/ps/PsAlignedMalloc.h
@@ -38,9 +38,13 @@ Alignment must be a power of 2!
-- should be templated by a base allocator
*/
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
/**
Allocator, which is used to access the global PxAllocatorCallback instance
@@ -82,7 +86,8 @@ class AlignedAllocator : public BaseAllocator
}
};
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSALIGNEDMALLOC_H
diff --git a/NvCloth/include/NvCloth/ps/PsAllocator.cpp b/NvCloth/include/NvCloth/ps/PsAllocator.cpp
index 4e6514f..cf15372 100644
--- a/NvCloth/include/NvCloth/ps/PsAllocator.cpp
+++ b/NvCloth/include/NvCloth/ps/PsAllocator.cpp
@@ -30,11 +30,14 @@
#include "PsAllocator.h"
#include "NvCloth/Callbacks.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
-
void* Allocator::allocate(size_t size, const char* file, int line)
{
if(!size)
@@ -47,5 +50,6 @@ void Allocator::deallocate(void* ptr)
GetNvClothAllocator()->deallocate(ptr);
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
diff --git a/NvCloth/include/NvCloth/ps/PsAllocator.h b/NvCloth/include/NvCloth/ps/PsAllocator.h
index 37605ee..59cdac3 100644
--- a/NvCloth/include/NvCloth/ps/PsAllocator.h
+++ b/NvCloth/include/NvCloth/ps/PsAllocator.h
@@ -46,9 +46,9 @@
#include <new>
// Allocation macros going through user allocator
-#define PX_ALLOC(n, name) physx::shdfnd::NonTrackingAllocator().allocate(n, __FILE__, __LINE__)
+#define PX_ALLOC(n, name) nv::cloth::NonTrackingAllocator().allocate(n, __FILE__, __LINE__)
#define PX_ALLOC_TEMP(n, name) PX_ALLOC(n, name)
-#define PX_FREE(x) physx::shdfnd::NonTrackingAllocator().deallocate(x)
+#define PX_FREE(x) nv::cloth::NonTrackingAllocator().deallocate(x)
#define PX_FREE_AND_RESET(x) \
{ \
PX_FREE(x); \
@@ -56,7 +56,7 @@
}
// The following macros support plain-old-types and classes derived from UserAllocated.
-#define PX_NEW(T) new (physx::shdfnd::ReflectionAllocator<T>(), __FILE__, __LINE__) T
+#define PX_NEW(T) new (nv::cloth::ReflectionAllocator<T>(), __FILE__, __LINE__) T
#define PX_NEW_TEMP(T) PX_NEW(T)
#define PX_DELETE(x) delete x
#define PX_DELETE_AND_RESET(x) \
@@ -76,8 +76,8 @@
}
// aligned allocation
-#define PX_ALIGNED16_ALLOC(n) physx::shdfnd::AlignedAllocator<16>().allocate(n, __FILE__, __LINE__)
-#define PX_ALIGNED16_FREE(x) physx::shdfnd::AlignedAllocator<16>().deallocate(x)
+#define PX_ALIGNED16_ALLOC(n) nv::cloth::AlignedAllocator<16>().allocate(n, __FILE__, __LINE__)
+#define PX_ALIGNED16_FREE(x) nv::cloth::AlignedAllocator<16>().deallocate(x)
//! placement new macro to make it easy to spot bad use of 'new'
#define PX_PLACEMENT_NEW(p, T) new (p) T
@@ -111,11 +111,14 @@
#define PxAllocaAligned(x, alignment) ((size_t(PxAlloca(x + alignment)) + (alignment - 1)) & ~size_t(alignment - 1))
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
-
//NV_CLOTH_IMPORT PxAllocatorCallback& getAllocator();
/**
@@ -257,7 +260,7 @@ class ReflectionAllocator
}
public:
- ReflectionAllocator(const PxEMPTY)
+ ReflectionAllocator(const physx::PxEMPTY)
{
}
ReflectionAllocator(const char* = 0)
@@ -293,8 +296,9 @@ union EnableIfPod
typedef X Type;
};
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
// Global placement new for ReflectionAllocator templated by
// plain-old-type. Allows using PX_NEW for pointers and built-in-types.
@@ -307,21 +311,21 @@ union EnableIfPod
// PX_DELETE_POD was preferred over PX_DELETE_ARRAY because it is used
// less often and applies to both single instances and arrays.
template <typename T>
-PX_INLINE void* operator new(size_t size, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line)
+PX_INLINE void* operator new(size_t size, nv::cloth::ps::ReflectionAllocator<T> alloc, const char* fileName,
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line)
{
return alloc.allocate(size, fileName, line);
}
template <typename T>
-PX_INLINE void* operator new [](size_t size, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line)
+PX_INLINE void* operator new [](size_t size, nv::cloth::ps::ReflectionAllocator<T> alloc, const char* fileName,
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line)
{ return alloc.allocate(size, fileName, line); }
// If construction after placement new throws, this placement delete is being called.
template <typename T>
-PX_INLINE void operator delete(void* ptr, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line)
+PX_INLINE void operator delete(void* ptr, nv::cloth::ps::ReflectionAllocator<T> alloc, const char* fileName,
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line)
{
PX_UNUSED(fileName);
PX_UNUSED(line);
@@ -331,8 +335,8 @@ PX_INLINE void operator delete(void* ptr, physx::shdfnd::ReflectionAllocator<T>
// If construction after placement new throws, this placement delete is being called.
template <typename T>
-PX_INLINE void operator delete [](void* ptr, physx::shdfnd::ReflectionAllocator<T> alloc, const char* fileName,
- typename physx::shdfnd::EnableIfPod<T, int>::Type line)
+PX_INLINE void operator delete [](void* ptr, nv::cloth::ps::ReflectionAllocator<T> alloc, const char* fileName,
+ typename nv::cloth::ps::EnableIfPod<T, int>::Type line)
{
PX_UNUSED(fileName);
PX_UNUSED(line);
diff --git a/NvCloth/include/NvCloth/ps/PsArray.h b/NvCloth/include/NvCloth/ps/PsArray.h
index e5f6698..8620d3d 100644
--- a/NvCloth/include/NvCloth/ps/PsArray.h
+++ b/NvCloth/include/NvCloth/ps/PsArray.h
@@ -35,9 +35,13 @@
#include "PsBasicTemplates.h"
#include "NvCloth/ps/PsAllocator.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
template <class Serializer>
void exportArray(Serializer& stream, const void* data, uint32_t size, uint32_t sizeOfElement, uint32_t capacity);
@@ -60,7 +64,7 @@ class Array : protected Alloc
typedef T* Iterator;
typedef const T* ConstIterator;
- explicit Array(const PxEMPTY v) : Alloc(v)
+ explicit Array(const physx::PxEMPTY v) : Alloc(v)
{
if(mData)
mCapacity |= PX_SIGN_BITMASK;
@@ -507,9 +511,9 @@ class Array : protected Alloc
//////////////////////////////////////////////////////////////////////////
PX_INLINE void swap(Array<T, Alloc>& other)
{
- shdfnd::swap(mData, other.mData);
- shdfnd::swap(mSize, other.mSize);
- shdfnd::swap(mCapacity, other.mCapacity);
+ ps::swap(mData, other.mData);
+ ps::swap(mSize, other.mSize);
+ ps::swap(mCapacity, other.mCapacity);
}
//////////////////////////////////////////////////////////////////////////
@@ -715,7 +719,8 @@ PX_INLINE void swap(Array<T, Alloc>& x, Array<T, Alloc>& y)
x.swap(y);
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSARRAY_H
diff --git a/NvCloth/include/NvCloth/ps/PsAtomic.h b/NvCloth/include/NvCloth/ps/PsAtomic.h
index dad18fc..2ab8bad 100644
--- a/NvCloth/include/NvCloth/ps/PsAtomic.h
+++ b/NvCloth/include/NvCloth/ps/PsAtomic.h
@@ -33,9 +33,13 @@
#include "NvCloth/ps/Ps.h"
#include "NvCloth/Callbacks.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
/* set *dest equal to val. Return the old value of *dest */
NV_CLOTH_IMPORT int32_t atomicExchange(volatile int32_t* dest, int32_t val);
@@ -58,7 +62,8 @@ NV_CLOTH_IMPORT int32_t atomicAdd(volatile int32_t* val, int32_t delta);
/* compute the maximum of dest and val. Return the new value */
NV_CLOTH_IMPORT int32_t atomicMax(volatile int32_t* val, int32_t val2);
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSATOMIC_H
diff --git a/NvCloth/include/NvCloth/ps/PsBasicTemplates.h b/NvCloth/include/NvCloth/ps/PsBasicTemplates.h
index 514da05..0646fb0 100644
--- a/NvCloth/include/NvCloth/ps/PsBasicTemplates.h
+++ b/NvCloth/include/NvCloth/ps/PsBasicTemplates.h
@@ -32,9 +32,13 @@
#include "Ps.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
template <typename A>
struct Equal
@@ -78,7 +82,7 @@ class Pair
Pair(const Pair& p) : first(p.first), second(p.second)
{
}
- // CN - fix for /.../PsBasicTemplates.h(61) : warning C4512: 'physx::shdfnd::Pair<F,S>' : assignment operator could
+ // CN - fix for /.../PsBasicTemplates.h(61) : warning C4512: 'nv::cloth::Pair<F,S>' : assignment operator could
// not be generated
Pair& operator=(const Pair& p)
{
@@ -140,7 +144,8 @@ PX_CUDA_CALLABLE PX_INLINE void swap(T& x, T& y)
y = tmp;
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSBASICTEMPLATES_H
diff --git a/NvCloth/include/NvCloth/ps/PsBitUtils.h b/NvCloth/include/NvCloth/ps/PsBitUtils.h
index 3d901ed..9fe7a96 100644
--- a/NvCloth/include/NvCloth/ps/PsBitUtils.h
+++ b/NvCloth/include/NvCloth/ps/PsBitUtils.h
@@ -35,9 +35,13 @@
#include "PsIntrinsics.h"
#include "Ps.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
PX_INLINE uint32_t bitCount(uint32_t v)
{
@@ -103,7 +107,8 @@ PX_INLINE uint32_t ilog2(uint32_t num)
return uint32_t(-1);
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSBITUTILS_H
diff --git a/NvCloth/include/NvCloth/ps/PsHash.h b/NvCloth/include/NvCloth/ps/PsHash.h
index 6b74fb2..daa88b9 100644
--- a/NvCloth/include/NvCloth/ps/PsHash.h
+++ b/NvCloth/include/NvCloth/ps/PsHash.h
@@ -46,9 +46,13 @@
Central definition of hash functions
*/
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
// Hash functions
@@ -152,8 +156,9 @@ struct Hash<const char*>
}
};
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#if PX_VC
#pragma warning(pop)
diff --git a/NvCloth/include/NvCloth/ps/PsHashInternals.h b/NvCloth/include/NvCloth/ps/PsHashInternals.h
index ec0d3dd..ddab8ed 100644
--- a/NvCloth/include/NvCloth/ps/PsHashInternals.h
+++ b/NvCloth/include/NvCloth/ps/PsHashInternals.h
@@ -40,9 +40,13 @@
#pragma warning(push)
#pragma warning(disable : 4127) // conditional expression is constant
#endif
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
namespace internal
{
@@ -190,7 +194,7 @@ class HashBase : private Allocator
destroy();
- intrinsics::memSet(mHash, EOL, mHashSize * sizeof(uint32_t));
+ physx::intrinsics::memSet(mHash, EOL, mHashSize * sizeof(uint32_t));
const uint32_t sizeMinus1 = mEntriesCapacity - 1;
for(uint32_t i = 0; i < sizeMinus1; i++)
@@ -378,7 +382,7 @@ class HashBase : private Allocator
}
// initialize new hash table
- intrinsics::memSet(newHash, uint32_t(EOL), newHashSize * sizeof(uint32_t));
+ physx::intrinsics::memSet(newHash, uint32_t(EOL), newHashSize * sizeof(uint32_t));
// iterate over old entries, re-hash and create new entries
if(resizeCompact)
@@ -399,7 +403,7 @@ class HashBase : private Allocator
else
{
// copy old free list, only required for non compact resizing
- intrinsics::memCopy(newEntriesNext, mEntriesNext, mEntriesCapacity * sizeof(uint32_t));
+ physx::intrinsics::memCopy(newEntriesNext, mEntriesNext, mEntriesCapacity * sizeof(uint32_t));
for(uint32_t bucket = 0; bucket < mHashSize; bucket++)
{
@@ -786,8 +790,9 @@ class HashMapBase
};
}
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#if PX_VC
#pragma warning(pop)
diff --git a/NvCloth/include/NvCloth/ps/PsHashMap.h b/NvCloth/include/NvCloth/ps/PsHashMap.h
index 5091dee..deb737c 100644
--- a/NvCloth/include/NvCloth/ps/PsHashMap.h
+++ b/NvCloth/include/NvCloth/ps/PsHashMap.h
@@ -69,9 +69,13 @@
// for(HashMap::Iterator iter = test.getIterator(); !iter.done(); ++iter)
// myFunction(iter->first, iter->second);
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
template <class Key, class Value, class HashFn = Hash<Key>, class Allocator = NonTrackingAllocator>
class HashMap : public internal::HashMapBase<Key, Value, HashFn, Allocator>
@@ -112,7 +116,8 @@ class CoalescedHashMap : public internal::HashMapBase<Key, Value, HashFn, Alloca
}
};
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSHASHMAP_H
diff --git a/NvCloth/include/NvCloth/ps/PsMathUtils.h b/NvCloth/include/NvCloth/ps/PsMathUtils.h
index aeaeb93..5551617 100644
--- a/NvCloth/include/NvCloth/ps/PsMathUtils.h
+++ b/NvCloth/include/NvCloth/ps/PsMathUtils.h
@@ -41,22 +41,26 @@
// If it's a math function where the inputs have specific semantics (e.g.
// separateSwingTwist) it doesn't.
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
/**
\brief sign returns the sign of its argument. The sign of zero is undefined.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 sign(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 sign(const physx::PxF32 a)
{
- return intrinsics::sign(a);
+ return physx::intrinsics::sign(a);
}
/**
\brief sign returns the sign of its argument. The sign of zero is undefined.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 sign(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 sign(const physx::PxF64 a)
{
return (a >= 0.0) ? 1.0 : -1.0;
}
@@ -64,7 +68,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 sign(const PxF64 a)
/**
\brief sign returns the sign of its argument. The sign of zero is undefined.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxI32 sign(const PxI32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxI32 sign(const physx::PxI32 a)
{
return (a >= 0) ? 1 : -1;
}
@@ -72,24 +76,24 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxI32 sign(const PxI32 a)
/**
\brief Returns true if the two numbers are within eps of each other.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE bool equals(const PxF32 a, const PxF32 b, const PxF32 eps)
+PX_CUDA_CALLABLE PX_FORCE_INLINE bool equals(const physx::PxF32 a, const physx::PxF32 b, const physx::PxF32 eps)
{
- return (PxAbs(a - b) < eps);
+ return (physx::PxAbs(a - b) < eps);
}
/**
\brief Returns true if the two numbers are within eps of each other.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE bool equals(const PxF64 a, const PxF64 b, const PxF64 eps)
+PX_CUDA_CALLABLE PX_FORCE_INLINE bool equals(const physx::PxF64 a, const physx::PxF64 b, const physx::PxF64 eps)
{
- return (PxAbs(a - b) < eps);
+ return (physx::PxAbs(a - b) < eps);
}
/**
\brief The floor function returns a floating-point value representing the largest integer that is less than or equal to
x.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 floor(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 floor(const physx::PxF32 a)
{
return floatFloor(a);
}
@@ -98,7 +102,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 floor(const PxF32 a)
\brief The floor function returns a floating-point value representing the largest integer that is less than or equal to
x.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 floor(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 floor(const physx::PxF64 a)
{
return ::floor(a);
}
@@ -106,7 +110,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 floor(const PxF64 a)
/**
\brief The ceil function returns a single value representing the smallest integer that is greater than or equal to x.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 ceil(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 ceil(const physx::PxF32 a)
{
return ::ceilf(a);
}
@@ -114,7 +118,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 ceil(const PxF32 a)
/**
\brief The ceil function returns a double value representing the smallest integer that is greater than or equal to x.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 ceil(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 ceil(const physx::PxF64 a)
{
return ::ceil(a);
}
@@ -124,9 +128,9 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 ceil(const PxF64 a)
If the value of y is 0.0, mod returns a quiet NaN.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 mod(const PxF32 x, const PxF32 y)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 mod(const physx::PxF32 x, const physx::PxF32 y)
{
- return PxF32(::fmodf(x, y));
+ return physx::PxF32(::fmodf(x, y));
}
/**
@@ -134,7 +138,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 mod(const PxF32 x, const PxF32 y)
If the value of y is 0.0, mod returns a quiet NaN.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 mod(const PxF64 x, const PxF64 y)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 mod(const physx::PxF64 x, const physx::PxF64 y)
{
return ::fmod(x, y);
}
@@ -142,7 +146,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 mod(const PxF64 x, const PxF64 y)
/**
\brief Square.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 sqr(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 sqr(const physx::PxF32 a)
{
return a * a;
}
@@ -150,7 +154,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 sqr(const PxF32 a)
/**
\brief Square.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 sqr(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 sqr(const physx::PxF64 a)
{
return a * a;
}
@@ -158,7 +162,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 sqr(const PxF64 a)
/**
\brief Calculates x raised to the power of y.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 pow(const PxF32 x, const PxF32 y)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 pow(const physx::PxF32 x, const physx::PxF32 y)
{
return ::powf(x, y);
}
@@ -166,7 +170,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 pow(const PxF32 x, const PxF32 y)
/**
\brief Calculates x raised to the power of y.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 pow(const PxF64 x, const PxF64 y)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 pow(const physx::PxF64 x, const physx::PxF64 y)
{
return ::pow(x, y);
}
@@ -174,7 +178,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 pow(const PxF64 x, const PxF64 y)
/**
\brief Calculates e^n
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 exp(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 exp(const physx::PxF32 a)
{
return ::expf(a);
}
@@ -182,7 +186,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 exp(const PxF32 a)
\brief Calculates e^n
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 exp(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 exp(const physx::PxF64 a)
{
return ::exp(a);
}
@@ -190,7 +194,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 exp(const PxF64 a)
/**
\brief Calculates 2^n
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 exp2(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 exp2(const physx::PxF32 a)
{
return ::expf(a * 0.693147180559945309417f);
}
@@ -198,7 +202,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 exp2(const PxF32 a)
\brief Calculates 2^n
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 exp2(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 exp2(const physx::PxF64 a)
{
return ::exp(a * 0.693147180559945309417);
}
@@ -206,7 +210,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 exp2(const PxF64 a)
/**
\brief Calculates logarithms.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 logE(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 logE(const physx::PxF32 a)
{
return ::logf(a);
}
@@ -214,7 +218,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 logE(const PxF32 a)
/**
\brief Calculates logarithms.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 logE(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 logE(const physx::PxF64 a)
{
return ::log(a);
}
@@ -222,7 +226,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 logE(const PxF64 a)
/**
\brief Calculates logarithms.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 log2(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 log2(const physx::PxF32 a)
{
return ::logf(a) / 0.693147180559945309417f;
}
@@ -230,7 +234,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 log2(const PxF32 a)
/**
\brief Calculates logarithms.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 log2(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 log2(const physx::PxF64 a)
{
return ::log(a) / 0.693147180559945309417;
}
@@ -238,7 +242,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 log2(const PxF64 a)
/**
\brief Calculates logarithms.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 log10(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 log10(const physx::PxF32 a)
{
return ::log10f(a);
}
@@ -246,7 +250,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 log10(const PxF32 a)
/**
\brief Calculates logarithms.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 log10(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 log10(const physx::PxF64 a)
{
return ::log10(a);
}
@@ -254,7 +258,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 log10(const PxF64 a)
/**
\brief Converts degrees to radians.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 degToRad(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 degToRad(const physx::PxF32 a)
{
return 0.01745329251994329547f * a;
}
@@ -262,7 +266,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 degToRad(const PxF32 a)
/**
\brief Converts degrees to radians.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 degToRad(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 degToRad(const physx::PxF64 a)
{
return 0.01745329251994329547 * a;
}
@@ -270,7 +274,7 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 degToRad(const PxF64 a)
/**
\brief Converts radians to degrees.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 radToDeg(const PxF32 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 radToDeg(const physx::PxF32 a)
{
return 57.29577951308232286465f * a;
}
@@ -278,13 +282,13 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 radToDeg(const PxF32 a)
/**
\brief Converts radians to degrees.
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF64 radToDeg(const PxF64 a)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF64 radToDeg(const physx::PxF64 a)
{
return 57.29577951308232286465 * a;
}
//! \brief compute sine and cosine at the same time. There is a 'fsincos' on PC that we probably want to use here
-PX_CUDA_CALLABLE PX_FORCE_INLINE void sincos(const PxF32 radians, PxF32& sin, PxF32& cos)
+PX_CUDA_CALLABLE PX_FORCE_INLINE void sincos(const physx::PxF32 radians, physx::PxF32& sin, physx::PxF32& cos)
{
/* something like:
_asm fld Local
@@ -292,49 +296,49 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE void sincos(const PxF32 radians, PxF32& sin, Px
_asm fstp LocalCos
_asm fstp LocalSin
*/
- sin = PxSin(radians);
- cos = PxCos(radians);
+ sin = physx::PxSin(radians);
+ cos = physx::PxCos(radians);
}
/**
\brief uniform random number in [a,b]
*/
-PX_FORCE_INLINE PxI32 rand(const PxI32 a, const PxI32 b)
+PX_FORCE_INLINE physx::PxI32 rand(const physx::PxI32 a, const physx::PxI32 b)
{
- return a + PxI32(::rand() % (b - a + 1));
+ return a + physx::PxI32(::rand() % (b - a + 1));
}
/**
\brief uniform random number in [a,b]
*/
-PX_FORCE_INLINE PxF32 rand(const PxF32 a, const PxF32 b)
+PX_FORCE_INLINE physx::PxF32 rand(const physx::PxF32 a, const physx::PxF32 b)
{
return a + (b - a) * ::rand() / RAND_MAX;
}
//! \brief return angle between two vectors in radians
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxF32 angle(const PxVec3& v0, const PxVec3& v1)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxF32 angle(const physx::PxVec3& v0, const physx::PxVec3& v1)
{
- const PxF32 cos = v0.dot(v1); // |v0|*|v1|*Cos(Angle)
- const PxF32 sin = (v0.cross(v1)).magnitude(); // |v0|*|v1|*Sin(Angle)
- return PxAtan2(sin, cos);
+ const physx::PxF32 cos = v0.dot(v1); // |v0|*|v1|*Cos(Angle)
+ const physx::PxF32 sin = (v0.cross(v1)).magnitude(); // |v0|*|v1|*Sin(Angle)
+ return physx::PxAtan2(sin, cos);
}
//! If possible use instead fsel on the dot product /*fsel(d.dot(p),onething,anotherthing);*/
//! Compares orientations (more readable, user-friendly function)
-PX_CUDA_CALLABLE PX_FORCE_INLINE bool sameDirection(const PxVec3& d, const PxVec3& p)
+PX_CUDA_CALLABLE PX_FORCE_INLINE bool sameDirection(const physx::PxVec3& d, const physx::PxVec3& p)
{
return d.dot(p) >= 0.0f;
}
//! Checks 2 values have different signs
-PX_CUDA_CALLABLE PX_FORCE_INLINE IntBool differentSign(PxReal f0, PxReal f1)
+PX_CUDA_CALLABLE PX_FORCE_INLINE IntBool differentSign(physx::PxReal f0, physx::PxReal f1)
{
#if !PX_EMSCRIPTEN
union
{
- PxU32 u;
- PxReal f;
+ physx::PxU32 u;
+ physx::PxReal f;
} u1, u2;
u1.f = f0;
u2.f = f1;
@@ -345,57 +349,57 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE IntBool differentSign(PxReal f0, PxReal f1)
#endif
}
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxMat33 star(const PxVec3& v)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxMat33 star(const physx::PxVec3& v)
{
- return PxMat33(PxVec3(0, v.z, -v.y), PxVec3(-v.z, 0, v.x), PxVec3(v.y, -v.x, 0));
+ return physx::PxMat33(physx::PxVec3(0, v.z, -v.y), physx::PxVec3(-v.z, 0, v.x), physx::PxVec3(v.y, -v.x, 0));
}
-PX_CUDA_CALLABLE PX_INLINE PxVec3 log(const PxQuat& q)
+PX_CUDA_CALLABLE PX_INLINE physx::PxVec3 log(const physx::PxQuat& q)
{
- const PxReal s = q.getImaginaryPart().magnitude();
+ const physx::PxReal s = q.getImaginaryPart().magnitude();
if(s < 1e-12f)
- return PxVec3(0.0f);
+ return physx::PxVec3(0.0f);
// force the half-angle to have magnitude <= pi/2
- PxReal halfAngle = q.w < 0 ? PxAtan2(-s, -q.w) : PxAtan2(s, q.w);
- NV_CLOTH_ASSERT(halfAngle >= -PxPi / 2 && halfAngle <= PxPi / 2);
+ physx::PxReal halfAngle = q.w < 0 ? physx::PxAtan2(-s, -q.w) : physx::PxAtan2(s, q.w);
+ NV_CLOTH_ASSERT(halfAngle >= -physx::PxPi / 2 && halfAngle <= physx::PxPi / 2);
return q.getImaginaryPart().getNormalized() * 2.f * halfAngle;
}
-PX_CUDA_CALLABLE PX_INLINE PxQuat exp(const PxVec3& v)
+PX_CUDA_CALLABLE PX_INLINE physx::PxQuat exp(const physx::PxVec3& v)
{
- const PxReal m = v.magnitudeSquared();
- return m < 1e-24f ? PxQuat(PxIdentity) : PxQuat(PxSqrt(m), v * PxRecipSqrt(m));
+ const physx::PxReal m = v.magnitudeSquared();
+ return m < 1e-24f ? physx::PxQuat(physx::PxIdentity) : physx::PxQuat(physx::PxSqrt(m), v * physx::PxRecipSqrt(m));
}
// quat to rotate v0 t0 v1
-PX_CUDA_CALLABLE PX_INLINE PxQuat rotationArc(const PxVec3& v0, const PxVec3& v1)
+PX_CUDA_CALLABLE PX_INLINE physx::PxQuat rotationArc(const physx::PxVec3& v0, const physx::PxVec3& v1)
{
- const PxVec3 cross = v0.cross(v1);
- const PxReal d = v0.dot(v1);
+ const physx::PxVec3 cross = v0.cross(v1);
+ const physx::PxReal d = v0.dot(v1);
if(d <= -0.99999f)
- return (PxAbs(v0.x) < 0.1f ? PxQuat(0.0f, v0.z, -v0.y, 0.0f) : PxQuat(v0.y, -v0.x, 0.0, 0.0)).getNormalized();
+ return (physx::PxAbs(v0.x) < 0.1f ? physx::PxQuat(0.0f, v0.z, -v0.y, 0.0f) : physx::PxQuat(v0.y, -v0.x, 0.0, 0.0)).getNormalized();
- const PxReal s = PxSqrt((1 + d) * 2), r = 1 / s;
+ const physx::PxReal s = physx::PxSqrt((1 + d) * 2), r = 1 / s;
- return PxQuat(cross.x * r, cross.y * r, cross.z * r, s * 0.5f).getNormalized();
+ return physx::PxQuat(cross.x * r, cross.y * r, cross.z * r, s * 0.5f).getNormalized();
}
/**
\brief returns largest axis
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 largestAxis(const PxVec3& v)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU32 largestAxis(const physx::PxVec3& v)
{
- PxU32 m = PxU32(v.y > v.x ? 1 : 0);
+ physx::PxU32 m = physx::PxU32(v.y > v.x ? 1 : 0);
return v.z > v[m] ? 2 : m;
}
/**
\brief returns indices for the largest axis and 2 other axii
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 largestAxis(const PxVec3& v, PxU32& other1, PxU32& other2)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU32 largestAxis(const physx::PxVec3& v, physx::PxU32& other1, physx::PxU32& other2)
{
- if(v.x >= PxMax(v.y, v.z))
+ if(v.x >= physx::PxMax(v.y, v.z))
{
other1 = 1;
other2 = 2;
@@ -418,20 +422,20 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 largestAxis(const PxVec3& v, PxU32& other
/**
\brief returns axis with smallest absolute value
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 closestAxis(const PxVec3& v)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxU32 closestAxis(const physx::PxVec3& v)
{
- PxU32 m = PxU32(PxAbs(v.y) > PxAbs(v.x) ? 1 : 0);
- return PxAbs(v.z) > PxAbs(v[m]) ? 2 : m;
+ physx::PxU32 m = physx::PxU32(physx::PxAbs(v.y) > physx::PxAbs(v.x) ? 1 : 0);
+ return physx::PxAbs(v.z) > physx::PxAbs(v[m]) ? 2 : m;
}
-PX_CUDA_CALLABLE PX_INLINE PxU32 closestAxis(const PxVec3& v, PxU32& j, PxU32& k)
+PX_CUDA_CALLABLE PX_INLINE physx::PxU32 closestAxis(const physx::PxVec3& v, physx::PxU32& j, physx::PxU32& k)
{
// find largest 2D plane projection
- const PxF32 absPx = PxAbs(v.x);
- const PxF32 absNy = PxAbs(v.y);
- const PxF32 absNz = PxAbs(v.z);
+ const physx::PxF32 absPx = physx::PxAbs(v.x);
+ const physx::PxF32 absNy = physx::PxAbs(v.y);
+ const physx::PxF32 absNz = physx::PxAbs(v.z);
- PxU32 m = 0; // x biggest axis
+ physx::PxU32 m = 0; // x biggest axis
j = 1;
k = 2;
if(absNy > absPx && absNy > absNz)
@@ -454,11 +458,11 @@ PX_CUDA_CALLABLE PX_INLINE PxU32 closestAxis(const PxVec3& v, PxU32& j, PxU32& k
/*!
Extend an edge along its length by a factor
*/
-PX_CUDA_CALLABLE PX_FORCE_INLINE void makeFatEdge(PxVec3& p0, PxVec3& p1, PxReal fatCoeff)
+PX_CUDA_CALLABLE PX_FORCE_INLINE void makeFatEdge(physx::PxVec3& p0, physx::PxVec3& p1, physx::PxReal fatCoeff)
{
- PxVec3 delta = p1 - p0;
+ physx::PxVec3 delta = p1 - p0;
- const PxReal m = delta.magnitude();
+ const physx::PxReal m = delta.magnitude();
if(m > 0.0f)
{
delta *= fatCoeff / m;
@@ -468,28 +472,28 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE void makeFatEdge(PxVec3& p0, PxVec3& p1, PxReal
}
//! Compute point as combination of barycentric coordinates
-PX_CUDA_CALLABLE PX_FORCE_INLINE PxVec3
-computeBarycentricPoint(const PxVec3& p0, const PxVec3& p1, const PxVec3& p2, PxReal u, PxReal v)
+PX_CUDA_CALLABLE PX_FORCE_INLINE physx::PxVec3
+computeBarycentricPoint(const physx::PxVec3& p0, const physx::PxVec3& p1, const physx::PxVec3& p2, physx::PxReal u, physx::PxReal v)
{
// This seems to confuse the compiler...
// return (1.0f - u - v)*p0 + u*p1 + v*p2;
- const PxF32 w = 1.0f - u - v;
- return PxVec3(w * p0.x + u * p1.x + v * p2.x, w * p0.y + u * p1.y + v * p2.y, w * p0.z + u * p1.z + v * p2.z);
+ const physx::PxF32 w = 1.0f - u - v;
+ return physx::PxVec3(w * p0.x + u * p1.x + v * p2.x, w * p0.y + u * p1.y + v * p2.y, w * p0.z + u * p1.z + v * p2.z);
}
// generates a pair of quaternions (swing, twist) such that in = swing * twist, with
// swing.x = 0
// twist.y = twist.z = 0, and twist is a unit quat
-PX_FORCE_INLINE void separateSwingTwist(const PxQuat& q, PxQuat& swing, PxQuat& twist)
+PX_FORCE_INLINE void separateSwingTwist(const physx::PxQuat& q, physx::PxQuat& swing, physx::PxQuat& twist)
{
- twist = q.x != 0.0f ? PxQuat(q.x, 0, 0, q.w).getNormalized() : PxQuat(PxIdentity);
+ twist = q.x != 0.0f ? physx::PxQuat(q.x, 0, 0, q.w).getNormalized() : physx::PxQuat(physx::PxIdentity);
swing = q * twist.getConjugate();
}
// generate two tangent vectors to a given normal
-PX_FORCE_INLINE void normalToTangents(const PxVec3& normal, PxVec3& tangent0, PxVec3& tangent1)
+PX_FORCE_INLINE void normalToTangents(const physx::PxVec3& normal, physx::PxVec3& tangent0, physx::PxVec3& tangent1)
{
- tangent0 = PxAbs(normal.x) < 0.70710678f ? PxVec3(0, -normal.z, normal.y) : PxVec3(-normal.y, normal.x, 0);
+ tangent0 = physx::PxAbs(normal.x) < 0.70710678f ? physx::PxVec3(0, -normal.z, normal.y) : physx::PxVec3(-normal.y, normal.x, 0);
tangent0.normalize();
tangent1 = normal.cross(tangent0);
}
@@ -499,11 +503,11 @@ PX_FORCE_INLINE void normalToTangents(const PxVec3& normal, PxVec3& tangent0, Px
\param basis Input = skewed basis, Output = (normalized) orthogonal basis.
\return Bounding box extent.
*/
-NV_CLOTH_IMPORT PxVec3 optimizeBoundingBox(PxMat33& basis);
+NV_CLOTH_IMPORT physx::PxVec3 optimizeBoundingBox(physx::PxMat33& basis);
-NV_CLOTH_IMPORT PxQuat slerp(const PxReal t, const PxQuat& left, const PxQuat& right);
+NV_CLOTH_IMPORT physx::PxQuat slerp(const physx::PxReal t, const physx::PxQuat& left, const physx::PxQuat& right);
-PX_CUDA_CALLABLE PX_INLINE PxVec3 ellipseClamp(const PxVec3& point, const PxVec3& radii)
+PX_CUDA_CALLABLE PX_INLINE physx::PxVec3 ellipseClamp(const physx::PxVec3& point, const physx::PxVec3& radii)
{
// This function need to be implemented in the header file because
// it is included in a spu shader program.
@@ -522,38 +526,38 @@ PX_CUDA_CALLABLE PX_INLINE PxVec3 ellipseClamp(const PxVec3& point, const PxVec3
// converges in 1-2 iterations where D&C works well, and it's good with 4 iterations
// with any ellipse that isn't completely crazy
- const PxU32 MAX_ITERATIONS = 20;
- const PxReal convergenceThreshold = 1e-4f;
+ const physx::PxU32 MAX_ITERATIONS = 20;
+ const physx::PxReal convergenceThreshold = 1e-4f;
// iteration requires first quadrant but we recover generality later
- PxVec3 q(0, PxAbs(point.y), PxAbs(point.z));
- const PxReal tinyEps = 1e-6f; // very close to minor axis is numerically problematic but trivial
+ physx::PxVec3 q(0, physx::PxAbs(point.y), physx::PxAbs(point.z));
+ const physx::PxReal tinyEps = 1e-6f; // very close to minor axis is numerically problematic but trivial
if(radii.y >= radii.z)
{
if(q.z < tinyEps)
- return PxVec3(0, point.y > 0 ? radii.y : -radii.y, 0);
+ return physx::PxVec3(0, point.y > 0 ? radii.y : -radii.y, 0);
}
else
{
if(q.y < tinyEps)
- return PxVec3(0, 0, point.z > 0 ? radii.z : -radii.z);
+ return physx::PxVec3(0, 0, point.z > 0 ? radii.z : -radii.z);
}
- PxVec3 denom, e2 = radii.multiply(radii), eq = radii.multiply(q);
+ physx::PxVec3 denom, e2 = radii.multiply(radii), eq = radii.multiply(q);
// we can use any initial guess which is > maximum(-e.y^2,-e.z^2) and for which f(t) is > 0.
// this guess works well near the axes, but is weak along the diagonals.
- PxReal t = PxMax(eq.y - e2.y, eq.z - e2.z);
+ physx::PxReal t = physx::PxMax(eq.y - e2.y, eq.z - e2.z);
- for(PxU32 i = 0; i < MAX_ITERATIONS; i++)
+ for(physx::PxU32 i = 0; i < MAX_ITERATIONS; i++)
{
- denom = PxVec3(0, 1 / (t + e2.y), 1 / (t + e2.z));
- PxVec3 denom2 = eq.multiply(denom);
+ denom = physx::PxVec3(0, 1 / (t + e2.y), 1 / (t + e2.z));
+ physx::PxVec3 denom2 = eq.multiply(denom);
- PxVec3 fv = denom2.multiply(denom2);
- PxReal f = fv.y + fv.z - 1;
+ physx::PxVec3 fv = denom2.multiply(denom2);
+ physx::PxReal f = fv.y + fv.z - 1;
// although in exact arithmetic we are guaranteed f>0, we can get here
// on the first iteration via catastrophic cancellation if the point is
@@ -562,44 +566,44 @@ PX_CUDA_CALLABLE PX_INLINE PxVec3 ellipseClamp(const PxVec3& point, const PxVec3
if(f < convergenceThreshold)
return e2.multiply(point).multiply(denom);
- PxReal df = fv.dot(denom) * -2.0f;
+ physx::PxReal df = fv.dot(denom) * -2.0f;
t = t - f / df;
}
// we didn't converge, so clamp what we have
- PxVec3 r = e2.multiply(point).multiply(denom);
- return r * PxRecipSqrt(sqr(r.y / radii.y) + sqr(r.z / radii.z));
+ physx::PxVec3 r = e2.multiply(point).multiply(denom);
+ return r * physx::PxRecipSqrt(sqr(r.y / radii.y) + sqr(r.z / radii.z));
}
-PX_CUDA_CALLABLE PX_INLINE PxReal tanHalf(PxReal sin, PxReal cos)
+PX_CUDA_CALLABLE PX_INLINE physx::PxReal tanHalf(physx::PxReal sin, physx::PxReal cos)
{
return sin / (1 + cos);
}
-PX_INLINE PxQuat quatFromTanQVector(const PxVec3& v)
+PX_INLINE physx::PxQuat quatFromTanQVector(const physx::PxVec3& v)
{
- PxReal v2 = v.dot(v);
+ physx::PxReal v2 = v.dot(v);
if(v2 < 1e-12f)
- return PxQuat(PxIdentity);
- PxReal d = 1 / (1 + v2);
- return PxQuat(v.x * 2, v.y * 2, v.z * 2, 1 - v2) * d;
+ return physx::PxQuat(physx::PxIdentity);
+ physx::PxReal d = 1 / (1 + v2);
+ return physx::PxQuat(v.x * 2, v.y * 2, v.z * 2, 1 - v2) * d;
}
-PX_FORCE_INLINE PxVec3 cross100(const PxVec3& b)
+PX_FORCE_INLINE physx::PxVec3 cross100(const physx::PxVec3& b)
{
- return PxVec3(0.0f, -b.z, b.y);
+ return physx::PxVec3(0.0f, -b.z, b.y);
}
-PX_FORCE_INLINE PxVec3 cross010(const PxVec3& b)
+PX_FORCE_INLINE physx::PxVec3 cross010(const physx::PxVec3& b)
{
- return PxVec3(b.z, 0.0f, -b.x);
+ return physx::PxVec3(b.z, 0.0f, -b.x);
}
-PX_FORCE_INLINE PxVec3 cross001(const PxVec3& b)
+PX_FORCE_INLINE physx::PxVec3 cross001(const physx::PxVec3& b)
{
- return PxVec3(-b.y, b.x, 0.0f);
+ return physx::PxVec3(-b.y, b.x, 0.0f);
}
-PX_INLINE void decomposeVector(PxVec3& normalCompo, PxVec3& tangentCompo, const PxVec3& outwardDir,
- const PxVec3& outwardNormal)
+PX_INLINE void decomposeVector(physx::PxVec3& normalCompo, physx::PxVec3& tangentCompo, const physx::PxVec3& outwardDir,
+ const physx::PxVec3& outwardNormal)
{
normalCompo = outwardNormal * (outwardDir.dot(outwardNormal));
tangentCompo = outwardDir - normalCompo;
@@ -607,31 +611,31 @@ PX_INLINE void decomposeVector(PxVec3& normalCompo, PxVec3& tangentCompo, const
//! \brief Return (i+1)%3
// Avoid variable shift for XBox:
-// PX_INLINE PxU32 Ps::getNextIndex3(PxU32 i) { return (1<<i) & 3; }
-PX_INLINE PxU32 getNextIndex3(PxU32 i)
+// PX_INLINE physx::PxU32 Ps::getNextIndex3(physx::PxU32 i) { return (1<<i) & 3; }
+PX_INLINE physx::PxU32 getNextIndex3(physx::PxU32 i)
{
return (i + 1 + (i >> 1)) & 3;
}
-PX_INLINE PxMat33 rotFrom2Vectors(const PxVec3& from, const PxVec3& to)
+PX_INLINE physx::PxMat33 rotFrom2Vectors(const physx::PxVec3& from, const physx::PxVec3& to)
{
// See bottom of http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index.htm
// Early exit if to = from
if((from - to).magnitudeSquared() < 1e-4f)
- return PxMat33(PxIdentity);
+ return physx::PxMat33(physx::PxIdentity);
// Early exit if to = -from
if((from + to).magnitudeSquared() < 1e-4f)
- return PxMat33::createDiagonal(PxVec3(1.0f, -1.0f, -1.0f));
+ return physx::PxMat33::createDiagonal(physx::PxVec3(1.0f, -1.0f, -1.0f));
- PxVec3 n = from.cross(to);
+ physx::PxVec3 n = from.cross(to);
- PxReal C = from.dot(to), S = PxSqrt(1 - C * C), CC = 1 - C;
+ physx::PxReal C = from.dot(to), S = physx::PxSqrt(1 - C * C), CC = 1 - C;
- PxReal xx = n.x * n.x, yy = n.y * n.y, zz = n.z * n.z, xy = n.x * n.y, yz = n.y * n.z, xz = n.x * n.z;
+ physx::PxReal xx = n.x * n.x, yy = n.y * n.y, zz = n.z * n.z, xy = n.x * n.y, yz = n.y * n.z, xz = n.x * n.z;
- PxMat33 R;
+ physx::PxMat33 R;
R(0, 0) = 1 + CC * (xx - 1);
R(0, 1) = -n.z * S + CC * xy;
@@ -648,31 +652,31 @@ PX_INLINE PxMat33 rotFrom2Vectors(const PxVec3& from, const PxVec3& to)
return R;
}
-NV_CLOTH_IMPORT void integrateTransform(const PxTransform& curTrans, const PxVec3& linvel, const PxVec3& angvel,
- PxReal timeStep, PxTransform& result);
+NV_CLOTH_IMPORT void integrateTransform(const physx::PxTransform& curTrans, const physx::PxVec3& linvel, const physx::PxVec3& angvel,
+ physx::PxReal timeStep, physx::PxTransform& result);
-PX_INLINE void computeBasis(const PxVec3& dir, PxVec3& right, PxVec3& up)
+PX_INLINE void computeBasis(const physx::PxVec3& dir, physx::PxVec3& right, physx::PxVec3& up)
{
// Derive two remaining vectors
- if(PxAbs(dir.y) <= 0.9999f)
+ if(physx::PxAbs(dir.y) <= 0.9999f)
{
- right = PxVec3(dir.z, 0.0f, -dir.x);
+ right = physx::PxVec3(dir.z, 0.0f, -dir.x);
right.normalize();
// PT: normalize not needed for 'up' because dir & right are unit vectors,
// and by construction the angle between them is 90 degrees (i.e. sin(angle)=1)
- up = PxVec3(dir.y * right.z, dir.z * right.x - dir.x * right.z, -dir.y * right.x);
+ up = physx::PxVec3(dir.y * right.z, dir.z * right.x - dir.x * right.z, -dir.y * right.x);
}
else
{
- right = PxVec3(1.0f, 0.0f, 0.0f);
+ right = physx::PxVec3(1.0f, 0.0f, 0.0f);
- up = PxVec3(0.0f, dir.z, -dir.y);
+ up = physx::PxVec3(0.0f, dir.z, -dir.y);
up.normalize();
}
}
-PX_INLINE void computeBasis(const PxVec3& p0, const PxVec3& p1, PxVec3& dir, PxVec3& right, PxVec3& up)
+PX_INLINE void computeBasis(const physx::PxVec3& p0, const physx::PxVec3& p1, physx::PxVec3& dir, physx::PxVec3& right, physx::PxVec3& up)
{
// Compute the new direction vector
dir = p1 - p0;
@@ -682,14 +686,14 @@ PX_INLINE void computeBasis(const PxVec3& p0, const PxVec3& p1, PxVec3& dir, PxV
computeBasis(dir, right, up);
}
-PX_FORCE_INLINE bool isAlmostZero(const PxVec3& v)
+PX_FORCE_INLINE bool isAlmostZero(const physx::PxVec3& v)
{
- if(PxAbs(v.x) > 1e-6f || PxAbs(v.y) > 1e-6f || PxAbs(v.z) > 1e-6f)
+ if(physx::PxAbs(v.x) > 1e-6f || physx::PxAbs(v.y) > 1e-6f || physx::PxAbs(v.z) > 1e-6f)
return false;
return true;
}
-
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif
diff --git a/NvCloth/include/NvCloth/ps/PsUserAllocated.h b/NvCloth/include/NvCloth/ps/PsUserAllocated.h
index f41d29e..45674d9 100644
--- a/NvCloth/include/NvCloth/ps/PsUserAllocated.h
+++ b/NvCloth/include/NvCloth/ps/PsUserAllocated.h
@@ -32,9 +32,13 @@
#include "PsAllocator.h"
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
/**
Provides new and delete using a UserAllocator.
@@ -86,7 +90,8 @@ class UserAllocated
PX_INLINE void operator delete [](void* ptr)
{ NonTrackingAllocator().deallocate(ptr); }
};
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSUSERALLOCATED_H
diff --git a/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h b/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h
index 93d20b5..5e25b31 100644
--- a/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h
+++ b/NvCloth/include/NvCloth/ps/unix/PsUnixIntrinsics.h
@@ -49,10 +49,15 @@
#error "This file should only be included by unix builds!!"
#endif
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
{
+namespace ps
+{
+
PX_FORCE_INLINE void memoryBarrier()
{
@@ -146,8 +151,8 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE float floatFloor(float x)
#define NS_EXPECT_TRUE(x) x
#define NS_EXPECT_FALSE(x) x
-
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSUNIXINTRINSICS_H
diff --git a/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h b/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h
index ac81f02..81f6c70 100644
--- a/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h
+++ b/NvCloth/include/NvCloth/ps/windows/PsWindowsIntrinsics.h
@@ -59,9 +59,13 @@
#pragma intrinsic(_BitScanForward)
#pragma intrinsic(_BitScanReverse)
-namespace physx
+/** \brief NVidia namespace */
+namespace nv
{
-namespace shdfnd
+/** \brief nvcloth namespace */
+namespace cloth
+{
+namespace ps
{
/*
@@ -183,7 +187,8 @@ PX_CUDA_CALLABLE PX_FORCE_INLINE float floatFloor(float x)
#define NS_EXPECT_TRUE(x) x
#define NS_EXPECT_FALSE(x) x
-} // namespace shdfnd
-} // namespace physx
+} // namespace ps
+} // namespace cloth
+} // namespace nv
#endif // #ifndef PSFOUNDATION_PSWINDOWSINTRINSICS_H