예제 #1
0
int
D3DOverdrawWindow::
CheckIsect(int iClusterA, int iClusterB)
{
    D3DXMATRIXA16 mWorldView;
    D3DXMatrixMultiply(&mWorldView, &m_mWorld, &m_mViewing);
#if 0
    D3DXVECTOR4 vTransA, vTransB;
    D3DXVec3Transform(&vTransA, (D3DXVECTOR3*)&m_vClusterCenter[iClusterA][0], &mWorldView);
    D3DXVec3Transform(&vTransB, (D3DXVECTOR3*)&m_vClusterCenter[iClusterB][0], &mWorldView);
    vTransA /= vTransA.w;
    vTransB /= vTransB.w;
    vTransA.z = 0;
    vTransB.z = 0;

    D3DXVECTOR4 v = vTransA - vTransB;

    if (D3DXVec4Length(&v) > (m_fClusterSize[iClusterA] + m_fClusterSize[iClusterB]) / 2.f)
    {
        return 0;
    }
    else
    {
        return 1;
    }

#else
    D3DXVECTOR4 vTransA, vTransB;
    float xminA = 2e30f, yminA = 2e30f, xmaxA = -2e30f, ymaxA = -2e30f;
    float xminB = 2e30f, yminB = 2e30f, xmaxB = -2e30f, ymaxB = -2e30f;

    for (int i = -1; i < 2; i += 2)
        for (int j = -1; j < 2; j += 2)
            for (int k = -1; k < 2; k += 2)
            {
                Vector3 v = m_vClusterCenter[iClusterA]
                            + Vector3(m_vClusterDiag[iClusterA][0] / 2.f * i,
                                      m_vClusterDiag[iClusterA][1] / 2.f * j,
                                      m_vClusterDiag[iClusterA][2] / 2.f * k);
                D3DXVec3Transform(&vTransA, (D3DXVECTOR3*)&v[0], &mWorldView);
                vTransA /= vTransA.w;
                xminA = min(xminA, vTransA.x);
                yminA = min(yminA, vTransA.y);
                xmaxA = max(xmaxA, vTransA.x);
                ymaxA = max(ymaxA, vTransA.y);

                v = m_vClusterCenter[iClusterB]
                    + Vector3(m_vClusterDiag[iClusterB][0] / 2.f * i,
                              m_vClusterDiag[iClusterB][1] / 2.f * j,
                              m_vClusterDiag[iClusterB][2] / 2.f * k);
                D3DXVec3Transform(&vTransB, (D3DXVECTOR3*)&v[0], &mWorldView);
                vTransB /= vTransB.w;
                xminB = min(xminB, vTransB.x);
                yminB = min(yminB, vTransB.y);
                xmaxB = max(xmaxB, vTransB.x);
                ymaxB = max(ymaxB, vTransB.y);
            }

    if (xminA > xmaxB || xminB > xmaxA || yminA > ymaxB || yminB > ymaxA)
    {
        return 0;
    }
    else
    {
        return 1;
    }

#endif
}
예제 #2
0
float float4::Length() {
	return D3DXVec4Length(this);
}
예제 #3
0
//@}
//-------------------------------------------------------------------------
/// @name 幾何ベクトルの大きさ
//@{
/// @copydoc psyq::geometry::vector::length
inline psyq::geometry::vector::traits<D3DXVECTOR4>::element length(
    D3DXVECTOR4 const& in_vector)
{
    return D3DXVec4Length(&in_vector);
}