public static bool TestCollision(CollisionHull2D a, CollisionHull2D b) { CollisionHullType2D hullTypeA = a.type; CollisionHullType2D hullTypeB = b.type; if (hullTypeA == CollisionHullType2D.hull_circle) { if (hullTypeB == CollisionHullType2D.hull_circle) { collided = a.TestCollsionVsCircle(b.GetComponent <CirlceCollisionHull2D>()); } if (hullTypeB == CollisionHullType2D.hull_aabb) { collided = a.TestCollsionVsAABB(b.GetComponent <AABBCollisionHull2D>()); } if (hullTypeB == CollisionHullType2D.hull_obb) { collided = a.TestCollsionVsOBB(b.GetComponent <OBBCollisionHull2D>()); } } else if (hullTypeA == CollisionHullType2D.hull_aabb) { if (hullTypeB == CollisionHullType2D.hull_circle) { collided = a.TestCollsionVsCircle(b.GetComponent <CirlceCollisionHull2D>()); } if (hullTypeB == CollisionHullType2D.hull_aabb) { collided = a.TestCollsionVsAABB(b.GetComponent <AABBCollisionHull2D>()); } if (hullTypeB == CollisionHullType2D.hull_obb) { collided = a.TestCollsionVsOBB(b.GetComponent <OBBCollisionHull2D>()); } } else if (hullTypeA == CollisionHullType2D.hull_obb) { if (hullTypeB == CollisionHullType2D.hull_circle) { collided = a.TestCollsionVsCircle(b.GetComponent <CirlceCollisionHull2D>()); } if (hullTypeB == CollisionHullType2D.hull_aabb) { collided = a.TestCollsionVsAABB(b.GetComponent <AABBCollisionHull2D>()); } if (hullTypeB == CollisionHullType2D.hull_obb) { collided = a.TestCollsionVsOBB(b.GetComponent <OBBCollisionHull2D>()); } } return(collided); }
public CollisionInfo(CollisionHull2D shapeA, CollisionHull2D shapeB, Vector2 normal, float penetration) { RigidBodyA = shapeA.GetComponent <Particle2D>(); ShapeA = shapeA; RigidBodyB = shapeB.GetComponent <Particle2D>(); ShapeB = shapeB; RelativeVelocity = RigidBodyB.velocity - RigidBodyA.velocity; contacts[0].normal = normal; contacts[0].penetration = penetration; contacts[0].restitution = Mathf.Min(RigidBodyA.restitution, RigidBodyB.restitution); }