Пример #1
0
        public static void DrawBvh(this IDebugCanvas canvas, BvhILS2 bvh)
        {
            void Helper(BvhILS2 node, int d)
            {
                if (d != 0)
                {
                    var s = new StrokeStyle(d % 2 == 0 ? Color.Red : Color.Lime, 10.0f / d, new[] { d % 2 == 0 ? 1.0f : 3.0f, d % 2 == 0 ? 3.0f : 1.0f });
                    canvas.DrawRectangle(node.Bounds, 0.0f, s);
                }
                if (node.First != null)
                {
                    Helper(node.First, d + 1);
                    Helper(node.Second, d + 1);
                }
                else
                {
                    for (var i = node.SegmentsStartIndexInclusive; i < node.SegmentsEndIndexExclusive; i++)
                    {
                        canvas.DrawLine(node.Segments[i].First, node.Segments[i].Second, StrokeStyle3);
                    }
                }
            }

            Helper(bvh, 0);
        }
Пример #2
0
 public static BvhILS2 FindContourAndChildHoleBarriersBvh(this PolyNode node)
 {
     if (node.visibilityGraphNodeData.ContourAndChildHoleBarriersBvh != null)
     {
         return(node.visibilityGraphNodeData.ContourAndChildHoleBarriersBvh);
     }
     return(node.visibilityGraphNodeData.ContourAndChildHoleBarriersBvh = BvhILS2.Build(node.FindContourAndChildHoleBarriers()));
 }
Пример #3
0
        private PolyTree PostProcessPunchedLand(PolyTree punchedLand)
        {
            void TagSectorSnapshotAndGeometryContext(PolyNode node)
            {
                node.visibilityGraphNodeData.LocalGeometryView = this;
                node.Childs.ForEach(TagSectorSnapshotAndGeometryContext);
            }

            void TagBoundingVolumeHierarchies(PolyNode node)
            {
                var contourEdges = node.Contour.Zip(node.Contour.RotateLeft(), IntLineSegment2.Create).ToArray();
                var bvh          = BvhILS2.Build(contourEdges);

                node.visibilityGraphNodeData.ContourBvh = bvh;
                node.Childs.ForEach(TagBoundingVolumeHierarchies);
            }

            punchedLand.Prune(HoleDilationRadius);
            TagSectorSnapshotAndGeometryContext(punchedLand);
            TagBoundingVolumeHierarchies(punchedLand);
            return(punchedLand);
        }