/
EugenyCh7
/
Puppet2D.Net
Обзор
Документация
Войти
/
EugenyCh7
/
Puppet2D.Net
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Puppet2D.Engine/Geometry/Collision.cs
165 строк
6 KB
EugenyCh7
Collision fix
24 авг 2025, 19:29
24 авг 2025, 19:29
25208d5
Код
Авторство
О чём код?
using Puppet2D.Engine.Common; namespace Puppet2D.Engine.Geometry { public static class Collision { /// <summary> /// Compute the contact manifold between two circles. /// </summary> public static Manifold CollideCircles(Circle circleA, Transform xfA, Circle circleB, Transform xfB) { unsafe { B2.Circle shapeA = circleA.CastToCircle(); B2.Circle shapeB = circleB.CastToCircle(); return new Manifold(B2.CollideCircles(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between a capsule and circle. /// </summary> public static Manifold CollideCapsuleAndCircle(Capsule capsuleA, Transform xfA, Circle circleB, Transform xfB) { unsafe { B2.Capsule shapeA = capsuleA.CastToCapsule(); B2.Circle shapeB = circleB.CastToCircle(); return new Manifold(B2.CollideCapsuleAndCircle(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between an segment and a circle. /// </summary> public static Manifold CollideSegmentAndCircle(Segment segmentA, Transform xfA, Circle circleB, Transform xfB) { unsafe { B2.Segment shapeA = segmentA.CastToSegment(); B2.Circle shapeB = circleB.CastToCircle(); return new Manifold(B2.CollideSegmentAndCircle(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between a polygon and a circle. /// </summary> public static Manifold CollidePolygonAndCircle(Polygon polygonA, Transform xfA, Circle circleB, Transform xfB) { unsafe { B2.Polygon shapeA = polygonA.CastToPolygon(); B2.Circle shapeB = circleB.CastToCircle(); return new Manifold(B2.CollidePolygonAndCircle(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between two capsules. /// </summary> public static Manifold CollideCapsules(Capsule capsuleA, Transform xfA, Capsule capsuleB, Transform xfB) { unsafe { B2.Capsule shapeA = capsuleA.CastToCapsule(); B2.Capsule shapeB = capsuleB.CastToCapsule(); return new Manifold(B2.CollideCapsules(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between an segment and a capsule. /// </summary> public static Manifold CollideSegmentAndCapsule(Segment segmentA, Transform xfA, Capsule capsuleB, Transform xfB) { unsafe { B2.Segment shapeA = segmentA.CastToSegment(); B2.Capsule shapeB = capsuleB.CastToCapsule(); return new Manifold(B2.CollideSegmentAndCapsule(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between a polygon and capsule. /// </summary> public static Manifold CollidePolygonAndCapsule(Polygon polygonA, Transform xfA, Capsule capsuleB, Transform xfB) { unsafe { B2.Polygon shapeA = polygonA.CastToPolygon(); B2.Capsule shapeB = capsuleB.CastToCapsule(); return new Manifold(B2.CollidePolygonAndCapsule(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between two polygons. /// </summary> public static Manifold CollidePolygons(Polygon polygonA, Transform xfA, Polygon polygonB, Transform xfB) { unsafe { B2.Polygon shapeA = polygonA.CastToPolygon(); B2.Polygon shapeB = polygonB.CastToPolygon(); return new Manifold(B2.CollidePolygons(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between an segment and a polygon. /// </summary> public static Manifold CollideSegmentAndPolygon(Segment segmentA, Transform xfA, Polygon polygonB, Transform xfB) { unsafe { B2.Segment shapeA = segmentA.CastToSegment(); B2.Polygon shapeB = polygonB.CastToPolygon(); return new Manifold(B2.CollideSegmentAndPolygon(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between a chain segment and a circle. /// </summary> public static Manifold CollideChainSegmentAndCircle(ChainSegment segmentA, Transform xfA, Circle circleB, Transform xfB) { unsafe { B2.ChainSegment shapeA = segmentA.CastToChainSegment(); B2.Circle shapeB = circleB.CastToCircle(); return new Manifold(B2.CollideChainSegmentAndCircle(&shapeA, xfA, &shapeB, xfB)); } } /// <summary> /// Compute the contact manifold between a chain segment and a capsule. /// </summary> public static Manifold CollideChainSegmentAndCapsule(ChainSegment segmentA, Transform xfA, Capsule capsuleB, Transform xfB) { unsafe { B2.ChainSegment shapeA = segmentA.CastToChainSegment(); B2.Capsule shapeB = capsuleB.CastToCapsule(); B2.SimplexCache simplexCache = default; return new Manifold(B2.CollideChainSegmentAndCapsule(&shapeA, xfA, &shapeB, xfB, &simplexCache)); } } /// <summary> /// Compute the contact manifold between a chain segment and a rounded polygon. /// </summary> public static Manifold CollideChainSegmentAndPolygon(ChainSegment segmentA, Transform xfA, Polygon polygonB, Transform xfB) { unsafe { B2.ChainSegment shapeA = segmentA.CastToChainSegment(); B2.Polygon shapeB = polygonB.CastToPolygon(); B2.SimplexCache simplexCache = default; return new Manifold(B2.CollideChainSegmentAndPolygon(&shapeA, xfA, &shapeB, xfB, &simplexCache)); } } } }