Fix #143291: USD: World uses wrong output node

The problem was that the first output node was chosen instead of the
active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/143292
This commit is contained in:
Habib Gahbiche
2025-07-28 10:27:44 +02:00
parent 6f426f498a
commit cf5be88e7f

View File

@@ -235,10 +235,16 @@ void world_material_to_dome_light(const USDExportParams &params,
if (scene->world->use_nodes && scene->world->nodetree) {
/* Find the world output. */
bNode *output = nullptr;
const bNodeTree *ntree = scene->world->nodetree;
ntree->ensure_topology_cache();
const Span<const bNode *> bsdf_nodes = ntree->nodes_by_type("ShaderNodeOutputWorld");
const bNode *output = bsdf_nodes.is_empty() ? nullptr : bsdf_nodes.first();
for (const bNode *node : bsdf_nodes) {
if (node->flag & NODE_DO_OUTPUT) {
output = const_cast<bNode *>(node);
break;
}
}
if (!output) {
/* No output, no valid network to convert. */