You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes the game freezes because it is stuck in an endless loop in physics code.
Steps to reproduce
Pick up a "storable" object like a pistol or keycard.
Store the object in your inventory.
Move so that you stand directly in front of a wall (doors work too)
Keep storing and retrieving the object in such a way that the hand or the object touch the wall.
Personally I use the pistols in the security entrance at the beginning of the Industrial Town level for testing this.
The bug only rarely occurs in Debug builds, but is easy to reproduce in Release builds.
The cause
The problem is caused by two loops in physics code that are supposed to normalize vectors. The code is almost the same for both. Those loops are Pelvis.cpp lines 1162 to 1187 and Xob_bc.cpp lines 3738 to 3763.
The loop is supposed to end when a float variable L becomes smaller than a certain threshold. However, the comparison does not work anymore when L becomes NaN. This happens because it was calculated from the vector entries, which are all NaN as well. Current research has shown that they were already NaN before the loop. Why this happens needs to be investigated.
Solution approaches
Ending the loop when L becomes NaN prevents the game from freezing. But the vector is still full of NaNs and new problems occur immediately:
The player cannot jump anymore
When moving, there are very frequent little jumps. Sometimes the player can barely move at all
The arm cannot be used anymore
In summary, the game is left in an unplayable state.
An alternative approach is to do the bailout described above, but also set the vector that was supposed to be normalized to a valid default value. That default value needs yet to be determined. After a first test with a quad-0.25 vector, various physics glitches with held items occur, but the game remains playable.
The best solution is to find out why the vector became NaN in the first place.
The text was updated successfully, but these errors were encountered:
Sometimes the game freezes because it is stuck in an endless loop in physics code.
Steps to reproduce
Personally I use the pistols in the security entrance at the beginning of the Industrial Town level for testing this.
The bug only rarely occurs in
Debug
builds, but is easy to reproduce inRelease
builds.The cause
The problem is caused by two loops in physics code that are supposed to normalize vectors. The code is almost the same for both. Those loops are
Pelvis.cpp
lines 1162 to 1187 andXob_bc.cpp
lines 3738 to 3763.The loop is supposed to end when a
float
variableL
becomes smaller than a certain threshold. However, the comparison does not work anymore whenL
becomesNaN
. This happens because it was calculated from the vector entries, which are allNaN
as well. Current research has shown that they were alreadyNaN
before the loop. Why this happens needs to be investigated.Solution approaches
Ending the loop when
L
becomesNaN
prevents the game from freezing. But the vector is still full ofNaNs
and new problems occur immediately:An alternative approach is to do the bailout described above, but also set the vector that was supposed to be normalized to a valid default value. That default value needs yet to be determined. After a first test with a quad-0.25 vector, various physics glitches with held items occur, but the game remains playable.
The best solution is to find out why the vector became
NaN
in the first place.The text was updated successfully, but these errors were encountered: