Add new scene import option to import as Skeleton
Adds a bool import option `nodes/import_as_skeleton_bones`. This is supported in all FBX or GLTF document based formats. It is especially useful for retargeting and importing animations.
This commit is contained in:
@@ -1932,6 +1932,7 @@ void ResourceImporterScene::get_import_options(const String &p_path, List<Import
|
||||
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/apply_root_scale"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::FLOAT, "nodes/root_scale", PROPERTY_HINT_RANGE, "0.001,1000,0.001"), 1.0));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "nodes/import_as_skeleton_bones"), false));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/generate_lods"), true));
|
||||
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/create_shadow_meshes"), true));
|
||||
|
||||
@@ -432,6 +432,16 @@ void SceneImportSettingsDialog::_update_view_gizmos() {
|
||||
if (!is_visible()) {
|
||||
return;
|
||||
}
|
||||
const HashMap<StringName, Variant> &main_settings = scene_import_settings_data->current;
|
||||
if (main_settings.has("nodes/import_as_skeleton_bones")) {
|
||||
bool new_import_as_skeleton = main_settings["nodes/import_as_skeleton_bones"];
|
||||
if (new_import_as_skeleton != previous_import_as_skeleton) {
|
||||
previous_import_as_skeleton = new_import_as_skeleton;
|
||||
_re_import();
|
||||
open_settings(base_path);
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (const KeyValue<String, NodeData> &e : node_map) {
|
||||
bool show_collider_view = false;
|
||||
if (e.value.settings.has(SNAME("generate/physics"))) {
|
||||
@@ -591,6 +601,7 @@ void SceneImportSettingsDialog::update_view() {
|
||||
|
||||
void SceneImportSettingsDialog::open_settings(const String &p_path, bool p_for_animation) {
|
||||
if (scene) {
|
||||
_cleanup();
|
||||
memdelete(scene);
|
||||
scene = nullptr;
|
||||
}
|
||||
@@ -667,6 +678,10 @@ void SceneImportSettingsDialog::open_settings(const String &p_path, bool p_for_a
|
||||
first_aabb = false;
|
||||
}
|
||||
|
||||
const HashMap<StringName, Variant> &main_settings = scene_import_settings_data->current;
|
||||
if (main_settings.has("nodes/import_as_skeleton_bones")) {
|
||||
previous_import_as_skeleton = main_settings["nodes/import_as_skeleton_bones"];
|
||||
}
|
||||
popup_centered_ratio();
|
||||
_update_view_gizmos();
|
||||
_update_camera();
|
||||
@@ -1137,6 +1152,7 @@ void SceneImportSettingsDialog::_re_import() {
|
||||
main_settings["_subresources"] = subresources;
|
||||
}
|
||||
|
||||
_cleanup(); // Prevent skeletons and other pointers from pointing to dangling references.
|
||||
EditorFileSystem::get_singleton()->reimport_file_with_custom_parameters(base_path, editing_animation ? "animation_library" : "scene", main_settings);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ class SceneImportSettingsDialog : public ConfirmationDialog {
|
||||
Button *animation_stop_button = nullptr;
|
||||
Animation::LoopMode animation_loop_mode = Animation::LOOP_NONE;
|
||||
bool animation_pingpong = false;
|
||||
bool previous_import_as_skeleton = false;
|
||||
|
||||
Ref<StandardMaterial3D> collider_mat;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user