1
0
mirror of https://github.com/microsoft/DirectXMath synced 2024-11-09 14:10:09 +00:00

DirectXMath 3.02

This commit is contained in:
Chuck Walbourn 2016-05-23 14:07:40 -07:00
parent 1fa826b8da
commit 409c3a3646
9 changed files with 10682 additions and 7478 deletions

View File

@ -33,14 +33,16 @@ enum PlaneIntersectionType
};
struct BoundingBox;
struct BoundingOrientedBox;
struct BoundingFrustum;
#pragma warning(push)
#pragma warning(disable:4324)
#pragma warning(disable:4324 4820)
//-------------------------------------------------------------------------------------
// Bounding sphere
//-------------------------------------------------------------------------------------
__declspec(align(16)) struct BoundingSphere
struct BoundingSphere
{
XMFLOAT3 Center; // Center of the sphere.
float Radius; // Radius of the sphere.
@ -63,10 +65,14 @@ __declspec(align(16)) struct BoundingSphere
ContainmentType Contains( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
ContainmentType Contains( _In_ const BoundingSphere& sh ) const;
ContainmentType Contains( _In_ const BoundingBox& box ) const;
ContainmentType Contains( _In_ const BoundingOrientedBox& box ) const;
ContainmentType Contains( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ const BoundingSphere& sh ) const;
bool Intersects( _In_ const BoundingBox& box ) const;
bool Intersects( _In_ const BoundingOrientedBox& box ) const;
bool Intersects( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
// Triangle-sphere test
@ -76,19 +82,26 @@ __declspec(align(16)) struct BoundingSphere
bool Intersects( _In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist ) const;
// Ray-sphere test
ContainmentType ContainedBy( _In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5 ) const;
// Test sphere against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateMerged( _Out_ BoundingSphere& Out, _In_ const BoundingSphere& S1, _In_ const BoundingSphere& S2 );
static void CreateFromBoundingBox( _Out_ BoundingSphere& Out, _In_ const BoundingBox& box );
static void CreateFromBoundingBox( _Out_ BoundingSphere& Out, _In_ const BoundingOrientedBox& box );
static void CreateFromPoints( _Out_ BoundingSphere& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3)+Stride*(Count-1)) const XMFLOAT3* pPoints, _In_ size_t Stride );
static void CreateFromFrustum( _Out_ BoundingSphere& Out, _In_ const BoundingFrustum& fr );
};
//-------------------------------------------------------------------------------------
// Axis-aligned bounding box
//-------------------------------------------------------------------------------------
__declspec(align(16)) struct BoundingBox
struct BoundingBox
{
static const size_t CORNER_COUNT = 8;
@ -114,9 +127,13 @@ __declspec(align(16)) struct BoundingBox
ContainmentType Contains( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
ContainmentType Contains( _In_ const BoundingSphere& sh ) const;
ContainmentType Contains( _In_ const BoundingBox& box ) const;
ContainmentType Contains( _In_ const BoundingOrientedBox& box ) const;
ContainmentType Contains( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ const BoundingSphere& sh ) const;
bool Intersects( _In_ const BoundingBox& box ) const;
bool Intersects( _In_ const BoundingOrientedBox& box ) const;
bool Intersects( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
// Triangle-Box test
@ -127,6 +144,10 @@ __declspec(align(16)) struct BoundingBox
bool Intersects( _In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist ) const;
// Ray-Box test
ContainmentType ContainedBy( _In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5 ) const;
// Test box against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateMerged( _Out_ BoundingBox& Out, _In_ const BoundingBox& b1, _In_ const BoundingBox& b2 );
@ -137,6 +158,164 @@ __declspec(align(16)) struct BoundingBox
_In_reads_bytes_(sizeof(XMFLOAT3)+Stride*(Count-1)) const XMFLOAT3* pPoints, _In_ size_t Stride );
};
//-------------------------------------------------------------------------------------
// Oriented bounding box
//-------------------------------------------------------------------------------------
struct BoundingOrientedBox
{
static const size_t CORNER_COUNT = 8;
XMFLOAT3 Center; // Center of the box.
XMFLOAT3 Extents; // Distance from the center to each side.
XMFLOAT4 Orientation; // Unit quaternion representing rotation (box -> world).
// Creators
BoundingOrientedBox() : Center(0,0,0), Extents( 1.f, 1.f, 1.f ), Orientation(0,0,0, 1.f ) {}
BoundingOrientedBox( _In_ const XMFLOAT3& _Center, _In_ const XMFLOAT3& _Extents, _In_ const XMFLOAT4& _Orientation )
: Center(_Center), Extents(_Extents), Orientation(_Orientation)
{
assert(_Extents.x >= 0 && _Extents.y >= 0 && _Extents.z >= 0);
}
BoundingOrientedBox( _In_ const BoundingOrientedBox& box )
: Center(box.Center), Extents(box.Extents), Orientation(box.Orientation) {}
// Methods
BoundingOrientedBox& operator=( _In_ const BoundingOrientedBox& box ) { Center = box.Center; Extents = box.Extents; Orientation = box.Orientation; return *this; }
void Transform( _Out_ BoundingOrientedBox& Out, _In_ CXMMATRIX M ) const;
void Transform( _Out_ BoundingOrientedBox& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation ) const;
void GetCorners( _Out_writes_(8) XMFLOAT3* Corners ) const;
// Gets the 8 corners of the box
ContainmentType Contains( _In_ FXMVECTOR Point ) const;
ContainmentType Contains( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
ContainmentType Contains( _In_ const BoundingSphere& sh ) const;
ContainmentType Contains( _In_ const BoundingBox& box ) const;
ContainmentType Contains( _In_ const BoundingOrientedBox& box ) const;
ContainmentType Contains( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ const BoundingSphere& sh ) const;
bool Intersects( _In_ const BoundingBox& box ) const;
bool Intersects( _In_ const BoundingOrientedBox& box ) const;
bool Intersects( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
// Triangle-OrientedBox test
PlaneIntersectionType Intersects( _In_ FXMVECTOR Plane ) const;
// Plane-OrientedBox test
bool Intersects( _In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist ) const;
// Ray-OrientedBox test
ContainmentType ContainedBy( _In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5 ) const;
// Test OrientedBox against six planes (see BoundingFrustum::GetPlanes)
// Static methods
static void CreateFromBoundingBox( _Out_ BoundingOrientedBox& Out, _In_ const BoundingBox& box );
static void CreateFromPoints( _Out_ BoundingOrientedBox& Out, _In_ size_t Count,
_In_reads_bytes_(sizeof(XMFLOAT3)+Stride*(Count-1)) const XMFLOAT3* pPoints, _In_ size_t Stride );
};
//-------------------------------------------------------------------------------------
// Bounding frustum
//-------------------------------------------------------------------------------------
struct BoundingFrustum
{
static const size_t CORNER_COUNT = 8;
XMFLOAT3 Origin; // Origin of the frustum (and projection).
XMFLOAT4 Orientation; // Quaternion representing rotation.
float RightSlope; // Positive X slope (X/Z).
float LeftSlope; // Negative X slope.
float TopSlope; // Positive Y slope (Y/Z).
float BottomSlope; // Negative Y slope.
float Near, Far; // Z of the near plane and far plane.
// Creators
BoundingFrustum() : Origin(0,0,0), Orientation(0,0,0, 1.f), RightSlope( 1.f ), LeftSlope( -1.f ),
TopSlope( 1.f ), BottomSlope( -1.f ), Near(0), Far( 1.f ) {}
BoundingFrustum( _In_ const XMFLOAT3& _Origin, _In_ const XMFLOAT4& _Orientation,
_In_ float _RightSlope, _In_ float _LeftSlope, _In_ float _TopSlope, _In_ float _BottomSlope,
_In_ float _Near, _In_ float _Far )
: Origin(_Origin), Orientation(_Orientation),
RightSlope(_RightSlope), LeftSlope(_LeftSlope), TopSlope(_TopSlope), BottomSlope(_BottomSlope),
Near(_Near), Far(_Far) { assert( _Near <= _Far ); }
BoundingFrustum( _In_ const BoundingFrustum& fr )
: Origin(fr.Origin), Orientation(fr.Orientation), RightSlope(fr.RightSlope), LeftSlope(fr.LeftSlope),
TopSlope(fr.TopSlope), BottomSlope(fr.BottomSlope), Near(fr.Near), Far(fr.Far) {}
BoundingFrustum( _In_ CXMMATRIX Projection ) { CreateFromMatrix( *this, Projection ); }
// Methods
BoundingFrustum& operator=( _In_ const BoundingFrustum& fr ) { Origin=fr.Origin; Orientation=fr.Orientation;
RightSlope=fr.RightSlope; LeftSlope=fr.LeftSlope;
TopSlope=fr.TopSlope; BottomSlope=fr.BottomSlope;
Near=fr.Near; Far=fr.Far; return *this; }
void Transform( _Out_ BoundingFrustum& Out, _In_ CXMMATRIX M ) const;
void Transform( _Out_ BoundingFrustum& Out, _In_ float Scale, _In_ FXMVECTOR Rotation, _In_ FXMVECTOR Translation ) const;
void GetCorners( _Out_writes_(8) XMFLOAT3* Corners ) const;
// Gets the 8 corners of the frustum
ContainmentType Contains( _In_ FXMVECTOR Point ) const;
ContainmentType Contains( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
ContainmentType Contains( _In_ const BoundingSphere& sp ) const;
ContainmentType Contains( _In_ const BoundingBox& box ) const;
ContainmentType Contains( _In_ const BoundingOrientedBox& box ) const;
ContainmentType Contains( _In_ const BoundingFrustum& fr ) const;
// Frustum-Frustum test
bool Intersects( _In_ const BoundingSphere& sh ) const;
bool Intersects( _In_ const BoundingBox& box ) const;
bool Intersects( _In_ const BoundingOrientedBox& box ) const;
bool Intersects( _In_ const BoundingFrustum& fr ) const;
bool Intersects( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2 ) const;
// Triangle-Frustum test
PlaneIntersectionType Intersects( _In_ FXMVECTOR Plane ) const;
// Plane-Frustum test
bool Intersects( _In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _Out_ float& Dist ) const;
// Ray-Frustum test
ContainmentType ContainedBy( _In_ FXMVECTOR Plane0, _In_ FXMVECTOR Plane1, _In_ FXMVECTOR Plane2,
_In_ GXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5 ) const;
// Test frustum against six planes (see BoundingFrustum::GetPlanes)
void GetPlanes( _Out_opt_ XMVECTOR* NearPlane, _Out_opt_ XMVECTOR* FarPlane, _Out_opt_ XMVECTOR* RightPlane,
_Out_opt_ XMVECTOR* LeftPlane, _Out_opt_ XMVECTOR* TopPlane, _Out_opt_ XMVECTOR* BottomPlane ) const;
// Create 6 Planes representation of Frustum
// Static methods
static void CreateFromMatrix( _Out_ BoundingFrustum& Out, _In_ CXMMATRIX Projection );
};
//-----------------------------------------------------------------------------
// Triangle intersection testing routines.
//-----------------------------------------------------------------------------
namespace TriangleTests
{
bool Intersects( _In_ FXMVECTOR Origin, _In_ FXMVECTOR Direction, _In_ FXMVECTOR V0, _In_ GXMVECTOR V1, _In_ CXMVECTOR V2, _Out_ float& Dist );
// Ray-Triangle
bool Intersects( _In_ FXMVECTOR A0, _In_ FXMVECTOR A1, _In_ FXMVECTOR A2, _In_ GXMVECTOR B0, _In_ CXMVECTOR B1, _In_ CXMVECTOR B2 );
// Triangle-Triangle
PlaneIntersectionType Intersects( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2, _In_ GXMVECTOR Plane );
// Plane-Triangle
ContainmentType ContainedBy( _In_ FXMVECTOR V0, _In_ FXMVECTOR V1, _In_ FXMVECTOR V2,
_In_ GXMVECTOR Plane0, _In_ CXMVECTOR Plane1, _In_ CXMVECTOR Plane2,
_In_ CXMVECTOR Plane3, _In_ CXMVECTOR Plane4, _In_ CXMVECTOR Plane5 );
// Test a triangle against six planes at once (see BoundingFrustum::GetPlanes)
};
#pragma warning(pop)
/****************************************************************************
@ -146,7 +325,7 @@ __declspec(align(16)) struct BoundingBox
****************************************************************************/
#pragma warning(push)
#pragma warning(disable:4068)
#pragma warning(disable : 4068 4616 6001)
#pragma prefast(push)
#pragma prefast(disable : 25000, "FXMVECTOR is 16 bytes")

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -854,9 +854,9 @@ struct XMU555
XMU555() {}
explicit XMU555(uint16_t Packed) : v(Packed) {}
XMU555(int8_t _x, int8_t _y, int8_t _z, bool _w) : x(_x), y(_y), z(_z), w(_w ? 0x1 : 0) {}
XMU555(_In_reads_(3) const int8_t *pArray, bool _w) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(_w ? 0x1 : 0) {}
XMU555(_In_reads_(3) const int8_t *pArray, _In_ bool _w) : x(pArray[0]), y(pArray[1]), z(pArray[2]), w(_w ? 0x1 : 0) {}
XMU555(float _x, float _y, float _z, bool _w);
XMU555(_In_reads_(3) const float *pArray, bool _w);
XMU555(_In_reads_(3) const float *pArray, _In_ bool _w);
operator uint16_t () const { return v; }
@ -936,39 +936,39 @@ XMVECTOR XMLoadU555(_In_ const XMU555* pSource);
*
****************************************************************************/
void XMStoreColor(_Out_ XMCOLOR* pDestination, FXMVECTOR V);
void XMStoreColor(_Out_ XMCOLOR* pDestination, _In_ FXMVECTOR V);
void XMStoreHalf2(_Out_ XMHALF2* pDestination, FXMVECTOR V);
void XMStoreShortN2(_Out_ XMSHORTN2* pDestination, FXMVECTOR V);
void XMStoreShort2(_Out_ XMSHORT2* pDestination, FXMVECTOR V);
void XMStoreUShortN2(_Out_ XMUSHORTN2* pDestination, FXMVECTOR V);
void XMStoreUShort2(_Out_ XMUSHORT2* pDestination, FXMVECTOR V);
void XMStoreByteN2(_Out_ XMBYTEN2* pDestination, FXMVECTOR V);
void XMStoreByte2(_Out_ XMBYTE2* pDestination, FXMVECTOR V);
void XMStoreUByteN2(_Out_ XMUBYTEN2* pDestination, FXMVECTOR V);
void XMStoreUByte2(_Out_ XMUBYTE2* pDestination, FXMVECTOR V);
void XMStoreHalf2(_Out_ XMHALF2* pDestination, _In_ FXMVECTOR V);
void XMStoreShortN2(_Out_ XMSHORTN2* pDestination, _In_ FXMVECTOR V);
void XMStoreShort2(_Out_ XMSHORT2* pDestination, _In_ FXMVECTOR V);
void XMStoreUShortN2(_Out_ XMUSHORTN2* pDestination, _In_ FXMVECTOR V);
void XMStoreUShort2(_Out_ XMUSHORT2* pDestination, _In_ FXMVECTOR V);
void XMStoreByteN2(_Out_ XMBYTEN2* pDestination, _In_ FXMVECTOR V);
void XMStoreByte2(_Out_ XMBYTE2* pDestination, _In_ FXMVECTOR V);
void XMStoreUByteN2(_Out_ XMUBYTEN2* pDestination, _In_ FXMVECTOR V);
void XMStoreUByte2(_Out_ XMUBYTE2* pDestination, _In_ FXMVECTOR V);
void XMStoreU565(_Out_ XMU565* pDestination, FXMVECTOR V);
void XMStoreFloat3PK(_Out_ XMFLOAT3PK* pDestination, FXMVECTOR V);
void XMStoreFloat3SE(_Out_ XMFLOAT3SE* pDestination, FXMVECTOR V);
void XMStoreU565(_Out_ XMU565* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat3PK(_Out_ XMFLOAT3PK* pDestination, _In_ FXMVECTOR V);
void XMStoreFloat3SE(_Out_ XMFLOAT3SE* pDestination, _In_ FXMVECTOR V);
void XMStoreHalf4(_Out_ XMHALF4* pDestination, FXMVECTOR V);
void XMStoreShortN4(_Out_ XMSHORTN4* pDestination, FXMVECTOR V);
void XMStoreShort4(_Out_ XMSHORT4* pDestination, FXMVECTOR V);
void XMStoreUShortN4(_Out_ XMUSHORTN4* pDestination, FXMVECTOR V);
void XMStoreUShort4(_Out_ XMUSHORT4* pDestination, FXMVECTOR V);
void XMStoreXDecN4(_Out_ XMXDECN4* pDestination, FXMVECTOR V);
void XMStoreXDec4(_Out_ XMXDEC4* pDestination, FXMVECTOR V);
void XMStoreDecN4(_Out_ XMDECN4* pDestination, FXMVECTOR V);
void XMStoreDec4(_Out_ XMDEC4* pDestination, FXMVECTOR V);
void XMStoreUDecN4(_Out_ XMUDECN4* pDestination, FXMVECTOR V);
void XMStoreUDec4(_Out_ XMUDEC4* pDestination, FXMVECTOR V);
void XMStoreByteN4(_Out_ XMBYTEN4* pDestination, FXMVECTOR V);
void XMStoreByte4(_Out_ XMBYTE4* pDestination, FXMVECTOR V);
void XMStoreUByteN4(_Out_ XMUBYTEN4* pDestination, FXMVECTOR V);
void XMStoreUByte4(_Out_ XMUBYTE4* pDestination, FXMVECTOR V);
void XMStoreUNibble4(_Out_ XMUNIBBLE4* pDestination, FXMVECTOR V);
void XMStoreU555(_Out_ XMU555* pDestination, FXMVECTOR V);
void XMStoreHalf4(_Out_ XMHALF4* pDestination, _In_ FXMVECTOR V);
void XMStoreShortN4(_Out_ XMSHORTN4* pDestination, _In_ FXMVECTOR V);
void XMStoreShort4(_Out_ XMSHORT4* pDestination, _In_ FXMVECTOR V);
void XMStoreUShortN4(_Out_ XMUSHORTN4* pDestination, _In_ FXMVECTOR V);
void XMStoreUShort4(_Out_ XMUSHORT4* pDestination, _In_ FXMVECTOR V);
void XMStoreXDecN4(_Out_ XMXDECN4* pDestination, _In_ FXMVECTOR V);
void XMStoreXDec4(_Out_ XMXDEC4* pDestination, _In_ FXMVECTOR V);
void XMStoreDecN4(_Out_ XMDECN4* pDestination, _In_ FXMVECTOR V);
void XMStoreDec4(_Out_ XMDEC4* pDestination, _In_ FXMVECTOR V);
void XMStoreUDecN4(_Out_ XMUDECN4* pDestination, _In_ FXMVECTOR V);
void XMStoreUDec4(_Out_ XMUDEC4* pDestination, _In_ FXMVECTOR V);
void XMStoreByteN4(_Out_ XMBYTEN4* pDestination, _In_ FXMVECTOR V);
void XMStoreByte4(_Out_ XMBYTE4* pDestination, _In_ FXMVECTOR V);
void XMStoreUByteN4(_Out_ XMUBYTEN4* pDestination, _In_ FXMVECTOR V);
void XMStoreUByte4(_Out_ XMUBYTE4* pDestination, _In_ FXMVECTOR V);
void XMStoreUNibble4(_Out_ XMUNIBBLE4* pDestination, _In_ FXMVECTOR V);
void XMStoreU555(_Out_ XMU555* pDestination, _In_ FXMVECTOR V);
/****************************************************************************

File diff suppressed because it is too large Load Diff