Improve pfnShouldCollide condition on SV_ClipToLinks #985
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.