コード例 #1
0
        private void CheckFrameBoundingBoxCollision(ref bool bFrameBoundBoxCollision, ref Component characterRootComponent, ref CollisionUnit characterCollisionUnit,
                                                    ref Component collidedRootComponent, ref List <BoundBase> collidedRootBounds)
        {
            foreach (var unit in CollisionUnits)
            {
                if (characterCollisionUnit.RootComponent == unit.RootComponent)
                {
                    continue;
                }

                AABB aabb1 = characterCollisionUnit.GetAndTryUpdateFramingBoundingBox();
                AABB aabb2 = unit.GetAndTryUpdateFramingBoundingBox();
                if (GeometryMath.AABBAABB(aabb1, aabb2))
                {
                    bFrameBoundBoxCollision = true;
                    collidedRootComponent   = aabb2.ParentComponent.GetRootComponent();
                    collidedRootBounds.AddRange(unit.GetBoundingBoxes());
                }
            }

            if (bFrameBoundBoxCollision)
            {
                CollisionOutput.Add(new CollisionOutputFramingAABB(characterRootComponent, collidedRootComponent));
            }
            else
            {
                CollisionOutput.Add(new CollisionOutputNoCollided(characterRootComponent));
            }
        }
コード例 #2
0
        private bool BoundBaseCollision_Ext(BoundBase characterBound, BoundBase collidedRootBound)
        {
            bool bHasCollision = false;

            BoundBase.BoundType collisionType = characterBound.GetBoundType() | collidedRootBound.GetBoundType();

            if (collisionType == (BoundBase.BoundType.AABB | BoundBase.BoundType.OBB))
            {
                AABB aabb = characterBound.GetBoundType() == BoundBase.BoundType.AABB ? characterBound as AABB : collidedRootBound as AABB;
                OBB  obb  = collidedRootBound.GetBoundType() == BoundBase.BoundType.OBB ? collidedRootBound as OBB : characterBound as OBB;
                bHasCollision = GeometryMath.AABBOBB(aabb, obb);
            }
            else if (collisionType == (BoundBase.BoundType.AABB | BoundBase.BoundType.AABB))
            {
                bHasCollision = GeometryMath.AABBAABB(characterBound as AABB, collidedRootBound as AABB);
            }
            else
            {
                bHasCollision = GeometryMath.OBBOBB(characterBound as OBB, collidedRootBound as OBB);
            }
            return(bHasCollision);
        }