Skip to content

Comments

Fix INFINITY checks for fast-math compatibility#262

Open
tguerin wants to merge 1 commit intoslembcke:masterfrom
tguerin:fix_infinite_loop
Open

Fix INFINITY checks for fast-math compatibility#262
tguerin wants to merge 1 commit intoslembcke:masterfrom
tguerin:fix_infinite_loop

Conversation

@tguerin
Copy link

@tguerin tguerin commented Jan 3, 2026

Problem:
The sleeping mechanism froze when enabled because -ffast-math (enabled by default in Release builds) optimizes away direct INFINITY comparisons, causing (sleepTimeThreshold != INFINITY) to always evaluate incorrectly.

Solution:
Replaced all INFINITY comparisons with isfinite()/isinf() across the codebase:

  • cpSpaceComponent.c: Fixed sleep check in cpSpaceProcessComponents
  • cpBody.c: Fixed mass and idle time checks
  • cpSpaceStep.c: Fixed collision filtering
  • cpBB.h: Fixed segment intersection check
  • ChipmunkDemo.c: Fixed kinetic energy and point query checks

Fixes #260

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.

Infinitely looping CP_BODY_FOREACH_ARBITER(body, arb) in FloodFillComponent(cpBody *root, cpBody *body)

1 participant