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

LocalPlayer: Fix sneaking on nodes with large collisionboxes #12626

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

SmallJoker
Copy link
Member

Fixes #12612 by taking the nodebox extent center into account.

To do

This PR is Ready for Review.

How to test

  1. Example node from Broken movement if you sneak on collision box that lies entirely in another node #12612
  2. Enable sneak_glitch (there's a mod for it) to ensure the ladder still work
  3. Optimal test setup:
    screenshot_20220801_123133

bool LocalPlayer::updateSneakNode(Map *map, const v3f &position,
const v3f &sneak_max)
{
// Acceptable distance to node center
constexpr f32 allowed_range = (0.5f + 0.1f) * BS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems pretty hardcoded and arbitrary to me

Copy link
Member Author

@SmallJoker SmallJoker Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could've as well changed nothing and nobody would ever notice or complain.

It's good as is and should be kept like that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would at least annotate this as a hack. The "allowed range" should be based on nodebox extent.

Copy link
Member

@sfan5 sfan5 Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting it to nodebox extent = no range checking = the bug seen in OP issue

at least with the current code structure

Copy link
Contributor

@TurkeyMcMac TurkeyMcMac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still notice some issues when sneaking on the janky nodes:

  1. When sneaking onto a janky node whose plane is vertical, my point of view sometimes gets snapped into a different position, suddenly moving horizontally.
  2. When I am on a janky node whose plane is horizontal and I start sneaking then walk off the edge, nothing stops my movement.

These things occur with or without the sneak glitch enabled.

src/client/localplayer.cpp Outdated Show resolved Hide resolved
@SmallJoker
Copy link
Member Author

SmallJoker commented Oct 12, 2022

@TurkeyMcMac Could you please provide an image of what nodes you tested? Preferably with testing code, if it is different to what's already provided in the issue. Is this a regression or behaviour that already exists in master?

@TurkeyMcMac
Copy link
Contributor

Setup for issue 1:
screenshot_20221012_153814

Setup for issue 2:
screenshot_20221012_153844

Issue 1 seems to be new with this PR, while issue 2 also occurs on master.

@SmallJoker
Copy link
Member Author

SmallJoker commented Oct 15, 2022

The fix for the first issue is to use the distance between the player and node collision box (using the nearest manhattan point). Currently I am using the center point of each the nodeboxes for simplcity. However I cannot think of a trivial implementation to fix this issue, as it would also have to be repeated for each node in range, making the code slower than it already is.

As of issue 2, I don't think I will address it in this PR and delay for later.

@TurkeyMcMac
Copy link
Contributor

Alright, it's good to have this fix anyway.

@TurkeyMcMac TurkeyMcMac merged commit 5d8a491 into minetest:master Oct 17, 2022
@lhofhansl
Copy link
Contributor

lhofhansl commented Oct 18, 2022

This seems to break auto-jump.

Never mind. I'm an idiot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken movement if you sneak on collision box that lies entirely in another node
5 participants