From f4124b4e20dc9f157d018e40e890600f7e2beffd Mon Sep 17 00:00:00 2001 From: Michael Kowalski Date: Wed, 11 Oct 2023 16:21:19 +0200 Subject: [PATCH 1/2] Fix #113400: USD transform cache crash on invalid prim. Updated CacheReader_open_usd_object() to issue a warning and return early if the given object path does not refer to a valid prim on the USD stage, to avoid crashing when attempting to create a reader from an invalid prim. Pull Request: https://projects.blender.org/blender/blender/pulls/113524 --- source/blender/io/usd/intern/usd_capi_import.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index f4a57ee9ffe..f26c83adcb0 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -553,6 +553,11 @@ CacheReader *CacheReader_open_usd_object(CacheArchiveHandle *handle, pxr::UsdPrim prim = archive->stage()->GetPrimAtPath(pxr::SdfPath(object_path)); + if (!prim) { + WM_reportf(RPT_WARNING, "USD Import: unable to open cache reader for object %s", object_path); + return nullptr; + } + if (reader) { USD_CacheReader_free(reader); } From 50ed14f22805456ee58ff808abd6b070d0b5949f Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Wed, 11 Oct 2023 16:51:32 +0200 Subject: [PATCH 2/2] Fix: Set selection node crashes with attributes on the wrong domain Remove the selection attributes on the non-selected domains, since they will be automatically filled by domain interopolation anyway. Arguably this should be fixed in a more general way, either by ensuring they are always on the expected domains or more gracefully handling the case when they aren't at a lower level. But for this node, for now this is a simpler approach. --- .../nodes/geometry/nodes/node_geo_tool_set_selection.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc index f0814aca8f2..c583f193143 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_tool_set_selection.cc @@ -44,6 +44,10 @@ static void node_geo_exec(GeoNodeExecParams params) if (Mesh *mesh = geometry.get_mesh_for_write()) { switch (domain) { case ATTR_DOMAIN_POINT: + /* Remove attributes in case they are on the wrong domain, which can happen after + * conversion to and from other geometry types. */ + mesh->attributes_for_write().remove(".select_edge"); + mesh->attributes_for_write().remove(".select_poly"); bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".select_vert", ATTR_DOMAIN_POINT, @@ -51,6 +55,10 @@ static void node_geo_exec(GeoNodeExecParams params) BKE_mesh_flush_select_from_verts(mesh); break; case ATTR_DOMAIN_FACE: + /* Remove attributes in case they are on the wrong domain, which can happen after + * conversion to and from other geometry types. */ + mesh->attributes_for_write().remove(".select_vert"); + mesh->attributes_for_write().remove(".select_edge"); bke::try_capture_field_on_geometry(geometry.get_component_for_write(), ".select_poly", ATTR_DOMAIN_FACE,