public override bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2) { Vector3 p = closestPointOnAabb(m_position, other); normal1 = new Vector3(); normal2 = new Vector3(); Vector3 v = p - m_position; if (v.LengthSquared() <= m_sphere.Radius * m_sphere.Radius) { normal1 = m_position - p; if (normal1 != Vector3.Zero) { normal1.Normalize(); } normal2 = Vector3.Negate(normal1); } return m_sphere.Intersects(other.BoundingBox); }
public override bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2) { throw new NotImplementedException(); }
//public override bool intersectsAxisAligned(CapsuleCollider other, out Vector3 normal1, out Vector3 normal2) //{ // throw new NotImplementedException(); //} //public override bool intersectsAxisAligned(CylinderCollider other, out Vector3 normal1, out Vector3 normal2) //{ // throw new NotImplementedException(); //} //public override bool intersectsAxisAligned(HeightfieldCollider other, out Vector3 normal1, out Vector3 normal2) //{ // throw new NotImplementedException(); //} //public override bool intersectsAxisAligned(MeshCollider other, out Vector3 normal1, out Vector3 normal2) //{ // throw new NotImplementedException(); //} //public override bool intersectsAxisAligned(PlaneCollider other, out Vector3 normal1, out Vector3 normal2) //{ // float ret = Vector3.Dot(other.Normal, m_position); // if (ret - other.D <= 0) // { // normal1 = other.Normal; // normal2 = Vector3.Negate(normal1); // return true; // } // normal1 = new Vector3(); // normal2 = new Vector3(); // return false; //} private Vector3 closestPointOnAabb(Vector3 point, BoxCollider other) { Vector3 min = other.BoundingBox.Min; Vector3 max = other.BoundingBox.Max; Vector3 q = Vector3.Zero; float v = 0; v = point.X; v = Math.Max(v, min.X); v = Math.Min(v, max.X); q.X = v; v = point.Y; v = Math.Max(v, min.Y); v = Math.Min(v, max.Y); q.Y = v; v = point.Z; v = Math.Max(v, min.Z); v = Math.Min(v, max.Z); q.Z = v; return q; }
public override bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2) { normal1 = m_normal; normal2 = Vector3.Negate(normal1); Vector3 center = other.getCenter(); Vector3 extend; Vector3 min = other.Bb.Min; Vector3 max = other.Bb.Max; Vector3.Subtract(ref max, ref min, out extend); float distance = getDistance(center); float maxDist = Vector3.Dot(m_normal, extend); if (distance > maxDist) { return false; } return true; }
public override bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2) { normal1 = new Vector3(); normal2 = new Vector3(); return false; //return other.intersectsAxisAligned(this, out normal2, out normal1); }
public override bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2) { normal1 = new Vector3(); normal2 = new Vector3(); if (other.Bb.Min.Y + other.Position.Y > m_position.Y + m_height) { return false; } if (other.Bb.Max.Y + other.Position.Y < m_position.Y) { return false; } if (m_position.X + m_radius < other.Position.X - other.Bb.Min.X) { return false; } if (m_position.X - m_radius > other.Position.X + other.Bb.Max.X) { return false; } if (m_position.Z + m_radius < other.Position.Z - other.Bb.Min.Z) { return false; } if (m_position.Z - m_radius > other.Position.Z + other.Bb.Max.Z) { return false; } return true; }
public abstract bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2);
public override bool intersectsAxisAligned(BoxCollider other, out Vector3 normal1, out Vector3 normal2) { normal1 = new Vector3(); normal2 = new Vector3(); return m_boundingBox.Intersects(other.m_boundingBox); //return other.intersectsAxisAligned(this, out normal2, out normal1); }