Пример #1
0
        public bool CollidesWith(AABBProjection other, out List <AABBProjectionCollisionResult> results)
        {
            results = new List <AABBProjectionCollisionResult>();

            if (Start.Overlaps(other.Start))
            {
                return(true);
            }

            bool collisions = false;

            foreach (AABBProjectionSegment localSegment in PathSegments.Values)
            {
                foreach (AABBProjectionSegment otherSegment in other.PathSegments.Values)
                {
                    SFML.Window.Vector2f[] segmentIntersectionResults = null;

                    if (localSegment.Path.CollidesWith(otherSegment.Path, out segmentIntersectionResults) && collisions == false)
                    {
                        collisions = true;
                    }

                    foreach (SFML.Window.Vector2f intersection in segmentIntersectionResults)
                    {
                        AABBProjectionCollisionResult aabbResult = new AABBProjectionCollisionResult();
                        aabbResult.CollisionPoint = intersection;
                        aabbResult.Length         = DistanceBetweenTwoPoints(localSegment.Path.Start, intersection);
                        aabbResult.LocalSide      = localSegment.SegmentEnum;
                        aabbResult.OtherSide      = otherSegment.SegmentEnum;

                        results.Add(aabbResult);
                    }
                }
            }

            return(collisions);
        }
Пример #2
0
        public bool CollidesWith(AABBProjection other, out List<AABBProjectionCollisionResult> results)
        {
            results = new List<AABBProjectionCollisionResult>();

            if (Start.Overlaps(other.Start))
                return true;

            bool collisions = false;

            foreach (AABBProjectionSegment localSegment in PathSegments.Values)
            {
                foreach (AABBProjectionSegment otherSegment in other.PathSegments.Values)
                {
                    SFML.Window.Vector2f[] segmentIntersectionResults = null;

                    if (localSegment.Path.CollidesWith(otherSegment.Path, out segmentIntersectionResults) && collisions == false)
                        collisions = true;

                    foreach (SFML.Window.Vector2f intersection in segmentIntersectionResults)
                    {
                        AABBProjectionCollisionResult aabbResult = new AABBProjectionCollisionResult();
                        aabbResult.CollisionPoint = intersection;
                        aabbResult.Length = DistanceBetweenTwoPoints(localSegment.Path.Start, intersection);
                        aabbResult.LocalSide = localSegment.SegmentEnum;
                        aabbResult.OtherSide = otherSegment.SegmentEnum;

                        results.Add(aabbResult);
                    }
                }
            }

            return collisions;
        }