コード例 #1
0
ファイル: ObjectGraph.cpp プロジェクト: Dragnalith/raynder
bool ObjectGraph::Intersect(Ray const& ray, Intersection* pIntersection) const
{
    DRGN_ASSERT(pIntersection != nullptr);

    Intersection neareast_intersection;

    for (auto const pObj : m_Objects)
    {
        Intersection intersection;
        if (!pObj->Intersect(ray, &intersection))
        {
            continue;
        }

        if (intersection.GetDistance() >= 0 && intersection.GetDistance() < neareast_intersection.GetDistance())
        {
            neareast_intersection = intersection;
        }
    }

    if (!neareast_intersection.HasIntersection())
    {
        return false;
    }

    *pIntersection = neareast_intersection;

    return true;
}