diff --git a/src/simulation/Gravity.cpp b/src/simulation/Gravity.cpp index 2ad2ea3f01..e032b9f89a 100755 --- a/src/simulation/Gravity.cpp +++ b/src/simulation/Gravity.cpp @@ -31,6 +31,7 @@ void Gravity::bilinear_interpolation(float *src, float *dst, int sw, int sh, int } } +bool ignoreNextResult = false; void Gravity::Clear() { std::fill(gravy, gravy+((XRES/CELL)*(YRES/CELL)), 0.0f); @@ -38,6 +39,8 @@ void Gravity::Clear() std::fill(gravp, gravp+((XRES/CELL)*(YRES/CELL)), 0.0f); std::fill(gravmap, gravmap+((XRES/CELL)*(YRES/CELL)), 0.0f); std::fill(gravmask, gravmask+((XRES/CELL)*(YRES/CELL)), 0xFFFFFFFF); + + ignoreNextResult = true; } void Gravity::gravity_init() @@ -90,7 +93,7 @@ void Gravity::gravity_update_async() //Switch the full size gravmaps, we don't really need the two above any more float *tmpf; - if(th_gravchanged) + if (th_gravchanged && !ignoreNextResult) { #if !defined(GRAVFFT) && defined(GRAV_DIFF) memcpy(gravy, th_gravy, (XRES/CELL)*(YRES/CELL)*sizeof(float)); @@ -110,6 +113,7 @@ void Gravity::gravity_update_async() th_gravp = tmpf; #endif } + ignoreNextResult = false; tmpf = gravmap; gravmap = th_gravmap; diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 2b7f1a1dfb..285a913194 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -517,6 +517,7 @@ void Simulation::Restore(const Snapshot & snap) std::copy(snap.WirelessData.begin(), snap.WirelessData.end(), &wireless[0][0]); if (grav->ngrav_enable) { + grav->Clear(); std::copy(snap.GravVelocityX.begin(), snap.GravVelocityX.end(), gravx); std::copy(snap.GravVelocityY.begin(), snap.GravVelocityY.end(), gravy); std::copy(snap.GravValue.begin(), snap.GravValue.end(), gravp);