From 27bab6203dbbb1a69ee5a61fca53592ccc4a30fa Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Mon, 24 Apr 2023 06:07:07 +0100 Subject: [PATCH] FBX IO: UVs access with new `uv` property Blender 3.5 moved UV layers to a generic attribute also accessible from the new `uv` property of the UV layer. The old API still works for now, but is slower and may be removed in 4.0, so this patch updates FBX IO to use the new `uv` property. There is no performance difference between accessing the UVs through the foreach_get/set functions of the attribute and the `uv` property. --- io_scene_fbx/export_fbx_bin.py | 2 +- io_scene_fbx/import_fbx.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/io_scene_fbx/export_fbx_bin.py b/io_scene_fbx/export_fbx_bin.py index e1f0ab6be..a8ac2d3ee 100644 --- a/io_scene_fbx/export_fbx_bin.py +++ b/io_scene_fbx/export_fbx_bin.py @@ -1342,7 +1342,7 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes): elem_data_single_string(lay_uv, b"MappingInformationType", b"ByPolygonVertex") elem_data_single_string(lay_uv, b"ReferenceInformationType", b"IndexToDirect") - uvlayer.data.foreach_get("uv", t_luv) + uvlayer.uv.foreach_get("vector", t_luv) # t_luv_fast_pair_view is a view in a dtype that compares elements by individual bytes, but float types have # separate byte representations of positive and negative zero. For uniqueness, these should be considered diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index dc3197f21..fec5f5d8b 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -1227,7 +1227,7 @@ def blen_read_geom_layer_uv(fbx_obj, mesh): "" % (layer_id, fbx_layer_name, mesh.name)) continue - blen_data = uv_lay.data + blen_data = uv_lay.uv # some valid files omit this data if fbx_layer_data is None: @@ -1235,7 +1235,7 @@ def blen_read_geom_layer_uv(fbx_obj, mesh): continue blen_read_geom_array_mapped_polyloop( - mesh, blen_data, "uv", np.single, + mesh, blen_data, "vector", np.single, fbx_layer_data, fbx_layer_index, fbx_layer_mapping, fbx_layer_ref, 2, 2, layer_id, -- 2.30.2