Cleanup: USD: remove now unneeded PXR_VERSION guards

These were primarily put in place during the library update period of
4.2 to ease the in-between time when not all platforms had updated
libraries. Also, now that we've begun depending on later version of USD
and MaterialX, there's little reason to pretend that using versions
prior to 24.03 is still supported.

Pull Request: https://projects.blender.org/blender/blender/pulls/135202
This commit is contained in:
Jesse Yurkovich
2025-02-27 00:15:41 +01:00
committed by Jesse Yurkovich
parent fb7b53143e
commit d6cdaff0c0
3 changed files with 4 additions and 20 deletions

View File

@@ -326,11 +326,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
const bool merge_parent_xform = RNA_boolean_get(op->ptr, "merge_parent_xform");
# if PXR_VERSION >= 2403
const bool allow_unicode = RNA_boolean_get(op->ptr, "allow_unicode");
# else
const bool allow_unicode = false;
# endif
/* When the texture export settings were moved into an enum this bit
* became more involved, but it needs to stick around for API backwards
@@ -456,9 +452,7 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op)
uiItemR(props_col, ptr, "custom_properties_namespace", UI_ITEM_NONE, std::nullopt, ICON_NONE);
uiItemR(props_col, ptr, "author_blender_name", UI_ITEM_NONE, std::nullopt, ICON_NONE);
uiLayoutSetActive(props_col, RNA_boolean_get(op->ptr, "export_custom_properties"));
# if PXR_VERSION >= 2403
uiItemR(sub, ptr, "allow_unicode", UI_ITEM_NONE, std::nullopt, ICON_NONE);
# endif
sub = uiLayoutColumnWithHeading(col, true, IFACE_("File References"));
uiItemR(sub, ptr, "relative_paths", UI_ITEM_NONE, std::nullopt, ICON_NONE);
@@ -832,7 +826,6 @@ void WM_OT_usd_export(wmOperatorType *ot)
"Currently works for simple materials, consisting of an environment texture "
"connected to a background shader, with an optional vector multiply of the texture color");
# if PXR_VERSION >= 2403
RNA_def_boolean(
ot->srna,
"allow_unicode",
@@ -840,7 +833,6 @@ void WM_OT_usd_export(wmOperatorType *ot)
"Allow Unicode",
"Preserve UTF-8 encoded characters when writing USD prim and property names "
"(requires software utilizing USD 24.03 or greater when opening the resulting files)");
# endif
RNA_def_boolean(ot->srna, "export_meshes", true, "Meshes", "Export all meshes");

View File

@@ -9,13 +9,11 @@
#include "BLI_string_utf8.h"
#include <pxr/base/tf/stringUtils.h>
#if PXR_VERSION >= 2403
# include <pxr/base/tf/unicodeUtils.h>
#endif
#include <pxr/base/tf/unicodeUtils.h>
namespace blender::io::usd {
std::string make_safe_name(const StringRef name, [[maybe_unused]] bool allow_unicode)
std::string make_safe_name(const StringRef name, bool allow_unicode)
{
if (name.is_empty()) {
return "_";
@@ -35,7 +33,6 @@ std::string make_safe_name(const StringRef name, [[maybe_unused]] bool allow_uni
first = false;
}
#if PXR_VERSION >= 2403
if (!allow_unicode) {
buf.take_back(name.size()).copy_from(name);
offset += name.size();
@@ -57,11 +54,6 @@ std::string make_safe_name(const StringRef name, [[maybe_unused]] bool allow_uni
}
return {buf.data(), offset};
#else
buf.take_back(name.size()).copy_from(name);
offset += name.size();
return pxr::TfMakeValidIdentifier({buf.data(), offset});
#endif
}
} // namespace blender::io::usd

View File

@@ -318,6 +318,7 @@ TEST_F(UsdExportTest, usd_export_material)
TEST(utilities, make_safe_name)
{
/* ASCII variations. */
ASSERT_EQ(make_safe_name("", false), std::string("_"));
ASSERT_EQ(make_safe_name("|", false), std::string("_"));
ASSERT_EQ(make_safe_name("1", false), std::string("_1"));
@@ -331,7 +332,7 @@ TEST(utilities, make_safe_name)
std::string("Test___________________________"));
ASSERT_EQ(make_safe_name("Test|∧hello ○ wórld", false), std::string("Test____hello_____w__rld"));
#if PXR_VERSION >= 2403
/* Unicode variations. */
ASSERT_EQ(make_safe_name("", true), std::string("_"));
ASSERT_EQ(make_safe_name("|", true), std::string("_"));
ASSERT_EQ(make_safe_name("1", true), std::string("_1"));
@@ -342,7 +343,6 @@ TEST(utilities, make_safe_name)
ASSERT_EQ(make_safe_name("Test|ハローワールド", true), std::string("Test_ハローワールド"));
ASSERT_EQ(make_safe_name("Test|Γεια σου κόσμε", true), std::string("Test_Γεια_σου_κόσμε"));
ASSERT_EQ(make_safe_name("Test|∧hello ○ wórld", true), std::string("Test__hello___wórld"));
#endif
}
} // namespace blender::io::usd