idmillington / cyclone-physics

The Physics engine that accompanies the book "Game Physics Engine Design"
MIT License
931 stars 262 forks source link

Question regarding calculateDesiredDeltaVelocity #62

Open redagito opened 1 year ago

redagito commented 1 year ago

Why does the calculateDesiredDeltaVelocity https://github.com/idmillington/cyclone-physics/blob/master/src/contacts.cpp#L148 only use the x component of the contact velocity for calculating the desired velocity?

Specifically this code here

    if (real_abs(contactVelocity.x) < velocityLimit)
    {
        thisRestitution = (real)0.0f;
    }

    // Combine the bounce velocity with the removed
    // acceleration velocity.
    desiredDeltaVelocity =
        -contactVelocity.x
        -thisRestitution * (contactVelocity.x - velocityFromAcc);

There is some weird behaviour where in the BigBallistics demo, where blocks sometimes seem to "absorb" shots without being moved and I suspect this is the cause.