Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to control asset versioning when getting write access #727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions engine/include/cubos/engine/assets/assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ namespace cubos::engine
///
/// @tparam T Type of the asset data.
/// @param handle Handle to get the asset data for.
/// @param incVersion Whether to increase the asset's version.
/// @return Reference to the asset data.
template <typename T>
inline AssetWrite<T> write(Asset<T> handle)
inline AssetWrite<T> write(Asset<T> handle, bool incVersion = true)
{
// Create a strong handle to the asset, so that the asset starts loading if it isn't already.
auto strong = this->load(handle);
auto lock = this->lockWrite(strong);
auto data = static_cast<T*>(this->access(strong, typeid(T), lock, true));
auto data = static_cast<T*>(this->access(strong, typeid(T), lock, incVersion));
return AssetWrite<T>(*data, std::move(lock));
}

Expand Down
Loading