diff options
| author | Sheikh Dawood Abdul Ajees <[email protected]> | 2017-11-20 14:41:07 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <[email protected]> | 2017-11-20 15:22:41 -0600 |
| commit | 4bda45ce4e8b509eb0da786a6044006942ac259c (patch) | |
| tree | a51eb808016e1710a4bbd537000a493250602944 /PxShared/src | |
| parent | Update README.md (diff) | |
| parent | PhysX 3.4.1, APEX 1.4.1 Release @23131702 (diff) | |
| download | physx-3.4-4bda45ce4e8b509eb0da786a6044006942ac259c.tar.xz physx-3.4-4bda45ce4e8b509eb0da786a6044006942ac259c.zip | |
Merge branch 'master'
Diffstat (limited to 'PxShared/src')
| -rw-r--r-- | PxShared/src/foundation/include/PsArray.h | 129 | ||||
| -rw-r--r-- | PxShared/src/foundation/include/PsMathUtils.h | 3 | ||||
| -rw-r--r-- | PxShared/src/foundation/include/PsVecMath.h | 2 | ||||
| -rw-r--r-- | PxShared/src/foundation/src/unix/PsUnixCpu.cpp | 2 | ||||
| -rw-r--r-- | PxShared/src/foundation/src/unix/PsUnixFPU.cpp | 8 |
5 files changed, 28 insertions, 116 deletions
diff --git a/PxShared/src/foundation/include/PsArray.h b/PxShared/src/foundation/include/PsArray.h index 8433fbe0..2121c303 100644 --- a/PxShared/src/foundation/include/PsArray.h +++ b/PxShared/src/foundation/include/PsArray.h @@ -35,17 +35,6 @@ #include "PsAllocator.h" #include "PsBasicTemplates.h" -#if PX_LIBCPP -#include <type_traits> -#else -#include <tr1/type_traits> -#endif - -#if PX_VC == 9 || PX_VC == 10 -#pragma warning(push) -#pragma warning(disable : 4347) // behavior change: 'function template' is called instead of 'function' -#endif - namespace physx { namespace shdfnd @@ -158,15 +147,6 @@ class Array : protected Alloc return operator=<Alloc>(t); } - PX_FORCE_INLINE static bool isArrayOfPOD() - { -#if PX_LIBCPP - return std::is_trivially_copyable<T>::value; -#else - return std::tr1::is_pod<T>::value; -#endif - } - /*! Array indexing operator. \param i @@ -338,14 +318,7 @@ class Array : protected Alloc PX_ASSERT(mSize); T t = mData[mSize - 1]; - if(!isArrayOfPOD()) - { - mData[--mSize].~T(); - } - else - { - --mSize; - } + mData[--mSize].~T(); return t; } @@ -379,10 +352,7 @@ class Array : protected Alloc PX_ASSERT(i < mSize); mData[i] = mData[--mSize]; - if(!isArrayOfPOD()) - { - mData[mSize].~T(); - } + mData[mSize].~T(); } PX_INLINE void replaceWithLast(Iterator i) @@ -424,24 +394,14 @@ class Array : protected Alloc { PX_ASSERT(i < mSize); - if(isArrayOfPOD()) - { - if(i + 1 != mSize) - { - physx::intrinsics::memMove(mData + i, mData + i + 1, (mSize - i - 1) * sizeof(T)); - } - } - else - { - T* it = mData + i; + T* it = mData + i; + it->~T(); + while (++i < mSize) + { + new (it) T(mData[i]); + ++it; it->~T(); - while (++i < mSize) - { - new (it) T(mData[i]); - ++it; - it->~T(); - } - } + } --mSize; } @@ -460,31 +420,19 @@ class Array : protected Alloc PX_ASSERT(begin < mSize); PX_ASSERT((begin + count) <= mSize); - if(!isArrayOfPOD()) - { - for(uint32_t i = 0; i < count; i++) - { - mData[begin + i].~T(); // call the destructor on the ones being removed first. - } - } + for(uint32_t i = 0; i < count; i++) + mData[begin + i].~T(); // call the destructor on the ones being removed first. T* dest = &mData[begin]; // location we are copying the tail end objects to T* src = &mData[begin + count]; // start of tail objects uint32_t move_count = mSize - (begin + count); // compute remainder that needs to be copied down - if(isArrayOfPOD()) - { - physx::intrinsics::memMove(dest, src, move_count * sizeof(T)); - } - else + for(uint32_t i = 0; i < move_count; i++) { - for(uint32_t i = 0; i < move_count; i++) - { - new (dest) T(*src); // copy the old one to the new location - src->~T(); // call the destructor on the old location - dest++; - src++; - } + new (dest) T(*src); // copy the old one to the new location + src->~T(); // call the destructor on the old location + dest++; + src++; } mSize -= count; } @@ -624,29 +572,10 @@ definition for serialized classes is complete in checked builds. Alloc::deallocate(mem); } - static PX_INLINE bool isZeroInit(const T& object) - { - if (!isArrayOfPOD()) - return false; - char ZeroBuffOnStack[sizeof(object)] = {}; - // bgaldrikian - casting to void* to avoid compiler error: - // error : first operand of this 'memcmp' call is a pointer to dynamic class [...]; vtable pointer will be compared [-Werror,-Wdynamic-class-memaccess] - // even though POD check prevents memcmp from being used on a dynamic class - return memcmp(reinterpret_cast<const void*>(&object), ZeroBuffOnStack, sizeof(object)) == 0; - } - static PX_INLINE void create(T* first, T* last, const T& a) { - if(isZeroInit(a)) - { - if(last > first) - physx::intrinsics::memZero(first, uint32_t((last - first) * sizeof(T))); - } - else - { - for(; first < last; ++first) - ::new (first) T(a); - } + for(; first < last; ++first) + ::new (first) T(a); } static PX_INLINE void copy(T* first, T* last, const T* src) @@ -654,24 +583,14 @@ definition for serialized classes is complete in checked builds. if(last <= first) return; - if(isArrayOfPOD()) - { - physx::intrinsics::memCopy(first, src, uint32_t((last - first) * sizeof(T))); - } - else - { - for(; first < last; ++first, ++src) - ::new (first) T(*src); - } + for(; first < last; ++first, ++src) + ::new (first) T(*src); } static PX_INLINE void destroy(T* first, T* last) { - if(!isArrayOfPOD()) - { - for(; first < last; ++first) - first->~T(); - } + for(; first < last; ++first) + first->~T(); } /*! @@ -799,8 +718,4 @@ PX_INLINE void swap(Array<T, Alloc>& x, Array<T, Alloc>& y) } // namespace shdfnd } // namespace physx -#if PX_VC == 9 || PX_VC == 10 -#pragma warning(pop) -#endif - #endif // #ifndef PSFOUNDATION_PSARRAY_H diff --git a/PxShared/src/foundation/include/PsMathUtils.h b/PxShared/src/foundation/include/PsMathUtils.h index 794419be..789cf3f2 100644 --- a/PxShared/src/foundation/include/PsMathUtils.h +++ b/PxShared/src/foundation/include/PsMathUtils.h @@ -493,9 +493,6 @@ PX_FORCE_INLINE void normalToTangents(const PxVec3& normal, PxVec3& tangent0, Px tangent1 = normal.cross(tangent0); } -// todo: what is this function doing? -PX_FOUNDATION_API PxQuat computeQuatFromNormal(const PxVec3& n); - /** \brief computes a oriented bounding box around the scaled basis. \param basis Input = skewed basis, Output = (normalized) orthogonal basis. diff --git a/PxShared/src/foundation/include/PsVecMath.h b/PxShared/src/foundation/include/PsVecMath.h index ffd2de86..bf60c756 100644 --- a/PxShared/src/foundation/include/PsVecMath.h +++ b/PxShared/src/foundation/include/PsVecMath.h @@ -48,7 +48,7 @@ // enable/disable SIMD #if !defined(PX_SIMD_DISABLED) -#if PX_INTEL_FAMILY && (!defined(__EMSCRIPTEN__) || defined(__SSE2__)) +#if PX_INTEL_FAMILY && (!PX_EMSCRIPTEN || defined(__SSE2__)) #define COMPILE_VECTOR_INTRINSICS 1 #elif PX_ANDROID&& PX_NEON #define COMPILE_VECTOR_INTRINSICS 1 diff --git a/PxShared/src/foundation/src/unix/PsUnixCpu.cpp b/PxShared/src/foundation/src/unix/PsUnixCpu.cpp index 0139fe4c..66e4fa86 100644 --- a/PxShared/src/foundation/src/unix/PsUnixCpu.cpp +++ b/PxShared/src/foundation/src/unix/PsUnixCpu.cpp @@ -30,7 +30,7 @@ #include "foundation/PxSimpleTypes.h" #include "PsCpu.h" -#if PX_X86 && !defined(__EMSCRIPTEN__) +#if PX_X86 && !PX_EMSCRIPTEN #define cpuid(op, reg) \ __asm__ __volatile__("pushl %%ebx \n\t" /* save %ebx */ \ "cpuid \n\t" \ diff --git a/PxShared/src/foundation/src/unix/PsUnixFPU.cpp b/PxShared/src/foundation/src/unix/PsUnixFPU.cpp index e12fa5f3..976e8d19 100644 --- a/PxShared/src/foundation/src/unix/PsUnixFPU.cpp +++ b/PxShared/src/foundation/src/unix/PsUnixFPU.cpp @@ -51,7 +51,7 @@ physx::shdfnd::FPUGuard::FPUGuard() mControlWords[0] = _mm_getcsr(); // set default (disable exceptions: _MM_MASK_MASK) and FTZ (_MM_FLUSH_ZERO_ON), DAZ (_MM_DENORMALS_ZERO_ON: (1<<6)) _mm_setcsr(_MM_MASK_MASK | _MM_FLUSH_ZERO_ON | (1 << 6)); -#elif defined(__EMSCRIPTEN__) +#elif PX_EMSCRIPTEN // not supported #else PX_COMPILE_TIME_ASSERT(sizeof(fenv_t) <= sizeof(mControlWords)); @@ -80,7 +80,7 @@ physx::shdfnd::FPUGuard::~FPUGuard() // restore control word and clear exception flags // (setting exception state flags cause exceptions on the first following fp operation) _mm_setcsr(mControlWords[0] & ~_MM_EXCEPT_MASK); -#elif defined(__EMSCRIPTEN__) +#elif PX_EMSCRIPTEN // not supported #else fesetenv(reinterpret_cast<fenv_t*>(mControlWords)); @@ -89,7 +89,7 @@ physx::shdfnd::FPUGuard::~FPUGuard() PX_FOUNDATION_API void physx::shdfnd::enableFPExceptions() { -#if PX_LINUX && !defined(__EMSCRIPTEN__) +#if PX_LINUX && !PX_EMSCRIPTEN feclearexcept(FE_ALL_EXCEPT); feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW); #elif PX_OSX @@ -106,7 +106,7 @@ PX_FOUNDATION_API void physx::shdfnd::enableFPExceptions() PX_FOUNDATION_API void physx::shdfnd::disableFPExceptions() { -#if PX_LINUX && !defined(__EMSCRIPTEN__) +#if PX_LINUX && !PX_EMSCRIPTEN fedisableexcept(FE_ALL_EXCEPT); #elif PX_OSX // clear any pending exceptions |