Skip to content

Commit

Permalink
Fixed two crashes.
Browse files Browse the repository at this point in the history
Added support for IOOptions.

Added USD interactive update.
  • Loading branch information
ggarra13 committed Oct 12, 2023
1 parent d69ac47 commit 5a4525c
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 141 deletions.
10 changes: 9 additions & 1 deletion mrv2/docs/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ v0.8.0
- Fixed reading of OCIO file name in network connections.
- Color channels (layers) are now kept with the file so that switching between
media will not revert to the rgba channel if there isn't an equivalent one.

- USD Panel is now interactive. You can change the parameters and it will
show the change. The only parameter not recommended to change (except for
very simple scenes) is the complexity.
- USD Panel visibility is now saved in the Preferences.
- Refreshing of cache is now done in seconds, without re-loading and
switching an image as before.
- Creating a timeline in the Playlist Panel is also done in seconds.
- Fixed a crash when creating an empty timeline or a timeline from a clip in
the Playlist Panel.

v0.7.9
======
Expand Down
1 change: 1 addition & 0 deletions mrv2/lib/mrvApp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(HEADERS
mrvPlaylistsModel.cpp
mrvSettingsObject.cpp
mrvUSD.cpp
mrvUSDInline.cpp
)

add_library(mrvApp ${SOURCES} ${HEADERS})
Expand Down
42 changes: 39 additions & 3 deletions mrv2/lib/mrvApp/mrvUSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

#ifdef TLRENDER_USD

# include "mrvApp/mrvUSD.h"
# include <tlCore/StringFormat.h>

# include "mrvPanels/mrvPanelsCallbacks.h"

# include "mrvApp/mrvSettingsObject.h"
# include "mrvApp/mrvUSD.h"
# include "mrvApp/App.h"

# include "mrViewer.h"

namespace mrv
{
namespace usd
Expand All @@ -34,20 +37,53 @@ namespace mrv
return o;
}

bool setRenderOptions(const RenderOptions& o)
void sendIOOptions()
{
auto player = App::ui->uiView->getTimelinePlayer();
if (!player)
return;

auto o = renderOptions();

io::Options ioOptions;
ioOptions["USD/renderWidth"] =
string::Format("{0}").arg(o.renderWidth);
ioOptions["USD/complexity"] =
string::Format("{0}").arg(o.complexity);
{
std::stringstream ss;
ss << o.drawMode;
ioOptions["USD/drawMode"] = ss.str();
}
ioOptions["USD/enableLighting"] =
string::Format("{0}").arg(o.enableLighting);
ioOptions["USD/stageCacheCount"] =
string::Format("{0}").arg(o.stageCache);
ioOptions["USD/diskCacheByteCount"] =
string::Format("{0}").arg(o.diskCache);

player->setIOOptions(ioOptions);
}

void setRenderOptions(const RenderOptions& o)
{
auto settingsObject = App::app->settingsObject();
if (o == renderOptions())
return;

settingsObject->setValue("USD/renderWidth", o.renderWidth);
settingsObject->setValue("USD/complexity", o.complexity);
settingsObject->setValue("USD/drawMode", o.drawMode);
settingsObject->setValue("USD/enableLighting", o.enableLighting);
settingsObject->setValue("USD/stageCache", o.stageCache);
settingsObject->setValue("USD/diskCache", o.diskCache);

sendIOOptions();

if (usdPanel)
usdPanel->refresh();
return true;
}

} // namespace usd
} // namespace mrv

Expand Down
10 changes: 9 additions & 1 deletion mrv2/lib/mrvApp/mrvUSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// mrv2
// Copyright Contributors to the mrv2 Project. All rights reserved.

#pragma once

#ifdef TLRENDER_USD

# include <tlIO/USD.h>
Expand All @@ -18,13 +20,19 @@ namespace mrv
bool enableLighting = true;
size_t stageCache = 10;
size_t diskCache = 0;

bool operator==(const RenderOptions& b) const;
bool operator!=(const RenderOptions& b) const;
};

//! Return the current USD Render Options
RenderOptions renderOptions();

//! Set the current USD Render Options
bool setRenderOptions(const RenderOptions& o);
void setRenderOptions(const RenderOptions& o);

