Exemplo n.º 1
0
        public void Step(FP timestep, bool multithread)
        {
            this.timestep = timestep;
            bool flag = timestep == FP.Zero;

            if (!flag)
            {
                bool flag2 = timestep < FP.Zero;
                if (flag2)
                {
                    throw new ArgumentException("The timestep can't be negative.", "timestep");
                }
                this.currentAngularDampFactor = FP.One;
                this.currentLinearDampFactor  = FP.One;
                this.events.RaiseWorldPreStep(timestep);
                this.UpdateContacts();
                int i     = 0;
                int count = this.initialCollisions.Count;
                while (i < count)
                {
                    OverlapPairContact overlapPairContact = this.initialCollisions[i];
                    this.events.RaiseBodiesStayCollide(overlapPairContact.contact);
                    i++;
                }
                int j      = 0;
                int count2 = this.initialTriggers.Count;
                while (j < count2)
                {
                    OverlapPairContact overlapPairContact2 = this.initialTriggers[j];
                    this.events.RaiseTriggerStayCollide(overlapPairContact2.contact);
                    j++;
                }
                while (this.removedArbiterQueue.Count > 0)
                {
                    this.islands.ArbiterRemoved(this.removedArbiterQueue.Dequeue());
                }
                int k      = 0;
                int count3 = this.softbodies.Count;
                while (k < count3)
                {
                    SoftBody softBody = this.softbodies[k];
                    softBody.Update(timestep);
                    softBody.DoSelfCollision(this.collisionDetectionHandler);
                    k++;
                }
                this.CollisionSystem.Detect(multithread);
                while (this.addedArbiterQueue.Count > 0)
                {
                    this.islands.ArbiterCreated(this.addedArbiterQueue.Dequeue());
                }
                this.CheckDeactivation();
                this.IntegrateForces();
                this.HandleArbiter(this.contactIterations, multithread);
                Integrate(multithread);
                int l      = 0;
                int count4 = this.rigidBodies.Count;
                while (l < count4)
                {
                    RigidBody rigidBody = this.rigidBodies[l];
                    rigidBody.PostStep();
                    int m      = 0;
                    int count5 = rigidBody.constraints.Count;
                    while (m < count5)
                    {
                        rigidBody.constraints[m].PostStep();
                        m++;
                    }
                    l++;
                }
                this.events.RaiseWorldPostStep(timestep);
            }
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            OverlapPairContact overlapPairContact = (OverlapPairContact)obj;

            return((overlapPairContact.Entity1.Equals(this.Entity1) && overlapPairContact.Entity2.Equals(this.Entity2)) || (overlapPairContact.Entity1.Equals(this.Entity2) && overlapPairContact.Entity2.Equals(this.Entity1)));
        }
Exemplo n.º 3
0
        private void CollisionDetected(RigidBody body1, RigidBody body2, TSVector point1, TSVector point2, TSVector normal, FP penetration)
        {
            bool       flag    = body1.IsColliderOnly || body2.IsColliderOnly;
            Arbiter    arbiter = null;
            bool       flag2   = flag;
            ArbiterMap arbiterMap;

            if (flag2)
            {
                arbiterMap = this.arbiterTriggerMap;
            }
            else
            {
                arbiterMap = this.arbiterMap;
            }
            bool       flag3 = false;
            ArbiterMap obj   = arbiterMap;

            lock (obj)
            {
                arbiterMap.LookUpArbiter(body1, body2, out arbiter);
                bool flag4 = arbiter == null;
                if (flag4)
                {
                    arbiter       = Arbiter.Pool.GetNew();
                    arbiter.body1 = body1;
                    arbiter.body2 = body2;
                    arbiterMap.Add(new ArbiterKey(body1, body2), arbiter);
                    flag3 = true;
                }
            }
            bool    flag5 = arbiter.body1 == body1;
            Contact contact;

            if (flag5)
            {
                TSVector.Negate(ref normal, out normal);
                contact = arbiter.AddContact(point1, point2, normal, penetration, this.contactSettings);
            }
            else
            {
                contact = arbiter.AddContact(point2, point1, normal, penetration, this.contactSettings);
            }
            bool flag6 = flag3;

            if (flag6)
            {
                bool flag7 = flag;
                if (flag7)
                {
                    this.events.RaiseTriggerBeginCollide(contact);
                    body1.arbitersTrigger.Add(arbiter);
                    body2.arbitersTrigger.Add(arbiter);
                    OverlapPairContact overlapPairContact = new OverlapPairContact(body1, body2);
                    overlapPairContact.contact = contact;
                    this.initialTriggers.Add(overlapPairContact);
                }
                else
                {
                    this.events.RaiseBodiesBeginCollide(contact);
                    this.addedArbiterQueue.Enqueue(arbiter);
                    OverlapPairContact overlapPairContact2 = new OverlapPairContact(body1, body2);
                    overlapPairContact2.contact = contact;
                    this.initialCollisions.Add(overlapPairContact2);
                }
            }
            bool flag8 = !flag && contact != null;

            if (flag8)
            {
                this.events.RaiseContactCreated(contact);
            }
        }