Пример #1
0
        public void QueuePatches(RenderQueue queue)
        {
            var idx = 0;

            for (var i = 0; i < Levels; i++)
            {
                var level = _levels[i];

                var mask = i == 0 ? PatchLocations.PatchSelection.Everything :PatchLocations.PatchSelection.Outer;

                if (i != 0)
                {
                    mask |= PatchLocations.PatchSelection.OuterDegenerated;
                }

                mask |= level.Bottom ? PatchLocations.PatchSelection.InteriorBottom : PatchLocations.PatchSelection.InteriorTop;
                mask |= level.Left ? PatchLocations.PatchSelection.InteriorLeft : PatchLocations.PatchSelection.InteriorRight;

                var subX = level.Position.X.Fraction * 2.0f - 1.0f;
                var intX = level.Position.X.Integer;
                var subY = level.Position.Y.Fraction * 2.0f - 1.0f;
                var intY = level.Position.Y.Integer;
                var texX = (intX * 2) & N;
                var texY = (intY * 2) & N;

                foreach (var p in Locations.Select(mask))
                {
                    PatchRenderable pp;
                    if (_queueCache.Count <= idx)
                    {
                        pp = new PatchRenderable(p.Patch, _shader);
                        _queueCache.Add(pp);
                    }
                    else
                    {
                        pp = _queueCache[idx];
                    }
                    idx++;


                    // queue the patch for rendering
                    pp.ScaleFactor     = new Vector4(p.X + subX, p.Y + subY, level.Scale, level.Scale);
                    pp.FineBlockOrigin = new Vector4(p.X - Hx - texX, p.Y - Hx - texY, (float)InverseD, (float)InverseD);
                    pp.Level           = level;
                    queue.AddRenderable(pp);
                }
            }
        }
Пример #2
0
        public void QueuePatches(RenderQueue queue)
        {
            var idx = 0;

            for (var i = 0; i < Levels; i++)
            {
                var level = _levels[i];

                var mask = i == 0 ? PatchLocations.PatchSelection.Everything :PatchLocations.PatchSelection.Outer;

                if (i != 0)
                    mask |= PatchLocations.PatchSelection.OuterDegenerated;

                mask |= level.Bottom ? PatchLocations.PatchSelection.InteriorBottom : PatchLocations.PatchSelection.InteriorTop;
                mask |= level.Left ? PatchLocations.PatchSelection.InteriorLeft : PatchLocations.PatchSelection.InteriorRight;

                var subX = level.Position.X.Fraction * 2.0f - 1.0f;
                var intX = level.Position.X.Integer;
                var subY = level.Position.Y.Fraction * 2.0f - 1.0f;
                var intY = level.Position.Y.Integer;
                var texX = (intX * 2) & N;
                var texY = (intY * 2) & N;

                foreach (var p in Locations.Select(mask))
                {
                    PatchRenderable pp;
                    if (_queueCache.Count <= idx)
                    {
                        pp = new PatchRenderable(p.Patch, _shader);
                        _queueCache.Add(pp);
                    } else
                        pp = _queueCache[idx];
                    idx++;

                    // queue the patch for rendering
                    pp.ScaleFactor = new Vector4(p.X + subX, p.Y + subY, level.Scale, level.Scale);
                    pp.FineBlockOrigin = new Vector4(p.X - Hx - texX, p.Y - Hx - texY, (float)InverseD, (float)InverseD);
                    pp.Level = level;
                    queue.AddRenderable(pp);
                }
            }
        }