technologies/Jitter/Collision/CollisionSystemPersistentSAP.cs
/// <summary>
/// Tells the collisionsystem to check all bodies for collisions. Hook into the
/// <see cref="CollisionSystem.PassedBroadphase"/>
/// and <see cref="CollisionSystem.CollisionDetected"/> events to get the results.
/// </summary>
/// <param name="multiThreaded">If true internal multithreading is used.</param>
Tells the collisionsystem to check all bodies for collisions. Hook into the

and  events to get the results.
Tells the collisionsystem to check all bodies for collisions . Hook into the and events to get the results .
public override void Detect(bool multiThreaded)
        {
            if (addCounter > AddedObjectsBruteForceIsUsed)
            {
                t2bM.ZeroAll();
                fullOverlaps.Clear();
                DirtySortAxis(axis1);
                DirtySortAxis(axis2);
                DirtySortAxis(axis3);
            }
            else
            {
                if (multiThreaded)
                {
                    ThreadManager.internalInstance.AddTask(sortCallback, axis1);
                    ThreadManager.internalInstance.AddTask(sortCallback, axis2);
                    ThreadManager.internalInstance.AddTask(sortCallback, axis3);
                    ThreadManager.internalInstance.Execute();
                }
                else
                {
                    SortAxis(axis1);
                    SortAxis(axis2);
                    SortAxis(axis3);
                }
            }
            addCounter = 0;
            if (multiThreaded)
            {
                foreach (BodyPair key in fullOverlaps)
                {
                    if (this.CheckBothStaticOrInactive(key.body1, key.body2)) continue;
                    if (base.RaisePassedBroadphase(key.body1, key.body2))
                    {
                        Pair pair = Pair.Pool.GetNew();
                        if (swapOrder) { pair.entity1 = key.body1; pair.entity2 = key.body2; }
                        else { pair.entity2 = key.body2; pair.entity1 = key.body1; }
                        swapOrder = !swapOrder;
                        ThreadManager.internalInstance.AddTask(detectCallback, pair);
                    }
                }
                ThreadManager.internalInstance.Execute();
            }
            else
            {
                foreach (BodyPair key in fullOverlaps)
                {
                    if (this.CheckBothStaticOrInactive(key.body1, key.body2)) continue;
                    if (base.RaisePassedBroadphase(key.body1, key.body2))
                    {
                        if (swapOrder) { Detect(key.body1, key.body2); }
                        else Detect(key.body2, key.body1);
                        swapOrder = !swapOrder;
                    }
                }
            }
        }
public override void Detect ( bool multiThreaded ) { if ( addCounter > AddedObjectsBruteForceIsUsed ) { t2bM . ZeroAll ( ) ; fullOverlaps . Clear ( ) ; DirtySortAxis ( axis1 ) ; DirtySortAxis ( axis2 ) ; DirtySortAxis ( axis3 ) ; } else { if ( multiThreaded ) { ThreadManager . internalInstance . AddTask ( sortCallback , axis1 ) ; ThreadManager . internalInstance . AddTask ( sortCallback , axis2 ) ; ThreadManager . internalInstance . AddTask ( sortCallback , axis3 ) ; ThreadManager . internalInstance . Execute ( ) ; } else { SortAxis ( axis1 ) ; SortAxis ( axis2 ) ; SortAxis ( axis3 ) ; } } addCounter = 0 ; if ( multiThreaded ) { foreach ( BodyPair key in fullOverlaps ) { if ( this . CheckBothStaticOrInactive ( key . body1 , key . body2 ) ) continue ; if ( base . RaisePassedBroadphase ( key . body1 , key . body2 ) ) { Pair pair = Pair . Pool . GetNew ( ) ; if ( swapOrder ) { pair . entity1 = key . body1 ; pair . entity2 = key . body2 ; } else { pair . entity2 = key . body2 ; pair . entity1 = key . body1 ; } swapOrder = ! swapOrder ; ThreadManager . internalInstance . AddTask ( detectCallback , pair ) ; } } ThreadManager . internalInstance . Execute ( ) ; } else { foreach ( BodyPair key in fullOverlaps ) { if ( this . CheckBothStaticOrInactive ( key . body1 , key . body2 ) ) continue ; if ( base . RaisePassedBroadphase ( key . body1 , key . body2 ) ) { if ( swapOrder ) { Detect ( key . body1 , key . body2 ) ; } else Detect ( key . body2 , key . body1 ) ; swapOrder = ! swapOrder ; } } } }
Tells the collisionsystem to check all bodies for collisions.
Tells the collisionsystem to check all bodies for collisions .
multiThreaded
bool
If true internal multithreading is used.
If true internal multithreading is used .