From c460f1de24824e66bf3217868ac0c1c30657b2d7 Mon Sep 17 00:00:00 2001 From: ywmaa Date: Tue, 30 Jan 2024 12:05:40 +0200 Subject: [PATCH] Add Option for Export Geometry Nodes Instances in blend importer --- modules/gltf/editor/editor_scene_importer_blend.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index ec3ea9bcae4..4201dcd2ad4 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -227,6 +227,18 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_ } else { parameters_map["export_normals"] = false; } + + if (blender_major_version > 4 || (blender_major_version == 4 && blender_minor_version >= 1)) { + if (p_options.has(SNAME("blender/meshes/export_geometry_nodes_instances")) && p_options[SNAME("blender/meshes/export_geometry_nodes_instances")]) { + parameters_map["export_gn_mesh"] = true; + if (blender_major_version == 4 && blender_minor_version == 1) { + // There is a bug in Blender 4.1 where it can't export lights and geometry nodes at the same time, one must be disabled. + parameters_map["export_lights"] = false; + } + } else { + parameters_map["export_gn_mesh"] = false; + } + } if (p_options.has(SNAME("blender/meshes/tangents")) && p_options[SNAME("blender/meshes/tangents")]) { parameters_map["export_tangents"] = true; } else { @@ -350,6 +362,7 @@ void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, Li ADD_OPTION_BOOL("blender/meshes/colors", false); ADD_OPTION_BOOL("blender/meshes/uvs", true); ADD_OPTION_BOOL("blender/meshes/normals", true); + ADD_OPTION_BOOL("blender/meshes/export_geometry_nodes_instances", false); ADD_OPTION_BOOL("blender/meshes/tangents", true); ADD_OPTION_ENUM("blender/meshes/skins", "None,4 Influences (Compatible),All Influences", BLEND_BONE_INFLUENCES_ALL); ADD_OPTION_BOOL("blender/meshes/export_bones_deforming_mesh_only", false);