Skip to content

Commit

Permalink
_paramDict uses actualFrame instead of _currentFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
parkchamchi committed Jan 9, 2023
1 parent 1c9e059 commit ac8b10d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
15 changes: 8 additions & 7 deletions DEPTH/Assets/Scripts/TexInputs/ImgVidDepthTexInputs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ private void UpdateVid() {
_dmesh.SetScene(depths, _x, _y, (float) _orig_width/_orig_height, texture);

//Check if the params exist in current frame
if (_paramsDict != null && _paramsDict.ContainsKey(_currentFrame))
_dmesh.ImportParams(_paramsDict[_currentFrame]);
if (_paramsDict != null && _paramsDict.ContainsKey(actualFrame))
_dmesh.ImportParams(_paramsDict[actualFrame]);
}

public void HaltVideo() {
Expand Down Expand Up @@ -676,7 +676,7 @@ public void PausePlay() {
else {
/* Pause */
_vp.Pause();
UITextSet.StatusText.text = $"#{_currentFrame}/{_framecount}";
UITextSet.StatusText.text = $"#{_currentFrame-_startFrame}/{_framecount-_startFrame}";

if (_asyncDmodel != null && _asyncDmodel.IsAvailable &&
ImgVidDepthGOs.CallServerOnPauseToggle != null && ImgVidDepthGOs.CallServerOnPauseToggle.isOn)
Expand Down Expand Up @@ -720,20 +720,21 @@ private void ExportParams(bool overwrite=false) {
if (_paramsDict == null)
_paramsDict = new Dictionary<long, string>();

long actualFrame = _currentFrame - _startFrame;

Debug.Log($"Exporting params, #{_currentFrame}/{_framecount}");
if (_paramsDict.ContainsKey(_currentFrame)) {
Debug.Log($"Exporting params, #{actualFrame}/{_framecount-_startFrame}");
if (_paramsDict.ContainsKey(actualFrame)) {
if (overwrite) {
Debug.Log("Overwriting.");
_paramsDict.Remove(_currentFrame);
_paramsDict.Remove(actualFrame);
}
else {
Debug.LogWarning("Already exists, use `ef` to overwrite it.");
return;
}
}

_paramsDict.Add(_currentFrame, _dmesh.ExportParams());
_paramsDict.Add(actualFrame, _dmesh.ExportParams());
_paramsDictChanged = true;

if (!_canUpdateArchive)
Expand Down
11 changes: 9 additions & 2 deletions DEPTH/Assets/Scripts/Utils/DepthFileUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,15 @@ and the _archive is disposed right after this
*/
ZipArchiveMode origMode = _archiveMode;
_archiveMode = ZipArchiveMode.Update;
if (origMode != _archiveMode)
Reopen();
if (origMode != _archiveMode) {
try {
Reopen();
}
catch (System.IO.IOException) {
Debug.LogError("Couldn't save params: failed to reopen the depthfile as Write mode (is it opened by other software?)");
return;
}
}

ZipArchiveEntry paramsEntry = _archive.GetEntry(_paramsFilename);
if (paramsEntry == null)
Expand Down

0 comments on commit ac8b10d

Please sign in to comment.