When dynamic RigidBodyControl is re-enabled it falls only thru static ones, but

How I simulate it here

On my project, that I have made so many things already, when:

I disable physics for one dynamic object with

RigidBodyControl.setEnabled(false)

and a bit later I re-enable it with

RigidBodyControl.setEnabled(true)

it falls thru static RigidBodyControl ones (like the terrain).
but… it still collides properly with dynamic ones!

if I disable and re-enable it again, it will work properly again (collide with terrain); and if I do it again, the bug happens again, so it alternates…

Tracking

I checked its collision group and collision mask and both are 1.

I was thinking on dumping the complete RigidBodyControl object data values (including super classes and everything that is linked to it), and compare with its bugged state, but it was all identical on the simple dump I checked; may be I can do it with some reflection…

I am still trying to find what I could have setup in that object that could be causing the bug? any clue what I should look for?

Test case

I tried to create a test case but the problem will not happen on it (I can post it but it is pointless right now). May be if I get a copy of my project and go stripping down everything to a minimum, I can prepare it. If I cant prepare a demo test case in a short time I will try to post a video.

Workaround

I am still having some issues but if I remove the RigidBodyControl from spatial and from bullet, and create a fresh new (instead of re-enabling the old one), the problem will not happen (of course I guess).

[quote=“teique, post:1, topic:31672, full:true”]
I tried to create a test case but the problem will not happen on it (I can post it but it is pointless right now). May be if I [/quote]

Then the problem is most probably in your code.
Maybe you have other controls (collision listeners?) moving the body even though the rigidbody is disabled? So when you enable the rigid body it is in an illegal starting state (e.g. inside some other body) that bullet physics does not know how to handle.

Maybe you create a body with mass but with a mesh collision shape (which is invalid) and when you re-enable it the auto-generation of a hull shape sets in based on the given mass?

I protected the getters of RigidBodyControl to throw exception in case it is disabled, and found many places that I was applying physics changes while it was disabled!!! like in the very moment it is created (had to queue the changes);

that must be it…
there must have some of your guesses out there somewhere, thanks :slight_smile:

too many places,
cant confirm yet as I am still fixing the code, but is probably it, I put the engine in an inconsistent state;

I wonder if protecting the engine with ‘enabled checks’ could cause any encumberance?