Page MenuHome

BGE: Fix T33722 : non sleeping static moved object.
AbandonedPublic

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

Details

Summary

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 : http://www.pasteall.org/blend/35998
Press "Q" to rotate, "A" to play a scale action, and right arrow to move.

Diff Detail

Repository
rB Blender
Branch
ge_static_sleeping_bug

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?

source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
127

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

1166

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

1508

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.

source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
127

Finaly it's useless to force activation

1166

it's just a safety check like every where.

1508

okay

Porteries Tristan (panzergame) edited edge metadata.

remove force argument in activation, fix comment typo

source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
1166

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?

source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
1507–1512

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?

source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
1507–1512

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.

source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
727

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.
source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
1507–1512

What is "inamatic"?

1510

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.

1511

"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...