public bool LoadSavedExport(UInt32 step) { if (step > _maxStep) { return(false); } if (step < _minStep) { return(false); } int index = CalculateExportIndex(step); PBodyExport2D export = bodyExports[index]; linearVelocity = export.linearVelocity; angularVelocity = export.angularVelocity; position = export.position; angle = export.angle; Parallel2D.UpdateBodyTransForm(this, position, angle); Parallel2D.UpdateBodyVelocity(this, linearVelocity, angularVelocity); return(true); }
public void SaveExport(UInt32 step) { if (step < _minStep) { _initialized = false; } if (!_initialized) { _maxStep = step; _initialized = true; _maxIndex = 0; _index = 0; } if (step == _maxStep + 1 || _index == 0) { if (_index == _exportsCapacity) { _index = 0; } PBodyExport2D export = bodyExports[_index]; export.linearVelocity = linearVelocity; export.angularVelocity = angularVelocity; export.position = position; export.angle = angle; bodyExports[_index] = export; _maxIndex = _index; _maxStep = step; if (_maxStep - _minStep >= _exportsCapacity) { _minStep = _maxStep - _exportsCapacity + 1; } _index++; } else { int index = CalculateExportIndex(step); _index = index; PBodyExport2D export = bodyExports[_index]; export.linearVelocity = linearVelocity; export.angularVelocity = angularVelocity; export.position = position; export.angle = angle; bodyExports[_index] = export; _maxIndex = _index; _maxStep = step; _index++; } }