예제 #1
0
        public static bool IsCollidedHSegmentHSegment(SHSegment HSegment0_, SHSegment HSegment1_, SPoint Dir_, SCollisionInfo CollisionInfo_)
        {
            if (!IsCollidedPointHLine(new SPoint(HSegment0_.Left, HSegment0_.Y), HSegment1_, Dir_, CollisionInfo_))
            {
                return(false);
            }

            // 라인의 중첩영역을 임시로 CollisionInfo의 Point에 저장
            CollisionInfo_.Point.Y = CollisionInfo_.Point.X + (HSegment0_.Right - HSegment0_.Left);

            if (CollisionInfo_.Point.X < HSegment1_.Left)   // Point.Y : ContactLeft
            {
                CollisionInfo_.Point.X = HSegment1_.Left;
            }
            if (CollisionInfo_.Point.Y > HSegment1_.Right)  // Point.X : ContactRight
            {
                CollisionInfo_.Point.Y = HSegment1_.Right;
            }

            if (CollisionInfo_.Point.Y < CollisionInfo_.Point.X)    // 중첩영역이 없으면
            {
                return(false);
            }

            CollisionInfo_.Point.X  = ((CollisionInfo_.Point.Y + CollisionInfo_.Point.X) / 2.0f);
            CollisionInfo_.Point.Y  = HSegment1_.Y;
            CollisionInfo_.Normal.X = 0.0f;
            CollisionInfo_.Normal.Y = -Dir_.Y;
            return(true);
        }
예제 #2
0
 public void Set(SHSegment Obj_)
 {
     base.Set(Obj_);
     Left  = Obj_.Left;
     Right = Obj_.Right;
 }
예제 #3
0
 public SHSegment(SHSegment Obj_) : base(Obj_)
 {
     Left  = Obj_.Left;
     Right = Obj_.Right;
 }