Пример #1
0
 public unsafe bool OverlapPoint <T>(OverlapPointInput input, ref T collector) where T : struct, ICollector <OverlapPointHit>
 {
     fixed(PhysicsCompoundCollider *target = &this)
     {
         return(OverlapQueries.OverlapPoint(input, (Collider *)target, ref collector));
     }
 }
Пример #2
0
        public static bool OverlapPoint <T>(ref T target, OverlapPointInput input, out OverlapPointHit closestHit) where T : struct, IQueryable
        {
            var collector = new ClosestHitCollector <OverlapPointHit>(1.0f);

            if (target.OverlapPoint(input, ref collector))
            {
                closestHit = collector.ClosestHit;
                return(true);
            }

            closestHit = new OverlapPointHit();
            return(false);
        }
Пример #3
0
 public bool OverlapPoint <T>(OverlapPointInput input, ref T collector) where T : struct, ICollector <OverlapPointHit>
 {
     return(CollisionWorld.OverlapPoint(input, ref collector));
 }
Пример #4
0
 public bool OverlapPoint(OverlapPointInput input, ref NativeList <OverlapPointHit> allHits) => QueryWrappers.OverlapPoint(ref this, input, ref allHits);
Пример #5
0
 public bool OverlapPoint(OverlapPointInput input, out OverlapPointHit hit) => QueryWrappers.OverlapPoint(ref this, input, out hit);
Пример #6
0
        public static bool OverlapPoint <T>(ref T target, OverlapPointInput input, ref NativeList <OverlapPointHit> allHits) where T : struct, IQueryable
        {
            var collector = new AllHitsCollector <OverlapPointHit>(1.0f, ref allHits);

            return(target.OverlapPoint(input, ref collector));
        }
Пример #7
0
        public static bool OverlapPoint <T>(ref T target, OverlapPointInput input) where T : struct, IQueryable
        {
            var collector = new AnyHitCollector <OverlapPointHit>(1.0f);

            return(target.OverlapPoint(input, ref collector));
        }
Пример #8
0
 public bool OverlapPoint <T>(OverlapPointInput input, ref T collector) where T : struct, ICollector <OverlapPointHit>
 {
     return(Broadphase.OverlapPoint(input, m_PhysicsBodies, ref collector));
 }
Пример #9
0
 public bool PointLeaf <T>(OverlapPointInput input, int leafData, ref T collector) where T : struct, ICollector <OverlapPointHit>
 {
     ref var child = ref m_CompoundCollider->Children[leafData];
Пример #10
0
        internal static unsafe bool OverlapPoint <T>(OverlapPointInput input, Collider *collider, ref T collector) where T : struct, ICollector <OverlapPointHit>
        {
            // Nothing to do if:
            // - MaxFraction is zero.
            // - Filtered out.
            if (math.abs(collector.MaxFraction) < 0f ||
                !CollisionFilter.IsCollisionEnabled(input.Filter, collider->Filter))
            {
                return(false);
            }

            // Ensure the query context is initialized.
            input.QueryContext.EnsureIsInitialized();

            bool hadHit;

            switch (collider->ColliderType)
            {
            case ColliderType.Box:
            {
                var box = (PhysicsBoxCollider *)collider;
                hadHit = PointConvex(input.Position, ref box->m_ConvexHull);
                break;
            }

            case ColliderType.Polygon:
            {
                var polygon = (PhysicsPolygonCollider *)collider;
                hadHit = PointConvex(input.Position, ref polygon->m_ConvexHull);
                break;
            }

            case ColliderType.Capsule:
            {
                var capsule = (PhysicsCapsuleCollider *)collider;
                hadHit = PointCapsule(input.Position, capsule->Vertex0, capsule->Vertex1, capsule->Radius);
                break;
            }

            case ColliderType.Circle:
            {
                var circle = (PhysicsCircleCollider *)collider;
                hadHit = PointCircle(input.Position, circle->Center, circle->Radius);
                break;
            }

            case ColliderType.Compound:
            {
                return(PointCompound(input, (PhysicsCompoundCollider *)collider, ref collector));
            }

            default:
                SafetyChecks.ThrowNotImplementedException();
                return(default);
            }

            if (hadHit)
            {
                var hit = new OverlapPointHit
                {
                    Fraction = 0f,
                    Position = PhysicsMath.mul(input.QueryContext.LocalToWorldTransform, input.Position),

                    PhysicsBodyIndex = input.QueryContext.PhysicsBodyIndex,
                    ColliderKey      = input.QueryContext.ColliderKey,
                    Entity           = input.QueryContext.Entity
                };

                return(collector.AddHit(hit));
            }
            return(false);
        }
Пример #11
0
 public bool OverlapPoint <T>(OverlapPointInput input, ref T collector) where T : struct, ICollector <OverlapPointHit>
 {
     return(Collider.IsCreated && Collider.Value.OverlapPoint(input, ref collector));
 }