jdolan / quetoo

Quetoo ("Q2") is a free first person shooter based on id Tech2. GPL v2 license.
http://quetoo.org
203 stars 28 forks source link

Player can get stuck in non-axial creases #149

Closed WickedShell closed 7 years ago

WickedShell commented 8 years ago

Encountered on windows build (july 19th)

Attatched demo shows reproducing

falling_space_and_time.zip

jdolan commented 8 years ago

CC @Panjoo

PM_DEBUG is defined to 1 in the current build, so enabling debug 1 at the console should reveal Pm_Move hints. My hunch is that you are going to see lots of:

Pm_GoodPosition: all solid at x, y, z

And, when stuck in walls or falling through floors, an occasional:

Pm_GoodPosition: still solid at x, y, z

Here's the stinker: https://github.com/jdolan/quetoo/blob/master/src/game/default/bg_pmove.c#L580

At some point last year, I decided to move to full 32 bit floating point coordinates for entity positions in the network protocol. I believe this is what Q3 does (quite certain that was my inspiration). Previously, we were using 16 bit integers to store quantized coordinates. They were "snapped" to 0.125 units, and packed into int16_t.

My gut tells me that, either through the fault of Pm_GoodPosition, or MinGW's floating point voodoo (because none of this happens on OS X or Linux -- or it's incredibly rare, if it does), full-precision floats are biting us in the ass here. I think we should approach this by first adding a quantize or "grid" back into Pm_GoodPosition. I think, in doing so, we might also fix the view "jittering" in corners.

Q3 uses a full 1.0 unit snap here, which surprises me, but obviously it works: https://github.com/ioquake/ioq3/blob/master/code/game/bg_pmove.c#L1023

If you do experiment with this, and find a fix, please remember to bump PROTOCOL_MINOR.

jdolan commented 8 years ago

Btw, one reason I would like to keep the 32 bit entity positions, if possible, is that it allows us to (theoretically) have maps that exceed +/-4096. The 16 bit coordinate packing from Quake2 overflows just beyond this point. This is why, in Quake2, if you managed to fall through the bottom of a map, you rather quickly fall right back down through the top of it. You only have to fall few thousand units before you overflow ;)

jdolan commented 8 years ago

@Panjoo Some improvements worth testing here. I think it'll be much, much harder to fall out of the map now. I found a definite hole in my logic (get it?). And hopefully you'll notice less jittering in corners, and less sticking to walls.

Panjoo commented 8 years ago

Getting stuck seems to happen a lot less now so that's good, but it's not impossible and I did get snagged briefly one or two times... BTW jittering didn't happen in corners but when moving along walls. It's not 100% gone unfortunately but definitely much better.

jdolan commented 8 years ago

Brief hangups along creases and corners, right?

Panjoo commented 8 years ago

If believe it happened one time in middle of a long wall on slimyplace, but I can't test this now because I updated with that snapshot which won't run for some reason.

jdolan commented 8 years ago

@Panjoo can you please retest the very latest build? I think we might be good here, finally.

tapir commented 8 years ago

maps.zip

Here is the bsp and map file, compiled with the latest revision quemap and the walls still stick

kaadmy commented 8 years ago

Is this issue still valid since the recent collision fix? I can't see what the demo explains because it's an older version now.

tapir commented 8 years ago

On the bsp file I provided above, it still sticks to the walls

jdolan commented 8 years ago

Yea, there are still sticky points in some rare corners (corner cases? get it??). I'll be working on this today.

kaadmy commented 8 years ago

I've also noticed on some walls you can very reliably get stuck in.

For example, the map i'm making has a wall facing left in Netradiant(I think this is -Y?). If you aim parallel to the wall facing down in Netradiant, and about 20 degrees towards to wall, you can then move backwards and left at the same time and jump, causing you to get stuck in the wall.

jdolan commented 7 years ago

A lot of work has been done here, and it's no longer possible to fall out of the map. You're also a lot less likely to get snagged anywhere. However, it's still possible to get stuck when walking along a non-axial crease, especially when crouching, or in a liquid volume.

I think what's happening here is that, with small enough frame movements (we're now at 60hz locked, so 16ms is average pmove), and small enough acceleration, a player's movement can approach a plane, but not deflect back off of it enough -- to the point where it basically rests directly on said plane. Subsequent traces or moves will then come back as start_solid, and you're stuck.

So some more things to try here are:

  1. Clamp the overbounce value to some minimum value, so that we're always deflected back off of planes.
  2. Add the plane normal to the velocity (similar idea, but maybe simpler).
  3. Give up, start drinking.
tapir commented 7 years ago

Yeap it doesn't get stuck to the wall anymore but I've noticed that climbing up stairs are not so smooth now. I can see jitters. Might be related to this one.

tapir commented 7 years ago

Oh NVM I've seen #251

jdolan commented 7 years ago

👍 Thanks @tapir. So we're on the right track.. ;)