OpenTechEngine / OpenTechBFG

Engine based on (RB) Doom 3 BFG aiming to allow the creation of standalone games
Other
85 stars 11 forks source link

Collision issue #76

Open BielBdeLuna opened 9 years ago

BielBdeLuna commented 9 years ago

@Motorsep dicussed it here: https://github.com/OpenTechEngine/Discussions/issues/11

Apparently user "NagaHuntress" (from some community) fixed it with this 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;
DanielGibson commented 9 years ago

the original fix from treb:

--------------------- 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 ) {

not sure which one should be applied, maybe the bug should be re-investigated before that. But at least we now have two possible fixes in the bugtracker :-)

BielBdeLuna commented 9 years ago

ok

BielBdeLuna commented 9 years ago

maybe NagaHuntress resolves this issues for all "collision models" while Treb's only solves it for players?

the thing is, is it a bug in the collision model system or is it a bug for the player specific collision model?

DanielGibson commented 9 years ago

maybe someone should investigate, if this bug affects non-players (because I don't know.)

BielBdeLuna commented 9 years ago

I've seen that normally when getting into noclip the position of the player never changed only the model stance, but never the position, but when getting stuck in the terrain, when getting into noclip (by pressing only and only only the "n" key (bound to noclip)) the player seems to move down a little bit, like if there where a force pulling him down (and I'm not crouching or moving at all)

then I've also spawned some monster_zsec_machineguners, and they don't seem to be stuck on any edge.

BielBdeLuna commented 9 years ago

maybe even it's a two part problem, in the collision system but also in the player collision model?