Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box vs Box SAT Check #39

Open
rahul-meda opened this issue Jan 19, 2016 · 2 comments
Open

Box vs Box SAT Check #39

rahul-meda opened this issue Jan 19, 2016 · 2 comments

Comments

@rahul-meda
Copy link

For calculating the projection of Box on to an axis, I tried this method that I found in
cyclone/src/collide_fine.cpp

static inline real transformToAxis(
    const CollisionBox &box,
    const Vector3 &axis
    )
{
    return
        box.halfSize.x * real_abs(axis * box.getAxis(0)) +
        box.halfSize.y * real_abs(axis * box.getAxis(1)) +
        box.halfSize.z * real_abs(axis * box.getAxis(2));
}

But it is not giving me correct results.

I made a small modification by taking absolute values of axis and box axis,
and that gives me correct results.

Can some one please verify this? I am not sure if I am doing something wrong elsewhere in my code.

@lch32111
Copy link

lch32111 commented Nov 3, 2018

I recommend you to read the Real-Time Collision Detection Book, the collision detection of cyclone code is based on the book.

you will find the related information on the AABB, OBB intersection tests.

@qwiff-dogg
Copy link

This may be related to this isssue.

The only problem I'm seeing (so far) with the BOX SAT is that it fails when the axes being compared are exactly parallel.

The comparison happens here:

https://github.com/idmillington/cyclone-physics/blob/master/src/collide_fine.cpp#L111-L119
and
https://github.com/idmillington/cyclone-physics/blob/master/src/collide_fine.cpp#L80-L84

If the two boxes are oriented on the same plane (e.g. the ground), their X, Y and Z-axis will be parallel and the resulting cross product will be 0.

I've worked around this changing the overlap comparison from < to <=

return (distance <= oneProject + twoProject);

This covers the case where distance is exactly 0 due to axis being a 0-vector. Obviously with this modification the SAT now succeeds in the rare case where the axis projections are exactly adjacent and not overlapping, but I find this to be an acceptable compromise for my own engine. YMMV.

Finally, note that the box intersection test is commented out in the contact generation code:
https://github.com/idmillington/cyclone-physics/blob/master/src/collide_fine.cpp#L415

Not sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants