Page MenuHome

BGE: Fix T33722 : non sleeping static moved object.

Authored by Porteries Tristan (panzergame) on May 10 2015, 7:46 PM.



Little fix for T33722.
Currently static objects are activated during movements.
Also the UpdateDeactivation is now used to unset the kinematic flag and to set sleep flag to the rigid body.

demo file :
Press "Q" to rotate, "A" to play a scale action, and right arrow to move.

Diff Detail

rB Blender

Event Timeline

Porteries Tristan (panzergame) retitled this revision from BGE: non sleeping static added object. to BGE: Fix T33722 : non sleeping static added object..May 10 2015, 7:52 PM
Porteries Tristan (panzergame) updated this object.

Remove useless function ActivateCollideWithCcdPhysicsController.

Thomas Szepe (hg1) edited edge metadata.

Looks OK for me.

This revision is now accepted and ready to land.May 11 2015, 8:10 PM

Overall, some of the changes seem a little arbitrary and not well explained. However, this isn't an area of Bullet I'm familiar with. Maybe @Sergej Reich (sergof) can provide further comments?


Didn't one of your other patches change this from true to false?


Can m_object be NULL? If so, how does this change behavior?


It would be better to keep this comment to one line since it isn't a doc string. I'd also prefer to see C++ style comments used here to keep things consistent with the rest of the file.


Finaly it's useless to force activation


it's just a safety check like every where.



Porteries Tristan (panzergame) edited edge metadata.

remove force argument in activation, fix comment typo


If we never expect m_object to be NULL, maybe we'd be better off with an assertion? Does it even make sense to have a NULL m_object?


This seems like it might be a different issue than the one in the original bug report. Also, should "inamatic" should be "kinematic"? Is it okay to always disable this flag every frame? Do we notice any sort of performance regression with a lot of physics objects since we now call this every frame?


We disable this falg only if it exist (isKinematicObject) and this operation it a simple test, so no problems with performance.

I'm very suspicious about clearing the kinematic flag.
I'm not familiar with how the game engine handles this exactly, but it should be possible to handle these flags when objects are added/modified.
If kinematic objects don't sleep, then there's probably a flag not being set correctly somewhere when it's added.


This souldn't be done here.
If activation needs to be updated, then a state change happened somewhere. That's also where the update should happen.

sergof : kinematic rigid body sleep correctly but don't use friction and the only way to move a static object is to use it as kinematic.
So when the rigid body move we set temporary kinematic flag to move it properly and in the next frame we remove the kinematic flag to use properly the friction.
You can try with comment line 1530, replace "isKinematicObject" by "isStaticObject" in the check and play the demo file.

Porteries Tristan (panzergame) retitled this revision from BGE: Fix T33722 : non sleeping static added object. to BGE: Fix T33722 : non sleeping static moved object..May 13 2015, 6:49 PM

After talking with @Porteries Tristan (panzergame) on IRC, I know have a clearer idea what what he is attempting to do. The underlying problem here is that changing the transform (position, rotation, etc.) of a static physics object causes it to not sleep. This affects added objects because set we their position. Setting this CF_KINEMATIC_OBJECT flag when updating the transform state is preventing these objects from sleeping. I don't know if this is how Bullet operates or if we are screwing something else up in the BGE. I am also not sure if we should even be setting this flag.

Hopefully this makes things clearer @Sergej Reich (sergof).

Porteries Tristan (panzergame) marked an inline comment as done.Jul 1 2015, 1:38 PM

Tested with more than 1 substep : all works.

Sybren A. Stüvel (sybren) requested changes to this revision.Jul 1 2015, 2:02 PM
Sybren A. Stüvel (sybren) edited edge metadata.
Sybren A. Stüvel (sybren) added inline comments.

What is "inamatic"?


Comments should not describe what is done, but describe why something is done. In this case, the code enables the CF_KINEMATIC_OBJECT flag, whereas the comment says that it is disabled. When another developer looks at it, he/she can no longer discern which one is correct.


"desactivate" → "deactivate"

This revision now requires changes to proceed.Jul 1 2015, 2:02 PM

It's no more working, i can't find a solution...