Nez.Portable/Physics/ColliderTriggerHelper.cs
/// <summary>
/// update should be called AFTER Entity is moved. It will take care of any ITriggerListeners that the Collider overlaps.
/// </summary>
update should be called AFTER Entity is moved. It will take care of any ITriggerListeners that the Collider overlaps.
update should be called AFTER Entity is moved . It will take care of any ITriggerListeners that the Collider overlaps .
public void update()
        {
            var colliders = _entity.getComponents<Collider>();
            for (var i = 0; i < colliders.Count; i++)
            {
                var collider = colliders[i];
                var neighbors = Physics.boxcastBroadphase(collider.bounds, collider.collidesWithLayers);
                foreach (var neighbor in neighbors)
                {
                    if (!collider.isTrigger && !neighbor.isTrigger)
                        continue;
                    if (collider.overlaps(neighbor))
                    {
                        var pair = new Pair<Collider>(collider, neighbor);
                        var shouldReportTriggerEvent = !_activeTriggerIntersections.Contains(pair)
                                                       && !_previousTriggerIntersections.Contains(pair);
                        if (shouldReportTriggerEvent)
                            notifyTriggerListeners(pair, true);
                        _activeTriggerIntersections.Add(pair);
                    }
                }
            }
            ListPool<Collider>.free(colliders);
            checkForExitedColliders();
        }
public void update ( ) { var colliders = _entity . getComponents < Collider > ( ) ; for ( var i = 0 ; i < colliders . Count ; i ++ ) { var collider = colliders [ i ] ; var neighbors = Physics . boxcastBroadphase ( collider . bounds , collider . collidesWithLayers ) ; foreach ( var neighbor in neighbors ) { if ( ! collider . isTrigger && ! neighbor . isTrigger ) continue ; if ( collider . overlaps ( neighbor ) ) { var pair = new Pair < Collider > ( collider , neighbor ) ; var shouldReportTriggerEvent = ! _activeTriggerIntersections . Contains ( pair ) && ! _previousTriggerIntersections . Contains ( pair ) ; if ( shouldReportTriggerEvent ) notifyTriggerListeners ( pair , true ) ; _activeTriggerIntersections . Add ( pair ) ; } } } ListPool < Collider > . free ( colliders ) ; checkForExitedColliders ( ) ; }
update should be called AFTER Entity is moved.
update should be called AFTER Entity is moved .
// 3. do an overlap check of all entity.colliders that are triggers with all broadphase colliders, triggers or not. // Any overlaps result in trigger events. // fetch anything that we might collide with us at our new position // we need at least one of the colliders to be a trigger // if we already have this pair in one of our sets (the previous or current trigger intersections) dont call the enter event // overlaps // end foreach