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

[FIX] Undefined behaviour on comparison of NaN and float at particlemgr.cpp #846

Merged

Conversation

celisej567
Copy link
Contributor

At particlemgr.cpp in class CParticleEffectBinding there is a variable named float m_flParticleCullRadius that (as i think valve expected to happen) are 0.0f -ed in constructor by calling SetParticleCullRadius(0.0f), but looks like they didnt know that if ( m_flParticleCullRadius != flMaxParticleRadius ) that happens in SetParticleCullRadius working with float NaN, which is Undefined Behaviour, and results of this thing are declared by individual compilers realization. Even differend msvc versions can handle this differendly.

As the result of the problem some particles like explosions, sparks, smoke and dust may not appear at all. There even where no drawcall at this conditions.

Hopefully it can be fixed easely, by manually 0.0f -ing m_flParticleCullRadius in constructor.

Also, it can be forced to happen every time. Just instead of m_flParticleCullRadius = 0.0f; put m_flParticleCullRadius = nanf(""); in constructor.

If you want to actually see how this looks like, ive recorded it in hl2 here. Exactly same happends in alien swarm.

Ive made same push request in mapbase and it was approved.

@BenLubar BenLubar merged commit d01357c into ReactiveDrop:reactivedrop_beta Jan 9, 2025
2 checks passed
@BenLubar
Copy link
Contributor

BenLubar commented Jan 9, 2025

Thanks!

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