Merge changes from the-witness.

This commit is contained in:
castano
2010-10-21 18:44:10 +00:00
parent 5d498d6824
commit bd74a9ffc6
27 changed files with 217 additions and 126 deletions

View File

@ -162,7 +162,7 @@ Plane nv::Fit::bestPlane(int n, const Vector3 *__restrict points)
return Plane(Vector3(0, 0, 1), centroid);
}
#pragma message(NV_FILE_LINE "TODO: need to write an eigensolver!")
#pragma NV_MESSAGE("TODO: need to write an eigensolver!")
// - Numerical Recipes in C is a good reference. Householder transforms followed by QL decomposition seems to be the best approach.
// - The one from magic-tools is now LGPL. For the 3D case it uses a cubic root solver, which is not very accurate.

View File

@ -275,7 +275,10 @@ static inline uint16 _uint16_sels( uint16 test, uint16 a, uint16 b )
return (result);
}
#if NV_CC_MSVC
#if NV_OS_XBOX
#include <PPCIntrinsics.h>
#elif NV_CC_MSVC
#include <intrin.h>
#pragma intrinsic(_BitScanReverse)
@ -297,6 +300,9 @@ static inline uint32 _uint32_cntlz( uint32 x )
uint32 nlz = __builtin_clz( x );
uint32 result = _uint32_sels( is_x_nez_msb, nlz, 0x00000020 );
return (result);
#elif NV_OS_XBOX
// Xbox PPC has this as an intrinsic.
return _CountLeadingZeros(x);
#elif NV_CC_MSVC
uint32 is_x_nez_msb = _uint32_neg( x );
uint32 nlz = _uint32_nlz( x );
@ -342,6 +348,9 @@ static inline uint16 _uint16_cntlz( uint16 x )
uint16 nlz32 = (uint16)_uint32_cntlz( (uint32)x );
uint32 nlz = _uint32_sub( nlz32, 16 );
return (nlz);
#elif _NV_OS_XBOX_
uint16 nlz32 = (uint16)_CountLeadingZeros( (uint32)x );
return _uint32_sub( nlz32, 16);
#else
const uint16 x0 = _uint16_srl( x, 1 );
const uint16 x1 = _uint16_or( x, x0 );

View File

@ -88,6 +88,10 @@ namespace nv
};
};
// Helpers to convert vector types. Assume T has x,y,z members and 3 argument constructor.
template <typename T> Vector3 from(const T & v) { return Vector3(v.x, v.y, v.z); }
template <typename T> T to(Vector3::Arg v) { return T(v.x, v.y, v.z); }
class NVMATH_CLASS Vector4
{

View File

@ -10,7 +10,7 @@
#include <math.h>
#include <limits.h> // INT_MAX
#if NV_OS_WIN32
#if NV_OS_WIN32 || NV_OS_XBOX
#include <float.h>
#endif
@ -116,7 +116,7 @@ namespace nv
inline bool isFinite(const float f)
{
#if NV_OS_WIN32
#if NV_OS_WIN32 || NV_OS_XBOX
return _finite(f) != 0;
#elif NV_OS_DARWIN || NV_OS_FREEBSD
return isfinite(f);
@ -131,7 +131,7 @@ namespace nv
inline bool isNan(const float f)
{
#if NV_OS_WIN32
#if NV_OS_WIN32 || NV_OS_XBOX
return _isnan(f) != 0;
#elif NV_OS_DARWIN || NV_OS_FREEBSD
return isnan(f);