Esempio n. 1
0
 private Collision _SphereCollide(SphereCollider sc)
 {
     var center = sc.Sphere.Center;
     var radius = sc.Sphere.Radius;
     var closest = Obb.ClosestPoint(center);
     var normal = center - closest;
     var depth = radius - normal.Length();
     if (depth < 0) return null;
     normal.Normalize();
     return new Collision(this, sc
         , new Contact(closest, center - radius * normal, normal, depth)
     );
 }
 private Collision _SphereCollide(SphereCollider sc)
 {
     var center = Sphere.Center;
     var radius = Sphere.Radius;
     var scCenter = sc.Sphere.Center;
     var scRadius = sc.Sphere.Radius;
     var normal = scCenter - center;
     var depth = scRadius + radius - normal.Length();
     if (depth < 0) return null;
     normal.Normalize();
     return new Collision(this, sc
         , new Contact(
             center + radius * normal,
             scCenter - scRadius * normal,
             normal, depth
        ));
 }