phys-collision 2.0.1-beta.0

Provides collision detection ability
// Copyright (C) 2020-2025 phys-collision authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use super::traits::CollisionTask;
use crate::collision_tasks::pairs::{
    FliplessPairWide, SphereIncludingPairWide, SpherePairWide, StandardPairWide,
};
use crate::shapes::{
    CapsuleWide, ConvexHullWide, CuboidWide, CylinderWide, InfinitePlaneWide, TriangleWide,
};

pub struct SphereSphereTask {}

impl CollisionTask<1> for SphereSphereTask {
    type TPairWide = SpherePairWide;

    #[inline]
    fn need_flip() -> bool {
        false
    }
}

pub struct SphereCapsuleTask {}

type SphereIncludingPairCapsuleWide = SphereIncludingPairWide<CapsuleWide>;

impl CollisionTask<1> for SphereCapsuleTask {
    type TPairWide = SphereIncludingPairCapsuleWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct SphereCuboidTask {}

type SphereIncludingPairCuboidWide = SphereIncludingPairWide<CuboidWide>;

impl CollisionTask<1> for SphereCuboidTask {
    type TPairWide = SphereIncludingPairCuboidWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct SphereInfinitePlaneTask {}

type SphereIncludingPairInfinitePlaneWide = SphereIncludingPairWide<InfinitePlaneWide>;

impl CollisionTask<1> for SphereInfinitePlaneTask {
    type TPairWide = SphereIncludingPairInfinitePlaneWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}
pub struct SphereCylinderTask {}

type SphereIncludingPairCylinderWide = SphereIncludingPairWide<CylinderWide>;

impl CollisionTask<1> for SphereCylinderTask {
    type TPairWide = SphereIncludingPairCylinderWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct CapsuleCuboidTask {}

type StandardPairCapsuleCuboidWide = StandardPairWide<CapsuleWide, CuboidWide>;

impl CollisionTask<2> for CapsuleCuboidTask {
    type TPairWide = StandardPairCapsuleCuboidWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct CapsuleCylinderTask {}

type StandnardPairCapsuleCylinderWide = StandardPairWide<CapsuleWide, CylinderWide>;

impl CollisionTask<2> for CapsuleCylinderTask {
    type TPairWide = StandnardPairCapsuleCylinderWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct CuboidCylinderTask {}

type StandardPairCuboidCylinderWide = StandardPairWide<CuboidWide, CylinderWide>;

impl CollisionTask<4> for CuboidCylinderTask {
    type TPairWide = StandardPairCuboidCylinderWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct CuboidInfinitePlaneTask {}

type StandardPairCuboidInfinitePlaneWide = StandardPairWide<CuboidWide, InfinitePlaneWide>;

impl CollisionTask<4> for CuboidInfinitePlaneTask {
    type TPairWide = StandardPairCuboidInfinitePlaneWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct ConvexHullInfinitePlaneTask {}

type StandardPairConvexHullInfinitePlaneWide = StandardPairWide<ConvexHullWide, InfinitePlaneWide>;

impl CollisionTask<4> for ConvexHullInfinitePlaneTask {
    type TPairWide = StandardPairConvexHullInfinitePlaneWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}
pub struct CylinderInfinitePlaneTask {}

type StandardPairCylinderInfinitePlaneWide = StandardPairWide<CylinderWide, InfinitePlaneWide>;

impl CollisionTask<2> for CylinderInfinitePlaneTask {
    type TPairWide = StandardPairCylinderInfinitePlaneWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct CapsuleInfinitePlaneTask {}

type StandardPairCapsuleInfinitePlaneWide = StandardPairWide<CapsuleWide, InfinitePlaneWide>;

impl CollisionTask<2> for CapsuleInfinitePlaneTask {
    type TPairWide = StandardPairCapsuleInfinitePlaneWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct CylinderConvexHullTask {}

type StandardPairCylinderConvexHullWide = StandardPairWide<CylinderWide, ConvexHullWide>;

impl CollisionTask<4> for CylinderConvexHullTask {
    type TPairWide = StandardPairCylinderConvexHullWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub struct CuboidPairTask {}

type FliplessPairCuboidWide = FliplessPairWide<CuboidWide>;

impl CollisionTask<4> for CuboidPairTask {
    type TPairWide = FliplessPairCuboidWide;

    #[inline]
    fn need_flip() -> bool {
        false
    }
}

pub struct CapsulePairTask {}

type FliplessPairCapsuleWide = FliplessPairWide<CapsuleWide>;

impl CollisionTask<2> for CapsulePairTask {
    type TPairWide = FliplessPairCapsuleWide;

    #[inline]
    fn need_flip() -> bool {
        false
    }
}

pub struct CylinderPairTask {}

type FliplessPairCylinderWide = FliplessPairWide<CylinderWide>;

impl CollisionTask<4> for CylinderPairTask {
    type TPairWide = FliplessPairCylinderWide;

    #[inline]
    fn need_flip() -> bool {
        false
    }
}

pub struct ConvexHullPairTask {}
type FliplessPairConvexHullWide = FliplessPairWide<ConvexHullWide>;

impl CollisionTask<4> for ConvexHullPairTask {
    type TPairWide = FliplessPairConvexHullWide;

    // convex hull pair need not flip
    #[inline]
    fn need_flip() -> bool {
        false
    }
}

pub(crate) struct CapsuleConvexHullTask {}
type StandardPairCapsuleConvexHullWide = StandardPairWide<CapsuleWide, ConvexHullWide>;

impl CollisionTask<2> for CapsuleConvexHullTask {
    type TPairWide = StandardPairCapsuleConvexHullWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct SphereConvexHullTask {}

type StandardPairSphereConvexHullWide = SphereIncludingPairWide<ConvexHullWide>;

impl CollisionTask<1> for SphereConvexHullTask {
    type TPairWide = StandardPairSphereConvexHullWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct CuboidConvexHullTask {}
type StandardPairCuboidConvexHullWide = StandardPairWide<CuboidWide, ConvexHullWide>;

impl CollisionTask<4> for CuboidConvexHullTask {
    type TPairWide = StandardPairCuboidConvexHullWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct SphereTriangleTask {}
type SphereIncludingPairTriangleWide = SphereIncludingPairWide<TriangleWide>;
impl CollisionTask<1> for SphereTriangleTask {
    type TPairWide = SphereIncludingPairTriangleWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct CapsuleTriangleTask {}
type StandardPairCapsuleTriangleWide = StandardPairWide<CapsuleWide, TriangleWide>;
impl CollisionTask<4> for CapsuleTriangleTask {
    type TPairWide = StandardPairCapsuleTriangleWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct CuboidTriangleTask {}
type StandardPairCuboidTriangleWide = StandardPairWide<CuboidWide, TriangleWide>;
impl CollisionTask<4> for CuboidTriangleTask {
    type TPairWide = StandardPairCuboidTriangleWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct TriangleCylinderTask {}
type StandardPairCylinderTriangleWide = StandardPairWide<TriangleWide, CylinderWide>;
impl CollisionTask<4> for TriangleCylinderTask {
    type TPairWide = StandardPairCylinderTriangleWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}

pub(crate) struct TriangleConvexHullTask {}
type StandardPairTriangleConvexHullWide = StandardPairWide<TriangleWide, ConvexHullWide>;
impl CollisionTask<4> for TriangleConvexHullTask {
    type TPairWide = StandardPairTriangleConvexHullWide;

    #[inline]
    fn need_flip() -> bool {
        true
    }
}