//! Set the current USD Render Options
void sendIOOptions();
} // namespace usd
} // namespace mrv

Expand Down
25 changes: 25 additions & 0 deletions mrv2/lib/mrvApp/mrvUSDInline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: BSD-3-Clause
// mrv2
// Copyright Contributors to the mrv2 Project. All rights reserved.

#ifdef TLRENDER_USD

# include <mrvApp/mrvUSD.h>

namespace mrv
{
namespace usd
{
bool RenderOptions::operator==(const RenderOptions& b) const
{
return (*this == b);
}

bool RenderOptions::operator!=(const RenderOptions& b) const
{
return !(*this == b);
}
} // namespace usd
} // namespace mrv

#endif
11 changes: 10 additions & 1 deletion mrv2/lib/mrvEdit/mrvEditCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,8 @@ namespace mrv
UndoRedo buffer;
buffer.json = state;
buffer.fileName = getEDLName(ui);

player = ui->uiView->getTimelinePlayer();
buffer.annotations = player->getAllAnnotations();
undoBuffer.push_back(buffer);
}
Expand Down Expand Up @@ -772,6 +774,7 @@ namespace mrv
UndoRedo buffer;
buffer.json = state;
buffer.fileName = getEDLName(ui);
player = ui->uiView->getTimelinePlayer();
buffer.annotations = player->getAllAnnotations();
redoBuffer.push_back(buffer);
}
Expand Down Expand Up @@ -1462,10 +1465,16 @@ namespace mrv

auto model = ui->app->filesModel();

const auto& sourceItems = model->observeFiles()->get();
const auto sourceItems = model->observeFiles()->get();

auto sourceItem = sourceItems[index];

auto destItem = model->observeA()->get();
if (!destItem)
{
LOG_ERROR(_("Destination file is invalid."));
return;
}

if (!isTemporaryEDL(destItem->path))
{
Expand Down
53 changes: 8 additions & 45 deletions mrv2/lib/mrvFl/mrvCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ namespace mrv
#ifdef MRV2_NETWORK
if (networkPanel)
networkPanel->save();
#endif
#ifdef TLRENDER_USD
if (usdPanel)
usdPanel->save();
#endif
if (stereo3DPanel)
stereo3DPanel->save();
Expand Down Expand Up @@ -1902,56 +1906,15 @@ namespace mrv
model->setStereo3DOptions(o);
}

// @todo: remove once tlRender supports this natively
void refresh_file_cache_cb(Fl_Menu_* m, void* d)
{
auto ui = App::ui;
auto app = ui->app;
auto model = app->filesModel();
if (model->observeFiles()->getSize() < 1)
return;

auto AIndex = model->observeAIndex()->get();
auto item = model->observeA()->get();
int layer = ui->uiColorChannel->value();

auto player = ui->uiView->getTimelinePlayer();
timeline::Playback playback = player->playback();
auto currentTime = player->currentTime();
auto inOutRange = player->inOutRange();

app->open(item->path.get(), item->audioPath.get());

auto newItem = model->observeA()->get();
auto ANewIndex = model->observeAIndex()->get();
newItem->inOutRange = inOutRange;
newItem->speed = item->speed;
newItem->audioOffset = item->audioOffset;
newItem->loop = item->loop;
newItem->playback = playback;
newItem->currentTime = currentTime;
newItem->annotations = item->annotations;
if (layer < ui->uiColorChannel->children())
{
ui->uiColorChannel->value(layer);
ui->uiColorChannel->do_callback();
}
else
{
ui->uiColorChannel->label(_("(no image)"));
}

// Close the old item
model->setA(AIndex);
model->close();

// Switch to new item
model->setA(ANewIndex);

player = ui->uiView->getTimelinePlayer();
player->setAllAnnotations(newItem->annotations);
player->seek(currentTime);
player->setPlayback(playback);
if (!player)
return;
const io::Options& options = player->getIOOptions();
player->setIOOptions(options);
}

void copy_filename_cb(Fl_Menu_* m, void* d)
Expand Down
Loading

0 comments on commit 5a4525c

Please sign in to comment.