mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-02-03 14:45:57 +01:00
Prevent AnimationPlayer from being added on GLTF import if the option is unchecked. Fixes #63954
(cherry picked from commit 805ffdfbf6841ac19c6fdbf3425a6ff15115bed7)
This commit is contained in:
parent
fe154362b1
commit
607964e973
@ -208,6 +208,8 @@
|
|||||||
<members>
|
<members>
|
||||||
<member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[ ]">
|
<member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[ ]">
|
||||||
</member>
|
</member>
|
||||||
|
<member name="create_animations" type="bool" setter="set_create_animations" getter="get_create_animations" default="true">
|
||||||
|
</member>
|
||||||
<member name="glb_data" type="PoolByteArray" setter="set_glb_data" getter="get_glb_data" default="PoolByteArray( )">
|
<member name="glb_data" type="PoolByteArray" setter="set_glb_data" getter="get_glb_data" default="PoolByteArray( )">
|
||||||
</member>
|
</member>
|
||||||
<member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}">
|
<member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}">
|
||||||
|
@ -81,6 +81,8 @@ void GLTFState::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons);
|
ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons);
|
||||||
ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node);
|
ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node);
|
||||||
ClassDB::bind_method(D_METHOD("set_skeleton_to_node", "skeleton_to_node"), &GLTFState::set_skeleton_to_node);
|
ClassDB::bind_method(D_METHOD("set_skeleton_to_node", "skeleton_to_node"), &GLTFState::set_skeleton_to_node);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_create_animations"), &GLTFState::get_create_animations);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_create_animations", "create_animations"), &GLTFState::set_create_animations);
|
||||||
ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations);
|
ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations);
|
||||||
ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations);
|
ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations);
|
||||||
ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node);
|
ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node);
|
||||||
@ -108,6 +110,7 @@ void GLTFState::_bind_methods() {
|
|||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String>
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String>
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>>
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>>
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // Map<GLTFSkeletonIndex,
|
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // Map<GLTFSkeletonIndex,
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations"), "set_create_animations", "get_create_animations"); // bool
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>>
|
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>>
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,6 +298,14 @@ void GLTFState::set_skeleton_to_node(Dictionary p_skeleton_to_node) {
|
|||||||
GLTFTemplateConvert::set_from_dict(skeleton_to_node, p_skeleton_to_node);
|
GLTFTemplateConvert::set_from_dict(skeleton_to_node, p_skeleton_to_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLTFState::get_create_animations() {
|
||||||
|
return create_animations;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLTFState::set_create_animations(bool p_create_animations) {
|
||||||
|
create_animations = p_create_animations;
|
||||||
|
}
|
||||||
|
|
||||||
Array GLTFState::get_animations() {
|
Array GLTFState::get_animations() {
|
||||||
return GLTFTemplateConvert::to_array(animations);
|
return GLTFTemplateConvert::to_array(animations);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@ class GLTFState : public Resource {
|
|||||||
bool use_khr_texture_transform = false;
|
bool use_khr_texture_transform = false;
|
||||||
bool use_legacy_names = false;
|
bool use_legacy_names = false;
|
||||||
uint32_t compress_flags = 0;
|
uint32_t compress_flags = 0;
|
||||||
|
bool create_animations = true;
|
||||||
|
|
||||||
Vector<Ref<GLTFNode>> nodes;
|
Vector<Ref<GLTFNode>> nodes;
|
||||||
Vector<Vector<uint8_t>> buffers;
|
Vector<Vector<uint8_t>> buffers;
|
||||||
@ -165,6 +166,9 @@ public:
|
|||||||
Dictionary get_skeleton_to_node();
|
Dictionary get_skeleton_to_node();
|
||||||
void set_skeleton_to_node(Dictionary p_skeleton_to_node);
|
void set_skeleton_to_node(Dictionary p_skeleton_to_node);
|
||||||
|
|
||||||
|
bool get_create_animations();
|
||||||
|
void set_create_animations(bool p_create_animations);
|
||||||
|
|
||||||
Array get_animations();
|
Array get_animations();
|
||||||
void set_animations(Array p_animations);
|
void set_animations(Array p_animations);
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ Node *PackedSceneGLTF::import_scene(const String &p_path, uint32_t p_flags,
|
|||||||
r_state->use_legacy_names =
|
r_state->use_legacy_names =
|
||||||
p_flags & EditorSceneImporter::IMPORT_USE_LEGACY_NAMES;
|
p_flags & EditorSceneImporter::IMPORT_USE_LEGACY_NAMES;
|
||||||
r_state->compress_flags = p_compress_flags;
|
r_state->compress_flags = p_compress_flags;
|
||||||
|
r_state->set_create_animations(p_flags & EditorSceneImporter::IMPORT_ANIMATION);
|
||||||
|
|
||||||
Ref<GLTFDocument> gltf_document;
|
Ref<GLTFDocument> gltf_document;
|
||||||
gltf_document.instance();
|
gltf_document.instance();
|
||||||
@ -84,7 +85,7 @@ Node *PackedSceneGLTF::import_scene(const String &p_path, uint32_t p_flags,
|
|||||||
gltf_document->_generate_scene_node(r_state, root, root, r_state->root_nodes[root_i]);
|
gltf_document->_generate_scene_node(r_state, root, root, r_state->root_nodes[root_i]);
|
||||||
}
|
}
|
||||||
gltf_document->_process_mesh_instances(r_state, root);
|
gltf_document->_process_mesh_instances(r_state, root);
|
||||||
if (r_state->animations.size()) {
|
if (r_state->get_create_animations() && r_state->animations.size()) {
|
||||||
AnimationPlayer *ap = memnew(AnimationPlayer);
|
AnimationPlayer *ap = memnew(AnimationPlayer);
|
||||||
root->add_child(ap);
|
root->add_child(ap);
|
||||||
ap->set_owner(root);
|
ap->set_owner(root);
|
||||||
|
Loading…
Reference in New Issue
Block a user