Problems with Box2d As3 Listener

I have a problem with the box2d as3 b2ContactListener class. I have a class called ContactListener that extends b2ContactListener and overrides the PostSolve method. PostSolve accepts 2 parameters, a contact that contains information about 2 objects that have a contact, and a pulse that contains information about a contact. I use the momentum parameter to decide how much 2 objects will suffer, and then I deal damage accordingly.

Here's the problem: If I do everything circular, and let it slowly roll over the static body that I have as the earth, then drop a fairly large object anywhere on the earth, the circle that is in motion will receive contacts, it will be repeated momentum, which is a great way to just rolling. This makes sliding circular objects break when they shouldn't.

It is almost as if he is shaking a static body and inflicting massive damage to objects hundreds of meters away, but it only affects circles.

Can anyone shed light on the situation? Is this a known issue? Workarounds?

I am using Box2DAs3 version 2.1a.

Update: . When the body enters this strange state of causing great damage, any circle that touches it receives tons of large impulses. As soon as something non-circular comes into contact with the body, it no longer has a problem. Also, this problem is associated not only with static objects, but also with dynamic and kinematic properties.

Update: . , . , , , PostSolve. 11 11 , . . , 12 12, . , 12 12 0,1 , . . . , 10 100, . , , , .

: Box2D, swf .

+3
1

WOW. , , .

, , , - ContactListener, , PostSolve. b2Island, Report . . :

private static var s_impulse:b2ContactImpulse = new b2ContactImpulse();
public function Report(constraints:Vector.<b2ContactConstraint>) : void
{
    if (m_listener == null)
    {
        return;
    }

    for (var i:int = 0; i < m_contactCount; ++i)
    {
        var c:b2Contact = m_contacts[i];
        var cc:b2ContactConstraint = constraints[ i ];

        for (var j:int = 0; j < cc.pointCount; ++j)
        {
            s_impulse.normalImpulses[j] = cc.points[j].normalImpulse;
            s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse;
        }
        m_listener.PostSolve(c, s_impulse);
    }
}

, , s_impulse var , b2Island ( ), reset . s_impulse var , . , , , , . , reset, , .

, , , , . , :

private static var s_impulse:b2ContactImpulse = new b2ContactImpulse();
public function Report(constraints:Vector.<b2ContactConstraint>) : void
{
    if (m_listener == null)
    {
        return;
    }

    for (var i:int = 0; i < m_contactCount; ++i)
    {
        s_impulse = new b2ContactImpulse();

        var c:b2Contact = m_contacts[i];
        var cc:b2ContactConstraint = constraints[ i ];

        for (var j:int = 0; j < cc.pointCount; ++j)
        {
            s_impulse.normalImpulses[j] = cc.points[j].normalImpulse;
            s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse;
        }
        m_listener.PostSolve(c, s_impulse);
    }
}

.

0

Source: https://habr.com/ru/post/1787855/


All Articles