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

HUD: Update selection mesh every frame #12270

Merged
merged 2 commits into from
May 9, 2022

Conversation

appgurueu
Copy link
Contributor

@appgurueu appgurueu commented May 4, 2022

Fixes #11904, most likely also fixes #3873

Minetest incorrectly made the assumption that the selectionbox doesn't change when the pointed thing doesn't change, which doesn't hold in the case of entities (which may have their properties changed) and nodes (which may have their neighborhood changed).

This PR fixes this by always updating the selection mesh. The performance impact is presumably negligible; worst-case performance (pointed thing constantly changing) hasn't changed at all. Only updating the selection mesh when it has changed would require way more code complexity and probably be less efficient.

@rubenwardy
Copy link
Member

Could this also fix #3873 ?

@appgurueu
Copy link
Contributor Author

appgurueu commented May 4, 2022

Could this also fix #3873 ?

Unless updateSelectionMesh is broken it definitely should. Looking at the code that handles comparison of pointed things, I'm very surprised that this code worked in the first place:

bool PointedThing::operator==(const PointedThing &pt2) const
{
	if (type != pt2.type)
	{
		return false;
	}
	if (type == POINTEDTHING_NODE)
	{
		if ((node_undersurface != pt2.node_undersurface)
				|| (node_abovesurface != pt2.node_abovesurface)
				|| (node_real_undersurface != pt2.node_real_undersurface))
			return false;
	}
	else if (type == POINTEDTHING_OBJECT)
	{
		if (object_id != pt2.object_id)
			return false;
	}
	return true;
}

for nodes it only compares position and direction, for objects only object ID. I assume that worked for doors in most of the cases because flipping a door is very likely to make you either (1) point another face of the door or (2) point another node.

For logging it's probably fine, although it shouldn't check direction there IMO (another log line just because you pointed another face seems odd to me).

@Zughy Zughy added Bugfix 🐛 PRs that fix a bug @ Client rendering labels May 4, 2022
Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

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

No noticeable "Draw scene" or "drawtime" increase. Works as expected.

@SmallJoker SmallJoker merged commit c2898f5 into minetest:master May 9, 2022
@appgurueu appgurueu deleted the fix-selectionbox-display branch May 10, 2022 13:10
sfan5 pushed a commit that referenced this pull request May 12, 2022
Fixes outdated selection boxes after entity property changes.
sfan5 pushed a commit that referenced this pull request May 12, 2022
Fixes outdated selection boxes after entity property changes.
sfan5 pushed a commit that referenced this pull request May 14, 2022
Fixes outdated selection boxes after entity property changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants