Example #1
0
        public ISkyBoxAble SkyBox;        // = DefaultSkyBox.Default; // todo: 删除默认值

        public RayCastResult Intersection(Ray ray)
        {
            RayCastResult result = null;

            foreach (RenderObject o in r_Objects)
            {
                RayCastResult re = o.Intersection(ray, float.MaxValue);
                result = RayCastResult.BetterOne(result, re);
            }
            return(result);
        }
Example #2
0
        public RayCastResult Intersection(Ray ray, float nowbest)
        {
            (bool cast, float mint) = BoundBox.Intersection(ray);
            if (!cast || mint > nowbest)               // 未相交 或 当前最小解已不是最优
            {
                return(null);
            }
            RayCastResult result = null;             // RayCastResult.BetterOne(lres, rres);

            if (Childs != null)
            {
                foreach (IRayCastAble obj in Childs)
                {
                    RayCastResult restmp = obj.Intersection(ray, nowbest);
                    result = RayCastResult.BetterOne(result, restmp);
                    if (result != null)
                    {
                        nowbest = Math.Min(nowbest, result.distance);
                    }
                }
            }

            return(result);
        }