Unverified Commit 6ba168cd authored by Peter Eastman's avatar Peter Eastman Committed by GitHub
Browse files

reinitialize() remembers whether positions have been set (#4501)

parent daab6862
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Biological Structures at Stanford, funded under the NIH Roadmap for * * Biological Structures at Stanford, funded under the NIH Roadmap for *
* Medical Research, grant U54 GM072970. See https://simtk.org. * * Medical Research, grant U54 GM072970. See https://simtk.org. *
* * * *
* Portions copyright (c) 2008-2016 Stanford University and the Authors. * * Portions copyright (c) 2008-2024 Stanford University and the Authors. *
* Authors: Peter Eastman * * Authors: Peter Eastman *
* Contributors: * * Contributors: *
* * * *
...@@ -252,12 +252,15 @@ void Context::reinitialize(bool preserveState) { ...@@ -252,12 +252,15 @@ void Context::reinitialize(bool preserveState) {
stringstream checkpoint(ios_base::out | ios_base::in | ios_base::binary); stringstream checkpoint(ios_base::out | ios_base::in | ios_base::binary);
if (preserveState) if (preserveState)
createCheckpoint(checkpoint); createCheckpoint(checkpoint);
bool hasSetPositions = impl->hasSetPositions;
integrator.cleanup(); integrator.cleanup();
delete impl; delete impl;
impl = new ContextImpl(*this, system, integrator, &platform, properties); impl = new ContextImpl(*this, system, integrator, &platform, properties);
impl->initialize(); impl->initialize();
if (preserveState) if (preserveState) {
loadCheckpoint(checkpoint); loadCheckpoint(checkpoint);
impl->hasSetPositions = hasSetPositions;
}
} }
void Context::createCheckpoint(ostream& stream) { void Context::createCheckpoint(ostream& stream) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment