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

Improve pfnShouldCollide condition on SV_ClipToLinks #985

Merged
merged 1 commit into from
Sep 24, 2023

Conversation

dystopm
Copy link
Contributor

@dystopm dystopm commented Sep 21, 2023

Considered a heavy function, SV_ClipToLinks is called almost every frame where things "move". Since a fix done in the pfnShouldCollide function (#46) this function can be used safely, but in the context given, it wastes a lot of checks.

pfnShouldCollide is used by mods to filter entity collision from one to another, by allowing to NOT collide (but not to force collision), but just after this is called, some basic physics stuff is called to detect collision each other, having by result an useless call of pfnShouldCollide before.

https://github.com/dreamstalker/rehlds/blob/de3679f0391f1452532c820f07a8c4042b1c4281/rehlds/engine/world.cpp#L1193-L1223

(like, checking they are far each other, why I'm checking collision on two distant entities?)

This PR moves pfnShouldCollide check after all the basic physics stuff, just to reduce function call inside plugins or submodules. There is no benefit in handling collisions in pfnShouldColide since subsequently there are conditions that will prevent their collision anyway.

@s1lentq s1lentq merged commit 5ec8c29 into rehlds:master Sep 24, 2023
4 checks passed
mlibre2 added a commit to mlibre2/rehlds that referenced this pull request Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants