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

Collisions issue fix #11

Open
motorsep opened this issue Aug 16, 2015 · 14 comments
Open

Collisions issue fix #11

motorsep opened this issue Aug 16, 2015 · 14 comments

Comments

@motorsep
Copy link

So, finally there is a breakthrough with collisions ( here is the test case https://drive.google.com/open?id=0BwE6dxM0O2PsQUNncWw0aGFuZms ):

http://www.pasteall.org/60504/diff

not mine, but I tested and it works. The only issue that is left is anim stuttering: https://www.youtube.com/watch?v=q-4Z7CTYodk

@BielBdeLuna
Copy link
Member

what was the problem originally?

@motorsep
Copy link
Author

You would get stuck on the edge. I provided a test case, so you could just try it and see what it does :)

https://www.youtube.com/watch?v=sE_A6awytSE

@BielBdeLuna
Copy link
Member

ok, this is for changing slopes? seems pretty interesting!

@motorsep
Copy link
Author

I could happen anywhere (I haven't tested flat floors made of models, only terrains, and that piece is a part of the terrain, replicated as brushes)

@BielBdeLuna
Copy link
Member

yes, it happens a lot in that map! I had never found a bug like this!, let's add this to the code!

who is the author of the diff?

the stuttering seems to happen anyway with the bug anyway, so solving the bug doesn't introduce the stuttering in the animation.

@motorsep
Copy link
Author

"NagaHuntress" is who fixed it.

I have never checked third person view with that bug, so I did know :/ I wonder now how to fix stuttering now.

@BielBdeLuna
Copy link
Member

is there a discussion about this somewhere? who is NagaHuntress?

@BielBdeLuna
Copy link
Member

in case pasteall deletes it, here is the diff:

Index: cm/CollisionModel_translate.cpp
===================================================================
--- cm/CollisionModel_translate.cpp (revision 6527)
+++ cm/CollisionModel_translate.cpp (working copy)
@@ -294,11 +294,25 @@
            // FIXME: do this normalize when we know the first collision
            tw->trace.c.normal.Normalize();
            tw->trace.c.dist = tw->trace.c.normal * start;
+#if 0
            // make sure the collision plane faces the trace model
            if ( tw->trace.c.normal * trmEdge->start - tw->trace.c.dist < 0.0f ) {
                tw->trace.c.normal = -tw->trace.c.normal;
                tw->trace.c.dist = -tw->trace.c.dist;
            }
+#elif 1
+           // make sure the collision plane faces the direction of the trace
+           if ( tw->trace.c.normal * -tw->dir < 0.0f ) {
+               tw->trace.c.normal = -tw->trace.c.normal;
+               tw->trace.c.dist = -tw->trace.c.dist;
+           }
+#elif 0
+           // make sure the collision plane faces the same way as the polygon plane
+           if ( tw->trace.c.normal * poly->plane.Normal() < 0.0f ) {
+               tw->trace.c.normal = -tw->trace.c.normal;
+               tw->trace.c.dist = -tw->trace.c.dist;
+           }
+#endif
            tw->trace.c.contents = poly->contents;
            tw->trace.c.material = poly->material;
            tw->trace.c.type = CONTACT_EDGE;

@BielBdeLuna
Copy link
Member

@motorsep i bet the stuttering is only in the animation script, the model for a moment thinks he is falling or her is not walking (maybe for a single frame) and so he stutters,

when the player is trapped there, he can't jump, maybe he thinks he is falling (you can't jump when not ON_GROUND, and I think it's the only time he can't jump) maybe c++ can't jump but c++ is reporting ON_GROUND anyway, therefore we don't see he is falling and the animation it's not corresponding to the c++ state? maybe this is another error not directly related to the collision error?

the stuttering is not related to IK, because I disabled IK with "ik_enable 0" and the stuttering continues.

@DanielGibson
Copy link
Member

You would get stuck on the edge. I provided a test case, so you could just try it and see what it does :)

Yeah right "you" provided a testcase. I recreated the buggy part of your terrain mesh in brushes back then to get this minimal testcase.

Back when we first debugged this issue, treb proposed a patch to do q3 style collision detection there which gave the same results (you don't get stuck anymore on that edge, but it stutters a bit).
For some reason you (motorsep) didn't want it.

Unfortunetely I think that fix got lost with doom3world

@DanielGibson
Copy link
Member

I just found trebs patch for dhewm3:

--------------------- neo/game/physics/Physics_Player.cpp ---------------------
index af1a764..9ab46a8 100644
@@ -971,6 +971,9 @@ void idPhysics_Player::CheckGround( void ) {
    EvaluateContacts();

    // setup a ground trace from the contacts
+   gameLocal.clip.Translation( groundTrace, current.origin, current.origin +
+                gravityNormal * CONTACT_EPSILON, clipModel, clipModel->GetAxis(), -1, self );
+   /*
    groundTrace.endpos = current.origin;
    groundTrace.endAxis = clipModel->GetAxis();
    if ( contacts.Num() ) {
@@ -983,6 +986,7 @@ void idPhysics_Player::CheckGround( void ) {
    } else {
        groundTrace.fraction = 1.0f;
    }
+   */

    contents = gameLocal.clip.Contents( current.origin, clipModel, clipModel->GetAxis(), -1, self );
    if ( contents & MASK_SOLID ) {

@BielBdeLuna
Copy link
Member

which one should we apply?

I'll copy Trebs solution to the issue...

@motorsep
Copy link
Author

@DanielGibson Just wow. "I provided" means I posted it here for you, people. You made the test case from the map I made, sure. Sorry if I didn't put copyright note here.

Trebor's fix might be as well as good, but it's for player only. The new fix addresses the issue in the collisions code, meaning it is potentially a fix for NPC and AI (although I never tested them on that ledge).

Btw, I think animation jerking got the fix coming too.

@BielBdeLuna
Copy link
Member

Motorsep, is there a forum or some web-page where this is discussed, maybe where NagaHuntress is? where did you get that fix from?

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