USD identifiers cannot start with a digit and, like all unsupported characters, they will be turned into an `_`. This is a bit unfortunate since object names like "1" or "2" both become "_" in the output file. This not only generates a naming collision, which is not currently handled, but it needlessly loses information even when there is no collision. Treat leading digits separately and turn names like "1" and "2" into "_1" and "_2" respectively. This will allow us to eventually enable the `light_tree_node_subtended_angle` render test which uses such names for the lights. Another recent test required investigation and then rework due to the same problem. Pull Request: https://projects.blender.org/blender/blender/pulls/134595
22 lines
532 B
C++
22 lines
532 B
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
#pragma once
|
|
|
|
#include "BLI_string_ref.hh"
|
|
|
|
#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(StringRef name, bool allow_unicode);
|
|
|
|
} // namespace blender::io::usd
|