-
Notifications
You must be signed in to change notification settings - Fork 309
Description
Attempting to continue a simulation using a state file when there's a motor driving rigid objects in the scene (specifically TargetPositionMotorSliderJoint in my case, but I'm guessing it's an issue for other joints) breaks the simulation, due to the driven rigid object being momentarily teleported to the start position of the object for a single tick. If fluid particles have now moved into the space where the rigid object was at time=0, then it manifests itself as some horrendous explosion of particles.
As far as I can tell, it's because when loading from a state file, the time in the SPH::TimeManager class is set correctly, but not for the PBD::TimeManager one. Having two singletons with the same name seems counterproductive, somehow!
I needed to work around it myself, so to fix it, I inserted a function called immediately after the line loading the time from the state file in SPH::SimulatorBase::loadState ("TimeManager::getCurrent()->loadState(binReader);"), which firstly, synced PBD::TimeManager::setTime with the value that SPH::TimeManager has just been loaded with, and secondly, because the joint targets are still based on the initial 0 time, run the portion of the PBD::TimeStepController::step function that updates the targets, which is almost everything after the 'update motor joint targets' comment. I'm not familiar enough with the code base to know if this is the Right Thing to do, but hopefully whoever does know this stuff can figure that out.