public static bool Intersects(this BurstBaseCollider testCollider, BurstBaseCollider other) { switch (testCollider.Type) { case BurstColliderType.Box: switch (other.Type) { case BurstColliderType.Box: return(IntersectionUtility.BoxBoxIntersects(testCollider.Box, other.Box)); case BurstColliderType.Sphere: return(IntersectionUtility.BoxSphereIntersects(testCollider.Box, other.Sphere)); default: throw new InvalidOperationException(); } case BurstColliderType.Sphere: switch (other.Type) { case BurstColliderType.Box: return(IntersectionUtility.BoxSphereIntersects(other.Box, testCollider.Sphere)); case BurstColliderType.Sphere: return(IntersectionUtility.SphereSphereIntersects(testCollider.Sphere, other.Sphere)); default: throw new InvalidOperationException(); } } throw new InvalidOperationException(); }
public static NativeList <BurstBaseCollider> Execute(BurstBaseCollider testCollider, BurstBaseCollider[] otherColliders) { using (var nativeArray = new NativeArray <BurstBaseCollider>(otherColliders, Allocator.TempJob)) { return(Execute(testCollider, nativeArray)); } }
public static NativeList <BurstBaseCollider> Execute(BurstBaseCollider testCollider, NativeArray <BurstBaseCollider> otherColliders) { var resultStartingSize = (int)Math.Abs(Math.Floor(otherColliders.Length * 0.1f)); var result = new NativeList <BurstBaseCollider>(resultStartingSize, Allocator.TempJob); new BaseIntersectionJob { TestCollider = testCollider, OtherColliders = otherColliders, ResultCollisions = result, }.Schedule().Complete(); return(result); }
public static Vector3 ClosestPosition(this BurstBaseCollider baseCollider, Vector3 worldPosition) { switch (baseCollider.Type) { case BurstColliderType.Box: return(baseCollider.Box.ClosestPosition(worldPosition)); case BurstColliderType.Sphere: return(baseCollider.Sphere.ClosestPosition(worldPosition)); default: throw new InvalidOperationException(); } }
public static BurstBaseCollider CreateFromCollider(Collider inputCollider) { var result = new BurstBaseCollider(); result.Id = inputCollider.gameObject.GetInstanceID(); switch (inputCollider) { case SphereCollider sphere: result.Type = BurstColliderType.Sphere; result.Sphere = CreateSphere(sphere); break; case BoxCollider box: result.Type = BurstColliderType.Box; result.Box = CreateBox(box); break; default: throw new InvalidOperationException(); } return(result); }
public static NativeList <BurstBaseCollider> Intersects(this BurstBaseCollider testCollider, NativeArray <BurstBaseCollider> colliders) { return(IntersectionJobs.BaseIntersectionJob.Execute(testCollider, colliders)); }