Darthfett / A-Priori-Physics-System

A side-scroller game based upon Mega Man X, with a priori collision detection, and objects being represented as a sequence of connected points.
3 stars 0 forks source link

Player falls through ground #21

Closed Darthfett closed 12 years ago

Darthfett commented 12 years ago

When the player's velocity becomes very small (close to 0), the player seems to fall through the ground, one vertex at a time. Will need to do some investigation to find out if this is a problem with collision detection/resolution.

Darthfett commented 12 years ago

I did some debugging on this. The velocity is not becoming epsilon-small and reflecting the wrong way, as I originally thought. The velocity was somewhere in the ####e-4 range, while the epsilon is 1e-8.

Another guess as to what is happening: The point on the line is on the wrong side of the line, and the velocity is small enough to where acceleration takes it away from the line such that it doesn't collide with it again.

Darthfett commented 12 years ago

I've done some more debugging. Just before the player falls through the ground, the player's bottom is at y ~= 0, x = [10, 57].

The next collision time is 8.033252939677466e-05, at y=0.

Somehow, the next time the collision detection algorithm is called, the player has already fallen through the ground. Therefore, this collision is being ignored. The only location this can occur, is if during the collision resolution, the collision is ignored because the collision time is equal (within epsilon) of the game time.

I also believe that the game time is large to the point that game_time + 8.033252939677466e-05 == game_time (floating point error is larger at larger numbers). Therefore, the current implementation of collision resolution is the issue, and a resting-state should be used to handle this. I am going to close the issue, so that I can move on with implementing a resting-state.

Darthfett commented 12 years ago

Here is the data I used for making the last statement:

8.033252939677466e-05
[(Vector(10.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00))), [Intersection(8.033252939677466e-05, Vector(10.00, 0.00))]]
    [(Vector(10.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00))), [Intersection(8.033252939677466e-05, Vector(10.00, 0.00))]]
    [(Vector(57.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00))), [Intersection(8.033252939677466e-05, Vector(57.00, 0.00))]]
    [(Vector(57.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00))), [Intersection(8.033252939677466e-05, Vector(57.00, 0.00))]]
    [(Vector(57.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00))), [Intersection(854.4004146980183, Vector(57.00, 0.00))]]
    [(Vector(57.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00))), [Intersection(854.4004146980183, Vector(57.00, 0.00))]]
    [(Vector(10.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00))), [Intersection(854.4004146980183, Vector(10.00, 0.00))]]
    [(Vector(10.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00))), [Intersection(854.4004146980183, Vector(10.00, 0.00))]]
tried:
    (Vector(10.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(10.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))
    (Vector(57.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(57.0, 7.967966086381749e-21), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))
    (Vector(57.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(57.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))
    (Vector(10.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(10.0, 73.0), Vector(-0.0, 8.033252840490174e-06), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))

1537.9206741571575
[(Vector(57.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00))), [Intersection(1537.9206741571575, Vector(57.00, 0.00))]]
    [(Vector(57.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00))), [Intersection(1537.9206741571575, Vector(57.00, 0.00))]]
    [(Vector(10.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00))), [Intersection(1537.9206741571575, Vector(10.00, 0.00))]]
    [(Vector(10.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00))), [Intersection(1537.9206741571575, Vector(10.00, 0.00))]]
tried:
    (Vector(10.0, -73.00000000000009), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(10.0, -73.00000000000009), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))
    (Vector(57.0, -73.00000000000009), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(57.0, -73.00000000000009), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))
    (Vector(57.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(57.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))
    (Vector(10.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(500.00, 0.00), Vector(0.00, 0.00)))
    (Vector(10.0, -8.526512829121202e-14), Vector(-0.0, 153.79206741571582), Vector(0, -200), Line(Vector(0.00, 0.00), Vector(500.00, 0.00)))

This was printed out in two sections, as consecutive collision detection calls:

Each section starts with the next collision detection time, followed by the argument/intersection tuple for which that time was taken, and then lists tuples of arguments alongside the resulting intersections calculated. This list only contains calls to _parabola_line_collision_wrapper which resulted in an intersection.

Then listed beneath 'tried' is --all-- of the calls to physics._parabola_line_collision_wrapper. I have filtered these, so that you only see attempts to find intersections between the player's vertices and the ground (only the ones I know are valid).