diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub index a7cdeca2e..060966d8b 100644 --- a/modules/gltf/SCsub +++ b/modules/gltf/SCsub @@ -6,9 +6,11 @@ Import("env_modules") env_gltf = env_modules.Clone() # Godot source files -env_gltf.add_source_files(env.modules_sources, "*.cpp") +env_gltf.add_source_files(env.modules_sources, "register_types.cpp") +#env_gltf.add_source_files(env.modules_sources, "*.cpp") + env_gltf.add_source_files(env.modules_sources, "extensions/*.cpp") env_gltf.add_source_files(env.modules_sources, "structures/*.cpp") -if env["tools"]: - env_gltf.add_source_files(env.modules_sources, "editor/*.cpp") +#if env["tools"]: +# env_gltf.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/gltf/extensions/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp index af21a4e80..ec951e44b 100644 --- a/modules/gltf/extensions/gltf_light.cpp +++ b/modules/gltf/extensions/gltf_light.cpp @@ -45,11 +45,11 @@ void GLTFLight::_bind_methods() { ClassDB::bind_method(D_METHOD("set_outer_cone_angle", "outer_cone_angle"), &GLTFLight::set_outer_cone_angle); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity"), "set_intensity", "get_intensity"); // float + ADD_PROPERTY(PropertyInfo(Variant::REAL, "intensity"), "set_intensity", "get_intensity"); // float ADD_PROPERTY(PropertyInfo(Variant::STRING, "light_type"), "set_light_type", "get_light_type"); // String - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range"), "set_range", "get_range"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_cone_angle"), "set_inner_cone_angle", "get_inner_cone_angle"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_cone_angle"), "set_outer_cone_angle", "get_outer_cone_angle"); // float + ADD_PROPERTY(PropertyInfo(Variant::REAL, "range"), "set_range", "get_range"); // float + ADD_PROPERTY(PropertyInfo(Variant::REAL, "inner_cone_angle"), "set_inner_cone_angle", "get_inner_cone_angle"); // float + ADD_PROPERTY(PropertyInfo(Variant::REAL, "outer_cone_angle"), "set_outer_cone_angle", "get_outer_cone_angle"); // float } Color GLTFLight::get_color() { diff --git a/modules/gltf/gltf_template_convert.h b/modules/gltf/gltf_template_convert.h index f0d8dfd50..a787c85b8 100644 --- a/modules/gltf/gltf_template_convert.h +++ b/modules/gltf/gltf_template_convert.h @@ -31,9 +31,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "core/hash_set.h" #include "core/array.h" #include "core/dictionary.h" +#include "core/hash_set.h" namespace GLTFTemplateConvert { template @@ -75,8 +75,9 @@ static void set_from_array(HashSet &r_out, const Array &p_inp) { template static Dictionary to_dict(const HashMap &p_inp) { Dictionary ret; - for (const KeyValue &E : p_inp) { - ret[E.key] = E.value; + const K *key = NULL; + while ((key = p_inp.next(key))) { + ret[*key] = p_inp[*key]; } return ret; } diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index 19b81d34d..90ca47411 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -32,20 +32,6 @@ #ifndef _3D_DISABLED -void register_gltf_types() { - -} -void unregister_gltf_types() { - -} - -/* -#include "extensions/gltf_light.h" -#include "extensions/gltf_spec_gloss.h" -#include "gltf_document.h" -#include "gltf_document_extension.h" -#include "gltf_document_extension_convert_importer_mesh.h" -#include "gltf_state.h" #include "structures/gltf_accessor.h" #include "structures/gltf_animation.h" #include "structures/gltf_buffer_view.h" @@ -56,6 +42,40 @@ void unregister_gltf_types() { #include "structures/gltf_skin.h" #include "structures/gltf_texture.h" +#include "extensions/gltf_light.h" +#include "extensions/gltf_spec_gloss.h" + +void register_gltf_types() { + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + + ClassDB::register_class(); + ClassDB::register_class(); + + //ClassDB::register_class(); + //ClassDB::register_class(); + //ClassDB::register_class(); + //ClassDB::register_class(); +} +void unregister_gltf_types() { + +} + +/* + +#include "gltf_document.h" +#include "gltf_document_extension.h" +#include "gltf_document_extension_convert_importer_mesh.h" +#include "gltf_state.h" + + #ifdef TOOLS_ENABLED #include "core/project_settings.h" #include "editor/editor_node.h" diff --git a/modules/gltf/structures/gltf_accessor.cpp b/modules/gltf/structures/gltf_accessor.cpp index dfeabb804..03955edee 100644 --- a/modules/gltf/structures/gltf_accessor.cpp +++ b/modules/gltf/structures/gltf_accessor.cpp @@ -124,19 +124,19 @@ void GLTFAccessor::set_type(int p_type) { type = (GLTFType)p_type; // TODO: Register enum } -Vector GLTFAccessor::get_min() { +PoolRealArray GLTFAccessor::get_min() { return min; } -void GLTFAccessor::set_min(Vector p_min) { +void GLTFAccessor::set_min(const PoolRealArray &p_min) { min = p_min; } -Vector GLTFAccessor::get_max() { +PoolRealArray GLTFAccessor::get_max() { return max; } -void GLTFAccessor::set_max(Vector p_max) { +void GLTFAccessor::set_max(const PoolRealArray &p_max) { max = p_max; } diff --git a/modules/gltf/structures/gltf_accessor.h b/modules/gltf/structures/gltf_accessor.h index 8a7d7fd72..991fda6f3 100644 --- a/modules/gltf/structures/gltf_accessor.h +++ b/modules/gltf/structures/gltf_accessor.h @@ -46,8 +46,8 @@ private: bool normalized = false; int count = 0; GLTFType type = GLTFType::TYPE_SCALAR; - Vector min; - Vector max; + PoolRealArray min; + PoolRealArray max; int sparse_count = 0; int sparse_indices_buffer_view = 0; int sparse_indices_byte_offset = 0; @@ -77,11 +77,11 @@ public: int get_type(); void set_type(int p_type); - Vector get_min(); - void set_min(Vector p_min); + PoolRealArray get_min(); + void set_min(const PoolRealArray &p_min); - Vector get_max(); - void set_max(Vector p_max); + PoolRealArray get_max(); + void set_max(const PoolRealArray &p_max); int get_sparse_count(); void set_sparse_count(int p_sparse_count); diff --git a/modules/gltf/structures/gltf_buffer_view.cpp b/modules/gltf/structures/gltf_buffer_view.cpp index ba19ed862..a15141225 100644 --- a/modules/gltf/structures/gltf_buffer_view.cpp +++ b/modules/gltf/structures/gltf_buffer_view.cpp @@ -30,8 +30,6 @@ #include "gltf_buffer_view.h" -#include "../gltf_document_extension.h" - void GLTFBufferView::_bind_methods() { ClassDB::bind_method(D_METHOD("get_buffer"), &GLTFBufferView::get_buffer); ClassDB::bind_method(D_METHOD("set_buffer", "buffer"), &GLTFBufferView::set_buffer); diff --git a/modules/gltf/structures/gltf_mesh.cpp b/modules/gltf/structures/gltf_mesh.cpp index 3add8304b..924099727 100644 --- a/modules/gltf/structures/gltf_mesh.cpp +++ b/modules/gltf/structures/gltf_mesh.cpp @@ -41,7 +41,7 @@ void GLTFMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("set_instance_materials", "instance_materials"), &GLTFMesh::set_instance_materials); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "blend_weights"), "set_blend_weights", "get_blend_weights"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "blend_weights"), "set_blend_weights", "get_blend_weights"); // Vector ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "instance_materials"), "set_instance_materials", "get_instance_materials"); } diff --git a/modules/gltf/structures/gltf_skeleton.h b/modules/gltf/structures/gltf_skeleton.h index ea7783b04..29708940b 100644 --- a/modules/gltf/structures/gltf_skeleton.h +++ b/modules/gltf/structures/gltf_skeleton.h @@ -33,6 +33,7 @@ #include "../gltf_defines.h" #include "core/resource.h" +#include "core/hash_set.h" class GLTFSkeleton : public Resource { GDCLASS(GLTFSkeleton, Resource); diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp index 72611534e..c2c59a149 100644 --- a/modules/gltf/structures/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -133,10 +133,10 @@ void GLTFSkin::set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i) { Dictionary GLTFSkin::get_joint_i_to_name() { Dictionary ret; - HashMap::Iterator elem = joint_i_to_name.begin(); - while (elem) { - ret[elem->key] = String(elem->value); - ++elem; + + const int *key = NULL; + while ((key = joint_i_to_name.next(key))) { + ret[*key] = String(joint_i_to_name[*key]); } return ret; }