1
\$\begingroup\$

I am currently doing OBB vs. OBB/Triangle collision resolution. I know that the penetration vectors I am getting are correct.

I currently resolve the penetration vectors by subtracting them from the object's velocity and then moving that object along the new velocity. This works perfectly for a single penetration vector; however, an object can end up clipping through objects if there are two penetration vectors that are pointing in different directions along a certain axis.

Pseudocode for my current multiple-penetration-vector resolution:

Vector finalPenetrationVector = new Vector(0, 0, 0);
for(int i = 0; i < penetrationVectors.size(); i++) {
    Vector v = penetrationVectors.get(i);

    if(finalPenetrationVector.x >= 0 && v.x >= 0) finalPenetrationVector.x = /*The larger of the two.*/;
    else if(finalPenetrationVector.x <= 0 && v.x <= 0) finalPenetrationVector.x = /*The smaller of the two.*/;
    else finalPenetrationVector.x = /*Both setting it to zero and adding them together yields clipping through one of the surfaces.*/;

    /*Repeat for the y-axis and the z-axis.*/
}

Is there a method of resolving these penetration vectors without having to switch to a force-based system or something like that? Note that I do want the entity to "slide" across the sliding plane like they do in most commercial games.

\$\endgroup\$
0
\$\begingroup\$

I got it to work well enough by simply stopping the entity at the point of collision in this case. I do forego the sliding effect, but the player can easily resolve it and I do get sliding otherwise.

I can't accept this answer for another 22 hours, so if someone knows a better way, please let me know.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.