@@ -1655,8 +1655,41 @@ inline XMMATRIX XM_CALLCONV XMMatrixRotationRollPitchYaw
16551655 float Roll
16561656) noexcept
16571657{
1658+ #if defined(_XM_NO_INTRINSICS_)
1659+ float cp = cosf (Pitch);
1660+ float sp = sinf (Pitch);
1661+
1662+ float cy = cosf (Yaw);
1663+ float sy = sinf (Yaw);
1664+
1665+ float cr = cosf (Roll);
1666+ float sr = sinf (Roll);
1667+
1668+ XMMATRIX M;
1669+ M.m [0 ][0 ] = cr * cy + sr * sp * sy;
1670+ M.m [0 ][1 ] = sr * cp;
1671+ M.m [0 ][2 ] = sr * sp * cy - cr * sy;
1672+ M.m [0 ][3 ] = 0 .0f ;
1673+
1674+ M.m [1 ][0 ] = cr * sp * sy - sr * cy;
1675+ M.m [1 ][1 ] = cr * cp;
1676+ M.m [1 ][2 ] = sr * sy + cr * sp * cy;
1677+ M.m [1 ][3 ] = 0 .0f ;
1678+
1679+ M.m [2 ][0 ] = cp * sy;
1680+ M.m [2 ][1 ] = -sp;
1681+ M.m [2 ][2 ] = cp * cy;
1682+ M.m [2 ][3 ] = 0 .0f ;
1683+
1684+ M.m [3 ][0 ] = 0 .0f ;
1685+ M.m [3 ][1 ] = 0 .0f ;
1686+ M.m [3 ][2 ] = 0 .0f ;
1687+ M.m [3 ][3 ] = 1 .0f ;
1688+ return M;
1689+ #else
16581690 XMVECTOR Angles = XMVectorSet (Pitch, Yaw, Roll, 0 .0f );
16591691 return XMMatrixRotationRollPitchYawFromVector (Angles);
1692+ #endif
16601693}
16611694
16621695// ------------------------------------------------------------------------------
@@ -1666,8 +1699,69 @@ inline XMMATRIX XM_CALLCONV XMMatrixRotationRollPitchYawFromVector
16661699 FXMVECTOR Angles // <Pitch, Yaw, Roll, undefined>
16671700) noexcept
16681701{
1669- XMVECTOR Q = XMQuaternionRotationRollPitchYawFromVector (Angles);
1670- return XMMatrixRotationQuaternion (Q);
1702+ #if defined(_XM_NO_INTRINSICS_)
1703+ float cp = cosf (Angles.vector4_f32 [0 ]);
1704+ float sp = sinf (Angles.vector4_f32 [0 ]);
1705+
1706+ float cy = cosf (Angles.vector4_f32 [1 ]);
1707+ float sy = sinf (Angles.vector4_f32 [1 ]);
1708+
1709+ float cr = cosf (Angles.vector4_f32 [2 ]);
1710+ float sr = sinf (Angles.vector4_f32 [2 ]);
1711+
1712+ XMMATRIX M;
1713+ M.m [0 ][0 ] = cr * cy + sr * sp * sy;
1714+ M.m [0 ][1 ] = sr * cp;
1715+ M.m [0 ][2 ] = sr * sp * cy - cr * sy;
1716+ M.m [0 ][3 ] = 0 .0f ;
1717+
1718+ M.m [1 ][0 ] = cr * sp * sy - sr * cy;
1719+ M.m [1 ][1 ] = cr * cp;
1720+ M.m [1 ][2 ] = sr * sy + cr * sp * cy;
1721+ M.m [1 ][3 ] = 0 .0f ;
1722+
1723+ M.m [2 ][0 ] = cp * sy;
1724+ M.m [2 ][1 ] = -sp;
1725+ M.m [2 ][2 ] = cp * cy;
1726+ M.m [2 ][3 ] = 0 .0f ;
1727+
1728+ M.m [3 ][0 ] = 0 .0f ;
1729+ M.m [3 ][1 ] = 0 .0f ;
1730+ M.m [3 ][2 ] = 0 .0f ;
1731+ M.m [3 ][3 ] = 1 .0f ;
1732+ return M;
1733+ #else
1734+ static const XMVECTORF32 Sign = { { { 1 .0f , -1 .0f , -1 .0f , 1 .0f } } };
1735+
1736+ XMVECTOR SinAngles, CosAngles;
1737+ XMVectorSinCos (&SinAngles, &CosAngles, Angles);
1738+
1739+ XMVECTOR P0 = XMVectorPermute<XM_PERMUTE_1X , XM_PERMUTE_0Z , XM_PERMUTE_1Z , XM_PERMUTE_1X >(SinAngles, CosAngles);
1740+ XMVECTOR Y0 = XMVectorPermute<XM_PERMUTE_0Y , XM_PERMUTE_1X , XM_PERMUTE_1X , XM_PERMUTE_1Y >(SinAngles, CosAngles);
1741+ XMVECTOR P1 = XMVectorPermute<XM_PERMUTE_1Z , XM_PERMUTE_0Z , XM_PERMUTE_1Z , XM_PERMUTE_0Z >(SinAngles, CosAngles);
1742+ XMVECTOR Y1 = XMVectorPermute<XM_PERMUTE_1Y , XM_PERMUTE_1Y , XM_PERMUTE_0Y , XM_PERMUTE_0Y >(SinAngles, CosAngles);
1743+ XMVECTOR P2 = XMVectorPermute<XM_PERMUTE_0Z , XM_PERMUTE_1Z , XM_PERMUTE_0Z , XM_PERMUTE_1Z >(SinAngles, CosAngles);
1744+ XMVECTOR P3 = XMVectorPermute<XM_PERMUTE_0Y , XM_PERMUTE_0Y , XM_PERMUTE_1Y , XM_PERMUTE_1Y >(SinAngles, CosAngles);
1745+ XMVECTOR Y2 = XMVectorSplatX (SinAngles);
1746+ XMVECTOR NS = XMVectorNegate (SinAngles);
1747+
1748+ XMVECTOR Q0 = XMVectorMultiply (P0 , Y0 );
1749+ XMVECTOR Q1 = XMVectorMultiply (P1 , Sign.v );
1750+ Q1 = XMVectorMultiply (Q1 , Y1 );
1751+ XMVECTOR Q2 = XMVectorMultiply (P2 , Y2 );
1752+ Q2 = XMVectorMultiplyAdd (Q2 , P3 , Q1 );
1753+
1754+ XMVECTOR V0 = XMVectorPermute<XM_PERMUTE_1X , XM_PERMUTE_0Y , XM_PERMUTE_1Z , XM_PERMUTE_0W >(Q0 , Q2 );
1755+ XMVECTOR V1 = XMVectorPermute<XM_PERMUTE_1Y , XM_PERMUTE_0Z , XM_PERMUTE_1W , XM_PERMUTE_0W >(Q0 , Q2 );
1756+ XMVECTOR V2 = XMVectorPermute<XM_PERMUTE_0X , XM_PERMUTE_1X , XM_PERMUTE_0W , XM_PERMUTE_0W >(Q0 , NS );
1757+
1758+ XMMATRIX M;
1759+ M.r [0 ] = XMVectorSelect (g_XMZero, V0 , g_XMSelect1110.v );
1760+ M.r [1 ] = XMVectorSelect (g_XMZero, V1 , g_XMSelect1110.v );
1761+ M.r [2 ] = XMVectorSelect (g_XMZero, V2 , g_XMSelect1110.v );
1762+ M.r [3 ] = g_XMIdentityR3;
1763+ return M;
1764+ #endif
16711765}
16721766
16731767// ------------------------------------------------------------------------------
0 commit comments