Пример #1
0
        public SamplerLeaf Combine(float angleErr)
        {
            for (int i = 0; i < Children.Length; ++i)
            {
                if (Children[i] == null || !(Children[i] is SamplerLeaf))
                {
                    return(null);
                }
            }
            for (int i = 0; i < Children.Length; ++i)
            {
                SamplerLeaf l   = (SamplerLeaf)Children[i];
                float       dot = Vector3.Dot(l.Normal.normalized, mVertex.Normal.normalized);
                if (Mathf.Rad2Deg * Mathf.Acos(dot) >= angleErr)
                {
                    return(null);
                }
            }
            SamplerLeaf leaf = new SamplerLeaf(mVertex);

            for (int i = 0; i < Children.Length; ++i)
            {
                SamplerLeaf l = (SamplerLeaf)Children[i];
                foreach (var k in l.Boundaries.Keys)
                {
                    if (Boundaries.ContainsKey(k))
                    {
                        Boundaries[k].Merge(l.Boundaries[k]);
                    }
                    else
                    {
                        Boundaries.Add(k, l.Boundaries[k]);
                    }
                }
            }
            leaf.Boundaries = Boundaries;
            return(leaf);
        }