Make use of USD's new UTF-8 support to allow our import/export code to accept and generate appropriate USD files. This has been a long standing shortcoming since USD's introduction, with incomplete and complicated DCC-specific workarounds often attempted. Summary of changes - Export gets a new "Allow Unicode" option defaulting to "false". The new Unicode USD files are not backward compatible. DCCs using older versions of USD (before 24.03) will not be able to load such files so we want to provide this as an opt-in option for now. - Every location which used to call either `USDHierarchyIterator::make_valid_name` or `pxr::TfMakeValidIdentifier` will now go through a new `make_safe_name` API instead - Export code is responsible for passing in the `allow_unicode` option - Import code will always pass in `true` meaning Blender will happily accept both existing and new Unicode USD files Strangely, USD does not provide a convenient way of making valid UTF-8 identifiers and they left their old API unchanged. We had to roll our own per their advice: https://forum.aousd.org/t/how-to-make-a-unicode-identifier-valid/1435 Pull Request: https://projects.blender.org/blender/blender/pulls/122471
20 lines
511 B
C++
20 lines
511 B
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
namespace blender::io::usd {
|
|
|
|
/**
|
|
* Return a valid USD identifier based on the passed in string.
|
|
*
|
|
* \param name: Incoming name to sanitize
|
|
* \param allow_unicode: Whether to allow unicode encoded characters in the USD identifier
|
|
* \return A valid USD identifier
|
|
*/
|
|
std::string make_safe_name(const std::string &name, bool allow_unicode);
|
|
|
|
} // namespace blender::io::usd
|