From 3890256fc57eafb2db83d328b8caf772188e21d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 16 Jan 2017 08:04:19 +0100 Subject: Style: Cleanups, added headers, renamed files Made sure files in core/ and tools/ have a proper Godot license header when written by us. Also renamed aabb.{cpp,h} and object_type_db.{cpp,h} to rect3.{cpp,h} and class_db.{cpp,h} respectively. Also added a proper header to core/io/base64.{c,h} after clarifying the licensing with the original author (public domain). --- core/array.cpp | 1 + core/class_db.cpp | 1299 ++++++++++++++++++++ core/class_db.h | 541 ++++++++ core/color.cpp | 1 + core/command_queue_mt.cpp | 1 + core/compressed_translation.cpp | 1 + core/dictionary.cpp | 1 + core/engine.cpp | 1 + core/error_macros.cpp | 1 + core/global_constants.cpp | 1 + core/globals.cpp | 3 +- core/image.cpp | 2 + core/input_map.cpp | 1 + core/io/base64.c | 8 + core/io/base64.h | 8 + core/io/networked_multiplayer_peer.cpp | 28 + core/io/networked_multiplayer_peer.h | 28 + core/io/pck_packer.cpp | 2 +- core/math/a_star.cpp | 2 +- core/math/aabb.cpp | 418 ------- core/math/aabb.h | 395 ------ core/math/bsp_tree.h | 2 +- core/math/face3.h | 2 +- core/math/octree.h | 2 +- core/math/quick_hull.h | 2 +- core/math/rect3.cpp | 418 +++++++ core/math/rect3.h | 395 ++++++ core/math/transform.h | 2 +- core/message_queue.cpp | 2 + core/object.cpp | 3 +- core/object.h | 2 +- core/object_type_db.cpp | 1298 ------------------- core/object_type_db.h | 540 -------- core/packed_data_container.cpp | 2 +- core/path_db.cpp | 2 +- core/path_remap.cpp | 2 + core/pool_allocator.cpp | 3 + core/print_string.cpp | 2 + core/ref_ptr.cpp | 1 + core/reference.cpp | 1 + core/reference.h | 2 +- core/register_core_types.cpp | 2 +- core/resource.cpp | 4 +- core/resource.h | 2 +- core/script_debugger_local.cpp | 1 + core/script_debugger_remote.cpp | 2 + core/string_db.cpp | 2 + core/translation.cpp | 1 + core/undo_redo.cpp | 1 + core/ustring.cpp | 10 +- core/variant.cpp | 1 + core/variant.h | 2 +- core/variant_call.cpp | 1 + core/variant_op.cpp | 2 + core/variant_parser.cpp | 2 +- modules/gdscript/gd_functions.cpp | 2 +- modules/gridmap/register_types.cpp | 2 +- modules/regex/register_types.cpp | 2 +- .../visual_script/visual_script_builtin_funcs.cpp | 2 +- scene/main/node.h | 2 +- scene/register_scene_types.cpp | 2 +- servers/physics/broad_phase_sw.h | 2 +- tools/collada/collada.cpp | 1 + tools/doc/doc_data.cpp | 2 +- tools/doc/doc_dump.cpp | 3 +- tools/doc/doc_dump.h | 2 +- tools/editor/animation_editor.cpp | 1 + tools/editor/asset_library_editor_plugin.cpp | 2 +- tools/editor/call_dialog.cpp | 2 +- tools/editor/code_editor.cpp | 1 + tools/editor/connections_dialog.cpp | 3 - tools/editor/create_dialog.cpp | 2 +- tools/editor/dependency_editor.cpp | 1 + tools/editor/editor_asset_installer.cpp | 2 + tools/editor/editor_autoload_settings.cpp | 2 - tools/editor/editor_data.cpp | 1 + tools/editor/editor_dir_dialog.cpp | 1 + tools/editor/editor_file_dialog.cpp | 2 + tools/editor/editor_file_system.cpp | 1 + tools/editor/editor_fonts.cpp | 1 + tools/editor/editor_help.cpp | 4 +- tools/editor/editor_import_export.cpp | 3 +- tools/editor/editor_initialize_ssl.cpp | 1 + tools/editor/editor_log.cpp | 3 +- tools/editor/editor_name_dialog.cpp | 4 +- tools/editor/editor_node.cpp | 33 +- tools/editor/editor_path.cpp | 1 + tools/editor/editor_plugin.cpp | 1 + tools/editor/editor_plugin_settings.cpp | 1 + tools/editor/editor_profiler.cpp | 29 + tools/editor/editor_profiler.h | 28 + tools/editor/editor_reimport_dialog.cpp | 2 + tools/editor/editor_resource_preview.cpp | 1 + tools/editor/editor_run.cpp | 1 + tools/editor/editor_run_native.cpp | 2 +- tools/editor/editor_run_script.cpp | 5 +- tools/editor/editor_scale.cpp | 29 + tools/editor/editor_scale.h | 28 + tools/editor/editor_settings.cpp | 5 +- tools/editor/editor_sub_scene.cpp | 3 +- tools/editor/editor_themes.cpp | 4 +- tools/editor/editor_themes.h | 2 +- tools/editor/file_type_cache.cpp | 2 +- tools/editor/fileserver/editor_file_server.cpp | 1 + tools/editor/filesystem_dock.cpp | 5 +- tools/editor/filesystem_dock.h | 2 +- tools/editor/groups_editor.cpp | 1 + tools/editor/io_plugins/editor_atlas.cpp | 1 + .../io_plugins/editor_bitmask_import_plugin.cpp | 29 + .../io_plugins/editor_bitmask_import_plugin.h | 28 + tools/editor/io_plugins/editor_export_scene.cpp | 1 + .../io_plugins/editor_font_import_plugin.cpp | 4 +- tools/editor/io_plugins/editor_import_collada.cpp | 1 + .../io_plugins/editor_sample_import_plugin.cpp | 2 +- .../io_plugins/editor_scene_import_plugin.cpp | 1 + .../io_plugins/editor_scene_importer_fbxconv.cpp | 1 + .../io_plugins/editor_texture_import_plugin.cpp | 1 + .../editor_translation_import_plugin.cpp | 1 + tools/editor/multi_node_edit.cpp | 1 + tools/editor/node_dock.cpp | 29 + tools/editor/node_dock.h | 28 + .../plugins/animation_player_editor_plugin.cpp | 1 + tools/editor/plugins/baked_light_baker.cpp | 1 + tools/editor/plugins/baked_light_editor_plugin.cpp | 1 + tools/editor/plugins/camera_editor_plugin.cpp | 1 + tools/editor/plugins/canvas_item_editor_plugin.cpp | 1 + .../plugins/collision_polygon_editor_plugin.cpp | 1 + .../plugins/collision_shape_2d_editor_plugin.cpp | 1 - tools/editor/plugins/color_ramp_editor_plugin.cpp | 1 + tools/editor/plugins/editor_preview_plugins.cpp | 1 + tools/editor/plugins/gi_probe_editor_plugin.cpp | 28 + tools/editor/plugins/gi_probe_editor_plugin.h | 28 + tools/editor/plugins/material_editor_plugin.cpp | 29 + tools/editor/plugins/material_editor_plugin.h | 28 + .../editor/plugins/mesh_instance_editor_plugin.cpp | 28 + tools/editor/plugins/mesh_instance_editor_plugin.h | 28 + tools/editor/plugins/multimesh_editor_plugin.cpp | 1 + .../editor/plugins/particles_2d_editor_plugin.cpp | 2 +- tools/editor/plugins/path_editor_plugin.cpp | 1 + tools/editor/plugins/polygon_2d_editor_plugin.cpp | 2 +- .../plugins/resource_preloader_editor_plugin.cpp | 3 +- tools/editor/plugins/rich_text_editor_plugin.cpp | 1 + tools/editor/plugins/sample_editor_plugin.cpp | 1 + .../plugins/sample_library_editor_plugin.cpp | 1 + tools/editor/plugins/script_editor_plugin.cpp | 1 + tools/editor/plugins/script_text_editor.cpp | 1 + tools/editor/plugins/shader_editor_plugin.cpp | 2 +- tools/editor/plugins/spatial_editor_plugin.cpp | 2 +- tools/editor/plugins/texture_editor_plugin.cpp | 28 + tools/editor/plugins/texture_editor_plugin.h | 28 + .../plugins/texture_region_editor_plugin.cpp | 4 +- .../editor/plugins/texture_region_editor_plugin.h | 2 +- tools/editor/plugins/theme_editor_plugin.cpp | 3 +- tools/editor/plugins/tile_map_editor_plugin.cpp | 2 - tools/editor/plugins/tile_set_editor_plugin.cpp | 2 + tools/editor/progress_dialog.cpp | 2 + tools/editor/project_export.cpp | 2 - tools/editor/project_manager.cpp | 7 +- tools/editor/project_settings.cpp | 1 + tools/editor/property_editor.cpp | 3 +- tools/editor/property_selector.cpp | 30 +- tools/editor/property_selector.h | 28 + tools/editor/pvrtc_compress.cpp | 2 + tools/editor/quick_open.cpp | 2 +- tools/editor/reparent_dialog.cpp | 2 - tools/editor/resources_dock.cpp | 1 + tools/editor/scene_tree_dock.cpp | 1 + tools/editor/scene_tree_editor.cpp | 2 +- tools/editor/script_create_dialog.cpp | 1 + tools/editor/script_editor_debugger.cpp | 1 + tools/editor/settings_config_dialog.cpp | 1 + tools/editor/spatial_editor_gizmos.cpp | 1 + 172 files changed, 3424 insertions(+), 2760 deletions(-) create mode 100644 core/class_db.cpp create mode 100644 core/class_db.h delete mode 100644 core/math/aabb.cpp delete mode 100644 core/math/aabb.h create mode 100644 core/math/rect3.cpp create mode 100644 core/math/rect3.h delete mode 100644 core/object_type_db.cpp delete mode 100644 core/object_type_db.h diff --git a/core/array.cpp b/core/array.cpp index b9c8f543da..16598a044d 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "array.h" + #include "vector.h" #include "hashfuncs.h" #include "variant.h" diff --git a/core/class_db.cpp b/core/class_db.cpp new file mode 100644 index 0000000000..bb3368c128 --- /dev/null +++ b/core/class_db.cpp @@ -0,0 +1,1299 @@ +/*************************************************************************/ +/* class_db.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "class_db.h" + +#include "os/mutex.h" + +#ifdef NO_THREADS + +#define OBJTYPE_RLOCK + +#else + +#define OBJTYPE_RLOCK RWLockRead _rw_lockr_(lock); +#define OBJTYPE_WLOCK RWLockWrite _rw_lockw_(lock); + +#endif + +#ifdef DEBUG_METHODS_ENABLED + +ParamDef::ParamDef(const Variant& p_variant) { used=true; val=p_variant; } + + +MethodDefinition _MD(const char* p_name) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.push_back(StaticCString::create(p_arg1)); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(2); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(3); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(4); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(5); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + md.args[4]=StaticCString::create(p_arg5); + return md; +} + + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(6); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + md.args[4]=StaticCString::create(p_arg5); + md.args[5]=StaticCString::create(p_arg6); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(7); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + md.args[4]=StaticCString::create(p_arg5); + md.args[5]=StaticCString::create(p_arg6); + md.args[6]=StaticCString::create(p_arg7); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(8); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + md.args[4]=StaticCString::create(p_arg5); + md.args[5]=StaticCString::create(p_arg6); + md.args[6]=StaticCString::create(p_arg7); + md.args[7]=StaticCString::create(p_arg8); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(9); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + md.args[4]=StaticCString::create(p_arg5); + md.args[5]=StaticCString::create(p_arg6); + md.args[6]=StaticCString::create(p_arg7); + md.args[7]=StaticCString::create(p_arg8); + md.args[8]=StaticCString::create(p_arg9); + return md; +} + +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10) { + + MethodDefinition md; + md.name=StaticCString::create(p_name); + md.args.resize(10); + md.args[0]=StaticCString::create(p_arg1); + md.args[1]=StaticCString::create(p_arg2); + md.args[2]=StaticCString::create(p_arg3); + md.args[3]=StaticCString::create(p_arg4); + md.args[4]=StaticCString::create(p_arg5); + md.args[5]=StaticCString::create(p_arg6); + md.args[6]=StaticCString::create(p_arg7); + md.args[7]=StaticCString::create(p_arg8); + md.args[8]=StaticCString::create(p_arg9); + md.args[9]=StaticCString::create(p_arg10); + return md; +} + + +#endif + + +ClassDB::APIType ClassDB::current_api=API_CORE; + +void ClassDB::set_current_api(APIType p_api) { + + current_api=p_api; +} + +HashMap ClassDB::classes; +HashMap ClassDB::resource_base_extensions; +HashMap ClassDB::compat_classes; + +ClassDB::ClassInfo::ClassInfo() { + + creation_func=NULL; + inherits_ptr=NULL; + disabled=false; +} +ClassDB::ClassInfo::~ClassInfo() { + + +} + + +bool ClassDB::is_parent_class(const StringName &p_class,const StringName& p_inherits) { + + OBJTYPE_RLOCK; + + StringName inherits=p_class; + + while (inherits.operator String().length()) { + + if (inherits==p_inherits) + return true; + inherits=get_parent_class(inherits); + } + + return false; +} +void ClassDB::get_class_list( List *p_classes) { + + OBJTYPE_RLOCK; + + const StringName *k=NULL; + + while((k=classes.next(k))) { + + p_classes->push_back(*k); + } + + p_classes->sort(); +} + + +void ClassDB::get_inheriters_from_class( const StringName& p_class,List *p_classes) { + + OBJTYPE_RLOCK; + + const StringName *k=NULL; + + while((k=classes.next(k))) { + + if (*k!=p_class && is_parent_class(*k,p_class)) + p_classes->push_back(*k); + } + +} + +StringName ClassDB::get_parent_class_nocheck(const StringName& p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + if (!ti) + return StringName(); + return ti->inherits; + +} + +StringName ClassDB::get_parent_class(const StringName& p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + ERR_FAIL_COND_V(!ti,StringName()); + return ti->inherits; +} + +ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + + ERR_FAIL_COND_V(!ti,API_NONE); + return ti->api; +} + +uint64_t ClassDB::get_api_hash(APIType p_api) { + + OBJTYPE_RLOCK; +#ifdef DEBUG_METHODS_ENABLED + + uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME)); + + List names; + + const StringName *k=NULL; + + while((k=classes.next(k))) { + + names.push_back(*k); + } + //must be alphabetically sorted for hash to compute + names.sort_custom(); + + for (List::Element *E=names.front();E;E=E->next()) { + + ClassInfo *t = classes.getptr(E->get()); + ERR_FAIL_COND_V(!t,0); + if (t->api!=p_api) + continue; + hash = hash_djb2_one_64(t->name.hash(),hash); + hash = hash_djb2_one_64(t->inherits.hash(),hash); + + { //methods + + List snames; + + k=NULL; + + while((k=t->method_map.next(k))) { + + snames.push_back(*k); + } + + snames.sort_custom(); + + for (List::Element *F=snames.front();F;F=F->next()) { + + MethodBind *mb = t->method_map[F->get()]; + hash = hash_djb2_one_64( mb->get_name().hash(), hash); + hash = hash_djb2_one_64( mb->get_argument_count(), hash); + hash = hash_djb2_one_64( mb->get_argument_type(-1), hash); //return + + for(int i=0;iget_argument_count();i++) { + hash = hash_djb2_one_64( mb->get_argument_info(i).type, hash ); + hash = hash_djb2_one_64( mb->get_argument_info(i).name.hash(), hash ); + hash = hash_djb2_one_64( mb->get_argument_info(i).hint, hash ); + hash = hash_djb2_one_64( mb->get_argument_info(i).hint_string.hash(), hash ); + } + + hash = hash_djb2_one_64( mb->get_default_argument_count(), hash); + + for(int i=0;iget_default_argument_count();i++) { + //hash should not change, i hope for tis + Variant da = mb->get_default_argument(i); + hash = hash_djb2_one_64( da.hash(), hash ); + } + + hash = hash_djb2_one_64( mb->get_hint_flags(), hash); + + } + } + + + { //constants + + List snames; + + k=NULL; + + while((k=t->constant_map.next(k))) { + + snames.push_back(*k); + } + + snames.sort_custom(); + + for (List::Element *F=snames.front();F;F=F->next()) { + + hash = hash_djb2_one_64(F->get().hash(), hash); + hash = hash_djb2_one_64( t->constant_map[F->get()], hash); + } + } + + + { //signals + + List snames; + + k=NULL; + + while((k=t->signal_map.next(k))) { + + snames.push_back(*k); + } + + snames.sort_custom(); + + for (List::Element *F=snames.front();F;F=F->next()) { + + MethodInfo &mi = t->signal_map[F->get()]; + hash = hash_djb2_one_64( F->get().hash(), hash); + for(int i=0;i snames; + + k=NULL; + + while((k=t->property_setget.next(k))) { + + snames.push_back(*k); + } + + snames.sort_custom(); + + for (List::Element *F=snames.front();F;F=F->next()) { + + PropertySetGet *psg=t->property_setget.getptr(F->get()); + + hash = hash_djb2_one_64( F->get().hash(), hash); + hash = hash_djb2_one_64( psg->setter.hash(), hash); + hash = hash_djb2_one_64( psg->getter.hash(), hash); + + } + } + + //property list + for (List::Element *F=t->property_list.front();F;F=F->next()) { + + hash = hash_djb2_one_64( F->get().name.hash(), hash); + hash = hash_djb2_one_64( F->get().type, hash); + hash = hash_djb2_one_64( F->get().hint, hash); + hash = hash_djb2_one_64( F->get().hint_string.hash(), hash); + hash = hash_djb2_one_64( F->get().usage, hash); + } + + + } + + + return hash; +#else + return 0; +#endif + +} + +bool ClassDB::class_exists(const StringName &p_class) { + + OBJTYPE_RLOCK; + return classes.has(p_class); +} + +void ClassDB::add_compatibility_class(const StringName& p_class,const StringName& p_fallback) { + + OBJTYPE_WLOCK; + compat_classes[p_class]=p_fallback; +} + +Object *ClassDB::instance(const StringName &p_class) { + + ClassInfo *ti; + { + OBJTYPE_RLOCK; + ti=classes.getptr(p_class); + if (!ti || ti->disabled || !ti->creation_func) { + if (compat_classes.has(p_class)) { + ti=classes.getptr(compat_classes[p_class]); + } + } + ERR_FAIL_COND_V(!ti,NULL); + ERR_FAIL_COND_V(ti->disabled,NULL); + ERR_FAIL_COND_V(!ti->creation_func,NULL); + } + + return ti->creation_func(); +} +bool ClassDB::can_instance(const StringName &p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + ERR_FAIL_COND_V(!ti,false); + return (!ti->disabled && ti->creation_func!=NULL); +} + + +void ClassDB::_add_class2(const StringName& p_class, const StringName& p_inherits) { + + OBJTYPE_WLOCK; + + StringName name = p_class; + + ERR_FAIL_COND(classes.has(name)); + + classes[name]=ClassInfo(); + ClassInfo &ti=classes[name]; + ti.name=name; + ti.inherits=p_inherits; + ti.api=current_api; + + if (ti.inherits) { + + ERR_FAIL_COND( !classes.has(ti.inherits) ); //it MUST be registered. + ti.inherits_ptr = &classes[ti.inherits]; + + } else { + ti.inherits_ptr=NULL; + } + + +} + +void ClassDB::get_method_list(StringName p_class,List *p_methods,bool p_no_inheritance) { + + + OBJTYPE_RLOCK; + + ClassInfo *type=classes.getptr(p_class); + + while(type) { + + if (type->disabled) { + + if (p_no_inheritance) + break; + + type=type->inherits_ptr; + continue; + } + +#ifdef DEBUG_METHODS_ENABLED + + for( List::Element *E=type->virtual_methods.front();E;E=E->next()) { + + p_methods->push_back(E->get()); + } + + for( List::Element *E=type->method_order.front();E;E=E->next()) { + + MethodBind *method=type->method_map.get(E->get()); + MethodInfo minfo; + minfo.name=E->get(); + minfo.id=method->get_method_id(); + + for (int i=0;iget_argument_count();i++) { + + //Variant::Type t=method->get_argument_type(i); + + minfo.arguments.push_back(method->get_argument_info(i)); + } + + + if (method->get_argument_type(-1)!=Variant::NIL) { + minfo.return_val=method->get_argument_info(-1); + } + + minfo.flags=method->get_hint_flags(); + p_methods->push_back(minfo); + } + + + +#else + + const StringName *K=NULL; + + while((K=type->method_map.next(K))) { + + MethodBind*m = type->method_map[*K]; + MethodInfo mi; + mi.name=m->get_name(); + p_methods->push_back(mi); + } + + +#endif + + if (p_no_inheritance) + break; + + type=type->inherits_ptr; + } + +} + + +MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { + + OBJTYPE_RLOCK; + + ClassInfo *type=classes.getptr(p_class); + + while(type) { + + MethodBind **method=type->method_map.getptr(p_name); + if (method && *method) + return *method; + type=type->inherits_ptr; + } + return NULL; +} + + +void ClassDB::bind_integer_constant(const StringName& p_class, const StringName &p_name, int p_constant) { + + OBJTYPE_WLOCK; + + ClassInfo *type=classes.getptr(p_class); + if (!type) { + + ERR_FAIL_COND(!type); + } + + if (type->constant_map.has(p_name)) { + + ERR_FAIL(); + } + + type->constant_map[p_name]=p_constant; +#ifdef DEBUG_METHODS_ENABLED + type->constant_order.push_back(p_name); +#endif + +} + +void ClassDB::get_integer_constant_list(const StringName& p_class, List *p_constants, bool p_no_inheritance) { + + OBJTYPE_RLOCK; + + ClassInfo *type=classes.getptr(p_class); + + while(type) { + +#ifdef DEBUG_METHODS_ENABLED + for(List::Element *E=type->constant_order.front();E;E=E->next()) + p_constants->push_back(E->get()); +#else + const StringName *K=NULL; + + while((K=type->constant_map.next(K))) { + p_constants->push_back(*K); + } + +#endif + if (p_no_inheritance) + break; + + type=type->inherits_ptr; + } + +} + + +int ClassDB::get_integer_constant(const StringName& p_class, const StringName &p_name, bool *p_success) { + + OBJTYPE_RLOCK; + + + ClassInfo *type=classes.getptr(p_class); + + while(type) { + + + int *constant=type->constant_map.getptr(p_name); + if (constant) { + + if (p_success) + *p_success=true; + return *constant; + } + + type=type->inherits_ptr; + } + + if (p_success) + *p_success=false; + + return 0; +} + +void ClassDB::add_signal(StringName p_class,const MethodInfo& p_signal) { + + OBJTYPE_WLOCK; + + ClassInfo *type=classes.getptr(p_class); + ERR_FAIL_COND(!type); + + ClassInfo *check=type; + StringName sname = p_signal.name; +#ifdef DEBUG_METHODS_ENABLED + + while(check) { + if (check->signal_map.has(sname)) { + ERR_EXPLAIN("Type "+String(p_class)+" already has signal: "+String(sname)); + ERR_FAIL(); + } + check=check->inherits_ptr; + } +#endif + + type->signal_map[sname]=p_signal; + +} + +void ClassDB::get_signal_list(StringName p_class,List *p_signals,bool p_no_inheritance) { + + OBJTYPE_RLOCK; + + ClassInfo *type=classes.getptr(p_class); + ERR_FAIL_COND(!type); + + ClassInfo *check=type; + + while(check) { + + const StringName *S=NULL; + while((S=check->signal_map.next(S))) { + + p_signals->push_back(check->signal_map[*S]); + } + + if (p_no_inheritance) + return; + + check=check->inherits_ptr; + } + + +} + +bool ClassDB::has_signal(StringName p_class,StringName p_signal) { + + OBJTYPE_RLOCK; + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + if (check->signal_map.has(p_signal)) + return true; + check=check->inherits_ptr; + } + + return false; +} + +bool ClassDB::get_signal(StringName p_class,StringName p_signal,MethodInfo *r_signal) { + + OBJTYPE_RLOCK; + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + if (check->signal_map.has(p_signal)) { + if (r_signal) { + *r_signal=check->signal_map[p_signal]; + } + return true; + } + check=check->inherits_ptr; + } + + return false; +} + + +void ClassDB::add_property_group(StringName p_class,const String& p_name,const String& p_prefix) { + + OBJTYPE_WLOCK; + ClassInfo *type=classes.getptr(p_class); + ERR_FAIL_COND(!type); + + type->property_list.push_back(PropertyInfo(Variant::NIL,p_name,PROPERTY_HINT_NONE,p_prefix,PROPERTY_USAGE_GROUP)); +} + +void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index) { + + + + lock->read_lock(); + + ClassInfo *type=classes.getptr(p_class); + + lock->read_unlock(); + + ERR_FAIL_COND(!type); + + MethodBind *mb_set=NULL; + if (p_setter) { + mb_set = get_method(p_class,p_setter); +#ifdef DEBUG_METHODS_ENABLED + if (!mb_set) { + ERR_EXPLAIN("Invalid Setter: "+p_class+"::"+p_setter+" for property: "+p_pinfo.name); + ERR_FAIL_COND(!mb_set); + } else { + int exp_args=1+(p_index>=0?1:0); + if (mb_set->get_argument_count()!=exp_args) { + ERR_EXPLAIN("Invalid Function for Setter: "+p_class+"::"+p_setter+" for property: "+p_pinfo.name); + ERR_FAIL(); + + } + } +#endif + } + + MethodBind *mb_get=NULL; + if (p_getter) { + + MethodBind *mb_get = get_method(p_class,p_getter); +#ifdef DEBUG_METHODS_ENABLED + + if (!mb_get) { + ERR_EXPLAIN("Invalid Getter: "+p_class+"::"+p_getter+" for property: "+p_pinfo.name); + ERR_FAIL_COND(!mb_get); + } else { + + int exp_args=0+(p_index>=0?1:0); + if (mb_get->get_argument_count()!=exp_args) { + ERR_EXPLAIN("Invalid Function for Getter: "+p_class+"::"+p_getter+" for property: "+p_pinfo.name); + ERR_FAIL(); + + } + + } +#endif + } + + + +#ifdef DEBUG_METHODS_ENABLED + + if (type->property_setget.has(p_pinfo.name)) { + ERR_EXPLAIN("Object already has property: "+p_class); + ERR_FAIL(); + } +#endif + + OBJTYPE_WLOCK + + type->property_list.push_back(p_pinfo); + + PropertySetGet psg; + psg.setter=p_setter; + psg.getter=p_getter; + psg._setptr=mb_set; + psg._getptr=mb_get; + psg.index=p_index; + psg.type=p_pinfo.type; + + type->property_setget[p_pinfo.name]=psg; + +} + + +void ClassDB::get_property_list(StringName p_class, List *p_list, bool p_no_inheritance,const Object *p_validator) { + + OBJTYPE_RLOCK; + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + + for(List::Element *E=check->property_list.front();E;E=E->next()) { + + + if (p_validator) { + PropertyInfo pi = E->get(); + p_validator->_validate_property(pi); + p_list->push_back(pi); + } else { + p_list->push_back(E->get()); + } + } + + if (p_no_inheritance) + return ; + check=check->inherits_ptr; + } + +} +bool ClassDB::set_property(Object* p_object,const StringName& p_property, const Variant& p_value,bool *r_valid) { + + + + ClassInfo *type=classes.getptr(p_object->get_class_name()); + ClassInfo *check=type; + while(check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + + if (!psg->setter) { + if (r_valid) + *r_valid=false; + return true; //return true but do nothing + } + + Variant::CallError ce; + + if (psg->index>=0) { + Variant index=psg->index; + const Variant* arg[2]={&index,&p_value}; + //p_object->call(psg->setter,arg,2,ce); + if (psg->_setptr) { + psg->_setptr->call(p_object,arg,2,ce); + } else { + p_object->call(psg->setter,arg,2,ce); + } + + + } else { + const Variant* arg[1]={&p_value}; + if (psg->_setptr) { + psg->_setptr->call(p_object,arg,1,ce); + } else { + p_object->call(psg->setter,arg,1,ce); + } + } + + if (r_valid) + *r_valid=ce.error==Variant::CallError::CALL_OK; + + return true; + } + + check=check->inherits_ptr; + } + + return false; +} +bool ClassDB::get_property(Object* p_object,const StringName& p_property, Variant& r_value) { + + ClassInfo *type=classes.getptr(p_object->get_class_name()); + ClassInfo *check=type; + while(check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + if (!psg->getter) + return true; //return true but do nothing + + if (psg->index>=0) { + Variant index=psg->index; + const Variant* arg[1]={&index}; + Variant::CallError ce; + r_value = p_object->call(psg->getter,arg,1,ce); + + } else { + + Variant::CallError ce; + if (psg->_getptr) { + + r_value = psg->_getptr->call(p_object,NULL,0,ce); + } else { + r_value = p_object->call(psg->getter,NULL,0,ce); + } + } + return true; + } + + const int *c =check->constant_map.getptr(p_property); + if (c) { + + r_value=*c; + return true; + } + //if (check->constant_map.fin) + + check=check->inherits_ptr; + } + + return false; +} + +Variant::Type ClassDB::get_property_type(const StringName& p_class, const StringName& p_property,bool *r_is_valid) { + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + + if (r_is_valid) + *r_is_valid=true; + + return psg->type; + } + + check=check->inherits_ptr; + } + if (r_is_valid) + *r_is_valid=false; + + return Variant::NIL; + +} + +StringName ClassDB::get_property_setter(StringName p_class,const StringName p_property) { + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + + return psg->setter; + } + + check=check->inherits_ptr; + } + + return StringName(); +} + +StringName ClassDB::get_property_getter(StringName p_class,const StringName p_property) { + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + const PropertySetGet *psg = check->property_setget.getptr(p_property); + if (psg) { + + return psg->getter; + } + + check=check->inherits_ptr; + } + + return StringName(); +} + +bool ClassDB::has_property(const StringName& p_class, const StringName& p_property, bool p_no_inheritance) { + + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + if (check->property_setget.has(p_property)) + return true; + + if (p_no_inheritance) + break; + check=check->inherits_ptr; + } + + return false; +} + +void ClassDB::set_method_flags(StringName p_class,StringName p_method,int p_flags) { + + OBJTYPE_WLOCK; + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + ERR_FAIL_COND(!check); + ERR_FAIL_COND(!check->method_map.has(p_method)); + check->method_map[p_method]->set_hint_flags(p_flags); + + +} + +bool ClassDB::has_method(StringName p_class,StringName p_method,bool p_no_inheritance) { + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + if (check->method_map.has(p_method)) + return true; + if (p_no_inheritance) + return false; + check=check->inherits_ptr; + } + + return false; + +} + +bool ClassDB::get_setter_and_type_for_property(const StringName& p_class, const StringName& p_prop, StringName& r_class, StringName& r_setter) { + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + + if (check->property_setget.has(p_prop)) { + r_class=check->name; + r_setter=check->property_setget[p_prop].setter; + return true; + } + + check=check->inherits_ptr; + } + + return false; + +} + +#ifdef DEBUG_METHODS_ENABLED +MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) { + StringName mdname=method_name.name; +#else +MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const char *method_name, const Variant **p_defs, int p_defcount) { + StringName mdname=StaticCString::create(method_name); +#endif + + + StringName rettype; + if (mdname.operator String().find(":")!=-1) { + rettype = mdname.operator String().get_slice(":",1); + mdname = mdname.operator String().get_slice(":",0); + } + + + OBJTYPE_WLOCK; + ERR_FAIL_COND_V(!p_bind,NULL); + p_bind->set_name(mdname); + + String instance_type=p_bind->get_instance_class(); + +#ifdef DEBUG_ENABLED + + if (has_method(instance_type,mdname)) { + ERR_EXPLAIN("Class "+String(instance_type)+" already has a method "+String(mdname)); + ERR_FAIL_V(NULL); + } +#endif + + + ClassInfo *type=classes.getptr(instance_type); + if (!type) { + ERR_PRINTS("Couldn't bind method '"+mdname+"' for instance: "+instance_type); + memdelete(p_bind); + ERR_FAIL_COND_V(!type,NULL); + } + + if (type->method_map.has(mdname)) { + memdelete(p_bind); + // overloading not supported + ERR_EXPLAIN("Method already bound: "+instance_type+"::"+mdname); + ERR_FAIL_V(NULL); + } +#ifdef DEBUG_METHODS_ENABLED + p_bind->set_argument_names(method_name.args); + p_bind->set_return_type(rettype); + type->method_order.push_back(mdname); +#endif + type->method_map[mdname]=p_bind; + + + Vector defvals; + + defvals.resize(p_defcount); + for(int i=0;iset_default_arguments(defvals); + p_bind->set_hint_flags(p_flags); + return p_bind; + +} + +void ClassDB::add_virtual_method(const StringName& p_class, const MethodInfo& p_method , bool p_virtual) { + ERR_FAIL_COND(!classes.has(p_class)); + + OBJTYPE_WLOCK; + +#ifdef DEBUG_METHODS_ENABLED + MethodInfo mi=p_method; + if (p_virtual) + mi.flags|=METHOD_FLAG_VIRTUAL; + classes[p_class].virtual_methods.push_back(mi); + +#endif + +} + +void ClassDB::get_virtual_methods(const StringName& p_class, List * p_methods , bool p_no_inheritance) { + + ERR_FAIL_COND(!classes.has(p_class)); + +#ifdef DEBUG_METHODS_ENABLED + + ClassInfo *type=classes.getptr(p_class); + ClassInfo *check=type; + while(check) { + + for(List::Element *E=check->virtual_methods.front();E;E=E->next()) { + p_methods->push_back(E->get()); + } + + if (p_no_inheritance) + return; + check=check->inherits_ptr; + } + +#endif + +} + +void ClassDB::set_class_enabled(StringName p_class,bool p_enable) { + + OBJTYPE_WLOCK; + + ERR_FAIL_COND(!classes.has(p_class)); + classes[p_class].disabled=!p_enable; +} + +bool ClassDB::is_class_enabled(StringName p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti=classes.getptr(p_class); + if (!ti || !ti->creation_func) { + if (compat_classes.has(p_class)) { + ti=classes.getptr(compat_classes[p_class]); + } + } + + ERR_FAIL_COND_V(!ti,false); + return !ti->disabled; +} + +StringName ClassDB::get_category(const StringName& p_node) { + + ERR_FAIL_COND_V(!classes.has(p_node),StringName()); +#ifdef DEBUG_ENABLED + return classes[p_node].category; +#else + return StringName(); +#endif +} + +void ClassDB::add_resource_base_extension(const StringName& p_extension,const StringName& p_class) { + + if (resource_base_extensions.has(p_extension)) + return; + + resource_base_extensions[p_extension]=p_class; +} + +void ClassDB::get_resource_base_extensions(List *p_extensions) { + + const StringName *K=NULL; + + while((K=resource_base_extensions.next(K))) { + + p_extensions->push_back(*K); + } +} + +void ClassDB::get_extensions_for_type(const StringName& p_class,List *p_extensions) { + + const StringName *K=NULL; + + while((K=resource_base_extensions.next(K))) { + StringName cmp = resource_base_extensions[*K]; + if (is_parent_class(cmp,p_class)) + p_extensions->push_back(*K); + } +} + + +RWLock *ClassDB::lock=NULL; + +void ClassDB::init() { + +#ifndef NO_THREADS + + lock = RWLock::create(); +#endif +} + +void ClassDB::cleanup() { + + + + //OBJTYPE_LOCK; hah not here + + const StringName *k=NULL; + + while((k=classes.next(k))) { + + ClassInfo &ti=classes[*k]; + + const StringName *m=NULL; + while((m=ti.method_map.next(m))) { + + memdelete( ti.method_map[*m] ); + } + } + classes.clear(); + resource_base_extensions.clear(); + compat_classes.clear(); + +#ifndef NO_THREADS + + memdelete(lock); +#endif + +} + +// diff --git a/core/class_db.h b/core/class_db.h new file mode 100644 index 0000000000..a09a42423b --- /dev/null +++ b/core/class_db.h @@ -0,0 +1,541 @@ +/*************************************************************************/ +/* class_db.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef CLASS_DB_H +#define CLASS_DB_H + +#include "object.h" +#include "method_bind.h" +#include "print_string.h" + +/** + @author Juan Linietsky +*/ + +struct ParamHint { + + String name; + PropertyHint hint; + String hint_text; + Variant default_val; + + ParamHint(const String& p_name="", PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_text="",Variant p_default_val=Variant()) { + + name=p_name; + hint=p_hint; + hint_text=p_hint_text; + default_val=p_default_val; + } + +}; + +struct ParamDef { + bool used; + Variant val; + _FORCE_INLINE_ ParamDef() { used=false; } + ParamDef(const Variant& p_variant); +}; + +//#define DEFVAL( m_defval ) ParamDef(m_defval) +#define DEFVAL( m_defval ) (m_defval) + + +//#define SIMPLE_METHODDEF + +#ifdef DEBUG_METHODS_ENABLED + +struct MethodDefinition { + + + StringName name; + Vector args; + MethodDefinition() {} + MethodDefinition(const char *p_name) { name=p_name; } + MethodDefinition(const StringName& p_name) { name=p_name; } +}; + + + +MethodDefinition _MD(const char* p_name); +MethodDefinition _MD(const char* p_name,const char *p_arg1); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9); +MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10); + +#else + +//#define NO_VARIADIC_MACROS + +#ifdef NO_VARIADIC_MACROS + +static _FORCE_INLINE_ const char* _MD(const char* m_name, ...) { return m_name; } + +#else + +#define _MD(m_c, ...) m_c + +#endif + +#endif + +class ClassDB { +public: + enum APIType { + API_CORE, + API_EDITOR, + API_NONE + }; +public: + struct PropertySetGet { + + int index; + StringName setter; + StringName getter; + MethodBind *_setptr; + MethodBind *_getptr; + Variant::Type type; + }; + + struct ClassInfo { + + APIType api; + ClassInfo *inherits_ptr; + HashMap method_map; + HashMap constant_map; + HashMap signal_map; + List property_list; +#ifdef DEBUG_METHODS_ENABLED + List constant_order; + List method_order; + List virtual_methods; + StringName category; +#endif + HashMap property_setget; + + + StringName inherits; + StringName name; + bool disabled; + Object* (*creation_func)(); + ClassInfo(); + ~ClassInfo(); + }; + + template + static Object *creator() { + return memnew( T ); + } + + static RWLock *lock; + static HashMap classes; + static HashMap resource_base_extensions; + static HashMap compat_classes; + +#ifdef DEBUG_METHODS_ENABLED + static MethodBind* bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const MethodDefinition &method_name, const Variant **p_defs, int p_defcount); +#else + static MethodBind* bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const char *method_name, const Variant **p_defs, int p_defcount); +#endif + + + static APIType current_api; + + static void _add_class2(const StringName& p_class, const StringName& p_inherits); +public: + + // DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!! + template + static void _add_class() { + + _add_class2(T::get_class_static(),T::get_parent_class_static()); +#if 0 + GLOBAL_LOCK_FUNCTION; + + StringName name = T::get_class_static(); + + ERR_FAIL_COND(types.has(name)); + + types[name]=TypeInfo(); + TypeInfo &ti=types[name]; + ti.name=name; + ti.inherits=T::get_parent_class_static(); + + if (ti.inherits) { + + ERR_FAIL_COND( !types.has(ti.inherits) ); //it MUST be registered. + ti.inherits_ptr = &types[ti.inherits]; + + } else { + ti.inherits_ptr=NULL; + } +#endif + } + + template + static void register_class() { + + GLOBAL_LOCK_FUNCTION; + T::initialize_class(); + ClassInfo *t=classes.getptr(T::get_class_static()); + ERR_FAIL_COND(!t); + t->creation_func=&creator; + T::register_custom_data_to_otdb(); + } + + template + static void register_virtual_class() { + + GLOBAL_LOCK_FUNCTION; + T::initialize_class(); + //nothing + } + + template + static Object* _create_ptr_func() { + + return T::create(); + } + + template + static void register_custom_instance_class() { + + GLOBAL_LOCK_FUNCTION; + T::initialize_class(); + ClassInfo *t=classes.getptr(T::get_class_static()); + ERR_FAIL_COND(!t); + t->creation_func=&_create_ptr_func; + T::register_custom_data_to_otdb(); + } + + static void get_class_list( List *p_classes); + static void get_inheriters_from_class( const StringName& p_class,List *p_classes); + static StringName get_parent_class_nocheck(const StringName& p_class); + static StringName get_parent_class(const StringName& p_class); + static bool class_exists(const StringName &p_class); + static bool is_parent_class(const StringName &p_class,const StringName& p_inherits); + static bool can_instance(const StringName &p_class); + static Object *instance(const StringName &p_class); + static APIType get_api_type(const StringName &p_class); + + static uint64_t get_api_hash(APIType p_api); + +#if 0 + template + static MethodBind* bind_method(N p_method_name, M p_method, + //default arguments + ParamDef d1=ParamDef(), + ParamDef d2=ParamDef(), + ParamDef d3=ParamDef(), + ParamDef d4=ParamDef(), + ParamDef d5=ParamDef() + ) { + + return bind_methodf(METHOD_FLAGS_DEFAULT,p_method_name, p_method, d1,d2,d3,d4,d5); + } + + + + template + static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, + + + //default arguments + const ParamDef &d1=ParamDef(), + const ParamDef &d2=ParamDef(), + const ParamDef &d3=ParamDef(), + const ParamDef &d4=ParamDef(), + const ParamDef &d5=ParamDef() + ) { + + GLOBAL_LOCK_FUNCTION; + + MethodDefinition method_name=p_method_name; + + MethodBind *bind = create_method_bind(p_method); + bind->set_name(method_name.name); + ERR_FAIL_COND_V(!bind,NULL); + + String instance_type=bind->get_instance_type(); + + TypeInfo *type=types.getptr(instance_type); + if (!type) { + memdelete(bind); + ERR_FAIL_COND_V(!type,NULL); + } + + if (type->method_map.has(method_name.name)) { + memdelete(bind); + // overloading not supported + ERR_EXPLAIN("Method already bound: "+instance_type+"::"+method_name.name); + ERR_FAIL_V(NULL); + } + bind->set_argument_names(method_name.args); + type->method_map[method_name.name]=bind; + + Vector defvals; + +#define PARSE_DEFVAL(m_defval)\ + if (d##m_defval.used) defvals.insert(0,d##m_defval.val);\ + else goto set_defvals; + + + PARSE_DEFVAL(1); + PARSE_DEFVAL(2); + PARSE_DEFVAL(3); + PARSE_DEFVAL(4); + PARSE_DEFVAL(5); + set_defvals: + + bind->set_default_arguments(defvals); + bind->set_hint_flags(p_flags); + + return bind; +#undef PARSE_DEFVAL + } +#else + +#if 0 + template + static MethodBind* bind_method(N p_method_name, M p_method, + //default arguments + const ParamDef &d1=ParamDef(), + const ParamDef &d2=ParamDef(), + const ParamDef &d3=ParamDef(), + const ParamDef &d4=ParamDef(), + const ParamDef &d5=ParamDef() + ) { + + MethodDefinition method_name=p_method_name; + + MethodBind *bind = create_method_bind(p_method); + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage + } +#endif + + template + static MethodBind* bind_method(N p_method_name, M p_method) { + + MethodBind *bind = create_method_bind(p_method); + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,NULL,0); //use static function, much smaller binary usage + } + + template + static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1) { + + MethodBind *bind = create_method_bind(p_method); + const Variant* ptr[1]={&p_def1}; + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,1); + } + + + template + static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2) { + + MethodBind *bind = create_method_bind(p_method); + const Variant* ptr[2]={&p_def1,&p_def2}; + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,2); + } + + template + static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3) { + + MethodBind *bind = create_method_bind(p_method); + const Variant* ptr[3]={&p_def1,&p_def2,&p_def3}; + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,3); + } + + template + static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3,const Variant& p_def4) { + + MethodBind *bind = create_method_bind(p_method); + const Variant* ptr[4]={&p_def1,&p_def2,&p_def3,&p_def4}; + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,4); + } + + template + static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3,const Variant& p_def4,const Variant& p_def5) { + + MethodBind *bind = create_method_bind(p_method); + const Variant* ptr[5]={&p_def1,&p_def2,&p_def3,&p_def4,&p_def5}; + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,5); + } + + template + static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3,const Variant& p_def4,const Variant& p_def5,const Variant& p_def6) { + + MethodBind *bind = create_method_bind(p_method); + const Variant* ptr[6]={&p_def1,&p_def2,&p_def3,&p_def4,&p_def5,&p_def6}; + + return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,6); + } + +#if 0 + template + static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, + + const ParamDef& d1=ParamDef(), + const ParamDef& d2=ParamDef(), + const ParamDef& d3=ParamDef(), + const ParamDef& d4=ParamDef(), + const ParamDef& d5=ParamDef() + ) { + + MethodDefinition method_name=p_method_name; + + MethodBind *bind = create_method_bind(p_method); + + return bind_methodfi(p_flags,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage + } +#endif + +#endif + template + static MethodBind* bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector& p_default_args=Vector()) { + + GLOBAL_LOCK_FUNCTION; + + + + MethodBind *bind = create_vararg_method_bind(p_method,p_info); + ERR_FAIL_COND_V(!bind,NULL); + + String rettype; + if (p_name.operator String().find(":")!=-1) { + rettype = p_name.operator String().get_slice(":",1); + p_name = p_name.operator String().get_slice(":",0); + } + + bind->set_name(p_name); + bind->set_default_arguments(p_default_args); + + String instance_type=bind->get_instance_class(); + + ClassInfo *type=classes.getptr(instance_type); + if (!type) { + memdelete(bind); + ERR_FAIL_COND_V(!type,NULL); + } + + if (type->method_map.has(p_name)) { + memdelete(bind); + // overloading not supported + ERR_EXPLAIN("Method already bound: "+instance_type+"::"+p_name); + ERR_FAIL_V(NULL); + } + type->method_map[p_name]=bind; +#ifdef DEBUG_METHODS_ENABLED + if (!rettype.empty()) + bind->set_return_type(rettype); + type->method_order.push_back(p_name); +#endif + + + return bind; + + } + + + static void add_signal(StringName p_class,const MethodInfo& p_signal); + static bool has_signal(StringName p_class,StringName p_signal); + static bool get_signal(StringName p_class,StringName p_signal,MethodInfo *r_signal); + static void get_signal_list(StringName p_class,List *p_signals,bool p_no_inheritance=false); + + static void add_property_group(StringName p_class,const String& p_name,const String& p_prefix=""); + static void add_property(StringName p_class,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index=-1); + static void get_property_list(StringName p_class, List *p_list, bool p_no_inheritance=false, const Object *p_validator=NULL); + static bool set_property(Object* p_object, const StringName& p_property, const Variant& p_value, bool *r_valid=NULL); + static bool get_property(Object* p_object,const StringName& p_property, Variant& r_value); + static bool has_property(const StringName& p_class,const StringName& p_property,bool p_no_inheritance=false); + static Variant::Type get_property_type(const StringName& p_class, const StringName& p_property,bool *r_is_valid=NULL); + static StringName get_property_setter(StringName p_class,const StringName p_property); + static StringName get_property_getter(StringName p_class,const StringName p_property); + + + + static bool has_method(StringName p_class,StringName p_method,bool p_no_inheritance=false); + static void set_method_flags(StringName p_class,StringName p_method,int p_flags); + + + static void get_method_list(StringName p_class,List *p_methods,bool p_no_inheritance=false); + static MethodBind *get_method(StringName p_class, StringName p_name); + + static void add_virtual_method(const StringName& p_class,const MethodInfo& p_method,bool p_virtual=true ); + static void get_virtual_methods(const StringName& p_class,List * p_methods,bool p_no_inheritance=false ); + + static void bind_integer_constant(const StringName& p_class, const StringName &p_name, int p_constant); + static void get_integer_constant_list(const StringName& p_class, List *p_constants, bool p_no_inheritance=false); + static int get_integer_constant(const StringName& p_class, const StringName &p_name, bool *p_success=NULL); + static StringName get_category(const StringName& p_node); + + static bool get_setter_and_type_for_property(const StringName& p_class, const StringName& p_prop, StringName& r_class, StringName& r_setter); + + static void set_class_enabled(StringName p_class,bool p_enable); + static bool is_class_enabled(StringName p_class); + + static void add_resource_base_extension(const StringName& p_extension,const StringName& p_class); + static void get_resource_base_extensions(List *p_extensions); + static void get_extensions_for_type(const StringName& p_class,List *p_extensions); + + static void add_compatibility_class(const StringName& p_class,const StringName& p_fallback); + static void init(); + + static void set_current_api(APIType p_api); + static void cleanup(); +}; + + +#define BIND_CONSTANT(m_constant)\ + ClassDB::bind_integer_constant( get_class_static() , #m_constant, m_constant); + +#ifdef TOOLS_ENABLED + +#define BIND_VMETHOD(m_method)\ + ClassDB::add_virtual_method( get_class_static() , m_method ); + +#else + +#define BIND_VMETHOD(m_method) + +#endif + + + +#endif // CLASS_DB_H diff --git a/core/color.cpp b/core/color.cpp index 89accbb6d2..80a98da252 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "color.h" + #include "math_funcs.h" #include "print_string.h" #include "map.h" diff --git a/core/command_queue_mt.cpp b/core/command_queue_mt.cpp index 9b1c052eb9..6d50ed8d9a 100644 --- a/core/command_queue_mt.cpp +++ b/core/command_queue_mt.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "command_queue_mt.h" + #include "os/os.h" void CommandQueueMT::lock() { diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp index 1e3a51fede..d39db5044b 100644 --- a/core/compressed_translation.cpp +++ b/core/compressed_translation.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "compressed_translation.h" + #include "pair.h" #include diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 3b4d3b65d0..1176b9be3b 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "dictionary.h" + #include "safe_refcount.h" #include "variant.h" diff --git a/core/engine.cpp b/core/engine.cpp index eb6d8a3478..b017e77275 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "engine.h" + #include "version.h" void Engine::set_iterations_per_second(int p_ips) { diff --git a/core/error_macros.cpp b/core/error_macros.cpp index 53a361fa3a..e963f6122b 100644 --- a/core/error_macros.cpp +++ b/core/error_macros.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "error_macros.h" + #include "os/os.h" diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 936facdd23..be619d9ee3 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "global_constants.h" + #include "variant.h" #include "os/keyboard.h" #include "object.h" diff --git a/core/globals.cpp b/core/globals.cpp index 96daf55276..af3ec403d5 100644 --- a/core/globals.cpp +++ b/core/globals.cpp @@ -27,9 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "globals.h" + #include "os/dir_access.h" #include "os/file_access.h" - #include "os/keyboard.h" #include "io/marshalls.h" #include "bind/core_bind.h" @@ -37,6 +37,7 @@ #include "io/file_access_pack.h" #include "io/file_access_network.h" #include "variant_parser.h" + GlobalConfig *GlobalConfig::singleton=NULL; GlobalConfig *GlobalConfig::get_singleton() { diff --git a/core/image.cpp b/core/image.cpp index d769e6a0b3..a34278ac33 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -27,11 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "image.h" + #include "hash_map.h" #include "core/io/image_loader.h" #include "core/os/copymem.h" #include "hq2x.h" #include "print_string.h" + #include diff --git a/core/input_map.cpp b/core/input_map.cpp index bcae630c76..cc14daa8eb 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "input_map.h" + #include "globals.h" #include "os/keyboard.h" diff --git a/core/io/base64.c b/core/io/base64.c index 0c799e9f07..0929ae5db5 100644 --- a/core/io/base64.c +++ b/core/io/base64.c @@ -1,3 +1,11 @@ +/* + * File: base64.c + * Description: Simple BASE64 conversion methods + * Author: Ari Edelkind + * License: Public Domain + * Website: http://episec.com/people/edelkind/c.html + */ + #include char b64string[] = diff --git a/core/io/base64.h b/core/io/base64.h index b70b387983..456ef1811b 100644 --- a/core/io/base64.h +++ b/core/io/base64.h @@ -1,3 +1,11 @@ +/* + * File: base64.h + * Description: Simple BASE64 conversion methods + * Author: Ari Edelkind + * License: Public Domain + * Website: http://episec.com/people/edelkind/c.html + */ + #ifndef BASE64_H #define BASE64_H diff --git a/core/io/networked_multiplayer_peer.cpp b/core/io/networked_multiplayer_peer.cpp index 6133401a8c..2981307af6 100644 --- a/core/io/networked_multiplayer_peer.cpp +++ b/core/io/networked_multiplayer_peer.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* networked_multiplayer_peer.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "networked_multiplayer_peer.h" diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index a59d9367d1..5d859a2f25 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* networked_multiplayer_peer.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef NETWORKED_MULTIPLAYER_PEER_H #define NETWORKED_MULTIPLAYER_PEER_H diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index a9f357a7c8..fb5875e4cc 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* pkc_packer.cpp */ +/* pck_packer.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index 0d6997183f..2c45009a60 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* a_star.cpp */ +/* a_star.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/core/math/aabb.cpp b/core/math/aabb.cpp deleted file mode 100644 index 3518eea7ac..0000000000 --- a/core/math/aabb.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/*************************************************************************/ -/* aabb.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "aabb.h" - -#include "print_string.h" - -float Rect3::get_area() const { - - return size.x*size.y*size.z; - -} - -bool Rect3::operator==(const Rect3& p_rval) const { - - return ((pos==p_rval.pos) && (size==p_rval.size)); - -} -bool Rect3::operator!=(const Rect3& p_rval) const { - - return ((pos!=p_rval.pos) || (size!=p_rval.size)); - -} - -void Rect3::merge_with(const Rect3& p_aabb) { - - Vector3 beg_1,beg_2; - Vector3 end_1,end_2; - Vector3 min,max; - - beg_1=pos; - beg_2=p_aabb.pos; - end_1=Vector3(size.x,size.y,size.z)+beg_1; - end_2=Vector3(p_aabb.size.x,p_aabb.size.y,p_aabb.size.z)+beg_2; - - min.x=(beg_1.xend_2.x)?end_1.x:end_2.x; - max.y=(end_1.y>end_2.y)?end_1.y:end_2.y; - max.z=(end_1.z>end_2.z)?end_1.z:end_2.z; - - pos=min; - size=max-min; -} - -Rect3 Rect3::intersection(const Rect3& p_aabb) const { - - Vector3 src_min=pos; - Vector3 src_max=pos+size; - Vector3 dst_min=p_aabb.pos; - Vector3 dst_max=p_aabb.pos+p_aabb.size; - - Vector3 min,max; - - if (src_min.x > dst_max.x || src_max.x < dst_min.x ) - return Rect3(); - else { - - min.x= ( src_min.x > dst_min.x ) ? src_min.x :dst_min.x; - max.x= ( src_max.x < dst_max.x ) ? src_max.x :dst_max.x; - - } - - if (src_min.y > dst_max.y || src_max.y < dst_min.y ) - return Rect3(); - else { - - min.y= ( src_min.y > dst_min.y ) ? src_min.y :dst_min.y; - max.y= ( src_max.y < dst_max.y ) ? src_max.y :dst_max.y; - - } - - if (src_min.z > dst_max.z || src_max.z < dst_min.z ) - return Rect3(); - else { - - min.z= ( src_min.z > dst_min.z ) ? src_min.z :dst_min.z; - max.z= ( src_max.z < dst_max.z ) ? src_max.z :dst_max.z; - - } - - - return Rect3( min, max-min ); -} - -bool Rect3::intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip,Vector3* r_normal) const { - - Vector3 c1, c2; - Vector3 end = pos+size; - float near=-1e20; - float far=1e20; - int axis=0; - - for (int i=0;i<3;i++){ - if (p_dir[i] == 0){ - if ((p_from[i] < pos[i]) || (p_from[i] > end[i])) { - return false; - } - } else { // ray not parallel to planes in this direction - c1[i] = (pos[i] - p_from[i]) / p_dir[i]; - c2[i] = (end[i] - p_from[i]) / p_dir[i]; - - if(c1[i] > c2[i]){ - SWAP(c1,c2); - } - if (c1[i] > near){ - near = c1[i]; - axis=i; - } - if (c2[i] < far){ - far = c2[i]; - } - if( (near > far) || (far < 0) ){ - return false; - } - } - } - - if (r_clip) - *r_clip=c1; - if (r_normal) { - *r_normal=Vector3(); - (*r_normal)[axis]=p_dir[axis]?-1:1; - } - - return true; - -} - - -bool Rect3::intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip,Vector3* r_normal) const { - - real_t min=0,max=1; - int axis=0; - float sign=0; - - for(int i=0;i<3;i++) { - real_t seg_from=p_from[i]; - real_t seg_to=p_to[i]; - real_t box_begin=pos[i]; - real_t box_end=box_begin+size[i]; - real_t cmin,cmax; - float csign; - - if (seg_from < seg_to) { - - if (seg_from > box_end || seg_to < box_begin) - return false; - real_t length=seg_to-seg_from; - cmin = (seg_from < box_begin)?((box_begin - seg_from)/length):0; - cmax = (seg_to > box_end)?((box_end - seg_from)/length):1; - csign=-1.0; - - } else { - - if (seg_to > box_end || seg_from < box_begin) - return false; - real_t length=seg_to-seg_from; - cmin = (seg_from > box_end)?(box_end - seg_from)/length:0; - cmax = (seg_to < box_begin)?(box_begin - seg_from)/length:1; - csign=1.0; - } - - if (cmin > min) { - min = cmin; - axis=i; - sign=csign; - } - if (cmax < max) - max = cmax; - if (max < min) - return false; - } - - - Vector3 rel=p_to-p_from; - - if (r_normal) { - Vector3 normal; - normal[axis]=sign; - *r_normal=normal; - } - - if (r_clip) - *r_clip=p_from+rel*min; - - return true; - -} - - -bool Rect3::intersects_plane(const Plane &p_plane) const { - - Vector3 points[8] = { - Vector3( pos.x , pos.y , pos.z ), - Vector3( pos.x , pos.y , pos.z+size.z ), - Vector3( pos.x , pos.y+size.y , pos.z ), - Vector3( pos.x , pos.y+size.y , pos.z+size.z ), - Vector3( pos.x+size.x , pos.y , pos.z ), - Vector3( pos.x+size.x , pos.y , pos.z+size.z ), - Vector3( pos.x+size.x , pos.y+size.y , pos.z ), - Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ), - }; - - bool over=false; - bool under=false; - - for (int i=0;i<8;i++) { - - if (p_plane.distance_to(points[i])>0) - over=true; - else - under=true; - - } - - return under && over; -} - - - -Vector3 Rect3::get_longest_axis() const { - - Vector3 axis(1,0,0); - real_t max_size=size.x; - - if (size.y > max_size ) { - axis=Vector3(0,1,0); - max_size=size.y; - } - - if (size.z > max_size ) { - axis=Vector3(0,0,1); - max_size=size.z; - } - - return axis; -} -int Rect3::get_longest_axis_index() const { - - int axis=0; - real_t max_size=size.x; - - if (size.y > max_size ) { - axis=1; - max_size=size.y; - } - - if (size.z > max_size ) { - axis=2; - max_size=size.z; - } - - return axis; -} - - -Vector3 Rect3::get_shortest_axis() const { - - Vector3 axis(1,0,0); - real_t max_size=size.x; - - if (size.y < max_size ) { - axis=Vector3(0,1,0); - max_size=size.y; - } - - if (size.z < max_size ) { - axis=Vector3(0,0,1); - max_size=size.z; - } - - return axis; -} -int Rect3::get_shortest_axis_index() const { - - int axis=0; - real_t max_size=size.x; - - if (size.y < max_size ) { - axis=1; - max_size=size.y; - } - - if (size.z < max_size ) { - axis=2; - max_size=size.z; - } - - return axis; -} - -Rect3 Rect3::merge(const Rect3& p_with) const { - - Rect3 aabb=*this; - aabb.merge_with(p_with); - return aabb; -} -Rect3 Rect3::expand(const Vector3& p_vector) const { - Rect3 aabb=*this; - aabb.expand_to(p_vector); - return aabb; - -} -Rect3 Rect3::grow(real_t p_by) const { - - Rect3 aabb=*this; - aabb.grow_by(p_by); - return aabb; -} - -void Rect3::get_edge(int p_edge,Vector3& r_from,Vector3& r_to) const { - - ERR_FAIL_INDEX(p_edge,12); - switch(p_edge) { - - case 0:{ - - r_from=Vector3( pos.x+size.x , pos.y , pos.z ); - r_to=Vector3( pos.x , pos.y , pos.z ); - } break; - case 1:{ - - r_from=Vector3( pos.x+size.x , pos.y , pos.z+size.z ); - r_to=Vector3( pos.x+size.x , pos.y , pos.z ); - } break; - case 2:{ - r_from=Vector3( pos.x , pos.y , pos.z+size.z ); - r_to=Vector3( pos.x+size.x , pos.y , pos.z+size.z ); - - } break; - case 3:{ - - r_from=Vector3( pos.x , pos.y , pos.z ); - r_to=Vector3( pos.x , pos.y , pos.z+size.z ); - - } break; - case 4:{ - - r_from=Vector3( pos.x , pos.y+size.y , pos.z ); - r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z ); - } break; - case 5:{ - - r_from=Vector3( pos.x+size.x , pos.y+size.y , pos.z ); - r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); - } break; - case 6:{ - r_from=Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); - r_to=Vector3( pos.x , pos.y+size.y , pos.z+size.z ); - - } break; - case 7:{ - - r_from=Vector3( pos.x , pos.y+size.y , pos.z+size.z ); - r_to=Vector3( pos.x , pos.y+size.y , pos.z ); - - } break; - case 8:{ - - r_from=Vector3( pos.x , pos.y , pos.z+size.z ); - r_to=Vector3( pos.x , pos.y+size.y , pos.z+size.z ); - - } break; - case 9:{ - - r_from=Vector3( pos.x , pos.y , pos.z ); - r_to=Vector3( pos.x , pos.y+size.y , pos.z ); - - } break; - case 10:{ - - r_from=Vector3( pos.x+size.x , pos.y , pos.z ); - r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z ); - - } break; - case 11:{ - - r_from=Vector3( pos.x+size.x , pos.y , pos.z+size.z ); - r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); - - } break; - - } - -} - -Rect3::operator String() const { - - return String()+pos +" - "+ size; -} diff --git a/core/math/aabb.h b/core/math/aabb.h deleted file mode 100644 index 2816d1f012..0000000000 --- a/core/math/aabb.h +++ /dev/null @@ -1,395 +0,0 @@ -/*************************************************************************/ -/* aabb.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef AABB_H -#define AABB_H - - - -#include "vector3.h" -#include "plane.h" -/** - * AABB / AABB (Axis Aligned Bounding Box) - * This is implemented by a point (pos) and the box size - */ - - - -class Rect3 { -public: - Vector3 pos; - Vector3 size; - - float get_area() const; /// get area - _FORCE_INLINE_ bool has_no_area() const { - - return (size.x<=CMP_EPSILON || size.y<=CMP_EPSILON || size.z<=CMP_EPSILON); - } - - _FORCE_INLINE_ bool has_no_surface() const { - - return (size.x<=CMP_EPSILON && size.y<=CMP_EPSILON && size.z<=CMP_EPSILON); - } - - const Vector3& get_pos() const { return pos; } - void set_pos(const Vector3& p_pos) { pos=p_pos; } - const Vector3& get_size() const { return size; } - void set_size(const Vector3& p_size) { size=p_size; } - - - bool operator==(const Rect3& p_rval) const; - bool operator!=(const Rect3& p_rval) const; - - _FORCE_INLINE_ bool intersects(const Rect3& p_aabb) const; /// Both AABBs overlap - _FORCE_INLINE_ bool intersects_inclusive(const Rect3& p_aabb) const; /// Both AABBs (or their faces) overlap - _FORCE_INLINE_ bool encloses(const Rect3 & p_aabb) const; /// p_aabb is completely inside this - - Rect3 merge(const Rect3& p_with) const; - void merge_with(const Rect3& p_aabb); ///merge with another AABB - Rect3 intersection(const Rect3& p_aabb) const; ///get box where two intersect, empty if no intersection occurs - bool intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const; - bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const; - _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, float t0, float t1) const; - - _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const; - bool intersects_plane(const Plane &p_plane) const; - - _FORCE_INLINE_ bool has_point(const Vector3& p_point) const; - _FORCE_INLINE_ Vector3 get_support(const Vector3& p_normal) const; - - - Vector3 get_longest_axis() const; - int get_longest_axis_index() const; - _FORCE_INLINE_ real_t get_longest_axis_size() const; - - Vector3 get_shortest_axis() const; - int get_shortest_axis_index() const; - _FORCE_INLINE_ real_t get_shortest_axis_size() const; - - Rect3 grow(real_t p_by) const; - _FORCE_INLINE_ void grow_by(real_t p_amount); - - void get_edge(int p_edge,Vector3& r_from,Vector3& r_to) const; - _FORCE_INLINE_ Vector3 get_endpoint(int p_point) const; - - Rect3 expand(const Vector3& p_vector) const; - _FORCE_INLINE_ void project_range_in_plane(const Plane& p_plane,float &r_min,float& r_max) const; - _FORCE_INLINE_ void expand_to(const Vector3& p_vector); /** expand to contain a point if necesary */ - - operator String() const; - - _FORCE_INLINE_ Rect3() {} - inline Rect3(const Vector3 &p_pos,const Vector3& p_size) { pos=p_pos; size=p_size; } - - -}; - -inline bool Rect3::intersects(const Rect3& p_aabb) const { - - if ( pos.x >= (p_aabb.pos.x + p_aabb.size.x) ) - return false; - if ( (pos.x+size.x) <= p_aabb.pos.x ) - return false; - if ( pos.y >= (p_aabb.pos.y + p_aabb.size.y) ) - return false; - if ( (pos.y+size.y) <= p_aabb.pos.y ) - return false; - if ( pos.z >= (p_aabb.pos.z + p_aabb.size.z) ) - return false; - if ( (pos.z+size.z) <= p_aabb.pos.z ) - return false; - - return true; -} - -inline bool Rect3::intersects_inclusive(const Rect3& p_aabb) const { - - if ( pos.x > (p_aabb.pos.x + p_aabb.size.x) ) - return false; - if ( (pos.x+size.x) < p_aabb.pos.x ) - return false; - if ( pos.y > (p_aabb.pos.y + p_aabb.size.y) ) - return false; - if ( (pos.y+size.y) < p_aabb.pos.y ) - return false; - if ( pos.z > (p_aabb.pos.z + p_aabb.size.z) ) - return false; - if ( (pos.z+size.z) < p_aabb.pos.z ) - return false; - - return true; -} - -inline bool Rect3::encloses(const Rect3 & p_aabb) const { - - Vector3 src_min=pos; - Vector3 src_max=pos+size; - Vector3 dst_min=p_aabb.pos; - Vector3 dst_max=p_aabb.pos+p_aabb.size; - - return ( - (src_min.x <= dst_min.x) && - (src_max.x > dst_max.x) && - (src_min.y <= dst_min.y) && - (src_max.y > dst_max.y) && - (src_min.z <= dst_min.z) && - (src_max.z > dst_max.z) ); - -} - -Vector3 Rect3::get_support(const Vector3& p_normal) const { - - Vector3 half_extents = size * 0.5; - Vector3 ofs = pos + half_extents; - - return Vector3( - (p_normal.x>0) ? -half_extents.x : half_extents.x, - (p_normal.y>0) ? -half_extents.y : half_extents.y, - (p_normal.z>0) ? -half_extents.z : half_extents.z - )+ofs; -} - - -Vector3 Rect3::get_endpoint(int p_point) const { - - switch(p_point) { - case 0: return Vector3( pos.x , pos.y , pos.z ); - case 1: return Vector3( pos.x , pos.y , pos.z+size.z ); - case 2: return Vector3( pos.x , pos.y+size.y , pos.z ); - case 3: return Vector3( pos.x , pos.y+size.y , pos.z+size.z ); - case 4: return Vector3( pos.x+size.x , pos.y , pos.z ); - case 5: return Vector3( pos.x+size.x , pos.y , pos.z+size.z ); - case 6: return Vector3( pos.x+size.x , pos.y+size.y , pos.z ); - case 7: return Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); - }; - - ERR_FAIL_V(Vector3()); -} - -bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const { - -#if 1 - - Vector3 half_extents = size * 0.5; - Vector3 ofs = pos + half_extents; - - for(int i=0;i0) ? -half_extents.x : half_extents.x, - (p.normal.y>0) ? -half_extents.y : half_extents.y, - (p.normal.z>0) ? -half_extents.z : half_extents.z - ); - point+=ofs; - if (p.is_point_over(point)) - return false; - } - - return true; -#else - //cache all points to check against! -// #warning should be easy to optimize, just use the same as when taking the support and use only that point - Vector3 points[8] = { - Vector3( pos.x , pos.y , pos.z ), - Vector3( pos.x , pos.y , pos.z+size.z ), - Vector3( pos.x , pos.y+size.y , pos.z ), - Vector3( pos.x , pos.y+size.y , pos.z+size.z ), - Vector3( pos.x+size.x , pos.y , pos.z ), - Vector3( pos.x+size.x , pos.y , pos.z+size.z ), - Vector3( pos.x+size.x , pos.y+size.y , pos.z ), - Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ), - }; - - for (int i=0;ipos.x+size.x) - return false; - if (p_point.y>pos.y+size.y) - return false; - if (p_point.z>pos.z+size.z) - return false; - - return true; -} - - -inline void Rect3::expand_to(const Vector3& p_vector) { - - Vector3 begin=pos; - Vector3 end=pos+size; - - if (p_vector.xend.x) - end.x=p_vector.x; - if (p_vector.y>end.y) - end.y=p_vector.y; - if (p_vector.z>end.z) - end.z=p_vector.z; - - pos=begin; - size=end-begin; -} - -void Rect3::project_range_in_plane(const Plane& p_plane,float &r_min,float& r_max) const { - - Vector3 half_extents( size.x * 0.5, size.y * 0.5, size.z * 0.5 ); - Vector3 center( pos.x + half_extents.x, pos.y + half_extents.y, pos.z + half_extents.z ); - - float length = p_plane.normal.abs().dot(half_extents); - float distance = p_plane.distance_to( center ); - r_min = distance - length; - r_max = distance + length; -} - -inline real_t Rect3::get_longest_axis_size() const { - - real_t max_size=size.x; - - if (size.y > max_size ) { - max_size=size.y; - } - - if (size.z > max_size ) { - max_size=size.z; - } - - return max_size; -} - -inline real_t Rect3::get_shortest_axis_size() const { - - real_t max_size=size.x; - - if (size.y < max_size ) { - max_size=size.y; - } - - if (size.z < max_size ) { - max_size=size.z; - } - - return max_size; -} - -bool Rect3::smits_intersect_ray(const Vector3 &from,const Vector3& dir, float t0, float t1) const { - - float divx=1.0/dir.x; - float divy=1.0/dir.y; - float divz=1.0/dir.z; - - Vector3 upbound=pos+size; - float tmin, tmax, tymin, tymax, tzmin, tzmax; - if (dir.x >= 0) { - tmin = (pos.x - from.x) * divx; - tmax = (upbound.x - from.x) * divx; - } - else { - tmin = (upbound.x - from.x) * divx; - tmax = (pos.x - from.x) * divx; - } - if (dir.y >= 0) { - tymin = (pos.y - from.y) * divy; - tymax = (upbound.y - from.y) * divy; - } - else { - tymin = (upbound.y - from.y) * divy; - tymax = (pos.y - from.y) * divy; - } - if ( (tmin > tymax) || (tymin > tmax) ) - return false; - if (tymin > tmin) - tmin = tymin; - if (tymax < tmax) - tmax = tymax; - if (dir.z >= 0) { - tzmin = (pos.z - from.z) * divz; - tzmax = (upbound.z - from.z) * divz; - } - else { - tzmin = (upbound.z - from.z) * divz; - tzmax = (pos.z - from.z) * divz; - } - if ( (tmin > tzmax) || (tzmin > tmax) ) - return false; - if (tzmin > tmin) - tmin = tzmin; - if (tzmax < tmax) - tmax = tzmax; - return ( (tmin < t1) && (tmax > t0) ); -} - -void Rect3::grow_by(real_t p_amount) { - - pos.x-=p_amount; - pos.y-=p_amount; - pos.z-=p_amount; - size.x+=2.0*p_amount; - size.y+=2.0*p_amount; - size.z+=2.0*p_amount; -} - - -#endif // AABB_H diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index e01df96555..a64fffcb78 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -30,7 +30,7 @@ #define BSP_TREE_H #include "plane.h" -#include "aabb.h" +#include "rect3.h" #include "face3.h" #include "vector.h" #include "dvector.h" diff --git a/core/math/face3.h b/core/math/face3.h index f08eb227b1..e957f64320 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -31,7 +31,7 @@ #include "vector3.h" #include "plane.h" -#include "aabb.h" +#include "rect3.h" #include "transform.h" class Face3 { diff --git a/core/math/octree.h b/core/math/octree.h index 483ba1d510..3630922d10 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -30,7 +30,7 @@ #define OCTREE_H #include "vector3.h" -#include "aabb.h" +#include "rect3.h" #include "list.h" #include "variant.h" #include "map.h" diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 04d25fef18..7bd23d31f2 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -29,7 +29,7 @@ #ifndef QUICK_HULL_H #define QUICK_HULL_H -#include "aabb.h" +#include "rect3.h" #include "set.h" #include "list.h" #include "geometry.h" diff --git a/core/math/rect3.cpp b/core/math/rect3.cpp new file mode 100644 index 0000000000..e0b0646505 --- /dev/null +++ b/core/math/rect3.cpp @@ -0,0 +1,418 @@ +/*************************************************************************/ +/* rect3.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "rect3.h" + +#include "print_string.h" + +float Rect3::get_area() const { + + return size.x*size.y*size.z; + +} + +bool Rect3::operator==(const Rect3& p_rval) const { + + return ((pos==p_rval.pos) && (size==p_rval.size)); + +} +bool Rect3::operator!=(const Rect3& p_rval) const { + + return ((pos!=p_rval.pos) || (size!=p_rval.size)); + +} + +void Rect3::merge_with(const Rect3& p_aabb) { + + Vector3 beg_1,beg_2; + Vector3 end_1,end_2; + Vector3 min,max; + + beg_1=pos; + beg_2=p_aabb.pos; + end_1=Vector3(size.x,size.y,size.z)+beg_1; + end_2=Vector3(p_aabb.size.x,p_aabb.size.y,p_aabb.size.z)+beg_2; + + min.x=(beg_1.xend_2.x)?end_1.x:end_2.x; + max.y=(end_1.y>end_2.y)?end_1.y:end_2.y; + max.z=(end_1.z>end_2.z)?end_1.z:end_2.z; + + pos=min; + size=max-min; +} + +Rect3 Rect3::intersection(const Rect3& p_aabb) const { + + Vector3 src_min=pos; + Vector3 src_max=pos+size; + Vector3 dst_min=p_aabb.pos; + Vector3 dst_max=p_aabb.pos+p_aabb.size; + + Vector3 min,max; + + if (src_min.x > dst_max.x || src_max.x < dst_min.x ) + return Rect3(); + else { + + min.x= ( src_min.x > dst_min.x ) ? src_min.x :dst_min.x; + max.x= ( src_max.x < dst_max.x ) ? src_max.x :dst_max.x; + + } + + if (src_min.y > dst_max.y || src_max.y < dst_min.y ) + return Rect3(); + else { + + min.y= ( src_min.y > dst_min.y ) ? src_min.y :dst_min.y; + max.y= ( src_max.y < dst_max.y ) ? src_max.y :dst_max.y; + + } + + if (src_min.z > dst_max.z || src_max.z < dst_min.z ) + return Rect3(); + else { + + min.z= ( src_min.z > dst_min.z ) ? src_min.z :dst_min.z; + max.z= ( src_max.z < dst_max.z ) ? src_max.z :dst_max.z; + + } + + + return Rect3( min, max-min ); +} + +bool Rect3::intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip,Vector3* r_normal) const { + + Vector3 c1, c2; + Vector3 end = pos+size; + float near=-1e20; + float far=1e20; + int axis=0; + + for (int i=0;i<3;i++){ + if (p_dir[i] == 0){ + if ((p_from[i] < pos[i]) || (p_from[i] > end[i])) { + return false; + } + } else { // ray not parallel to planes in this direction + c1[i] = (pos[i] - p_from[i]) / p_dir[i]; + c2[i] = (end[i] - p_from[i]) / p_dir[i]; + + if(c1[i] > c2[i]){ + SWAP(c1,c2); + } + if (c1[i] > near){ + near = c1[i]; + axis=i; + } + if (c2[i] < far){ + far = c2[i]; + } + if( (near > far) || (far < 0) ){ + return false; + } + } + } + + if (r_clip) + *r_clip=c1; + if (r_normal) { + *r_normal=Vector3(); + (*r_normal)[axis]=p_dir[axis]?-1:1; + } + + return true; + +} + + +bool Rect3::intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip,Vector3* r_normal) const { + + real_t min=0,max=1; + int axis=0; + float sign=0; + + for(int i=0;i<3;i++) { + real_t seg_from=p_from[i]; + real_t seg_to=p_to[i]; + real_t box_begin=pos[i]; + real_t box_end=box_begin+size[i]; + real_t cmin,cmax; + float csign; + + if (seg_from < seg_to) { + + if (seg_from > box_end || seg_to < box_begin) + return false; + real_t length=seg_to-seg_from; + cmin = (seg_from < box_begin)?((box_begin - seg_from)/length):0; + cmax = (seg_to > box_end)?((box_end - seg_from)/length):1; + csign=-1.0; + + } else { + + if (seg_to > box_end || seg_from < box_begin) + return false; + real_t length=seg_to-seg_from; + cmin = (seg_from > box_end)?(box_end - seg_from)/length:0; + cmax = (seg_to < box_begin)?(box_begin - seg_from)/length:1; + csign=1.0; + } + + if (cmin > min) { + min = cmin; + axis=i; + sign=csign; + } + if (cmax < max) + max = cmax; + if (max < min) + return false; + } + + + Vector3 rel=p_to-p_from; + + if (r_normal) { + Vector3 normal; + normal[axis]=sign; + *r_normal=normal; + } + + if (r_clip) + *r_clip=p_from+rel*min; + + return true; + +} + + +bool Rect3::intersects_plane(const Plane &p_plane) const { + + Vector3 points[8] = { + Vector3( pos.x , pos.y , pos.z ), + Vector3( pos.x , pos.y , pos.z+size.z ), + Vector3( pos.x , pos.y+size.y , pos.z ), + Vector3( pos.x , pos.y+size.y , pos.z+size.z ), + Vector3( pos.x+size.x , pos.y , pos.z ), + Vector3( pos.x+size.x , pos.y , pos.z+size.z ), + Vector3( pos.x+size.x , pos.y+size.y , pos.z ), + Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ), + }; + + bool over=false; + bool under=false; + + for (int i=0;i<8;i++) { + + if (p_plane.distance_to(points[i])>0) + over=true; + else + under=true; + + } + + return under && over; +} + + + +Vector3 Rect3::get_longest_axis() const { + + Vector3 axis(1,0,0); + real_t max_size=size.x; + + if (size.y > max_size ) { + axis=Vector3(0,1,0); + max_size=size.y; + } + + if (size.z > max_size ) { + axis=Vector3(0,0,1); + max_size=size.z; + } + + return axis; +} +int Rect3::get_longest_axis_index() const { + + int axis=0; + real_t max_size=size.x; + + if (size.y > max_size ) { + axis=1; + max_size=size.y; + } + + if (size.z > max_size ) { + axis=2; + max_size=size.z; + } + + return axis; +} + + +Vector3 Rect3::get_shortest_axis() const { + + Vector3 axis(1,0,0); + real_t max_size=size.x; + + if (size.y < max_size ) { + axis=Vector3(0,1,0); + max_size=size.y; + } + + if (size.z < max_size ) { + axis=Vector3(0,0,1); + max_size=size.z; + } + + return axis; +} +int Rect3::get_shortest_axis_index() const { + + int axis=0; + real_t max_size=size.x; + + if (size.y < max_size ) { + axis=1; + max_size=size.y; + } + + if (size.z < max_size ) { + axis=2; + max_size=size.z; + } + + return axis; +} + +Rect3 Rect3::merge(const Rect3& p_with) const { + + Rect3 aabb=*this; + aabb.merge_with(p_with); + return aabb; +} +Rect3 Rect3::expand(const Vector3& p_vector) const { + Rect3 aabb=*this; + aabb.expand_to(p_vector); + return aabb; + +} +Rect3 Rect3::grow(real_t p_by) const { + + Rect3 aabb=*this; + aabb.grow_by(p_by); + return aabb; +} + +void Rect3::get_edge(int p_edge,Vector3& r_from,Vector3& r_to) const { + + ERR_FAIL_INDEX(p_edge,12); + switch(p_edge) { + + case 0:{ + + r_from=Vector3( pos.x+size.x , pos.y , pos.z ); + r_to=Vector3( pos.x , pos.y , pos.z ); + } break; + case 1:{ + + r_from=Vector3( pos.x+size.x , pos.y , pos.z+size.z ); + r_to=Vector3( pos.x+size.x , pos.y , pos.z ); + } break; + case 2:{ + r_from=Vector3( pos.x , pos.y , pos.z+size.z ); + r_to=Vector3( pos.x+size.x , pos.y , pos.z+size.z ); + + } break; + case 3:{ + + r_from=Vector3( pos.x , pos.y , pos.z ); + r_to=Vector3( pos.x , pos.y , pos.z+size.z ); + + } break; + case 4:{ + + r_from=Vector3( pos.x , pos.y+size.y , pos.z ); + r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z ); + } break; + case 5:{ + + r_from=Vector3( pos.x+size.x , pos.y+size.y , pos.z ); + r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); + } break; + case 6:{ + r_from=Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); + r_to=Vector3( pos.x , pos.y+size.y , pos.z+size.z ); + + } break; + case 7:{ + + r_from=Vector3( pos.x , pos.y+size.y , pos.z+size.z ); + r_to=Vector3( pos.x , pos.y+size.y , pos.z ); + + } break; + case 8:{ + + r_from=Vector3( pos.x , pos.y , pos.z+size.z ); + r_to=Vector3( pos.x , pos.y+size.y , pos.z+size.z ); + + } break; + case 9:{ + + r_from=Vector3( pos.x , pos.y , pos.z ); + r_to=Vector3( pos.x , pos.y+size.y , pos.z ); + + } break; + case 10:{ + + r_from=Vector3( pos.x+size.x , pos.y , pos.z ); + r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z ); + + } break; + case 11:{ + + r_from=Vector3( pos.x+size.x , pos.y , pos.z+size.z ); + r_to=Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); + + } break; + + } + +} + +Rect3::operator String() const { + + return String()+pos +" - "+ size; +} diff --git a/core/math/rect3.h b/core/math/rect3.h new file mode 100644 index 0000000000..80c67200f4 --- /dev/null +++ b/core/math/rect3.h @@ -0,0 +1,395 @@ +/*************************************************************************/ +/* rect3.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef AABB_H +#define AABB_H + + + +#include "vector3.h" +#include "plane.h" +/** + * AABB / AABB (Axis Aligned Bounding Box) + * This is implemented by a point (pos) and the box size + */ + + + +class Rect3 { +public: + Vector3 pos; + Vector3 size; + + float get_area() const; /// get area + _FORCE_INLINE_ bool has_no_area() const { + + return (size.x<=CMP_EPSILON || size.y<=CMP_EPSILON || size.z<=CMP_EPSILON); + } + + _FORCE_INLINE_ bool has_no_surface() const { + + return (size.x<=CMP_EPSILON && size.y<=CMP_EPSILON && size.z<=CMP_EPSILON); + } + + const Vector3& get_pos() const { return pos; } + void set_pos(const Vector3& p_pos) { pos=p_pos; } + const Vector3& get_size() const { return size; } + void set_size(const Vector3& p_size) { size=p_size; } + + + bool operator==(const Rect3& p_rval) const; + bool operator!=(const Rect3& p_rval) const; + + _FORCE_INLINE_ bool intersects(const Rect3& p_aabb) const; /// Both AABBs overlap + _FORCE_INLINE_ bool intersects_inclusive(const Rect3& p_aabb) const; /// Both AABBs (or their faces) overlap + _FORCE_INLINE_ bool encloses(const Rect3 & p_aabb) const; /// p_aabb is completely inside this + + Rect3 merge(const Rect3& p_with) const; + void merge_with(const Rect3& p_aabb); ///merge with another AABB + Rect3 intersection(const Rect3& p_aabb) const; ///get box where two intersect, empty if no intersection occurs + bool intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const; + bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const; + _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, float t0, float t1) const; + + _FORCE_INLINE_ bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const; + bool intersects_plane(const Plane &p_plane) const; + + _FORCE_INLINE_ bool has_point(const Vector3& p_point) const; + _FORCE_INLINE_ Vector3 get_support(const Vector3& p_normal) const; + + + Vector3 get_longest_axis() const; + int get_longest_axis_index() const; + _FORCE_INLINE_ real_t get_longest_axis_size() const; + + Vector3 get_shortest_axis() const; + int get_shortest_axis_index() const; + _FORCE_INLINE_ real_t get_shortest_axis_size() const; + + Rect3 grow(real_t p_by) const; + _FORCE_INLINE_ void grow_by(real_t p_amount); + + void get_edge(int p_edge,Vector3& r_from,Vector3& r_to) const; + _FORCE_INLINE_ Vector3 get_endpoint(int p_point) const; + + Rect3 expand(const Vector3& p_vector) const; + _FORCE_INLINE_ void project_range_in_plane(const Plane& p_plane,float &r_min,float& r_max) const; + _FORCE_INLINE_ void expand_to(const Vector3& p_vector); /** expand to contain a point if necesary */ + + operator String() const; + + _FORCE_INLINE_ Rect3() {} + inline Rect3(const Vector3 &p_pos,const Vector3& p_size) { pos=p_pos; size=p_size; } + + +}; + +inline bool Rect3::intersects(const Rect3& p_aabb) const { + + if ( pos.x >= (p_aabb.pos.x + p_aabb.size.x) ) + return false; + if ( (pos.x+size.x) <= p_aabb.pos.x ) + return false; + if ( pos.y >= (p_aabb.pos.y + p_aabb.size.y) ) + return false; + if ( (pos.y+size.y) <= p_aabb.pos.y ) + return false; + if ( pos.z >= (p_aabb.pos.z + p_aabb.size.z) ) + return false; + if ( (pos.z+size.z) <= p_aabb.pos.z ) + return false; + + return true; +} + +inline bool Rect3::intersects_inclusive(const Rect3& p_aabb) const { + + if ( pos.x > (p_aabb.pos.x + p_aabb.size.x) ) + return false; + if ( (pos.x+size.x) < p_aabb.pos.x ) + return false; + if ( pos.y > (p_aabb.pos.y + p_aabb.size.y) ) + return false; + if ( (pos.y+size.y) < p_aabb.pos.y ) + return false; + if ( pos.z > (p_aabb.pos.z + p_aabb.size.z) ) + return false; + if ( (pos.z+size.z) < p_aabb.pos.z ) + return false; + + return true; +} + +inline bool Rect3::encloses(const Rect3 & p_aabb) const { + + Vector3 src_min=pos; + Vector3 src_max=pos+size; + Vector3 dst_min=p_aabb.pos; + Vector3 dst_max=p_aabb.pos+p_aabb.size; + + return ( + (src_min.x <= dst_min.x) && + (src_max.x > dst_max.x) && + (src_min.y <= dst_min.y) && + (src_max.y > dst_max.y) && + (src_min.z <= dst_min.z) && + (src_max.z > dst_max.z) ); + +} + +Vector3 Rect3::get_support(const Vector3& p_normal) const { + + Vector3 half_extents = size * 0.5; + Vector3 ofs = pos + half_extents; + + return Vector3( + (p_normal.x>0) ? -half_extents.x : half_extents.x, + (p_normal.y>0) ? -half_extents.y : half_extents.y, + (p_normal.z>0) ? -half_extents.z : half_extents.z + )+ofs; +} + + +Vector3 Rect3::get_endpoint(int p_point) const { + + switch(p_point) { + case 0: return Vector3( pos.x , pos.y , pos.z ); + case 1: return Vector3( pos.x , pos.y , pos.z+size.z ); + case 2: return Vector3( pos.x , pos.y+size.y , pos.z ); + case 3: return Vector3( pos.x , pos.y+size.y , pos.z+size.z ); + case 4: return Vector3( pos.x+size.x , pos.y , pos.z ); + case 5: return Vector3( pos.x+size.x , pos.y , pos.z+size.z ); + case 6: return Vector3( pos.x+size.x , pos.y+size.y , pos.z ); + case 7: return Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ); + }; + + ERR_FAIL_V(Vector3()); +} + +bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const { + +#if 1 + + Vector3 half_extents = size * 0.5; + Vector3 ofs = pos + half_extents; + + for(int i=0;i0) ? -half_extents.x : half_extents.x, + (p.normal.y>0) ? -half_extents.y : half_extents.y, + (p.normal.z>0) ? -half_extents.z : half_extents.z + ); + point+=ofs; + if (p.is_point_over(point)) + return false; + } + + return true; +#else + //cache all points to check against! +// #warning should be easy to optimize, just use the same as when taking the support and use only that point + Vector3 points[8] = { + Vector3( pos.x , pos.y , pos.z ), + Vector3( pos.x , pos.y , pos.z+size.z ), + Vector3( pos.x , pos.y+size.y , pos.z ), + Vector3( pos.x , pos.y+size.y , pos.z+size.z ), + Vector3( pos.x+size.x , pos.y , pos.z ), + Vector3( pos.x+size.x , pos.y , pos.z+size.z ), + Vector3( pos.x+size.x , pos.y+size.y , pos.z ), + Vector3( pos.x+size.x , pos.y+size.y , pos.z+size.z ), + }; + + for (int i=0;ipos.x+size.x) + return false; + if (p_point.y>pos.y+size.y) + return false; + if (p_point.z>pos.z+size.z) + return false; + + return true; +} + + +inline void Rect3::expand_to(const Vector3& p_vector) { + + Vector3 begin=pos; + Vector3 end=pos+size; + + if (p_vector.xend.x) + end.x=p_vector.x; + if (p_vector.y>end.y) + end.y=p_vector.y; + if (p_vector.z>end.z) + end.z=p_vector.z; + + pos=begin; + size=end-begin; +} + +void Rect3::project_range_in_plane(const Plane& p_plane,float &r_min,float& r_max) const { + + Vector3 half_extents( size.x * 0.5, size.y * 0.5, size.z * 0.5 ); + Vector3 center( pos.x + half_extents.x, pos.y + half_extents.y, pos.z + half_extents.z ); + + float length = p_plane.normal.abs().dot(half_extents); + float distance = p_plane.distance_to( center ); + r_min = distance - length; + r_max = distance + length; +} + +inline real_t Rect3::get_longest_axis_size() const { + + real_t max_size=size.x; + + if (size.y > max_size ) { + max_size=size.y; + } + + if (size.z > max_size ) { + max_size=size.z; + } + + return max_size; +} + +inline real_t Rect3::get_shortest_axis_size() const { + + real_t max_size=size.x; + + if (size.y < max_size ) { + max_size=size.y; + } + + if (size.z < max_size ) { + max_size=size.z; + } + + return max_size; +} + +bool Rect3::smits_intersect_ray(const Vector3 &from,const Vector3& dir, float t0, float t1) const { + + float divx=1.0/dir.x; + float divy=1.0/dir.y; + float divz=1.0/dir.z; + + Vector3 upbound=pos+size; + float tmin, tmax, tymin, tymax, tzmin, tzmax; + if (dir.x >= 0) { + tmin = (pos.x - from.x) * divx; + tmax = (upbound.x - from.x) * divx; + } + else { + tmin = (upbound.x - from.x) * divx; + tmax = (pos.x - from.x) * divx; + } + if (dir.y >= 0) { + tymin = (pos.y - from.y) * divy; + tymax = (upbound.y - from.y) * divy; + } + else { + tymin = (upbound.y - from.y) * divy; + tymax = (pos.y - from.y) * divy; + } + if ( (tmin > tymax) || (tymin > tmax) ) + return false; + if (tymin > tmin) + tmin = tymin; + if (tymax < tmax) + tmax = tymax; + if (dir.z >= 0) { + tzmin = (pos.z - from.z) * divz; + tzmax = (upbound.z - from.z) * divz; + } + else { + tzmin = (upbound.z - from.z) * divz; + tzmax = (pos.z - from.z) * divz; + } + if ( (tmin > tzmax) || (tzmin > tmax) ) + return false; + if (tzmin > tmin) + tmin = tzmin; + if (tzmax < tmax) + tmax = tzmax; + return ( (tmin < t1) && (tmax > t0) ); +} + +void Rect3::grow_by(real_t p_amount) { + + pos.x-=p_amount; + pos.y-=p_amount; + pos.z-=p_amount; + size.x+=2.0*p_amount; + size.y+=2.0*p_amount; + size.z+=2.0*p_amount; +} + + +#endif // AABB_H diff --git a/core/math/transform.h b/core/math/transform.h index d65e87cc6a..45d7b2a12c 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -31,7 +31,7 @@ #include "matrix3.h" #include "plane.h" -#include "aabb.h" +#include "rect3.h" /** @author Juan Linietsky */ diff --git a/core/message_queue.cpp b/core/message_queue.cpp index fe46e1671c..668d321e05 100644 --- a/core/message_queue.cpp +++ b/core/message_queue.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "message_queue.h" + #include "globals.h" #include "script_language.h" + MessageQueue *MessageQueue::singleton=NULL; MessageQueue *MessageQueue::get_singleton() { diff --git a/core/object.cpp b/core/object.cpp index 8af088122e..26308dc64f 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -27,8 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "object.h" + #include "print_string.h" -#include "object_type_db.h" +#include "class_db.h" #include "script_language.h" #include "message_queue.h" #include "core_string_names.h" diff --git a/core/object.h b/core/object.h index 6ce579ea99..b9a800afc4 100644 --- a/core/object.h +++ b/core/object.h @@ -721,6 +721,6 @@ public: }; //needed by macros -#include "object_type_db.h" +#include "class_db.h" #endif diff --git a/core/object_type_db.cpp b/core/object_type_db.cpp deleted file mode 100644 index 24b9c26e71..0000000000 --- a/core/object_type_db.cpp +++ /dev/null @@ -1,1298 +0,0 @@ -/*************************************************************************/ -/* object_type_db.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "object_type_db.h" -#include "os/mutex.h" - -#ifdef NO_THREADS - -#define OBJTYPE_RLOCK - -#else - -#define OBJTYPE_RLOCK RWLockRead _rw_lockr_(lock); -#define OBJTYPE_WLOCK RWLockWrite _rw_lockw_(lock); - -#endif - -#ifdef DEBUG_METHODS_ENABLED - -ParamDef::ParamDef(const Variant& p_variant) { used=true; val=p_variant; } - - -MethodDefinition _MD(const char* p_name) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.push_back(StaticCString::create(p_arg1)); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(2); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(3); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(4); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(5); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - md.args[4]=StaticCString::create(p_arg5); - return md; -} - - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(6); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - md.args[4]=StaticCString::create(p_arg5); - md.args[5]=StaticCString::create(p_arg6); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(7); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - md.args[4]=StaticCString::create(p_arg5); - md.args[5]=StaticCString::create(p_arg6); - md.args[6]=StaticCString::create(p_arg7); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(8); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - md.args[4]=StaticCString::create(p_arg5); - md.args[5]=StaticCString::create(p_arg6); - md.args[6]=StaticCString::create(p_arg7); - md.args[7]=StaticCString::create(p_arg8); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(9); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - md.args[4]=StaticCString::create(p_arg5); - md.args[5]=StaticCString::create(p_arg6); - md.args[6]=StaticCString::create(p_arg7); - md.args[7]=StaticCString::create(p_arg8); - md.args[8]=StaticCString::create(p_arg9); - return md; -} - -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10) { - - MethodDefinition md; - md.name=StaticCString::create(p_name); - md.args.resize(10); - md.args[0]=StaticCString::create(p_arg1); - md.args[1]=StaticCString::create(p_arg2); - md.args[2]=StaticCString::create(p_arg3); - md.args[3]=StaticCString::create(p_arg4); - md.args[4]=StaticCString::create(p_arg5); - md.args[5]=StaticCString::create(p_arg6); - md.args[6]=StaticCString::create(p_arg7); - md.args[7]=StaticCString::create(p_arg8); - md.args[8]=StaticCString::create(p_arg9); - md.args[9]=StaticCString::create(p_arg10); - return md; -} - - -#endif - - -ClassDB::APIType ClassDB::current_api=API_CORE; - -void ClassDB::set_current_api(APIType p_api) { - - current_api=p_api; -} - -HashMap ClassDB::classes; -HashMap ClassDB::resource_base_extensions; -HashMap ClassDB::compat_classes; - -ClassDB::ClassInfo::ClassInfo() { - - creation_func=NULL; - inherits_ptr=NULL; - disabled=false; -} -ClassDB::ClassInfo::~ClassInfo() { - - -} - - -bool ClassDB::is_parent_class(const StringName &p_class,const StringName& p_inherits) { - - OBJTYPE_RLOCK; - - StringName inherits=p_class; - - while (inherits.operator String().length()) { - - if (inherits==p_inherits) - return true; - inherits=get_parent_class(inherits); - } - - return false; -} -void ClassDB::get_class_list( List *p_classes) { - - OBJTYPE_RLOCK; - - const StringName *k=NULL; - - while((k=classes.next(k))) { - - p_classes->push_back(*k); - } - - p_classes->sort(); -} - - -void ClassDB::get_inheriters_from_class( const StringName& p_class,List *p_classes) { - - OBJTYPE_RLOCK; - - const StringName *k=NULL; - - while((k=classes.next(k))) { - - if (*k!=p_class && is_parent_class(*k,p_class)) - p_classes->push_back(*k); - } - -} - -StringName ClassDB::get_parent_class_nocheck(const StringName& p_class) { - - OBJTYPE_RLOCK; - - ClassInfo *ti = classes.getptr(p_class); - if (!ti) - return StringName(); - return ti->inherits; - -} - -StringName ClassDB::get_parent_class(const StringName& p_class) { - - OBJTYPE_RLOCK; - - ClassInfo *ti = classes.getptr(p_class); - ERR_FAIL_COND_V(!ti,StringName()); - return ti->inherits; -} - -ClassDB::APIType ClassDB::get_api_type(const StringName &p_class) { - - OBJTYPE_RLOCK; - - ClassInfo *ti = classes.getptr(p_class); - - ERR_FAIL_COND_V(!ti,API_NONE); - return ti->api; -} - -uint64_t ClassDB::get_api_hash(APIType p_api) { - - OBJTYPE_RLOCK; -#ifdef DEBUG_METHODS_ENABLED - - uint64_t hash = hash_djb2_one_64(HashMapHahserDefault::hash(VERSION_FULL_NAME)); - - List names; - - const StringName *k=NULL; - - while((k=classes.next(k))) { - - names.push_back(*k); - } - //must be alphabetically sorted for hash to compute - names.sort_custom(); - - for (List::Element *E=names.front();E;E=E->next()) { - - ClassInfo *t = classes.getptr(E->get()); - ERR_FAIL_COND_V(!t,0); - if (t->api!=p_api) - continue; - hash = hash_djb2_one_64(t->name.hash(),hash); - hash = hash_djb2_one_64(t->inherits.hash(),hash); - - { //methods - - List snames; - - k=NULL; - - while((k=t->method_map.next(k))) { - - snames.push_back(*k); - } - - snames.sort_custom(); - - for (List::Element *F=snames.front();F;F=F->next()) { - - MethodBind *mb = t->method_map[F->get()]; - hash = hash_djb2_one_64( mb->get_name().hash(), hash); - hash = hash_djb2_one_64( mb->get_argument_count(), hash); - hash = hash_djb2_one_64( mb->get_argument_type(-1), hash); //return - - for(int i=0;iget_argument_count();i++) { - hash = hash_djb2_one_64( mb->get_argument_info(i).type, hash ); - hash = hash_djb2_one_64( mb->get_argument_info(i).name.hash(), hash ); - hash = hash_djb2_one_64( mb->get_argument_info(i).hint, hash ); - hash = hash_djb2_one_64( mb->get_argument_info(i).hint_string.hash(), hash ); - } - - hash = hash_djb2_one_64( mb->get_default_argument_count(), hash); - - for(int i=0;iget_default_argument_count();i++) { - //hash should not change, i hope for tis - Variant da = mb->get_default_argument(i); - hash = hash_djb2_one_64( da.hash(), hash ); - } - - hash = hash_djb2_one_64( mb->get_hint_flags(), hash); - - } - } - - - { //constants - - List snames; - - k=NULL; - - while((k=t->constant_map.next(k))) { - - snames.push_back(*k); - } - - snames.sort_custom(); - - for (List::Element *F=snames.front();F;F=F->next()) { - - hash = hash_djb2_one_64(F->get().hash(), hash); - hash = hash_djb2_one_64( t->constant_map[F->get()], hash); - } - } - - - { //signals - - List snames; - - k=NULL; - - while((k=t->signal_map.next(k))) { - - snames.push_back(*k); - } - - snames.sort_custom(); - - for (List::Element *F=snames.front();F;F=F->next()) { - - MethodInfo &mi = t->signal_map[F->get()]; - hash = hash_djb2_one_64( F->get().hash(), hash); - for(int i=0;i snames; - - k=NULL; - - while((k=t->property_setget.next(k))) { - - snames.push_back(*k); - } - - snames.sort_custom(); - - for (List::Element *F=snames.front();F;F=F->next()) { - - PropertySetGet *psg=t->property_setget.getptr(F->get()); - - hash = hash_djb2_one_64( F->get().hash(), hash); - hash = hash_djb2_one_64( psg->setter.hash(), hash); - hash = hash_djb2_one_64( psg->getter.hash(), hash); - - } - } - - //property list - for (List::Element *F=t->property_list.front();F;F=F->next()) { - - hash = hash_djb2_one_64( F->get().name.hash(), hash); - hash = hash_djb2_one_64( F->get().type, hash); - hash = hash_djb2_one_64( F->get().hint, hash); - hash = hash_djb2_one_64( F->get().hint_string.hash(), hash); - hash = hash_djb2_one_64( F->get().usage, hash); - } - - - } - - - return hash; -#else - return 0; -#endif - -} - -bool ClassDB::class_exists(const StringName &p_class) { - - OBJTYPE_RLOCK; - return classes.has(p_class); -} - -void ClassDB::add_compatibility_class(const StringName& p_class,const StringName& p_fallback) { - - OBJTYPE_WLOCK; - compat_classes[p_class]=p_fallback; -} - -Object *ClassDB::instance(const StringName &p_class) { - - ClassInfo *ti; - { - OBJTYPE_RLOCK; - ti=classes.getptr(p_class); - if (!ti || ti->disabled || !ti->creation_func) { - if (compat_classes.has(p_class)) { - ti=classes.getptr(compat_classes[p_class]); - } - } - ERR_FAIL_COND_V(!ti,NULL); - ERR_FAIL_COND_V(ti->disabled,NULL); - ERR_FAIL_COND_V(!ti->creation_func,NULL); - } - - return ti->creation_func(); -} -bool ClassDB::can_instance(const StringName &p_class) { - - OBJTYPE_RLOCK; - - ClassInfo *ti = classes.getptr(p_class); - ERR_FAIL_COND_V(!ti,false); - return (!ti->disabled && ti->creation_func!=NULL); -} - - -void ClassDB::_add_class2(const StringName& p_class, const StringName& p_inherits) { - - OBJTYPE_WLOCK; - - StringName name = p_class; - - ERR_FAIL_COND(classes.has(name)); - - classes[name]=ClassInfo(); - ClassInfo &ti=classes[name]; - ti.name=name; - ti.inherits=p_inherits; - ti.api=current_api; - - if (ti.inherits) { - - ERR_FAIL_COND( !classes.has(ti.inherits) ); //it MUST be registered. - ti.inherits_ptr = &classes[ti.inherits]; - - } else { - ti.inherits_ptr=NULL; - } - - -} - -void ClassDB::get_method_list(StringName p_class,List *p_methods,bool p_no_inheritance) { - - - OBJTYPE_RLOCK; - - ClassInfo *type=classes.getptr(p_class); - - while(type) { - - if (type->disabled) { - - if (p_no_inheritance) - break; - - type=type->inherits_ptr; - continue; - } - -#ifdef DEBUG_METHODS_ENABLED - - for( List::Element *E=type->virtual_methods.front();E;E=E->next()) { - - p_methods->push_back(E->get()); - } - - for( List::Element *E=type->method_order.front();E;E=E->next()) { - - MethodBind *method=type->method_map.get(E->get()); - MethodInfo minfo; - minfo.name=E->get(); - minfo.id=method->get_method_id(); - - for (int i=0;iget_argument_count();i++) { - - //Variant::Type t=method->get_argument_type(i); - - minfo.arguments.push_back(method->get_argument_info(i)); - } - - - if (method->get_argument_type(-1)!=Variant::NIL) { - minfo.return_val=method->get_argument_info(-1); - } - - minfo.flags=method->get_hint_flags(); - p_methods->push_back(minfo); - } - - - -#else - - const StringName *K=NULL; - - while((K=type->method_map.next(K))) { - - MethodBind*m = type->method_map[*K]; - MethodInfo mi; - mi.name=m->get_name(); - p_methods->push_back(mi); - } - - -#endif - - if (p_no_inheritance) - break; - - type=type->inherits_ptr; - } - -} - - -MethodBind *ClassDB::get_method(StringName p_class, StringName p_name) { - - OBJTYPE_RLOCK; - - ClassInfo *type=classes.getptr(p_class); - - while(type) { - - MethodBind **method=type->method_map.getptr(p_name); - if (method && *method) - return *method; - type=type->inherits_ptr; - } - return NULL; -} - - -void ClassDB::bind_integer_constant(const StringName& p_class, const StringName &p_name, int p_constant) { - - OBJTYPE_WLOCK; - - ClassInfo *type=classes.getptr(p_class); - if (!type) { - - ERR_FAIL_COND(!type); - } - - if (type->constant_map.has(p_name)) { - - ERR_FAIL(); - } - - type->constant_map[p_name]=p_constant; -#ifdef DEBUG_METHODS_ENABLED - type->constant_order.push_back(p_name); -#endif - -} - -void ClassDB::get_integer_constant_list(const StringName& p_class, List *p_constants, bool p_no_inheritance) { - - OBJTYPE_RLOCK; - - ClassInfo *type=classes.getptr(p_class); - - while(type) { - -#ifdef DEBUG_METHODS_ENABLED - for(List::Element *E=type->constant_order.front();E;E=E->next()) - p_constants->push_back(E->get()); -#else - const StringName *K=NULL; - - while((K=type->constant_map.next(K))) { - p_constants->push_back(*K); - } - -#endif - if (p_no_inheritance) - break; - - type=type->inherits_ptr; - } - -} - - -int ClassDB::get_integer_constant(const StringName& p_class, const StringName &p_name, bool *p_success) { - - OBJTYPE_RLOCK; - - - ClassInfo *type=classes.getptr(p_class); - - while(type) { - - - int *constant=type->constant_map.getptr(p_name); - if (constant) { - - if (p_success) - *p_success=true; - return *constant; - } - - type=type->inherits_ptr; - } - - if (p_success) - *p_success=false; - - return 0; -} - -void ClassDB::add_signal(StringName p_class,const MethodInfo& p_signal) { - - OBJTYPE_WLOCK; - - ClassInfo *type=classes.getptr(p_class); - ERR_FAIL_COND(!type); - - ClassInfo *check=type; - StringName sname = p_signal.name; -#ifdef DEBUG_METHODS_ENABLED - - while(check) { - if (check->signal_map.has(sname)) { - ERR_EXPLAIN("Type "+String(p_class)+" already has signal: "+String(sname)); - ERR_FAIL(); - } - check=check->inherits_ptr; - } -#endif - - type->signal_map[sname]=p_signal; - -} - -void ClassDB::get_signal_list(StringName p_class,List *p_signals,bool p_no_inheritance) { - - OBJTYPE_RLOCK; - - ClassInfo *type=classes.getptr(p_class); - ERR_FAIL_COND(!type); - - ClassInfo *check=type; - - while(check) { - - const StringName *S=NULL; - while((S=check->signal_map.next(S))) { - - p_signals->push_back(check->signal_map[*S]); - } - - if (p_no_inheritance) - return; - - check=check->inherits_ptr; - } - - -} - -bool ClassDB::has_signal(StringName p_class,StringName p_signal) { - - OBJTYPE_RLOCK; - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - if (check->signal_map.has(p_signal)) - return true; - check=check->inherits_ptr; - } - - return false; -} - -bool ClassDB::get_signal(StringName p_class,StringName p_signal,MethodInfo *r_signal) { - - OBJTYPE_RLOCK; - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - if (check->signal_map.has(p_signal)) { - if (r_signal) { - *r_signal=check->signal_map[p_signal]; - } - return true; - } - check=check->inherits_ptr; - } - - return false; -} - - -void ClassDB::add_property_group(StringName p_class,const String& p_name,const String& p_prefix) { - - OBJTYPE_WLOCK; - ClassInfo *type=classes.getptr(p_class); - ERR_FAIL_COND(!type); - - type->property_list.push_back(PropertyInfo(Variant::NIL,p_name,PROPERTY_HINT_NONE,p_prefix,PROPERTY_USAGE_GROUP)); -} - -void ClassDB::add_property(StringName p_class,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index) { - - - - lock->read_lock(); - - ClassInfo *type=classes.getptr(p_class); - - lock->read_unlock(); - - ERR_FAIL_COND(!type); - - MethodBind *mb_set=NULL; - if (p_setter) { - mb_set = get_method(p_class,p_setter); -#ifdef DEBUG_METHODS_ENABLED - if (!mb_set) { - ERR_EXPLAIN("Invalid Setter: "+p_class+"::"+p_setter+" for property: "+p_pinfo.name); - ERR_FAIL_COND(!mb_set); - } else { - int exp_args=1+(p_index>=0?1:0); - if (mb_set->get_argument_count()!=exp_args) { - ERR_EXPLAIN("Invalid Function for Setter: "+p_class+"::"+p_setter+" for property: "+p_pinfo.name); - ERR_FAIL(); - - } - } -#endif - } - - MethodBind *mb_get=NULL; - if (p_getter) { - - MethodBind *mb_get = get_method(p_class,p_getter); -#ifdef DEBUG_METHODS_ENABLED - - if (!mb_get) { - ERR_EXPLAIN("Invalid Getter: "+p_class+"::"+p_getter+" for property: "+p_pinfo.name); - ERR_FAIL_COND(!mb_get); - } else { - - int exp_args=0+(p_index>=0?1:0); - if (mb_get->get_argument_count()!=exp_args) { - ERR_EXPLAIN("Invalid Function for Getter: "+p_class+"::"+p_getter+" for property: "+p_pinfo.name); - ERR_FAIL(); - - } - - } -#endif - } - - - -#ifdef DEBUG_METHODS_ENABLED - - if (type->property_setget.has(p_pinfo.name)) { - ERR_EXPLAIN("Object already has property: "+p_class); - ERR_FAIL(); - } -#endif - - OBJTYPE_WLOCK - - type->property_list.push_back(p_pinfo); - - PropertySetGet psg; - psg.setter=p_setter; - psg.getter=p_getter; - psg._setptr=mb_set; - psg._getptr=mb_get; - psg.index=p_index; - psg.type=p_pinfo.type; - - type->property_setget[p_pinfo.name]=psg; - -} - - -void ClassDB::get_property_list(StringName p_class, List *p_list, bool p_no_inheritance,const Object *p_validator) { - - OBJTYPE_RLOCK; - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - - for(List::Element *E=check->property_list.front();E;E=E->next()) { - - - if (p_validator) { - PropertyInfo pi = E->get(); - p_validator->_validate_property(pi); - p_list->push_back(pi); - } else { - p_list->push_back(E->get()); - } - } - - if (p_no_inheritance) - return ; - check=check->inherits_ptr; - } - -} -bool ClassDB::set_property(Object* p_object,const StringName& p_property, const Variant& p_value,bool *r_valid) { - - - - ClassInfo *type=classes.getptr(p_object->get_class_name()); - ClassInfo *check=type; - while(check) { - const PropertySetGet *psg = check->property_setget.getptr(p_property); - if (psg) { - - if (!psg->setter) { - if (r_valid) - *r_valid=false; - return true; //return true but do nothing - } - - Variant::CallError ce; - - if (psg->index>=0) { - Variant index=psg->index; - const Variant* arg[2]={&index,&p_value}; - //p_object->call(psg->setter,arg,2,ce); - if (psg->_setptr) { - psg->_setptr->call(p_object,arg,2,ce); - } else { - p_object->call(psg->setter,arg,2,ce); - } - - - } else { - const Variant* arg[1]={&p_value}; - if (psg->_setptr) { - psg->_setptr->call(p_object,arg,1,ce); - } else { - p_object->call(psg->setter,arg,1,ce); - } - } - - if (r_valid) - *r_valid=ce.error==Variant::CallError::CALL_OK; - - return true; - } - - check=check->inherits_ptr; - } - - return false; -} -bool ClassDB::get_property(Object* p_object,const StringName& p_property, Variant& r_value) { - - ClassInfo *type=classes.getptr(p_object->get_class_name()); - ClassInfo *check=type; - while(check) { - const PropertySetGet *psg = check->property_setget.getptr(p_property); - if (psg) { - if (!psg->getter) - return true; //return true but do nothing - - if (psg->index>=0) { - Variant index=psg->index; - const Variant* arg[1]={&index}; - Variant::CallError ce; - r_value = p_object->call(psg->getter,arg,1,ce); - - } else { - - Variant::CallError ce; - if (psg->_getptr) { - - r_value = psg->_getptr->call(p_object,NULL,0,ce); - } else { - r_value = p_object->call(psg->getter,NULL,0,ce); - } - } - return true; - } - - const int *c =check->constant_map.getptr(p_property); - if (c) { - - r_value=*c; - return true; - } - //if (check->constant_map.fin) - - check=check->inherits_ptr; - } - - return false; -} - -Variant::Type ClassDB::get_property_type(const StringName& p_class, const StringName& p_property,bool *r_is_valid) { - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - const PropertySetGet *psg = check->property_setget.getptr(p_property); - if (psg) { - - if (r_is_valid) - *r_is_valid=true; - - return psg->type; - } - - check=check->inherits_ptr; - } - if (r_is_valid) - *r_is_valid=false; - - return Variant::NIL; - -} - -StringName ClassDB::get_property_setter(StringName p_class,const StringName p_property) { - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - const PropertySetGet *psg = check->property_setget.getptr(p_property); - if (psg) { - - return psg->setter; - } - - check=check->inherits_ptr; - } - - return StringName(); -} - -StringName ClassDB::get_property_getter(StringName p_class,const StringName p_property) { - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - const PropertySetGet *psg = check->property_setget.getptr(p_property); - if (psg) { - - return psg->getter; - } - - check=check->inherits_ptr; - } - - return StringName(); -} - -bool ClassDB::has_property(const StringName& p_class, const StringName& p_property, bool p_no_inheritance) { - - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - if (check->property_setget.has(p_property)) - return true; - - if (p_no_inheritance) - break; - check=check->inherits_ptr; - } - - return false; -} - -void ClassDB::set_method_flags(StringName p_class,StringName p_method,int p_flags) { - - OBJTYPE_WLOCK; - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - ERR_FAIL_COND(!check); - ERR_FAIL_COND(!check->method_map.has(p_method)); - check->method_map[p_method]->set_hint_flags(p_flags); - - -} - -bool ClassDB::has_method(StringName p_class,StringName p_method,bool p_no_inheritance) { - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - if (check->method_map.has(p_method)) - return true; - if (p_no_inheritance) - return false; - check=check->inherits_ptr; - } - - return false; - -} - -bool ClassDB::get_setter_and_type_for_property(const StringName& p_class, const StringName& p_prop, StringName& r_class, StringName& r_setter) { - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - - if (check->property_setget.has(p_prop)) { - r_class=check->name; - r_setter=check->property_setget[p_prop].setter; - return true; - } - - check=check->inherits_ptr; - } - - return false; - -} - -#ifdef DEBUG_METHODS_ENABLED -MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) { - StringName mdname=method_name.name; -#else -MethodBind* ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const char *method_name, const Variant **p_defs, int p_defcount) { - StringName mdname=StaticCString::create(method_name); -#endif - - - StringName rettype; - if (mdname.operator String().find(":")!=-1) { - rettype = mdname.operator String().get_slice(":",1); - mdname = mdname.operator String().get_slice(":",0); - } - - - OBJTYPE_WLOCK; - ERR_FAIL_COND_V(!p_bind,NULL); - p_bind->set_name(mdname); - - String instance_type=p_bind->get_instance_class(); - -#ifdef DEBUG_ENABLED - - if (has_method(instance_type,mdname)) { - ERR_EXPLAIN("Class "+String(instance_type)+" already has a method "+String(mdname)); - ERR_FAIL_V(NULL); - } -#endif - - - ClassInfo *type=classes.getptr(instance_type); - if (!type) { - ERR_PRINTS("Couldn't bind method '"+mdname+"' for instance: "+instance_type); - memdelete(p_bind); - ERR_FAIL_COND_V(!type,NULL); - } - - if (type->method_map.has(mdname)) { - memdelete(p_bind); - // overloading not supported - ERR_EXPLAIN("Method already bound: "+instance_type+"::"+mdname); - ERR_FAIL_V(NULL); - } -#ifdef DEBUG_METHODS_ENABLED - p_bind->set_argument_names(method_name.args); - p_bind->set_return_type(rettype); - type->method_order.push_back(mdname); -#endif - type->method_map[mdname]=p_bind; - - - Vector defvals; - - defvals.resize(p_defcount); - for(int i=0;iset_default_arguments(defvals); - p_bind->set_hint_flags(p_flags); - return p_bind; - -} - -void ClassDB::add_virtual_method(const StringName& p_class, const MethodInfo& p_method , bool p_virtual) { - ERR_FAIL_COND(!classes.has(p_class)); - - OBJTYPE_WLOCK; - -#ifdef DEBUG_METHODS_ENABLED - MethodInfo mi=p_method; - if (p_virtual) - mi.flags|=METHOD_FLAG_VIRTUAL; - classes[p_class].virtual_methods.push_back(mi); - -#endif - -} - -void ClassDB::get_virtual_methods(const StringName& p_class, List * p_methods , bool p_no_inheritance) { - - ERR_FAIL_COND(!classes.has(p_class)); - -#ifdef DEBUG_METHODS_ENABLED - - ClassInfo *type=classes.getptr(p_class); - ClassInfo *check=type; - while(check) { - - for(List::Element *E=check->virtual_methods.front();E;E=E->next()) { - p_methods->push_back(E->get()); - } - - if (p_no_inheritance) - return; - check=check->inherits_ptr; - } - -#endif - -} - -void ClassDB::set_class_enabled(StringName p_class,bool p_enable) { - - OBJTYPE_WLOCK; - - ERR_FAIL_COND(!classes.has(p_class)); - classes[p_class].disabled=!p_enable; -} - -bool ClassDB::is_class_enabled(StringName p_class) { - - OBJTYPE_RLOCK; - - ClassInfo *ti=classes.getptr(p_class); - if (!ti || !ti->creation_func) { - if (compat_classes.has(p_class)) { - ti=classes.getptr(compat_classes[p_class]); - } - } - - ERR_FAIL_COND_V(!ti,false); - return !ti->disabled; -} - -StringName ClassDB::get_category(const StringName& p_node) { - - ERR_FAIL_COND_V(!classes.has(p_node),StringName()); -#ifdef DEBUG_ENABLED - return classes[p_node].category; -#else - return StringName(); -#endif -} - -void ClassDB::add_resource_base_extension(const StringName& p_extension,const StringName& p_class) { - - if (resource_base_extensions.has(p_extension)) - return; - - resource_base_extensions[p_extension]=p_class; -} - -void ClassDB::get_resource_base_extensions(List *p_extensions) { - - const StringName *K=NULL; - - while((K=resource_base_extensions.next(K))) { - - p_extensions->push_back(*K); - } -} - -void ClassDB::get_extensions_for_type(const StringName& p_class,List *p_extensions) { - - const StringName *K=NULL; - - while((K=resource_base_extensions.next(K))) { - StringName cmp = resource_base_extensions[*K]; - if (is_parent_class(cmp,p_class)) - p_extensions->push_back(*K); - } -} - - -RWLock *ClassDB::lock=NULL; - -void ClassDB::init() { - -#ifndef NO_THREADS - - lock = RWLock::create(); -#endif -} - -void ClassDB::cleanup() { - - - - //OBJTYPE_LOCK; hah not here - - const StringName *k=NULL; - - while((k=classes.next(k))) { - - ClassInfo &ti=classes[*k]; - - const StringName *m=NULL; - while((m=ti.method_map.next(m))) { - - memdelete( ti.method_map[*m] ); - } - } - classes.clear(); - resource_base_extensions.clear(); - compat_classes.clear(); - -#ifndef NO_THREADS - - memdelete(lock); -#endif - -} - -// diff --git a/core/object_type_db.h b/core/object_type_db.h deleted file mode 100644 index f745e3d5fd..0000000000 --- a/core/object_type_db.h +++ /dev/null @@ -1,540 +0,0 @@ -/*************************************************************************/ -/* object_type_db.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef OBJECT_TYPE_DB_H -#define OBJECT_TYPE_DB_H - -#include "object.h" -#include "method_bind.h" -#include "print_string.h" -/** - @author Juan Linietsky -*/ - -struct ParamHint { - - String name; - PropertyHint hint; - String hint_text; - Variant default_val; - - ParamHint(const String& p_name="", PropertyHint p_hint=PROPERTY_HINT_NONE, const String& p_hint_text="",Variant p_default_val=Variant()) { - - name=p_name; - hint=p_hint; - hint_text=p_hint_text; - default_val=p_default_val; - } - -}; - -struct ParamDef { - bool used; - Variant val; - _FORCE_INLINE_ ParamDef() { used=false; } - ParamDef(const Variant& p_variant); -}; - -//#define DEFVAL( m_defval ) ParamDef(m_defval) -#define DEFVAL( m_defval ) (m_defval) - - -//#define SIMPLE_METHODDEF - -#ifdef DEBUG_METHODS_ENABLED - -struct MethodDefinition { - - - StringName name; - Vector args; - MethodDefinition() {} - MethodDefinition(const char *p_name) { name=p_name; } - MethodDefinition(const StringName& p_name) { name=p_name; } -}; - - - -MethodDefinition _MD(const char* p_name); -MethodDefinition _MD(const char* p_name,const char *p_arg1); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9); -MethodDefinition _MD(const char* p_name,const char *p_arg1,const char *p_arg2,const char *p_arg3,const char *p_arg4,const char *p_arg5,const char *p_arg6,const char *p_arg7,const char *p_arg8,const char *p_arg9,const char *p_arg10); - -#else - -//#define NO_VARIADIC_MACROS - -#ifdef NO_VARIADIC_MACROS - -static _FORCE_INLINE_ const char* _MD(const char* m_name, ...) { return m_name; } - -#else - -#define _MD(m_c, ...) m_c - -#endif - -#endif - -class ClassDB { -public: - enum APIType { - API_CORE, - API_EDITOR, - API_NONE - }; -public: - struct PropertySetGet { - - int index; - StringName setter; - StringName getter; - MethodBind *_setptr; - MethodBind *_getptr; - Variant::Type type; - }; - - struct ClassInfo { - - APIType api; - ClassInfo *inherits_ptr; - HashMap method_map; - HashMap constant_map; - HashMap signal_map; - List property_list; -#ifdef DEBUG_METHODS_ENABLED - List constant_order; - List method_order; - List virtual_methods; - StringName category; -#endif - HashMap property_setget; - - - StringName inherits; - StringName name; - bool disabled; - Object* (*creation_func)(); - ClassInfo(); - ~ClassInfo(); - }; - - template - static Object *creator() { - return memnew( T ); - } - - static RWLock *lock; - static HashMap classes; - static HashMap resource_base_extensions; - static HashMap compat_classes; - -#ifdef DEBUG_METHODS_ENABLED - static MethodBind* bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const MethodDefinition &method_name, const Variant **p_defs, int p_defcount); -#else - static MethodBind* bind_methodfi(uint32_t p_flags, MethodBind *p_bind , const char *method_name, const Variant **p_defs, int p_defcount); -#endif - - - static APIType current_api; - - static void _add_class2(const StringName& p_class, const StringName& p_inherits); -public: - - // DO NOT USE THIS!!!!!! NEEDS TO BE PUBLIC BUT DO NOT USE NO MATTER WHAT!!! - template - static void _add_class() { - - _add_class2(T::get_class_static(),T::get_parent_class_static()); -#if 0 - GLOBAL_LOCK_FUNCTION; - - StringName name = T::get_class_static(); - - ERR_FAIL_COND(types.has(name)); - - types[name]=TypeInfo(); - TypeInfo &ti=types[name]; - ti.name=name; - ti.inherits=T::get_parent_class_static(); - - if (ti.inherits) { - - ERR_FAIL_COND( !types.has(ti.inherits) ); //it MUST be registered. - ti.inherits_ptr = &types[ti.inherits]; - - } else { - ti.inherits_ptr=NULL; - } -#endif - } - - template - static void register_class() { - - GLOBAL_LOCK_FUNCTION; - T::initialize_class(); - ClassInfo *t=classes.getptr(T::get_class_static()); - ERR_FAIL_COND(!t); - t->creation_func=&creator; - T::register_custom_data_to_otdb(); - } - - template - static void register_virtual_class() { - - GLOBAL_LOCK_FUNCTION; - T::initialize_class(); - //nothing - } - - template - static Object* _create_ptr_func() { - - return T::create(); - } - - template - static void register_custom_instance_class() { - - GLOBAL_LOCK_FUNCTION; - T::initialize_class(); - ClassInfo *t=classes.getptr(T::get_class_static()); - ERR_FAIL_COND(!t); - t->creation_func=&_create_ptr_func; - T::register_custom_data_to_otdb(); - } - - static void get_class_list( List *p_classes); - static void get_inheriters_from_class( const StringName& p_class,List *p_classes); - static StringName get_parent_class_nocheck(const StringName& p_class); - static StringName get_parent_class(const StringName& p_class); - static bool class_exists(const StringName &p_class); - static bool is_parent_class(const StringName &p_class,const StringName& p_inherits); - static bool can_instance(const StringName &p_class); - static Object *instance(const StringName &p_class); - static APIType get_api_type(const StringName &p_class); - - static uint64_t get_api_hash(APIType p_api); - -#if 0 - template - static MethodBind* bind_method(N p_method_name, M p_method, - //default arguments - ParamDef d1=ParamDef(), - ParamDef d2=ParamDef(), - ParamDef d3=ParamDef(), - ParamDef d4=ParamDef(), - ParamDef d5=ParamDef() - ) { - - return bind_methodf(METHOD_FLAGS_DEFAULT,p_method_name, p_method, d1,d2,d3,d4,d5); - } - - - - template - static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, - - - //default arguments - const ParamDef &d1=ParamDef(), - const ParamDef &d2=ParamDef(), - const ParamDef &d3=ParamDef(), - const ParamDef &d4=ParamDef(), - const ParamDef &d5=ParamDef() - ) { - - GLOBAL_LOCK_FUNCTION; - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - bind->set_name(method_name.name); - ERR_FAIL_COND_V(!bind,NULL); - - String instance_type=bind->get_instance_type(); - - TypeInfo *type=types.getptr(instance_type); - if (!type) { - memdelete(bind); - ERR_FAIL_COND_V(!type,NULL); - } - - if (type->method_map.has(method_name.name)) { - memdelete(bind); - // overloading not supported - ERR_EXPLAIN("Method already bound: "+instance_type+"::"+method_name.name); - ERR_FAIL_V(NULL); - } - bind->set_argument_names(method_name.args); - type->method_map[method_name.name]=bind; - - Vector defvals; - -#define PARSE_DEFVAL(m_defval)\ - if (d##m_defval.used) defvals.insert(0,d##m_defval.val);\ - else goto set_defvals; - - - PARSE_DEFVAL(1); - PARSE_DEFVAL(2); - PARSE_DEFVAL(3); - PARSE_DEFVAL(4); - PARSE_DEFVAL(5); - set_defvals: - - bind->set_default_arguments(defvals); - bind->set_hint_flags(p_flags); - - return bind; -#undef PARSE_DEFVAL - } -#else - -#if 0 - template - static MethodBind* bind_method(N p_method_name, M p_method, - //default arguments - const ParamDef &d1=ParamDef(), - const ParamDef &d2=ParamDef(), - const ParamDef &d3=ParamDef(), - const ParamDef &d4=ParamDef(), - const ParamDef &d5=ParamDef() - ) { - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage - } -#endif - - template - static MethodBind* bind_method(N p_method_name, M p_method) { - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,NULL,0); //use static function, much smaller binary usage - } - - template - static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1) { - - MethodBind *bind = create_method_bind(p_method); - const Variant* ptr[1]={&p_def1}; - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,1); - } - - - template - static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2) { - - MethodBind *bind = create_method_bind(p_method); - const Variant* ptr[2]={&p_def1,&p_def2}; - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,2); - } - - template - static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3) { - - MethodBind *bind = create_method_bind(p_method); - const Variant* ptr[3]={&p_def1,&p_def2,&p_def3}; - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,3); - } - - template - static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3,const Variant& p_def4) { - - MethodBind *bind = create_method_bind(p_method); - const Variant* ptr[4]={&p_def1,&p_def2,&p_def3,&p_def4}; - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,4); - } - - template - static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3,const Variant& p_def4,const Variant& p_def5) { - - MethodBind *bind = create_method_bind(p_method); - const Variant* ptr[5]={&p_def1,&p_def2,&p_def3,&p_def4,&p_def5}; - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,5); - } - - template - static MethodBind* bind_method(N p_method_name, M p_method,const Variant& p_def1,const Variant& p_def2,const Variant& p_def3,const Variant& p_def4,const Variant& p_def5,const Variant& p_def6) { - - MethodBind *bind = create_method_bind(p_method); - const Variant* ptr[6]={&p_def1,&p_def2,&p_def3,&p_def4,&p_def5,&p_def6}; - - return bind_methodfi(METHOD_FLAGS_DEFAULT,bind,p_method_name,ptr,6); - } - -#if 0 - template - static MethodBind* bind_methodf(uint32_t p_flags, N p_method_name, M p_method, - - const ParamDef& d1=ParamDef(), - const ParamDef& d2=ParamDef(), - const ParamDef& d3=ParamDef(), - const ParamDef& d4=ParamDef(), - const ParamDef& d5=ParamDef() - ) { - - MethodDefinition method_name=p_method_name; - - MethodBind *bind = create_method_bind(p_method); - - return bind_methodfi(p_flags,bind,method_name,d1,d2,d3,d4,d5); //use static function, much smaller binary usage - } -#endif - -#endif - template - static MethodBind* bind_vararg_method(uint32_t p_flags, StringName p_name, M p_method,const MethodInfo& p_info=MethodInfo(),const Vector& p_default_args=Vector()) { - - GLOBAL_LOCK_FUNCTION; - - - - MethodBind *bind = create_vararg_method_bind(p_method,p_info); - ERR_FAIL_COND_V(!bind,NULL); - - String rettype; - if (p_name.operator String().find(":")!=-1) { - rettype = p_name.operator String().get_slice(":",1); - p_name = p_name.operator String().get_slice(":",0); - } - - bind->set_name(p_name); - bind->set_default_arguments(p_default_args); - - String instance_type=bind->get_instance_class(); - - ClassInfo *type=classes.getptr(instance_type); - if (!type) { - memdelete(bind); - ERR_FAIL_COND_V(!type,NULL); - } - - if (type->method_map.has(p_name)) { - memdelete(bind); - // overloading not supported - ERR_EXPLAIN("Method already bound: "+instance_type+"::"+p_name); - ERR_FAIL_V(NULL); - } - type->method_map[p_name]=bind; -#ifdef DEBUG_METHODS_ENABLED - if (!rettype.empty()) - bind->set_return_type(rettype); - type->method_order.push_back(p_name); -#endif - - - return bind; - - } - - - static void add_signal(StringName p_class,const MethodInfo& p_signal); - static bool has_signal(StringName p_class,StringName p_signal); - static bool get_signal(StringName p_class,StringName p_signal,MethodInfo *r_signal); - static void get_signal_list(StringName p_class,List *p_signals,bool p_no_inheritance=false); - - static void add_property_group(StringName p_class,const String& p_name,const String& p_prefix=""); - static void add_property(StringName p_class,const PropertyInfo& p_pinfo, const StringName& p_setter, const StringName& p_getter, int p_index=-1); - static void get_property_list(StringName p_class, List *p_list, bool p_no_inheritance=false, const Object *p_validator=NULL); - static bool set_property(Object* p_object, const StringName& p_property, const Variant& p_value, bool *r_valid=NULL); - static bool get_property(Object* p_object,const StringName& p_property, Variant& r_value); - static bool has_property(const StringName& p_class,const StringName& p_property,bool p_no_inheritance=false); - static Variant::Type get_property_type(const StringName& p_class, const StringName& p_property,bool *r_is_valid=NULL); - static StringName get_property_setter(StringName p_class,const StringName p_property); - static StringName get_property_getter(StringName p_class,const StringName p_property); - - - - static bool has_method(StringName p_class,StringName p_method,bool p_no_inheritance=false); - static void set_method_flags(StringName p_class,StringName p_method,int p_flags); - - - static void get_method_list(StringName p_class,List *p_methods,bool p_no_inheritance=false); - static MethodBind *get_method(StringName p_class, StringName p_name); - - static void add_virtual_method(const StringName& p_class,const MethodInfo& p_method,bool p_virtual=true ); - static void get_virtual_methods(const StringName& p_class,List * p_methods,bool p_no_inheritance=false ); - - static void bind_integer_constant(const StringName& p_class, const StringName &p_name, int p_constant); - static void get_integer_constant_list(const StringName& p_class, List *p_constants, bool p_no_inheritance=false); - static int get_integer_constant(const StringName& p_class, const StringName &p_name, bool *p_success=NULL); - static StringName get_category(const StringName& p_node); - - static bool get_setter_and_type_for_property(const StringName& p_class, const StringName& p_prop, StringName& r_class, StringName& r_setter); - - static void set_class_enabled(StringName p_class,bool p_enable); - static bool is_class_enabled(StringName p_class); - - static void add_resource_base_extension(const StringName& p_extension,const StringName& p_class); - static void get_resource_base_extensions(List *p_extensions); - static void get_extensions_for_type(const StringName& p_class,List *p_extensions); - - static void add_compatibility_class(const StringName& p_class,const StringName& p_fallback); - static void init(); - - static void set_current_api(APIType p_api); - static void cleanup(); -}; - - -#define BIND_CONSTANT(m_constant)\ - ClassDB::bind_integer_constant( get_class_static() , #m_constant, m_constant); - -#ifdef TOOLS_ENABLED - -#define BIND_VMETHOD(m_method)\ - ClassDB::add_virtual_method( get_class_static() , m_method ); - -#else - -#define BIND_VMETHOD(m_method) - -#endif - - - -#endif diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index 5f3b877822..d3bb03ab5e 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -27,11 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "packed_data_container.h" + #include "io/marshalls.h" #include "core_string_names.h" - Variant PackedDataContainer::getvar(const Variant& p_key, bool *r_valid) const { bool err=false; diff --git a/core/path_db.cpp b/core/path_db.cpp index 25f62ed951..de3a4cceee 100644 --- a/core/path_db.cpp +++ b/core/path_db.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "path_db.h" -#include "print_string.h" +#include "print_string.h" uint32_t NodePath::hash() const { diff --git a/core/path_remap.cpp b/core/path_remap.cpp index 646c1c497b..ed77fd8840 100644 --- a/core/path_remap.cpp +++ b/core/path_remap.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "path_remap.h" + #include "globals.h" #include "os/os.h" #include "translation.h" + PathRemap* PathRemap::singleton=NULL; PathRemap* PathRemap::get_singleton() { diff --git a/core/pool_allocator.cpp b/core/pool_allocator.cpp index e425218060..b1417dd107 100644 --- a/core/pool_allocator.cpp +++ b/core/pool_allocator.cpp @@ -27,12 +27,15 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "pool_allocator.h" + #include "error_macros.h" #include "core/os/os.h" #include "os/memory.h" #include "os/copymem.h" #include "print_string.h" + #include + #define COMPACT_CHUNK( m_entry , m_to_pos ) \ do { \ void *_dst=&((unsigned char*)pool)[m_to_pos]; \ diff --git a/core/print_string.cpp b/core/print_string.cpp index 3faed62bb4..36316af619 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -27,7 +27,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "print_string.h" + #include "os/os.h" + #include static PrintHandlerList *print_handler_list=NULL; diff --git a/core/ref_ptr.cpp b/core/ref_ptr.cpp index e781bae496..29ffe974d2 100644 --- a/core/ref_ptr.cpp +++ b/core/ref_ptr.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "ref_ptr.h" + #include "reference.h" #include "resource.h" diff --git a/core/reference.cpp b/core/reference.cpp index 69e053cc1a..d21caf0839 100644 --- a/core/reference.cpp +++ b/core/reference.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "reference.h" + #include "script_language.h" diff --git a/core/reference.h b/core/reference.h index ce196801bb..e130b4c2b4 100644 --- a/core/reference.h +++ b/core/reference.h @@ -32,7 +32,7 @@ #include "object.h" #include "safe_refcount.h" #include "ref_ptr.h" -#include "object_type_db.h" +#include "class_db.h" /** @author Juan Linietsky diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 85fa5d27c0..242d36042d 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -36,7 +36,7 @@ #include "math/a_star.h" #include "math/triangle_mesh.h" #include "globals.h" -#include "object_type_db.h" +#include "class_db.h" #include "geometry.h" #include "bind/core_bind.h" #include "core_string_names.h" diff --git a/core/resource.cpp b/core/resource.cpp index 3369e4a5a2..df18d9584e 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -27,12 +27,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource.h" + #include "core_string_names.h" -#include #include "os/file_access.h" #include "io/resource_loader.h" #include "script_language.h" +#include + void ResourceImportMetadata::set_editor(const String& p_editor) { editor=p_editor; diff --git a/core/resource.h b/core/resource.h index 284c59e1a8..2b071c8e1c 100644 --- a/core/resource.h +++ b/core/resource.h @@ -33,7 +33,7 @@ #include "safe_refcount.h" #include "ref_ptr.h" #include "reference.h" -#include "object_type_db.h" +#include "class_db.h" /** @author Juan Linietsky diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index a8d77668f5..5cce68af1c 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_debugger_local.h" + #include "os/os.h" void ScriptDebuggerLocal::debug(ScriptLanguage *p_script,bool p_can_continue) { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index bb0109467e..62d14c4e5a 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -27,10 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_debugger_remote.h" + #include "os/os.h" #include "io/ip.h" #include "globals.h" #include "os/input.h" + void ScriptDebuggerRemote::_send_video_memory() { List usage; diff --git a/core/string_db.cpp b/core/string_db.cpp index be35a44ed1..004b07b9e5 100644 --- a/core/string_db.cpp +++ b/core/string_db.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "string_db.h" + #include "print_string.h" #include "os/os.h" + StaticCString StaticCString::create(const char *p_ptr) { StaticCString scs; scs.ptr=p_ptr; return scs; } diff --git a/core/translation.cpp b/core/translation.cpp index 5215e5f6d1..d5ec61b8d6 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "translation.h" + #include "globals.h" #include "io/resource_loader.h" #include "os/os.h" diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index acb262d400..1a0ccc4a7e 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "undo_redo.h" + #include "os/os.h" void UndoRedo::_discard_redo() { diff --git a/core/ustring.cpp b/core/ustring.cpp index 66608379be..bfcdcb39e6 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include #include "ustring.h" + #include "os/memory.h" #include "print_string.h" #include "math_funcs.h" @@ -36,10 +36,8 @@ #include "ucaps.h" #include "color.h" #include "variant.h" -#define MAX_DIGITS 6 -#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c)) -#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c)) +#include #ifndef NO_USE_STDLIB #include @@ -50,6 +48,10 @@ #define snprintf _snprintf #endif +#define MAX_DIGITS 6 +#define UPPERCASE(m_c) (((m_c)>='a' && (m_c)<='z')?((m_c)-('a'-'A')):(m_c)) +#define LOWERCASE(m_c) (((m_c)>='A' && (m_c)<='Z')?((m_c)+('a'-'A')):(m_c)) + /** STRING **/ const char *CharString::get_data() const { diff --git a/core/variant.cpp b/core/variant.cpp index 5a670a2786..37f971770d 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant.h" + #include "resource.h" #include "print_string.h" #include "scene/main/node.h" diff --git a/core/variant.h b/core/variant.h index 9d29fd64c3..5936325c1b 100644 --- a/core/variant.h +++ b/core/variant.h @@ -33,7 +33,7 @@ @author Juan Linietsky */ -#include "aabb.h" +#include "rect3.h" #include "ustring.h" #include "vector3.h" #include "plane.h" diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 51ad115d46..37dd91c4cf 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant.h" + #include "object.h" #include "os/os.h" #include "core_string_names.h" diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 50f0b96715..6ed8a3dd85 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -27,9 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant.h" + #include "object.h" #include "script_language.h" #include "core_string_names.h" + Variant::operator bool() const { bool b; diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index ca748b7fd3..ee73444aa3 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -27,11 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "variant_parser.h" + #include "io/resource_loader.h" #include "os/keyboard.h" - CharType VariantParser::StreamFile::get_char() { return f->get_8(); diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp index 1c41b2e73b..36f75111d7 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gd_functions.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "gd_functions.h" #include "math_funcs.h" -#include "object_type_db.h" +#include "class_db.h" #include "reference.h" #include "gd_script.h" #include "func_ref.h" diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp index b4a0d3b0b7..9cd70a0f9b 100644 --- a/modules/gridmap/register_types.cpp +++ b/modules/gridmap/register_types.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "register_types.h" #ifndef _3D_DISABLED -#include "object_type_db.h" +#include "class_db.h" #include "grid_map.h" #include "grid_map_editor_plugin.h" #endif diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp index d44c7e563c..c62a04d80f 100644 --- a/modules/regex/register_types.cpp +++ b/modules/regex/register_types.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "register_types.h" -#include "object_type_db.h" +#include "class_db.h" #include "regex.h" void register_regex_types() { diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 27242384ac..422e323d6d 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -1,6 +1,6 @@ #include "visual_script_builtin_funcs.h" #include "math_funcs.h" -#include "object_type_db.h" +#include "class_db.h" #include "reference.h" #include "func_ref.h" #include "os/os.h" diff --git a/scene/main/node.h b/scene/main/node.h index 14fd19a76f..d88db8ecb0 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -33,7 +33,7 @@ #include "object.h" #include "path_db.h" #include "map.h" -#include "object_type_db.h" +#include "class_db.h" #include "script_language.h" #include "scene/main/scene_main_loop.h" diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index f1b0af0dd2..1932f9cbf6 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -34,7 +34,7 @@ //#include "scene/io/scene_format_script.h" #include "resources/default_theme/default_theme.h" -#include "object_type_db.h" +#include "class_db.h" #include "scene/main/canvas_layer.h" #include "scene/main/instance_placeholder.h" #include "scene/main/viewport.h" diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 2cc2d7d45e..20b3efc7fb 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -30,7 +30,7 @@ #define BROAD_PHASE_SW_H #include "math_funcs.h" -#include "aabb.h" +#include "rect3.h" class CollisionObjectSW; diff --git a/tools/collada/collada.cpp b/tools/collada/collada.cpp index daf30b00d7..3b2c3a99e9 100644 --- a/tools/collada/collada.cpp +++ b/tools/collada/collada.cpp @@ -29,6 +29,7 @@ #ifdef TOOLS_ENABLED #include "collada.h" + #include "stdio.h" //#define DEBUG_DEFAULT_ANIMATION diff --git a/tools/doc/doc_data.cpp b/tools/doc/doc_data.cpp index f18265c541..d51dc886b2 100644 --- a/tools/doc/doc_data.cpp +++ b/tools/doc/doc_data.cpp @@ -26,9 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "doc_data.h" +#include "version.h" #include "global_constants.h" #include "globals.h" #include "script_language.h" diff --git a/tools/doc/doc_dump.cpp b/tools/doc/doc_dump.cpp index e1ffcfbbb2..5ebba596e9 100644 --- a/tools/doc/doc_dump.cpp +++ b/tools/doc/doc_dump.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "doc_dump.h" + +#include "version.h" #include "os/file_access.h" #include "scene/main/node.h" diff --git a/tools/doc/doc_dump.h b/tools/doc/doc_dump.h index 4577af078e..84629b89c8 100644 --- a/tools/doc/doc_dump.h +++ b/tools/doc/doc_dump.h @@ -29,7 +29,7 @@ #ifndef DOC_DUMP_H #define DOC_DUMP_H -#include "object_type_db.h" +#include "class_db.h" class DocDump { public: diff --git a/tools/editor/animation_editor.cpp b/tools/editor/animation_editor.cpp index cb95f5fb7d..d69e48f9b2 100644 --- a/tools/editor/animation_editor.cpp +++ b/tools/editor/animation_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "animation_editor.h" + #include "editor_settings.h" #include "os/keyboard.h" #include "os/os.h" diff --git a/tools/editor/asset_library_editor_plugin.cpp b/tools/editor/asset_library_editor_plugin.cpp index ad17364685..823f134379 100644 --- a/tools/editor/asset_library_editor_plugin.cpp +++ b/tools/editor/asset_library_editor_plugin.cpp @@ -27,12 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "asset_library_editor_plugin.h" + #include "editor_node.h" #include "editor_settings.h" #include "io/json.h" - void EditorAssetLibraryItem::configure(const String& p_title,int p_asset_id,const String& p_category,int p_category_id,const String& p_author,int p_author_id,int p_rating,const String& p_cost) { title->set_text(p_title); diff --git a/tools/editor/call_dialog.cpp b/tools/editor/call_dialog.cpp index f8966093f6..6dfeb87dfd 100644 --- a/tools/editor/call_dialog.cpp +++ b/tools/editor/call_dialog.cpp @@ -30,7 +30,7 @@ #if 0 #include "scene/gui/label.h" -#include "object_type_db.h" +#include "class_db.h" #include "print_string.h" diff --git a/tools/editor/code_editor.cpp b/tools/editor/code_editor.cpp index 00767fd297..0a25b43716 100644 --- a/tools/editor/code_editor.cpp +++ b/tools/editor/code_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "code_editor.h" + #include "editor_settings.h" #include "scene/gui/margin_container.h" #include "scene/gui/separator.h" diff --git a/tools/editor/connections_dialog.cpp b/tools/editor/connections_dialog.cpp index 92dd206030..91ba419c97 100644 --- a/tools/editor/connections_dialog.cpp +++ b/tools/editor/connections_dialog.cpp @@ -28,10 +28,7 @@ /*************************************************************************/ #include "connections_dialog.h" - #include "scene/gui/label.h" - - #include "print_string.h" #include "editor_settings.h" #include "editor_node.h" diff --git a/tools/editor/create_dialog.cpp b/tools/editor/create_dialog.cpp index b69234e704..53e968f389 100644 --- a/tools/editor/create_dialog.cpp +++ b/tools/editor/create_dialog.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "create_dialog.h" -#include "object_type_db.h" +#include "class_db.h" #include "print_string.h" #include "scene/gui/box_container.h" #include "editor_node.h" diff --git a/tools/editor/dependency_editor.cpp b/tools/editor/dependency_editor.cpp index 20e185104b..a01383a868 100644 --- a/tools/editor/dependency_editor.cpp +++ b/tools/editor/dependency_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "dependency_editor.h" + #include "os/file_access.h" #include "scene/gui/margin_container.h" #include "io/resource_loader.h" diff --git a/tools/editor/editor_asset_installer.cpp b/tools/editor/editor_asset_installer.cpp index 9992100ff8..8af01012a4 100644 --- a/tools/editor/editor_asset_installer.cpp +++ b/tools/editor/editor_asset_installer.cpp @@ -27,10 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_asset_installer.h" + #include "io/zip_io.h" #include "os/dir_access.h" #include "os/file_access.h" #include "editor_node.h" + void EditorAssetInstaller::_update_subitems(TreeItem* p_item,bool p_check,bool p_first) { diff --git a/tools/editor/editor_autoload_settings.cpp b/tools/editor/editor_autoload_settings.cpp index 087bf1a3b7..0038ab48d5 100644 --- a/tools/editor/editor_autoload_settings.cpp +++ b/tools/editor/editor_autoload_settings.cpp @@ -26,12 +26,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "editor_autoload_settings.h" #include "globals.h" #include "global_constants.h" - #include "editor_node.h" #define PREVIEW_LIST_MAX_SIZE 10 diff --git a/tools/editor/editor_data.cpp b/tools/editor/editor_data.cpp index 08b03ae65f..44de1836b6 100644 --- a/tools/editor/editor_data.cpp +++ b/tools/editor/editor_data.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_data.h" + #include "globals.h" #include "editor_settings.h" #include "os/dir_access.h" diff --git a/tools/editor/editor_dir_dialog.cpp b/tools/editor/editor_dir_dialog.cpp index e2b7d475b0..bb9ddc2aef 100644 --- a/tools/editor/editor_dir_dialog.cpp +++ b/tools/editor/editor_dir_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_dir_dialog.h" + #include "os/os.h" #include "os/keyboard.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/editor_file_dialog.cpp b/tools/editor/editor_file_dialog.cpp index d4ca515493..d801cc396d 100644 --- a/tools/editor/editor_file_dialog.cpp +++ b/tools/editor/editor_file_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_dialog.h" + #include "scene/gui/label.h" #include "scene/gui/center_container.h" #include "print_string.h" @@ -36,6 +37,7 @@ #include "scene/gui/margin_container.h" #include "os/file_access.h" #include "editor_scale.h" + EditorFileDialog::GetIconFunc EditorFileDialog::get_icon_func=NULL; EditorFileDialog::GetIconFunc EditorFileDialog::get_large_icon_func=NULL; diff --git a/tools/editor/editor_file_system.cpp b/tools/editor/editor_file_system.cpp index 1d32415be9..39869beef4 100644 --- a/tools/editor/editor_file_system.cpp +++ b/tools/editor/editor_file_system.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_system.h" + #include "globals.h" #include "io/resource_loader.h" #include "os/os.h" diff --git a/tools/editor/editor_fonts.cpp b/tools/editor/editor_fonts.cpp index 3c846fc538..3652a59978 100644 --- a/tools/editor/editor_fonts.cpp +++ b/tools/editor/editor_fonts.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_fonts.h" + #include "doc_font.h" #include "doc_title_font.h" #include "doc_code_font.h" diff --git a/tools/editor/editor_help.cpp b/tools/editor/editor_help.cpp index f96a02bc52..03e631cbc3 100644 --- a/tools/editor/editor_help.cpp +++ b/tools/editor/editor_help.cpp @@ -27,15 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_help.h" + #include "editor_node.h" #include "editor_settings.h" #include "os/keyboard.h" #include "doc_data_compressed.h" #include "tools/editor/plugins/script_editor_plugin.h" - -#include "os/keyboard.h" - void EditorHelpSearch::popup() { popup_centered_ratio(0.6); if (search_box->get_text()!="") { diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index cf83052ee0..c512ec6067 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "editor_import_export.h" + +#include "version.h" #include "script_language.h" #include "globals.h" #include "os/file_access.h" diff --git a/tools/editor/editor_initialize_ssl.cpp b/tools/editor/editor_initialize_ssl.cpp index 9ac4f90e9f..c08dcc6656 100644 --- a/tools/editor/editor_initialize_ssl.cpp +++ b/tools/editor/editor_initialize_ssl.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_initialize_ssl.h" + #include "certs_compressed.h" #include "io/stream_peer_ssl.h" #include "io/compression.h" diff --git a/tools/editor/editor_log.cpp b/tools/editor/editor_log.cpp index fd2da2e4c0..6b6a1b9988 100644 --- a/tools/editor/editor_log.cpp +++ b/tools/editor/editor_log.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "editor_log.h" + +#include "version.h" #include "scene/gui/center_container.h" #include "editor_node.h" diff --git a/tools/editor/editor_name_dialog.cpp b/tools/editor/editor_name_dialog.cpp index e7dcea4d40..da9f25f1e3 100644 --- a/tools/editor/editor_name_dialog.cpp +++ b/tools/editor/editor_name_dialog.cpp @@ -26,9 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "editor_name_dialog.h" -#include "object_type_db.h" + +#include "class_db.h" #include "os/keyboard.h" void EditorNameDialog::_line_gui_input(const InputEvent& p_event) { diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 5f382688a4..96752f6515 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -26,22 +26,20 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "editor_node.h" + +#include "version.h" #include "print_string.h" #include "editor_themes.h" - #include "editor_help.h" #include "core/io/resource_saver.h" #include "core/io/resource_loader.h" #include "servers/physics_2d_server.h" #include "scene/resources/packed_scene.h" #include "editor_settings.h" -#include "io_plugins/editor_import_collada.h" -#include "io_plugins/editor_scene_importer_fbxconv.h" #include "globals.h" #include -#include "object_type_db.h" +#include "class_db.h" #include "os/keyboard.h" #include "os/os.h" #include "os/file_access.h" @@ -56,6 +54,8 @@ #include "io/config_file.h" #include "animation_editor.h" #include "io/stream_peer_ssl.h" +#include "main/input_default.h" + // plugins #include "plugins/sprite_frames_editor_plugin.h" #include "plugins/texture_region_editor_plugin.h" @@ -76,7 +76,6 @@ #include "plugins/mesh_instance_editor_plugin.h" #include "plugins/mesh_editor_plugin.h" #include "plugins/theme_editor_plugin.h" - #include "plugins/tile_map_editor_plugin.h" #include "plugins/cube_grid_theme_editor_plugin.h" #include "plugins/shader_editor_plugin.h" @@ -100,17 +99,19 @@ #include "plugins/color_ramp_editor_plugin.h" #include "plugins/collision_shape_2d_editor_plugin.h" #include "plugins/gi_probe_editor_plugin.h" -#include "main/input_default.h" + // end -#include "tools/editor/editor_settings.h" -#include "tools/editor/io_plugins/editor_texture_import_plugin.h" -#include "tools/editor/io_plugins/editor_scene_import_plugin.h" -#include "tools/editor/io_plugins/editor_font_import_plugin.h" -#include "tools/editor/io_plugins/editor_sample_import_plugin.h" -#include "tools/editor/io_plugins/editor_translation_import_plugin.h" -#include "tools/editor/io_plugins/editor_bitmask_import_plugin.h" -#include "tools/editor/io_plugins/editor_mesh_import_plugin.h" -#include "tools/editor/io_plugins/editor_export_scene.h" +#include "editor_settings.h" +#include "io_plugins/editor_texture_import_plugin.h" +#include "io_plugins/editor_scene_import_plugin.h" +#include "io_plugins/editor_font_import_plugin.h" +#include "io_plugins/editor_sample_import_plugin.h" +#include "io_plugins/editor_translation_import_plugin.h" +#include "io_plugins/editor_bitmask_import_plugin.h" +#include "io_plugins/editor_mesh_import_plugin.h" +#include "io_plugins/editor_export_scene.h" +#include "io_plugins/editor_import_collada.h" +#include "io_plugins/editor_scene_importer_fbxconv.h" #include "plugins/editor_preview_plugins.h" #include "editor_initialize_ssl.h" diff --git a/tools/editor/editor_path.cpp b/tools/editor/editor_path.cpp index b359522e4f..8cd31c4bcc 100644 --- a/tools/editor/editor_path.cpp +++ b/tools/editor/editor_path.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_path.h" + #include "editor_scale.h" #include "editor_node.h" diff --git a/tools/editor/editor_plugin.cpp b/tools/editor/editor_plugin.cpp index 273fc3a6d4..69be7f8a4d 100644 --- a/tools/editor/editor_plugin.cpp +++ b/tools/editor/editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_plugin.h" + #include "scene/gui/popup_menu.h" #include "scene/3d/camera.h" #include "plugins/canvas_item_editor_plugin.h" diff --git a/tools/editor/editor_plugin_settings.cpp b/tools/editor/editor_plugin_settings.cpp index 208e576a8a..2b6828e82f 100644 --- a/tools/editor/editor_plugin_settings.cpp +++ b/tools/editor/editor_plugin_settings.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_plugin_settings.h" + #include "scene/gui/margin_container.h" #include "io/config_file.h" #include "os/file_access.h" diff --git a/tools/editor/editor_profiler.cpp b/tools/editor/editor_profiler.cpp index 5279711b0f..e769c8e40d 100644 --- a/tools/editor/editor_profiler.cpp +++ b/tools/editor/editor_profiler.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* editor_profiler.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "editor_profiler.h" + #include "editor_settings.h" #include "os/os.h" diff --git a/tools/editor/editor_profiler.h b/tools/editor/editor_profiler.h index 52b38cdae8..bf89e3939c 100644 --- a/tools/editor/editor_profiler.h +++ b/tools/editor/editor_profiler.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* editor_profiler.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef EDITORPROFILER_H #define EDITORPROFILER_H diff --git a/tools/editor/editor_reimport_dialog.cpp b/tools/editor/editor_reimport_dialog.cpp index c6a8f13dc7..e5ae33e919 100644 --- a/tools/editor/editor_reimport_dialog.cpp +++ b/tools/editor/editor_reimport_dialog.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_reimport_dialog.h" + #include "editor_file_system.h" #include "editor_node.h" + void EditorReImportDialog::popup_reimport() { if (EditorFileSystem::get_singleton()->is_scanning()) { diff --git a/tools/editor/editor_resource_preview.cpp b/tools/editor/editor_resource_preview.cpp index 76ae53d821..b4c459a493 100644 --- a/tools/editor/editor_resource_preview.cpp +++ b/tools/editor/editor_resource_preview.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_resource_preview.h" + #include "editor_settings.h" #include "os/file_access.h" #include "io/resource_loader.h" diff --git a/tools/editor/editor_run.cpp b/tools/editor/editor_run.cpp index 7d79412b3b..813a8ee5b7 100644 --- a/tools/editor/editor_run.cpp +++ b/tools/editor/editor_run.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_run.h" + #include "globals.h" #include "editor_settings.h" diff --git a/tools/editor/editor_run_native.cpp b/tools/editor/editor_run_native.cpp index caa1bf5db7..12b7b761ed 100644 --- a/tools/editor/editor_run_native.cpp +++ b/tools/editor/editor_run_native.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_run_native.h" -#include "editor_import_export.h" +#include "editor_import_export.h" void EditorRunNative::_notification(int p_what) { diff --git a/tools/editor/editor_run_script.cpp b/tools/editor/editor_run_script.cpp index 4a3cbfbccb..6a980019e4 100644 --- a/tools/editor/editor_run_script.cpp +++ b/tools/editor/editor_run_script.cpp @@ -27,11 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_run_script.h" -#include "editor_node.h" - - - +#include "editor_node.h" void EditorScript::add_root_node(Node *p_node) { diff --git a/tools/editor/editor_scale.cpp b/tools/editor/editor_scale.cpp index 8575e1c30a..5687f97b22 100644 --- a/tools/editor/editor_scale.cpp +++ b/tools/editor/editor_scale.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* editor_scale.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "editor_scale.h" + #include "os/os.h" static float scale = 1.0; diff --git a/tools/editor/editor_scale.h b/tools/editor/editor_scale.h index 90e575f771..035a5056c1 100644 --- a/tools/editor/editor_scale.h +++ b/tools/editor/editor_scale.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* editor_scale.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef EDITOR_SCALE_H #define EDITOR_SCALE_H diff --git a/tools/editor/editor_settings.cpp b/tools/editor/editor_settings.cpp index 04be202129..27aeaeb5b6 100644 --- a/tools/editor/editor_settings.cpp +++ b/tools/editor/editor_settings.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http:/www.godotengine.org */ +/* http:/www.godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ @@ -27,13 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_settings.h" + #include "os/os.h" #include "os/dir_access.h" #include "os/file_access.h" - #include "version.h" #include "scene/main/scene_main_loop.h" -#include "os/os.h" #include "scene/main/node.h" #include "io/resource_loader.h" #include "io/resource_saver.h" diff --git a/tools/editor/editor_sub_scene.cpp b/tools/editor/editor_sub_scene.cpp index 34c3d47006..094cf049b3 100644 --- a/tools/editor/editor_sub_scene.cpp +++ b/tools/editor/editor_sub_scene.cpp @@ -27,10 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_sub_scene.h" + #include "scene/gui/margin_container.h" #include "scene/resources/packed_scene.h" -void EditorSubScene::_path_selected(const String& p_path) { +void EditorSubScene::_path_selected(const String& p_path) { path->set_text(p_path); _path_changed(p_path); diff --git a/tools/editor/editor_themes.cpp b/tools/editor/editor_themes.cpp index 56654cad7a..7657996b81 100644 --- a/tools/editor/editor_themes.cpp +++ b/tools/editor/editor_themes.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_themes.cpp */ +/* editor_themes.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "editor_themes.h" + #include "editor_icons.h" #include "editor_fonts.h" #include "editor_settings.h" diff --git a/tools/editor/editor_themes.h b/tools/editor/editor_themes.h index 83e7dde78a..bf15420917 100644 --- a/tools/editor/editor_themes.h +++ b/tools/editor/editor_themes.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* editor_themes.h */ +/* editor_themes.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/tools/editor/file_type_cache.cpp b/tools/editor/file_type_cache.cpp index 176205a7df..aff99fbc05 100644 --- a/tools/editor/file_type_cache.cpp +++ b/tools/editor/file_type_cache.cpp @@ -27,10 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "file_type_cache.h" + #include "globals.h" #include "os/file_access.h" - FileTypeCache* FileTypeCache::singleton=NULL; bool FileTypeCache::has_file(const String& p_path) const { diff --git a/tools/editor/fileserver/editor_file_server.cpp b/tools/editor/fileserver/editor_file_server.cpp index 6330b06d3e..2e5dbf6248 100644 --- a/tools/editor/fileserver/editor_file_server.cpp +++ b/tools/editor/fileserver/editor_file_server.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_server.h" + #include "io/marshalls.h" #include "io/marshalls.h" #include "../editor_settings.h" diff --git a/tools/editor/filesystem_dock.cpp b/tools/editor/filesystem_dock.cpp index 792eb54dd4..8cb221e4cf 100644 --- a/tools/editor/filesystem_dock.cpp +++ b/tools/editor/filesystem_dock.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* scenes_dock.cpp */ +/* filesystem_dock.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,14 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "filesystem_dock.h" + #include "os/dir_access.h" #include "os/file_access.h" #include "globals.h" - #include "io/resource_loader.h" #include "os/os.h" #include "editor_node.h" - #include "editor_settings.h" #include "scene/main/viewport.h" diff --git a/tools/editor/filesystem_dock.h b/tools/editor/filesystem_dock.h index 0b0a73b9a2..ccd43847d6 100644 --- a/tools/editor/filesystem_dock.h +++ b/tools/editor/filesystem_dock.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* scenes_dock.h */ +/* filesystem_dock.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/tools/editor/groups_editor.cpp b/tools/editor/groups_editor.cpp index 07b2bca385..90f0bab6dd 100644 --- a/tools/editor/groups_editor.cpp +++ b/tools/editor/groups_editor.cpp @@ -32,6 +32,7 @@ #include "scene/gui/label.h" #include "editor_node.h" #include "scene/resources/packed_scene.h" + void GroupsEditor::_add_group(const String& p_group) { if (!node) diff --git a/tools/editor/io_plugins/editor_atlas.cpp b/tools/editor/io_plugins/editor_atlas.cpp index ac776f4ff5..c5f1ee73cf 100644 --- a/tools/editor/io_plugins/editor_atlas.cpp +++ b/tools/editor/io_plugins/editor_atlas.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_atlas.h" + #include "print_string.h" struct _EditorAtlasWorkRect { diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp index 722b02f77b..222a9d9517 100644 --- a/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* editor_bitmask_import_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "editor_bitmask_import_plugin.h" + #include "io/image_loader.h" #include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_dir_dialog.h" diff --git a/tools/editor/io_plugins/editor_bitmask_import_plugin.h b/tools/editor/io_plugins/editor_bitmask_import_plugin.h index 28dddca50a..3a6aababe2 100644 --- a/tools/editor/io_plugins/editor_bitmask_import_plugin.h +++ b/tools/editor/io_plugins/editor_bitmask_import_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* editor_bitmask_import_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef EDITOR_BITMASK_IMPORT_PLUGIN_H #define EDITOR_BITMASK_IMPORT_PLUGIN_H diff --git a/tools/editor/io_plugins/editor_export_scene.cpp b/tools/editor/io_plugins/editor_export_scene.cpp index ea67128f3c..7d19258411 100644 --- a/tools/editor/io_plugins/editor_export_scene.cpp +++ b/tools/editor/io_plugins/editor_export_scene.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_export_scene.h" + #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/dir_access.h" diff --git a/tools/editor/io_plugins/editor_font_import_plugin.cpp b/tools/editor/io_plugins/editor_font_import_plugin.cpp index 099535b1ef..ada6000d82 100644 --- a/tools/editor/io_plugins/editor_font_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_font_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_font_import_plugin.h" + #include "scene/gui/dialogs.h" #include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_node.h" @@ -34,11 +35,10 @@ #include "editor_atlas.h" #include "io/image_loader.h" #include "io/resource_saver.h" -#ifdef FREETYPE_ENABLED +#ifdef FREETYPE_ENABLED #include #include FT_FREETYPE_H - #endif diff --git a/tools/editor/io_plugins/editor_import_collada.cpp b/tools/editor/io_plugins/editor_import_collada.cpp index 1cbb594a51..a910b9c3ab 100644 --- a/tools/editor/io_plugins/editor_import_collada.cpp +++ b/tools/editor/io_plugins/editor_import_collada.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_import_collada.h" + #include "collada/collada.h" #include "scene/3d/spatial.h" #include "scene/3d/skeleton.h" diff --git a/tools/editor/io_plugins/editor_sample_import_plugin.cpp b/tools/editor/io_plugins/editor_sample_import_plugin.cpp index 59e593c081..ca873cab72 100644 --- a/tools/editor/io_plugins/editor_sample_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_sample_import_plugin.cpp @@ -27,11 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_sample_import_plugin.h" + #include "tools/editor/editor_file_dialog.h" #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" #include "tools/editor/property_editor.h" - #include "io/resource_saver.h" #include "os/file_access.h" #include "io/marshalls.h" diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 79c88e7407..ce6c49fcba 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_scene_import_plugin.h" + #include "globals.h" #include "tools/editor/editor_node.h" #include "scene/resources/packed_scene.h" diff --git a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp index e1b0719941..af12d85650 100644 --- a/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp +++ b/tools/editor/io_plugins/editor_scene_importer_fbxconv.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_scene_importer_fbxconv.h" + #include "os/file_access.h" #include "os/os.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 5ba7d0c417..081e360142 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_texture_import_plugin.h" + #include "io/image_loader.h" #include "tools/editor/editor_node.h" #include "io/resource_saver.h" diff --git a/tools/editor/io_plugins/editor_translation_import_plugin.cpp b/tools/editor/io_plugins/editor_translation_import_plugin.cpp index fca740afcc..7079120feb 100644 --- a/tools/editor/io_plugins/editor_translation_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_translation_import_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_translation_import_plugin.h" + #include "scene/gui/file_dialog.h" #include "tools/editor/editor_dir_dialog.h" #include "tools/editor/editor_node.h" diff --git a/tools/editor/multi_node_edit.cpp b/tools/editor/multi_node_edit.cpp index 47b776ed06..97a996fe48 100644 --- a/tools/editor/multi_node_edit.cpp +++ b/tools/editor/multi_node_edit.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "multi_node_edit.h" + #include "editor_node.h" bool MultiNodeEdit::_set(const StringName& p_name, const Variant& p_value){ diff --git a/tools/editor/node_dock.cpp b/tools/editor/node_dock.cpp index a8e66a8680..3d906cf960 100644 --- a/tools/editor/node_dock.cpp +++ b/tools/editor/node_dock.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* node_dock.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "node_dock.h" + #include "editor_node.h" void NodeDock::show_groups() { diff --git a/tools/editor/node_dock.h b/tools/editor/node_dock.h index fd4105d1b2..df41ecf5bd 100644 --- a/tools/editor/node_dock.h +++ b/tools/editor/node_dock.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* node_dock.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef NODE_DOCK_H #define NODE_DOCK_H diff --git a/tools/editor/plugins/animation_player_editor_plugin.cpp b/tools/editor/plugins/animation_player_editor_plugin.cpp index a3f254ce49..b3d16bb660 100644 --- a/tools/editor/plugins/animation_player_editor_plugin.cpp +++ b/tools/editor/plugins/animation_player_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "animation_player_editor_plugin.h" + #include "globals.h" #include "io/resource_loader.h" #include "io/resource_saver.h" diff --git a/tools/editor/plugins/baked_light_baker.cpp b/tools/editor/plugins/baked_light_baker.cpp index 0b12d080e4..caf37550cb 100644 --- a/tools/editor/plugins/baked_light_baker.cpp +++ b/tools/editor/plugins/baked_light_baker.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "baked_light_baker.h" + #include #include #include "io/marshalls.h" diff --git a/tools/editor/plugins/baked_light_editor_plugin.cpp b/tools/editor/plugins/baked_light_editor_plugin.cpp index 26c3144188..6a7e708b85 100644 --- a/tools/editor/plugins/baked_light_editor_plugin.cpp +++ b/tools/editor/plugins/baked_light_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "baked_light_editor_plugin.h" + #include "scene/gui/box_container.h" #include "scene/3d/mesh_instance.h" #include "io/marshalls.h" diff --git a/tools/editor/plugins/camera_editor_plugin.cpp b/tools/editor/plugins/camera_editor_plugin.cpp index 1c8c392d65..1e0ec2b4a0 100644 --- a/tools/editor/plugins/camera_editor_plugin.cpp +++ b/tools/editor/plugins/camera_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "camera_editor_plugin.h" + #include "spatial_editor_plugin.h" diff --git a/tools/editor/plugins/canvas_item_editor_plugin.cpp b/tools/editor/plugins/canvas_item_editor_plugin.cpp index 53b521f2fa..13a322ae6e 100644 --- a/tools/editor/plugins/canvas_item_editor_plugin.cpp +++ b/tools/editor/plugins/canvas_item_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "canvas_item_editor_plugin.h" + #include "print_string.h" #include "tools/editor/editor_node.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/collision_polygon_editor_plugin.cpp b/tools/editor/plugins/collision_polygon_editor_plugin.cpp index 010d6f1a47..c5cd15cf72 100644 --- a/tools/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/tools/editor/plugins/collision_polygon_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "collision_polygon_editor_plugin.h" + #include "spatial_editor_plugin.h" #include "os/file_access.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp index 626ca9e132..a05eeb7a27 100644 --- a/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp +++ b/tools/editor/plugins/collision_shape_2d_editor_plugin.cpp @@ -29,7 +29,6 @@ #include "collision_shape_2d_editor_plugin.h" #include "canvas_item_editor_plugin.h" - #include "scene/resources/segment_shape_2d.h" #include "scene/resources/shape_line_2d.h" #include "scene/resources/circle_shape_2d.h" diff --git a/tools/editor/plugins/color_ramp_editor_plugin.cpp b/tools/editor/plugins/color_ramp_editor_plugin.cpp index 90ec1e9f4e..9509eb1b03 100644 --- a/tools/editor/plugins/color_ramp_editor_plugin.cpp +++ b/tools/editor/plugins/color_ramp_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "color_ramp_editor_plugin.h" + #include "spatial_editor_plugin.h" #include "canvas_item_editor_plugin.h" diff --git a/tools/editor/plugins/editor_preview_plugins.cpp b/tools/editor/plugins/editor_preview_plugins.cpp index f713d03530..5d9b281874 100644 --- a/tools/editor/plugins/editor_preview_plugins.cpp +++ b/tools/editor/plugins/editor_preview_plugins.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_preview_plugins.h" + #include "io/resource_loader.h" #include "tools/editor/editor_settings.h" #include "io/file_access_memory.h" diff --git a/tools/editor/plugins/gi_probe_editor_plugin.cpp b/tools/editor/plugins/gi_probe_editor_plugin.cpp index f550b7972a..12dcadc041 100644 --- a/tools/editor/plugins/gi_probe_editor_plugin.cpp +++ b/tools/editor/plugins/gi_probe_editor_plugin.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* gi_probe_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "gi_probe_editor_plugin.h" diff --git a/tools/editor/plugins/gi_probe_editor_plugin.h b/tools/editor/plugins/gi_probe_editor_plugin.h index 8d2ec17d2f..35e0b93aae 100644 --- a/tools/editor/plugins/gi_probe_editor_plugin.h +++ b/tools/editor/plugins/gi_probe_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* gi_probe_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef GIPROBEEDITORPLUGIN_H #define GIPROBEEDITORPLUGIN_H diff --git a/tools/editor/plugins/material_editor_plugin.cpp b/tools/editor/plugins/material_editor_plugin.cpp index e9bcf063fd..1aababa91b 100644 --- a/tools/editor/plugins/material_editor_plugin.cpp +++ b/tools/editor/plugins/material_editor_plugin.cpp @@ -1,4 +1,33 @@ +/*************************************************************************/ +/* material_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "material_editor_plugin.h" + #include "scene/main/viewport.h" #if 0 diff --git a/tools/editor/plugins/material_editor_plugin.h b/tools/editor/plugins/material_editor_plugin.h index 556e56e66b..5daae124e0 100644 --- a/tools/editor/plugins/material_editor_plugin.h +++ b/tools/editor/plugins/material_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* material_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef MATERIAL_EDITOR_PLUGIN_H #define MATERIAL_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.cpp b/tools/editor/plugins/mesh_instance_editor_plugin.cpp index de29991057..322e212534 100644 --- a/tools/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/tools/editor/plugins/mesh_instance_editor_plugin.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* mesh_instance_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "mesh_instance_editor_plugin.h" #include "scene/3d/physics_body.h" diff --git a/tools/editor/plugins/mesh_instance_editor_plugin.h b/tools/editor/plugins/mesh_instance_editor_plugin.h index 23dcbfc9b1..441d4d1d3f 100644 --- a/tools/editor/plugins/mesh_instance_editor_plugin.h +++ b/tools/editor/plugins/mesh_instance_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* mesh_instance_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef MESH_INSTANCE_EDITOR_PLUGIN_H #define MESH_INSTANCE_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/multimesh_editor_plugin.cpp b/tools/editor/plugins/multimesh_editor_plugin.cpp index cce1c52215..949d1127af 100644 --- a/tools/editor/plugins/multimesh_editor_plugin.cpp +++ b/tools/editor/plugins/multimesh_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "multimesh_editor_plugin.h" + #include "scene/gui/box_container.h" #include "scene/3d/mesh_instance.h" #include "spatial_editor_plugin.h" diff --git a/tools/editor/plugins/particles_2d_editor_plugin.cpp b/tools/editor/plugins/particles_2d_editor_plugin.cpp index 331a958518..20b1b9d1ca 100644 --- a/tools/editor/plugins/particles_2d_editor_plugin.cpp +++ b/tools/editor/plugins/particles_2d_editor_plugin.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "particles_2d_editor_plugin.h" + #include "canvas_item_editor_plugin.h" #include "io/image_loader.h" #include "scene/gui/separator.h" diff --git a/tools/editor/plugins/path_editor_plugin.cpp b/tools/editor/plugins/path_editor_plugin.cpp index 4f0afe9e94..fc914097e9 100644 --- a/tools/editor/plugins/path_editor_plugin.cpp +++ b/tools/editor/plugins/path_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "path_editor_plugin.h" + #include "spatial_editor_plugin.h" #include "scene/resources/curve.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/polygon_2d_editor_plugin.cpp b/tools/editor/plugins/polygon_2d_editor_plugin.cpp index dc56348700..7958dce75a 100644 --- a/tools/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/tools/editor/plugins/polygon_2d_editor_plugin.cpp @@ -26,8 +26,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "polygon_2d_editor_plugin.h" + #include "canvas_item_editor_plugin.h" #include "os/file_access.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/resource_preloader_editor_plugin.cpp b/tools/editor/plugins/resource_preloader_editor_plugin.cpp index 0799732e02..cb139cbe24 100644 --- a/tools/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/tools/editor/plugins/resource_preloader_editor_plugin.cpp @@ -27,13 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resource_preloader_editor_plugin.h" + #include "io/resource_loader.h" #include "globals.h" #include "tools/editor/editor_settings.h" - - void ResourcePreloaderEditor::_gui_input(InputEvent p_event) { diff --git a/tools/editor/plugins/rich_text_editor_plugin.cpp b/tools/editor/plugins/rich_text_editor_plugin.cpp index f91af2fa60..8629d6ec8f 100644 --- a/tools/editor/plugins/rich_text_editor_plugin.cpp +++ b/tools/editor/plugins/rich_text_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "rich_text_editor_plugin.h" + #include "os/file_access.h" #include "canvas_item_editor_plugin.h" diff --git a/tools/editor/plugins/sample_editor_plugin.cpp b/tools/editor/plugins/sample_editor_plugin.cpp index 7318b1d036..c333ba017f 100644 --- a/tools/editor/plugins/sample_editor_plugin.cpp +++ b/tools/editor/plugins/sample_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "sample_editor_plugin.h" + #if 0 #include "io/resource_loader.h" #include "globals.h" diff --git a/tools/editor/plugins/sample_library_editor_plugin.cpp b/tools/editor/plugins/sample_library_editor_plugin.cpp index a8bef7759b..116c5d11b6 100644 --- a/tools/editor/plugins/sample_library_editor_plugin.cpp +++ b/tools/editor/plugins/sample_library_editor_plugin.cpp @@ -29,6 +29,7 @@ #if 0 #include "sample_library_editor_plugin.h" + #include "io/resource_loader.h" #include "globals.h" #include "tools/editor/editor_settings.h" diff --git a/tools/editor/plugins/script_editor_plugin.cpp b/tools/editor/plugins/script_editor_plugin.cpp index 61c2d5acfc..4738b348f4 100644 --- a/tools/editor/plugins/script_editor_plugin.cpp +++ b/tools/editor/plugins/script_editor_plugin.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_editor_plugin.h" + #include "tools/editor/editor_settings.h" #include "io/resource_loader.h" #include "io/resource_saver.h" diff --git a/tools/editor/plugins/script_text_editor.cpp b/tools/editor/plugins/script_text_editor.cpp index 95e7afa04c..e26a3b23bc 100644 --- a/tools/editor/plugins/script_text_editor.cpp +++ b/tools/editor/plugins/script_text_editor.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_text_editor.h" + #include "tools/editor/editor_settings.h" #include "os/keyboard.h" #include "tools/editor/script_editor_debugger.h" diff --git a/tools/editor/plugins/shader_editor_plugin.cpp b/tools/editor/plugins/shader_editor_plugin.cpp index 90d0f7fc93..56a8fccb9c 100644 --- a/tools/editor/plugins/shader_editor_plugin.cpp +++ b/tools/editor/plugins/shader_editor_plugin.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "shader_editor_plugin.h" -#include "tools/editor/editor_settings.h" +#include "tools/editor/editor_settings.h" #include "spatial_editor_plugin.h" #include "scene/resources/shader_graph.h" #include "io/resource_loader.h" diff --git a/tools/editor/plugins/spatial_editor_plugin.cpp b/tools/editor/plugins/spatial_editor_plugin.cpp index 81db5d5fbf..2f232b75b2 100644 --- a/tools/editor/plugins/spatial_editor_plugin.cpp +++ b/tools/editor/plugins/spatial_editor_plugin.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "spatial_editor_plugin.h" -#include "print_string.h" +#include "print_string.h" #include "os/keyboard.h" #include "scene/3d/visual_instance.h" #include "scene/3d/camera.h" diff --git a/tools/editor/plugins/texture_editor_plugin.cpp b/tools/editor/plugins/texture_editor_plugin.cpp index a846a908d2..82cba7ac0e 100644 --- a/tools/editor/plugins/texture_editor_plugin.cpp +++ b/tools/editor/plugins/texture_editor_plugin.cpp @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* texture_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "texture_editor_plugin.h" #include "io/resource_loader.h" diff --git a/tools/editor/plugins/texture_editor_plugin.h b/tools/editor/plugins/texture_editor_plugin.h index 4b05f7f7ab..456a5249de 100644 --- a/tools/editor/plugins/texture_editor_plugin.h +++ b/tools/editor/plugins/texture_editor_plugin.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* texture_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef TEXTURE_EDITOR_PLUGIN_H #define TEXTURE_EDITOR_PLUGIN_H diff --git a/tools/editor/plugins/texture_region_editor_plugin.cpp b/tools/editor/plugins/texture_region_editor_plugin.cpp index 1ad880c4d6..9b0ca0a482 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.cpp +++ b/tools/editor/plugins/texture_region_editor_plugin.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_region_editor_plugin.cpp */ +/* texture_region_editor_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,9 +28,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ +#include "texture_region_editor_plugin.h" #include "core/core_string_names.h" -#include "texture_region_editor_plugin.h" #include "scene/gui/check_box.h" #include "os/input.h" #include "os/keyboard.h" diff --git a/tools/editor/plugins/texture_region_editor_plugin.h b/tools/editor/plugins/texture_region_editor_plugin.h index 35c0f18efa..da713a53d3 100644 --- a/tools/editor/plugins/texture_region_editor_plugin.h +++ b/tools/editor/plugins/texture_region_editor_plugin.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* texture_region_editor_plugin.h */ +/* texture_region_editor_plugin.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ diff --git a/tools/editor/plugins/theme_editor_plugin.cpp b/tools/editor/plugins/theme_editor_plugin.cpp index 027e91ade8..7c55e8563e 100644 --- a/tools/editor/plugins/theme_editor_plugin.cpp +++ b/tools/editor/plugins/theme_editor_plugin.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "theme_editor_plugin.h" + +#include "version.h" #include "os/file_access.h" void ThemeEditor::edit(const Ref& p_theme) { diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index 1a8c35a0be..7c232f0c32 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -26,12 +26,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ - #include "tile_map_editor_plugin.h" #include "os/keyboard.h" #include "os/input.h" - #include "canvas_item_editor_plugin.h" #include "tools/editor/editor_settings.h" #include "tools/editor/editor_scale.h" diff --git a/tools/editor/plugins/tile_set_editor_plugin.cpp b/tools/editor/plugins/tile_set_editor_plugin.cpp index bb6236a6d6..3db6c94917 100644 --- a/tools/editor/plugins/tile_set_editor_plugin.cpp +++ b/tools/editor/plugins/tile_set_editor_plugin.cpp @@ -27,8 +27,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "tile_set_editor_plugin.h" + #include "scene/2d/sprite.h" #include "scene/2d/physics_body_2d.h" + void TileSetEditor::edit(const Ref& p_tileset) { tileset=p_tileset; diff --git a/tools/editor/progress_dialog.cpp b/tools/editor/progress_dialog.cpp index 03303b8c48..76626c4556 100644 --- a/tools/editor/progress_dialog.cpp +++ b/tools/editor/progress_dialog.cpp @@ -27,10 +27,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "progress_dialog.h" + #include "main/main.h" #include "message_queue.h" #include "os/os.h" #include "editor_scale.h" + void BackgroundProgress::_add_task(const String& p_task,const String& p_label, int p_steps) { _THREAD_SAFE_METHOD_ diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 10005b6850..cacefaa1a2 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -31,12 +31,10 @@ #include "os/dir_access.h" #include "os/file_access.h" #include "globals.h" - #include "io/resource_loader.h" #include "io/resource_saver.h" #include "os/os.h" #include "scene/gui/box_container.h" - #include "scene/gui/tab_container.h" #include "scene/gui/scroll_container.h" #include "editor_data.h" diff --git a/tools/editor/project_manager.cpp b/tools/editor/project_manager.cpp index 2cf940a29a..fb8cccdb79 100644 --- a/tools/editor/project_manager.cpp +++ b/tools/editor/project_manager.cpp @@ -26,8 +26,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "version.h" #include "project_manager.h" + +#include "version.h" #include "os/os.h" #include "os/dir_access.h" #include "os/file_access.h" @@ -36,20 +37,16 @@ #include "scene/gui/separator.h" #include "scene/gui/tool_button.h" #include "io/config_file.h" - #include "scene/gui/line_edit.h" #include "scene/gui/panel_container.h" #include "scene/gui/center_container.h" #include "io/stream_peer_ssl.h" - #include "scene/gui/texture_rect.h" #include "scene/gui/margin_container.h" #include "io/resource_saver.h" - #include "editor_themes.h" #include "editor_initialize_ssl.h" #include "editor_scale.h" - #include "io/zip_io.h" class NewProjectDialog : public ConfirmationDialog { diff --git a/tools/editor/project_settings.cpp b/tools/editor/project_settings.cpp index 0396456c49..a8f87ce5d9 100644 --- a/tools/editor/project_settings.cpp +++ b/tools/editor/project_settings.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "project_settings.h" + #include "scene/gui/tab_container.h" #include "globals.h" #include "os/keyboard.h" diff --git a/tools/editor/property_editor.cpp b/tools/editor/property_editor.cpp index 8f294a5102..319ca86129 100644 --- a/tools/editor/property_editor.cpp +++ b/tools/editor/property_editor.cpp @@ -27,10 +27,11 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "property_editor.h" + #include "scene/gui/label.h" #include "io/resource_loader.h" #include "io/image_loader.h" -#include "object_type_db.h" +#include "class_db.h" #include "print_string.h" #include "globals.h" #include "scene/resources/font.h" diff --git a/tools/editor/property_selector.cpp b/tools/editor/property_selector.cpp index 3d9695ac2a..3eeec1634d 100644 --- a/tools/editor/property_selector.cpp +++ b/tools/editor/property_selector.cpp @@ -1,6 +1,34 @@ +/*************************************************************************/ +/* property_selector.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #include "property_selector.h" -#include "editor_scale.h" +#include "editor_scale.h" #include "os/keyboard.h" void PropertySelector::_text_changed(const String& p_newtext) { diff --git a/tools/editor/property_selector.h b/tools/editor/property_selector.h index 4823d50e0f..d29183f85e 100644 --- a/tools/editor/property_selector.h +++ b/tools/editor/property_selector.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* property_selector.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef PROPERTYSELECTOR_H #define PROPERTYSELECTOR_H diff --git a/tools/editor/pvrtc_compress.cpp b/tools/editor/pvrtc_compress.cpp index 7f84d8d00e..b130f6c773 100644 --- a/tools/editor/pvrtc_compress.cpp +++ b/tools/editor/pvrtc_compress.cpp @@ -27,12 +27,14 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "pvrtc_compress.h" + #include "editor_settings.h" #include "scene/resources/texture.h" #include "io/resource_saver.h" #include "io/resource_loader.h" #include "os/os.h" #include "os/file_access.h" + static void (*_base_image_compress_pvrtc2_func)(Image *)=NULL; static void (*_base_image_compress_pvrtc4_func)(Image *)=NULL; diff --git a/tools/editor/quick_open.cpp b/tools/editor/quick_open.cpp index ff5ecdf01b..615b42b411 100644 --- a/tools/editor/quick_open.cpp +++ b/tools/editor/quick_open.cpp @@ -27,8 +27,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "quick_open.h" -#include "os/keyboard.h" +#include "os/keyboard.h" void EditorQuickOpen::popup(const StringName &p_base, bool p_enable_multi, bool p_add_dirs, bool p_dontclear) { diff --git a/tools/editor/reparent_dialog.cpp b/tools/editor/reparent_dialog.cpp index 4b6a032b64..ea82eed44e 100644 --- a/tools/editor/reparent_dialog.cpp +++ b/tools/editor/reparent_dialog.cpp @@ -30,8 +30,6 @@ #include "scene/gui/label.h" #include "scene/gui/box_container.h" - - #include "print_string.h" void ReparentDialog::_notification(int p_what) { diff --git a/tools/editor/resources_dock.cpp b/tools/editor/resources_dock.cpp index ddd4a782e4..02b6a85f8e 100644 --- a/tools/editor/resources_dock.cpp +++ b/tools/editor/resources_dock.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "resources_dock.h" + #include "editor_node.h" #include "io/resource_loader.h" #include "io/resource_saver.h" diff --git a/tools/editor/scene_tree_dock.cpp b/tools/editor/scene_tree_dock.cpp index 6a1d1ed3b2..bd81c57676 100644 --- a/tools/editor/scene_tree_dock.cpp +++ b/tools/editor/scene_tree_dock.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scene_tree_dock.h" + #include "editor_node.h" #include "globals.h" #include "os/keyboard.h" diff --git a/tools/editor/scene_tree_editor.cpp b/tools/editor/scene_tree_editor.cpp index 7b6a03e20e..77640b9c80 100644 --- a/tools/editor/scene_tree_editor.cpp +++ b/tools/editor/scene_tree_editor.cpp @@ -27,13 +27,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "scene_tree_editor.h" + #include "scene/gui/label.h" #include "editor_node.h" #include "print_string.h" #include "message_queue.h" #include "scene/main/viewport.h" #include "tools/editor/plugins/canvas_item_editor_plugin.h" - #include "scene/resources/packed_scene.h" Node *SceneTreeEditor::get_scene_node() { diff --git a/tools/editor/script_create_dialog.cpp b/tools/editor/script_create_dialog.cpp index 2a76224e33..da01cdefe5 100644 --- a/tools/editor/script_create_dialog.cpp +++ b/tools/editor/script_create_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_create_dialog.h" + #include "script_language.h" #include "globals.h" #include "io/resource_saver.h" diff --git a/tools/editor/script_editor_debugger.cpp b/tools/editor/script_editor_debugger.cpp index e53e69d9e0..05cf92e702 100644 --- a/tools/editor/script_editor_debugger.cpp +++ b/tools/editor/script_editor_debugger.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_editor_debugger.h" + #include "scene/gui/separator.h" #include "scene/gui/label.h" #include "scene/gui/split_container.h" diff --git a/tools/editor/settings_config_dialog.cpp b/tools/editor/settings_config_dialog.cpp index c72f2641b7..31cbcee5ae 100644 --- a/tools/editor/settings_config_dialog.cpp +++ b/tools/editor/settings_config_dialog.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "settings_config_dialog.h" + #include "editor_settings.h" #include "scene/gui/margin_container.h" #include "globals.h" diff --git a/tools/editor/spatial_editor_gizmos.cpp b/tools/editor/spatial_editor_gizmos.cpp index d69844dc7a..d4119b746f 100644 --- a/tools/editor/spatial_editor_gizmos.cpp +++ b/tools/editor/spatial_editor_gizmos.cpp @@ -27,6 +27,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "spatial_editor_gizmos.h" + #include "geometry.h" #include "scene/3d/camera.h" #include "scene/resources/surface_tool.h" -- cgit v1.2.3