diff options
Diffstat (limited to 'modules/gltf')
-rw-r--r-- | modules/gltf/doc_classes/GLTFSkeleton.xml | 4 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFSkin.xml | 4 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFState.xml | 60 | ||||
-rw-r--r-- | modules/gltf/gltf_state.cpp | 68 | ||||
-rw-r--r-- | modules/gltf/gltf_state.h | 64 | ||||
-rw-r--r-- | modules/gltf/gltf_template_convert.h | 6 | ||||
-rw-r--r-- | modules/gltf/register_types.cpp | 4 | ||||
-rw-r--r-- | modules/gltf/structures/gltf_skeleton.cpp | 4 | ||||
-rw-r--r-- | modules/gltf/structures/gltf_skeleton.h | 4 | ||||
-rw-r--r-- | modules/gltf/structures/gltf_skin.cpp | 5 | ||||
-rw-r--r-- | modules/gltf/structures/gltf_skin.h | 7 |
11 files changed, 117 insertions, 113 deletions
diff --git a/modules/gltf/doc_classes/GLTFSkeleton.xml b/modules/gltf/doc_classes/GLTFSkeleton.xml index e1276d0e21..d6ec09f113 100644 --- a/modules/gltf/doc_classes/GLTFSkeleton.xml +++ b/modules/gltf/doc_classes/GLTFSkeleton.xml @@ -29,7 +29,7 @@ </description> </method> <method name="get_unique_names"> - <return type="Array" /> + <return type="String[]" /> <description> </description> </method> @@ -41,7 +41,7 @@ </method> <method name="set_unique_names"> <return type="void" /> - <param index="0" name="unique_names" type="Array" /> + <param index="0" name="unique_names" type="String[]" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFSkin.xml b/modules/gltf/doc_classes/GLTFSkin.xml index 5abdf33360..4de32857b5 100644 --- a/modules/gltf/doc_classes/GLTFSkin.xml +++ b/modules/gltf/doc_classes/GLTFSkin.xml @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="get_inverse_binds"> - <return type="Array" /> + <return type="Transform3D[]" /> <description> </description> </method> @@ -24,7 +24,7 @@ </method> <method name="set_inverse_binds"> <return type="void" /> - <param index="0" name="inverse_binds" type="Array" /> + <param index="0" name="inverse_binds" type="Transform3D[]" /> <description> </description> </method> diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index adf51ab59e..1dbd89aed8 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -8,7 +8,7 @@ </tutorials> <methods> <method name="get_accessors"> - <return type="Array" /> + <return type="GLTFAccessor[]" /> <description> </description> </method> @@ -25,42 +25,42 @@ </description> </method> <method name="get_animations"> - <return type="Array" /> + <return type="GLTFAnimation[]" /> <description> </description> </method> <method name="get_buffer_views"> - <return type="Array" /> + <return type="GLTFBufferView[]" /> <description> </description> </method> <method name="get_cameras"> - <return type="Array" /> + <return type="GLTFCamera[]" /> <description> </description> </method> <method name="get_images"> - <return type="Array" /> + <return type="Texture2D[]" /> <description> </description> </method> <method name="get_lights"> - <return type="Array" /> + <return type="GLTFLight[]" /> <description> </description> </method> <method name="get_materials"> - <return type="Array" /> + <return type="BaseMaterial3D[]" /> <description> </description> </method> <method name="get_meshes"> - <return type="Array" /> + <return type="GLTFMesh[]" /> <description> </description> </method> <method name="get_nodes"> - <return type="Array" /> + <return type="GLTFNode[]" /> <description> </description> </method> @@ -76,81 +76,81 @@ </description> </method> <method name="get_skeletons"> - <return type="Array" /> + <return type="GLTFSkeleton[]" /> <description> </description> </method> <method name="get_skins"> - <return type="Array" /> + <return type="GLTFSkin[]" /> <description> </description> </method> <method name="get_textures"> - <return type="Array" /> + <return type="GLTFTexture[]" /> <description> </description> </method> <method name="get_unique_animation_names"> - <return type="Array" /> + <return type="String[]" /> <description> </description> </method> <method name="get_unique_names"> - <return type="Array" /> + <return type="String[]" /> <description> </description> </method> <method name="set_accessors"> <return type="void" /> - <param index="0" name="accessors" type="Array" /> + <param index="0" name="accessors" type="GLTFAccessor[]" /> <description> </description> </method> <method name="set_animations"> <return type="void" /> - <param index="0" name="animations" type="Array" /> + <param index="0" name="animations" type="GLTFAnimation[]" /> <description> </description> </method> <method name="set_buffer_views"> <return type="void" /> - <param index="0" name="buffer_views" type="Array" /> + <param index="0" name="buffer_views" type="GLTFBufferView[]" /> <description> </description> </method> <method name="set_cameras"> <return type="void" /> - <param index="0" name="cameras" type="Array" /> + <param index="0" name="cameras" type="GLTFCamera[]" /> <description> </description> </method> <method name="set_images"> <return type="void" /> - <param index="0" name="images" type="Array" /> + <param index="0" name="images" type="Texture2D[]" /> <description> </description> </method> <method name="set_lights"> <return type="void" /> - <param index="0" name="lights" type="Array" /> + <param index="0" name="lights" type="GLTFLight[]" /> <description> </description> </method> <method name="set_materials"> <return type="void" /> - <param index="0" name="materials" type="Array" /> + <param index="0" name="materials" type="BaseMaterial3D[]" /> <description> </description> </method> <method name="set_meshes"> <return type="void" /> - <param index="0" name="meshes" type="Array" /> + <param index="0" name="meshes" type="GLTFMesh[]" /> <description> </description> </method> <method name="set_nodes"> <return type="void" /> - <param index="0" name="nodes" type="Array" /> + <param index="0" name="nodes" type="GLTFNode[]" /> <description> </description> </method> @@ -162,31 +162,31 @@ </method> <method name="set_skeletons"> <return type="void" /> - <param index="0" name="skeletons" type="Array" /> + <param index="0" name="skeletons" type="GLTFSkeleton[]" /> <description> </description> </method> <method name="set_skins"> <return type="void" /> - <param index="0" name="skins" type="Array" /> + <param index="0" name="skins" type="GLTFSkin[]" /> <description> </description> </method> <method name="set_textures"> <return type="void" /> - <param index="0" name="textures" type="Array" /> + <param index="0" name="textures" type="GLTFTexture[]" /> <description> </description> </method> <method name="set_unique_animation_names"> <return type="void" /> - <param index="0" name="unique_animation_names" type="Array" /> + <param index="0" name="unique_animation_names" type="String[]" /> <description> </description> </method> <method name="set_unique_names"> <return type="void" /> - <param index="0" name="unique_names" type="Array" /> + <param index="0" name="unique_names" type="String[]" /> <description> </description> </method> @@ -194,7 +194,7 @@ <members> <member name="base_path" type="String" setter="set_base_path" getter="get_base_path" default=""""> </member> - <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]"> + <member name="buffers" type="PackedByteArray[]" setter="set_buffers" getter="get_buffers" default="[]"> </member> <member name="create_animations" type="bool" setter="set_create_animations" getter="get_create_animations" default="true"> </member> @@ -206,7 +206,7 @@ </member> <member name="minor_version" type="int" setter="set_minor_version" getter="get_minor_version" default="0"> </member> - <member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[]"> + <member name="root_nodes" type="PackedInt32Array" setter="set_root_nodes" getter="get_root_nodes" default="PackedInt32Array()"> </member> <member name="scene_name" type="String" setter="set_scene_name" getter="get_scene_name" default=""""> </member> diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index 8212e4c22f..85bac446cc 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -152,51 +152,51 @@ void GLTFState::set_use_named_skin_binds(bool p_use_named_skin_binds) { use_named_skin_binds = p_use_named_skin_binds; } -Array GLTFState::get_nodes() { +TypedArray<GLTFNode> GLTFState::get_nodes() { return GLTFTemplateConvert::to_array(nodes); } -void GLTFState::set_nodes(Array p_nodes) { +void GLTFState::set_nodes(TypedArray<GLTFNode> p_nodes) { GLTFTemplateConvert::set_from_array(nodes, p_nodes); } -Array GLTFState::get_buffers() { +TypedArray<PackedByteArray> GLTFState::get_buffers() { return GLTFTemplateConvert::to_array(buffers); } -void GLTFState::set_buffers(Array p_buffers) { +void GLTFState::set_buffers(TypedArray<PackedByteArray> p_buffers) { GLTFTemplateConvert::set_from_array(buffers, p_buffers); } -Array GLTFState::get_buffer_views() { +TypedArray<GLTFBufferView> GLTFState::get_buffer_views() { return GLTFTemplateConvert::to_array(buffer_views); } -void GLTFState::set_buffer_views(Array p_buffer_views) { +void GLTFState::set_buffer_views(TypedArray<GLTFBufferView> p_buffer_views) { GLTFTemplateConvert::set_from_array(buffer_views, p_buffer_views); } -Array GLTFState::get_accessors() { +TypedArray<GLTFAccessor> GLTFState::get_accessors() { return GLTFTemplateConvert::to_array(accessors); } -void GLTFState::set_accessors(Array p_accessors) { +void GLTFState::set_accessors(TypedArray<GLTFAccessor> p_accessors) { GLTFTemplateConvert::set_from_array(accessors, p_accessors); } -Array GLTFState::get_meshes() { +TypedArray<GLTFMesh> GLTFState::get_meshes() { return GLTFTemplateConvert::to_array(meshes); } -void GLTFState::set_meshes(Array p_meshes) { +void GLTFState::set_meshes(TypedArray<GLTFMesh> p_meshes) { GLTFTemplateConvert::set_from_array(meshes, p_meshes); } -Array GLTFState::get_materials() { +TypedArray<BaseMaterial3D> GLTFState::get_materials() { return GLTFTemplateConvert::to_array(materials); } -void GLTFState::set_materials(Array p_materials) { +void GLTFState::set_materials(TypedArray<BaseMaterial3D> p_materials) { GLTFTemplateConvert::set_from_array(materials, p_materials); } @@ -208,75 +208,75 @@ void GLTFState::set_scene_name(String p_scene_name) { scene_name = p_scene_name; } -Array GLTFState::get_root_nodes() { - return GLTFTemplateConvert::to_array(root_nodes); +PackedInt32Array GLTFState::get_root_nodes() { + return root_nodes; } -void GLTFState::set_root_nodes(Array p_root_nodes) { - GLTFTemplateConvert::set_from_array(root_nodes, p_root_nodes); +void GLTFState::set_root_nodes(PackedInt32Array p_root_nodes) { + root_nodes = p_root_nodes; } -Array GLTFState::get_textures() { +TypedArray<GLTFTexture> GLTFState::get_textures() { return GLTFTemplateConvert::to_array(textures); } -void GLTFState::set_textures(Array p_textures) { +void GLTFState::set_textures(TypedArray<GLTFTexture> p_textures) { GLTFTemplateConvert::set_from_array(textures, p_textures); } -Array GLTFState::get_images() { +TypedArray<Texture2D> GLTFState::get_images() { return GLTFTemplateConvert::to_array(images); } -void GLTFState::set_images(Array p_images) { +void GLTFState::set_images(TypedArray<Texture2D> p_images) { GLTFTemplateConvert::set_from_array(images, p_images); } -Array GLTFState::get_skins() { +TypedArray<GLTFSkin> GLTFState::get_skins() { return GLTFTemplateConvert::to_array(skins); } -void GLTFState::set_skins(Array p_skins) { +void GLTFState::set_skins(TypedArray<GLTFSkin> p_skins) { GLTFTemplateConvert::set_from_array(skins, p_skins); } -Array GLTFState::get_cameras() { +TypedArray<GLTFCamera> GLTFState::get_cameras() { return GLTFTemplateConvert::to_array(cameras); } -void GLTFState::set_cameras(Array p_cameras) { +void GLTFState::set_cameras(TypedArray<GLTFCamera> p_cameras) { GLTFTemplateConvert::set_from_array(cameras, p_cameras); } -Array GLTFState::get_lights() { +TypedArray<GLTFLight> GLTFState::get_lights() { return GLTFTemplateConvert::to_array(lights); } -void GLTFState::set_lights(Array p_lights) { +void GLTFState::set_lights(TypedArray<GLTFLight> p_lights) { GLTFTemplateConvert::set_from_array(lights, p_lights); } -Array GLTFState::get_unique_names() { +TypedArray<String> GLTFState::get_unique_names() { return GLTFTemplateConvert::to_array(unique_names); } -void GLTFState::set_unique_names(Array p_unique_names) { +void GLTFState::set_unique_names(TypedArray<String> p_unique_names) { GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); } -Array GLTFState::get_unique_animation_names() { +TypedArray<String> GLTFState::get_unique_animation_names() { return GLTFTemplateConvert::to_array(unique_animation_names); } -void GLTFState::set_unique_animation_names(Array p_unique_animation_names) { +void GLTFState::set_unique_animation_names(TypedArray<String> p_unique_animation_names) { GLTFTemplateConvert::set_from_array(unique_animation_names, p_unique_animation_names); } -Array GLTFState::get_skeletons() { +TypedArray<GLTFSkeleton> GLTFState::get_skeletons() { return GLTFTemplateConvert::to_array(skeletons); } -void GLTFState::set_skeletons(Array p_skeletons) { +void GLTFState::set_skeletons(TypedArray<GLTFSkeleton> p_skeletons) { GLTFTemplateConvert::set_from_array(skeletons, p_skeletons); } @@ -296,11 +296,11 @@ void GLTFState::set_create_animations(bool p_create_animations) { create_animations = p_create_animations; } -Array GLTFState::get_animations() { +TypedArray<GLTFAnimation> GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } -void GLTFState::set_animations(Array p_animations) { +void GLTFState::set_animations(TypedArray<GLTFAnimation> p_animations) { GLTFTemplateConvert::set_from_array(animations, p_animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index c08132f874..6b2d1ca228 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -115,23 +115,23 @@ public: bool get_discard_meshes_and_materials(); void set_discard_meshes_and_materials(bool p_discard_meshes_and_materials); - Array get_nodes(); - void set_nodes(Array p_nodes); + TypedArray<GLTFNode> get_nodes(); + void set_nodes(TypedArray<GLTFNode> p_nodes); - Array get_buffers(); - void set_buffers(Array p_buffers); + TypedArray<PackedByteArray> get_buffers(); + void set_buffers(TypedArray<PackedByteArray> p_buffers); - Array get_buffer_views(); - void set_buffer_views(Array p_buffer_views); + TypedArray<GLTFBufferView> get_buffer_views(); + void set_buffer_views(TypedArray<GLTFBufferView> p_buffer_views); - Array get_accessors(); - void set_accessors(Array p_accessors); + TypedArray<GLTFAccessor> get_accessors(); + void set_accessors(TypedArray<GLTFAccessor> p_accessors); - Array get_meshes(); - void set_meshes(Array p_meshes); + TypedArray<GLTFMesh> get_meshes(); + void set_meshes(TypedArray<GLTFMesh> p_meshes); - Array get_materials(); - void set_materials(Array p_materials); + TypedArray<BaseMaterial3D> get_materials(); + void set_materials(TypedArray<BaseMaterial3D> p_materials); String get_scene_name(); void set_scene_name(String p_scene_name); @@ -139,32 +139,32 @@ public: String get_base_path(); void set_base_path(String p_base_path); - Array get_root_nodes(); - void set_root_nodes(Array p_root_nodes); + PackedInt32Array get_root_nodes(); + void set_root_nodes(PackedInt32Array p_root_nodes); - Array get_textures(); - void set_textures(Array p_textures); + TypedArray<GLTFTexture> get_textures(); + void set_textures(TypedArray<GLTFTexture> p_textures); - Array get_images(); - void set_images(Array p_images); + TypedArray<Texture2D> get_images(); + void set_images(TypedArray<Texture2D> p_images); - Array get_skins(); - void set_skins(Array p_skins); + TypedArray<GLTFSkin> get_skins(); + void set_skins(TypedArray<GLTFSkin> p_skins); - Array get_cameras(); - void set_cameras(Array p_cameras); + TypedArray<GLTFCamera> get_cameras(); + void set_cameras(TypedArray<GLTFCamera> p_cameras); - Array get_lights(); - void set_lights(Array p_lights); + TypedArray<GLTFLight> get_lights(); + void set_lights(TypedArray<GLTFLight> p_lights); - Array get_unique_names(); - void set_unique_names(Array p_unique_names); + TypedArray<String> get_unique_names(); + void set_unique_names(TypedArray<String> p_unique_names); - Array get_unique_animation_names(); - void set_unique_animation_names(Array p_unique_names); + TypedArray<String> get_unique_animation_names(); + void set_unique_animation_names(TypedArray<String> p_unique_names); - Array get_skeletons(); - void set_skeletons(Array p_skeletons); + TypedArray<GLTFSkeleton> get_skeletons(); + void set_skeletons(TypedArray<GLTFSkeleton> p_skeletons); Dictionary get_skeleton_to_node(); void set_skeleton_to_node(Dictionary p_skeleton_to_node); @@ -172,8 +172,8 @@ public: bool get_create_animations(); void set_create_animations(bool p_create_animations); - Array get_animations(); - void set_animations(Array p_animations); + TypedArray<GLTFAnimation> get_animations(); + void set_animations(TypedArray<GLTFAnimation> p_animations); Node *get_scene_node(GLTFNodeIndex idx); diff --git a/modules/gltf/gltf_template_convert.h b/modules/gltf/gltf_template_convert.h index c915d3deb0..8a4b595c9f 100644 --- a/modules/gltf/gltf_template_convert.h +++ b/modules/gltf/gltf_template_convert.h @@ -46,8 +46,8 @@ static Array to_array(const Vector<T> &p_inp) { } template <class T> -static Array to_array(const HashSet<T> &p_inp) { - Array ret; +static TypedArray<T> to_array(const HashSet<T> &p_inp) { + TypedArray<T> ret; typename HashSet<T>::Iterator elem = p_inp.begin(); while (elem) { ret.push_back(*elem); @@ -65,7 +65,7 @@ static void set_from_array(Vector<T> &r_out, const Array &p_inp) { } template <class T> -static void set_from_array(HashSet<T> &r_out, const Array &p_inp) { +static void set_from_array(HashSet<T> &r_out, const TypedArray<T> &p_inp) { r_out.clear(); for (int i = 0; i < p_inp.size(); i++) { r_out.insert(p_inp[i]); diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index cc1ca9131d..dbbccc9bcc 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -73,8 +73,8 @@ static void _editor_init() { Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (blender3_path.is_empty()) { WARN_PRINT("Blend file import is enabled in the project settings, but no Blender path is configured in the editor settings. Blend files will not be imported."); - } else if (!da->file_exists(blender3_path)) { - WARN_PRINT("Blend file import is enabled, but the Blender path doesn't point to an accessible file. Blend files will not be imported."); + } else if (!da->dir_exists(blender3_path)) { + WARN_PRINT("Blend file import is enabled, but the Blender path doesn't point to an accessible directory. Blend files will not be imported."); } else { Ref<EditorSceneFormatImporterBlend> importer; importer.instantiate(); diff --git a/modules/gltf/structures/gltf_skeleton.cpp b/modules/gltf/structures/gltf_skeleton.cpp index 90a6b0f50f..0073357eda 100644 --- a/modules/gltf/structures/gltf_skeleton.cpp +++ b/modules/gltf/structures/gltf_skeleton.cpp @@ -72,11 +72,11 @@ Skeleton3D *GLTFSkeleton::get_godot_skeleton() { return godot_skeleton; } -Array GLTFSkeleton::get_unique_names() { +TypedArray<String> GLTFSkeleton::get_unique_names() { return GLTFTemplateConvert::to_array(unique_names); } -void GLTFSkeleton::set_unique_names(Array p_unique_names) { +void GLTFSkeleton::set_unique_names(TypedArray<String> p_unique_names) { GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); } diff --git a/modules/gltf/structures/gltf_skeleton.h b/modules/gltf/structures/gltf_skeleton.h index db88623213..0f20b493b6 100644 --- a/modules/gltf/structures/gltf_skeleton.h +++ b/modules/gltf/structures/gltf_skeleton.h @@ -75,8 +75,8 @@ public: // this->godot_skeleton = p_godot_skeleton; // } - Array get_unique_names(); - void set_unique_names(Array p_unique_names); + TypedArray<String> get_unique_names(); + void set_unique_names(TypedArray<String> p_unique_names); //RBMap<int32_t, GLTFNodeIndex> get_godot_bone_node() { // return this->godot_bone_node; diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp index 2e46ee3be2..9717a66048 100644 --- a/modules/gltf/structures/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -31,6 +31,7 @@ #include "gltf_skin.h" #include "../gltf_template_convert.h" +#include "core/variant/typed_array.h" #include "scene/resources/skin.h" void GLTFSkin::_bind_methods() { @@ -83,11 +84,11 @@ void GLTFSkin::set_joints_original(Vector<GLTFNodeIndex> p_joints_original) { joints_original = p_joints_original; } -Array GLTFSkin::get_inverse_binds() { +TypedArray<Transform3D> GLTFSkin::get_inverse_binds() { return GLTFTemplateConvert::to_array(inverse_binds); } -void GLTFSkin::set_inverse_binds(Array p_inverse_binds) { +void GLTFSkin::set_inverse_binds(TypedArray<Transform3D> p_inverse_binds) { GLTFTemplateConvert::set_from_array(inverse_binds, p_inverse_binds); } diff --git a/modules/gltf/structures/gltf_skin.h b/modules/gltf/structures/gltf_skin.h index 59b6a300ac..1a4d54b380 100644 --- a/modules/gltf/structures/gltf_skin.h +++ b/modules/gltf/structures/gltf_skin.h @@ -34,6 +34,9 @@ #include "../gltf_defines.h" #include "core/io/resource.h" +template <typename T> +class TypedArray; + class GLTFSkin : public Resource { GDCLASS(GLTFSkin, Resource); friend class GLTFDocument; @@ -82,8 +85,8 @@ public: Vector<GLTFNodeIndex> get_joints_original(); void set_joints_original(Vector<GLTFNodeIndex> p_joints_original); - Array get_inverse_binds(); - void set_inverse_binds(Array p_inverse_binds); + TypedArray<Transform3D> get_inverse_binds(); + void set_inverse_binds(TypedArray<Transform3D> p_inverse_binds); Vector<GLTFNodeIndex> get_joints(); void set_joints(Vector<GLTFNodeIndex> p_joints); |