SuperTux / supertux

SuperTux source code
https://supertux.org
GNU General Public License v3.0
2.54k stars 492 forks source link

[Bug]: Big rocks push small rocks through the floor #3105

Open weluvgoatz opened 2 days ago

weluvgoatz commented 2 days ago

SuperTux Version

SuperTux Latest Nightly

System Information

Windows 10 64-bit

Expected Behavior

When big rocks are stacked on top of smaller rocks, they should not push the smaller rocks through the floor.

Actual Behavior

When big rocks are stacked on top of smaller rocks, they push the smaller rocks through the floor.

Steps To Reproduce Actual Behavior

Take a big rock and place it on top of a smaller rock.

Additional Information

This is probably a result of the MovingStatic collision changes I made earlier this spring, so it might be worthy to add a check to not let bigger movingstatics push smaller movingstatics through movingstatics that are larger than the small one, or normal statics.

Guidelines For Reporting Issues

swagtoy commented 1 day ago

I believe there is quite a bit of jank with the physics engine right now. I can confirm similar bugs occurring with many enemies i.e. Collisions do not behave well and clipping behavior in Supertux is absurdly aggressive. This bug may be independent of these things, however. Regardless, this issue does go further down the line. I will analyze a tiny bit:

A quick look at src/collision/collision_system.cpp shows that there is a forgiveness variable, and the following logic using that variable should make sense really. However, in all honesty, this forgiveness is a bit of a "hack".

static const float FORGIVENESS = 256.f; // 16.f * 16.f - half a tile by half a tile.

Why is this a hack? Well, because it just is. Once the forgiveness becomes unforgivable, then we just.. kind of warp the player through the floor. That's at least specifically why this happens.

Now, surprisingly, your issue has nothing to do with this particular instance, however, it would honestly be nice if the collision system could more appropriately handle this mishapping behavior. In fact, it could entirely prevent issues like this to begin with if we changed the way "forgiveness" worked, i.e. pushing objects back up based on the reverse of their direction, or rather, the closest surface as well as factoring the latter position (what a mouthful!). It seems the game just likes to clip crap through the floor, such a bummer on that.

The collision system for objects likely doesn't communicate well with other objects. And honestly, that's somewhat okay, it's pretty difficult to properly handle collision like this. But with stacks on stacks of enemies, this is more noticeable. Enemies that I believe try to "fall" can end up kind of pushing each other down (?). I have not checked this code in particular simply because I am lazy.

I'm going to boldly assume this code is related. It looks a bit like a cheesy hack that just slows down collision with things collision. Falling might be related, or rather, anything that pushes itself down, might be causing this kind of behavior. Some enemies, I believe can actually stack correctly, however their walking velocity (correctly) accelerates along with things, which I always found funny (that should be a feature one day? :-)

tldr This is a bug dammit. But, its a little deeper than that, because it's kind of a flaw stacked on a bug, so I felt like talking about the aforementioned bug, just so it doesn't go unnoticed here. :D