Ejemplo n.º 1
0
    public Model3d Raycast(Ray3d ray)
    {
        if (m_octree != null)
        {
            // :: lets the compiler know to look outside class scope
            return(Octree3d.Raycast(m_octree, ray));
        }

        Model3d result   = null;
        FloatL  result_t = -1;

        for (int i = 0, size = m_modleList.Count; i < size; ++i)
        {
            FloatL t = IntersectionTest3D.Ray3dWithModel3d(ray, m_modleList[i]);
            if (result == null && t >= 0)
            {
                result   = m_modleList[i];
                result_t = t;
            }
            else if (result != null && t < result_t)
            {
                result   = m_modleList[i];
                result_t = t;
            }
        }

        return(result);
    }
Ejemplo n.º 2
0
    public static Model3d FindClosest(List <Model3d> set, Ray3d ray)
    {
        if (set.Count == 0)
        {
            return(null);
        }

        Model3d closest   = null;
        FloatL  closest_t = -1;

        for (int i = 0, size = set.Count; i < size; ++i)
        {
            FloatL this_t = IntersectionTest3D.Ray3dWithModel3d(ray, set[i]);

            if (this_t < 0)
            {
                continue;
            }

            if (closest_t < 0 || this_t < closest_t)
            {
                closest_t = this_t;
                closest   = set[i];
            }
        }

        return(closest);
    }