public virtual void PostSolve(b2Contact contact, b2ContactImpulse impulse)
 {
     if (SwigDerivedClassHasMethod("PostSolve", swigMethodTypes3))
     {
         Box2dPINVOKE.b2ContactListener_PostSolveSwigExplicitb2ContactListener(swigCPtr, b2Contact.getCPtr(contact), b2ContactImpulse.getCPtr(impulse));
     }
     else
     {
         Box2dPINVOKE.b2ContactListener_PostSolve(swigCPtr, b2Contact.getCPtr(contact), b2ContactImpulse.getCPtr(impulse));
     }
 }
Beispiel #2
0
        public override void PostSolve(b2Contact contact, ref b2ContactImpulse impulse)
        {
            if (m_broke)
            {
                // The body already broke.
                return;
            }

            // Should the body break?
            int count = contact.GetManifold().pointCount;

            float maxImpulse = 0.0f;

            for (int i = 0; i < count; ++i)
            {
                maxImpulse = Math.Max(maxImpulse, impulse.normalImpulses[i]);
            }

            if (maxImpulse > 40.0f)
            {
                // Flag the body for breaking.
                m_break = true;
            }
        }
Beispiel #3
0
    public void Report(b2ContactVelocityConstraint[] constraints)
    {
        if (m_listener == null)
        {
            return;
        }

        for (int i = 0; i < m_contactCount; ++i)
        {
            b2Contact c = m_contacts[i];

            b2ContactVelocityConstraint vc = constraints[i];

            b2ContactImpulse impulse = new b2ContactImpulse();
            impulse.count = vc.pointCount;
            for (int j = 0; j < vc.pointCount; ++j)
            {
                impulse.normalImpulses[j]  = vc.points[j].normalImpulse;
                impulse.tangentImpulses[j] = vc.points[j].tangentImpulse;
            }

            m_listener.PostSolve(c, impulse);
        }
    }
Beispiel #4
0
 public override void PostSolve(b2Contact contact, ref b2ContactImpulse impulse)
 {
 }
Beispiel #5
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(b2ContactImpulse obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Beispiel #6
0
 public override void PostSolve(Box2D.Dynamics.Contacts.b2Contact contact, ref b2ContactImpulse impulse)
 {
 }
Beispiel #7
0
 public override void PostSolve(b2Contact contact, ref b2ContactImpulse impulse)
 {
     //throw new NotImplementedException ();
 }
 /// This lets you inspect a contact after the solver is finished. This is useful
 /// for inspecting impulses.
 /// Note: the contact manifold does not include time of impact impulses, which can be
 /// arbitrarily large if the sub-step is small. Hence the impulse is provided explicitly
 /// in a separate data structure.
 /// Note: this is only called for contacts that are touching, solid, and awake.
 public virtual void PostSolve(b2Contact contact, b2ContactImpulse impulse)
 {
 }
Beispiel #9
0
 public virtual void PostSolve(b2Contact contact, b2ContactImpulse impulse)
 {
     Box2DPINVOKE.b2ContactListener_PostSolve(swigCPtr, b2Contact.getCPtr(contact), b2ContactImpulse.getCPtr(impulse));
 }
Beispiel #10
0
        public void PostSolve(b2Contact contact, b2ContactImpulse impulse)
        {
            // http://stackoverflow.com/questions/11149091/box2d-damage-physics

            //M:\web\FlashHeatZeekerWithStarlingB2\XContactListener.as(34): col: 83 Error: Implicit coercion of a value of type __AS3__.vec:Vector.<Number> to an unrelated type __AS3__.vec:Vector.<*>.

            //double0 = __Enumerable.Sum_100669321(X.AsEnumerable_100664676(impulse.normalImpulses));

            // http://blog.allanbishop.com/box-2d-2-1a-tutorial-part-6-collision-strength/
            var forceA = impulse.normalImpulses[0];
            // { impulse = { length = 2, forceA = 2.9642496469208197, forceB = 0 } }

            var forceB = impulse.normalImpulses[1];

            if (DiscardSmallImpulse)
            {
                if (forceA < 0.5)
                {
                    if (forceB < 0.5)
                    {
                        // do we care about friction?
                        return;
                    }
                }
            }

            //var min = impulse.normalImpulses.AsEnumerable().Min();
            //var max = impulse.normalImpulses.AsEnumerable().Max();

            //            System.Linq.Enumerable for Double Min(System.Collections.Generic.IEnumerable`1[System.Double]) used at
            //FlashHeatZeekerWithStarlingB2.XContactListener.PostSolve at offset 001d.

            var done = false;

            var fixA = contact.GetFixtureA();

            if (fixA != null)
            {
                var hitA = fixA.GetUserData() as Action <double>;
                if (hitA != null)
                {
                    //Console.WriteLine(new
                    //{
                    //    hitA = new
                    //    {
                    //        forceA,
                    //    }
                    //});

                    hitA(forceA);
                    done = true;
                }
            }

            var fixB = contact.GetFixtureB();

            if (fixB != null)
            {
                var hitB = fixB.GetUserData() as Action <double>;
                if (hitB != null)
                {
                    //Console.WriteLine(new
                    //{
                    //    hitB = new
                    //    {
                    //        forceA,
                    //    }
                    //});

                    hitB(forceA);
                    done = true;
                }
            }

            if (done)
            {
                return;
            }

            Console.WriteLine(new
            {
                impulse = new
                {
                    impulse.normalImpulses.length,
                    forceA,
                    fixA,
                    forceB,
                    fixB
                    //, min, max
                }
            });
        }