Пример #1
0
        private void Clip(NavigationPolygon floor, NavigationPolygons staticObjects)
        {
            Clipper clipper = new Clipper();

            if (!clipper.AddPath(floor, PolyType.ptSubject, true))
            {
                throw new Exception("Can't add Paths (Subject).");
            }

            if (staticObjects.Count > 0 && !clipper.AddPaths(staticObjects, PolyType.ptClip, true))
            {
                throw new Exception("Can't add Paths (Clip).");
            }

            // we do it twice (it's easier than deep copy the polygons), since this is loading screen time... We don't mind performance too much here
            if (!clipper.Execute(ClipType.ctDifference, floorWithStaticObjects, PolyFillType.pftNonZero))
            {
                throw new Exception("Can't clip floorWithStaticObjects.");
            }

            if (!clipper.Execute(ClipType.ctDifference, FloorWithDynamicObjects, PolyFillType.pftNonZero))
            {
                throw new Exception("Can't clip floorWithStaticObjects.");
            }

            clipper.Reset();
        }
Пример #2
0
        public Map(NavigationPolygon floor, NavigationPolygons staticObjects)
        {
            this.floor         = floor;
            this.staticObjects = staticObjects;

            Initialize();
        }
Пример #3
0
        private void Union(NavigationPolygons floor, List <NavigationEdge> dynamicObject)
        {
            if (dynamicObject.Count == 0)
            {
                return;
            }

            Clipper clipper = new Clipper();

            if (!clipper.AddPaths(floor, PolyType.ptSubject, true))
            {
                throw new Exception("Can't add Paths (Subject).");
            }

            if (!clipper.AddPaths(new NavigationPolygons(dynamicObject.ConvertAll(x => x.BoundingBox())), PolyType.ptClip, true))
            {
                throw new Exception("Can't add Paths (Clip).");
            }

            NavigationPolygons result = new NavigationPolygons();

            if (!clipper.Execute(ClipType.ctUnion, result, PolyFillType.pftNonZero))
            {
                throw new Exception("Can't clip dynamicObjects.");
            }
            FloorWithDynamicObjects = result;
        }
Пример #4
0
        public NavigationPolygons DeepCopy()
        {
            NavigationPolygons copy = new NavigationPolygons(this.Count);

            for (var i = 0; i < this.Count; i++)
            {
                copy.Add(this[i].DeepCopy());
            }

            return(copy);
        }