diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/bind/core_bind.cpp | 6 | ||||
| -rw-r--r-- | core/bind/core_bind.h | 1 | ||||
| -rw-r--r-- | core/error_macros.h | 5 | ||||
| -rw-r--r-- | core/global_constants.cpp | 1 | ||||
| -rw-r--r-- | core/input_map.cpp | 5 | ||||
| -rw-r--r-- | core/io/http_client.cpp | 4 | ||||
| -rw-r--r-- | core/io/http_client.h | 4 | ||||
| -rw-r--r-- | core/register_core_types.cpp | 3 | ||||
| -rw-r--r-- | core/typedefs.h | 11 | ||||
| -rw-r--r-- | core/variant.cpp | 15 | ||||
| -rw-r--r-- | core/variant.h | 2 | ||||
| -rw-r--r-- | core/variant_op.cpp | 53 |
12 files changed, 98 insertions, 12 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index cbeb58b411..9d380aa33a 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -55,11 +55,17 @@ bool _ResourceLoader::has(const String &p_path) { return ResourceCache::has(local_path); }; +Ref<ResourceImportMetadata> _ResourceLoader::load_import_metadata(const String& p_path) { + + return ResourceLoader::load_import_metadata(p_path); +} + void _ResourceLoader::_bind_methods() { ObjectTypeDB::bind_method(_MD("load_interactive:ResourceInteractiveLoader","path","type_hint"),&_ResourceLoader::load_interactive,DEFVAL("")); ObjectTypeDB::bind_method(_MD("load:Resource","path","type_hint", "p_no_cache"),&_ResourceLoader::load,DEFVAL(""), DEFVAL(false)); + ObjectTypeDB::bind_method(_MD("load_import_metadata:ResourceImportMetadata","path"),&_ResourceLoader::load_import_metadata); ObjectTypeDB::bind_method(_MD("get_recognized_extensions_for_type","type"),&_ResourceLoader::get_recognized_extensions_for_type); ObjectTypeDB::bind_method(_MD("set_abort_on_missing_resources","abort"),&_ResourceLoader::set_abort_on_missing_resources); ObjectTypeDB::bind_method(_MD("get_dependencies","path"),&_ResourceLoader::get_dependencies); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 7a08147dc6..64a4e94aec 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -26,6 +26,7 @@ public: void set_abort_on_missing_resources(bool p_abort); StringArray get_dependencies(const String& p_path); bool has(const String& p_path); + Ref<ResourceImportMetadata> load_import_metadata(const String& p_path); _ResourceLoader(); }; diff --git a/core/error_macros.h b/core/error_macros.h index cafbf0c16e..47b1de5df3 100644 --- a/core/error_macros.h +++ b/core/error_macros.h @@ -223,5 +223,10 @@ extern bool _err_error_exists; } \ +#define WARN_PRINTS(m_string) \ + { \ + _err_print_error(FUNCTION_STR,__FILE__,__LINE__,String(m_string).utf8().get_data(),ERR_HANDLER_WARNING); \ + _err_error_exists=false;\ + } \ #endif diff --git a/core/global_constants.cpp b/core/global_constants.cpp index a183255b06..130fca1b2a 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -432,6 +432,7 @@ static _GlobalConstant _global_constants[]={ BIND_GLOBAL_CONSTANT( ERR_FILE_EOF ), BIND_GLOBAL_CONSTANT( ERR_CANT_OPEN ), ///< Can't open a resource/socket/file BIND_GLOBAL_CONSTANT( ERR_CANT_CREATE ), + BIND_GLOBAL_CONSTANT( ERR_PARSE_ERROR ), BIND_GLOBAL_CONSTANT( ERROR_QUERY_FAILED ), BIND_GLOBAL_CONSTANT( ERR_ALREADY_IN_USE ), BIND_GLOBAL_CONSTANT( ERR_LOCKED ), ///< resource is locked diff --git a/core/input_map.cpp b/core/input_map.cpp index d4560a1e1b..874ce1c424 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -156,10 +156,7 @@ void InputMap::action_erase_event(const StringName& p_action,const InputEvent& p List<InputEvent>::Element *E=_find_event(input_map[p_action].inputs,p_event); if (E) - return; //already gots - - input_map[p_action].inputs.erase(E); - + input_map[p_action].inputs.erase(E); } diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index b070e52f0a..dd53c8f8eb 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -31,10 +31,6 @@ VARIANT_ENUM_CAST(HTTPClient::Status); -Error HTTPClient::connect_url(const String& p_url) { - - return OK; -} Error HTTPClient::connect(const String &p_host, int p_port, bool p_ssl,bool p_verify_host){ diff --git a/core/io/http_client.h b/core/io/http_client.h index e138681396..e795646c70 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -164,7 +164,7 @@ private: public: - Error connect_url(const String& p_url); //connects to a full url and perform request + //Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request Error connect(const String &p_host,int p_port,bool p_ssl=false,bool p_verify_host=true); void set_connection(const Ref<StreamPeer>& p_connection); @@ -192,7 +192,7 @@ public: Error poll(); - String query_string_from_dict(const Dictionary& p_dict); + String query_string_from_dict(const Dictionary& p_dict); HTTPClient(); ~HTTPClient(); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index d977ea3e18..54431cf381 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -51,6 +51,7 @@ #include "packed_data_container.h" #include "func_ref.h" #include "input_map.h" +#include "undo_redo.h" #ifdef XML_ENABLED static ResourceFormatSaverXML *resource_saver_xml=NULL; @@ -128,7 +129,7 @@ void register_core_types() { // ObjectTypeDB::register_type<OptimizedSaver>(); ObjectTypeDB::register_type<Translation>(); ObjectTypeDB::register_type<PHashTranslation>(); - + ObjectTypeDB::register_type<UndoRedo>(); ObjectTypeDB::register_type<HTTPClient>(); ObjectTypeDB::register_virtual_type<ResourceInteractiveLoader>(); diff --git a/core/typedefs.h b/core/typedefs.h index 48acca326e..eab0ebc545 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -188,13 +188,22 @@ static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) { return ++x; } +// We need this definition inside the function below. +static inline int get_shift_from_power_of_2(unsigned int p_pixel); + template<class T> static _FORCE_INLINE_ T nearest_power_of_2_templated(T x) { --x; + + // The number of operations on x is the base two logarithm + // of the p_number of bits in the type. Add three to account + // for sizeof(T) being in bytes. + size_t num = get_shift_from_power_of_2(sizeof(T)) + 3; + // If the compiler is smart, it unrolls this loop // If its dumb, this is a bit slow. - for (size_t i = 0; i < sizeof(T); i++) + for (size_t i = 0; i < num; i++) x |= x >> (1 << i); return ++x; diff --git a/core/variant.cpp b/core/variant.cpp index 3bd8d80528..1fdbc9f753 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -1116,6 +1116,21 @@ void Variant::reference(const Variant& p_variant) { } +void Variant::zero() { + switch(type) { + case NIL: break; + case BOOL: this->_data._bool = false; break; + case INT: this->_data._int = 0; break; + case REAL: this->_data._real = 0; break; + case VECTOR2: *reinterpret_cast<Vector2*>(this->_data._mem) = Vector2(); break; + case RECT2: *reinterpret_cast<Rect2*>(this->_data._mem) = Rect2(); break; + case VECTOR3: *reinterpret_cast<Vector3*>(this->_data._mem) = Vector3(); break; + case PLANE: *reinterpret_cast<Plane*>(this->_data._mem) = Plane(); break; + case QUAT: *reinterpret_cast<Quat*>(this->_data._mem) = Quat(); break; + case COLOR: *reinterpret_cast<Color*>(this->_data._mem) = Color(); break; + default: this->clear(); break; + } +} void Variant::clear() { switch(type) { diff --git a/core/variant.h b/core/variant.h index b58c781bdd..d8813c4937 100644 --- a/core/variant.h +++ b/core/variant.h @@ -372,6 +372,8 @@ public: return res; } + void zero(); + static void blend(const Variant& a, const Variant& b, float c,Variant &r_dst); static void interpolate(const Variant& a, const Variant& b, float c,Variant &r_dst); struct CallError { diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 204a00e1d5..5463e1cabb 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -3431,6 +3431,59 @@ Variant Variant::iter_get(const Variant& r_iter,bool &r_valid) const { } +void Variant::blend(const Variant& a, const Variant& b, float c, Variant &r_dst) { + if (a.type!=b.type) { + if(a.is_num() && b.is_num()) { + real_t va=a; + real_t vb=b; + r_dst=va + vb * c; + } else { + r_dst=a; + } + return; + } + + switch(a.type) { + case NIL: { r_dst=Variant(); } return; + case INT:{ + int va=a._data._int; + int vb=b._data._int; + r_dst=int(va + vb * c + 0.5); + } return; + case REAL:{ + double ra=a._data._real; + double rb=b._data._real; + r_dst=ra + rb * c; + } return; + case VECTOR2:{ r_dst=*reinterpret_cast<const Vector2*>(a._data._mem)+*reinterpret_cast<const Vector2*>(b._data._mem)*c; } return; + case RECT2:{ + const Rect2 *ra = reinterpret_cast<const Rect2*>(a._data._mem); + const Rect2 *rb = reinterpret_cast<const Rect2*>(b._data._mem); + r_dst=Rect2(ra->pos + rb->pos * c, ra->size + rb->size * c); + } return; + case VECTOR3:{ r_dst=*reinterpret_cast<const Vector2*>(a._data._mem)+*reinterpret_cast<const Vector2*>(b._data._mem)*c; } return; + case _AABB:{ + const AABB *ra = reinterpret_cast<const AABB*>(a._data._mem); + const AABB *rb = reinterpret_cast<const AABB*>(b._data._mem); + r_dst=AABB(ra->pos + rb->pos * c, ra->size + rb->size * c); + } return; + case COLOR:{ + const Color *ca = reinterpret_cast<const Color*>(a._data._mem); + const Color *cb = reinterpret_cast<const Color*>(b._data._mem); + float r = ca->r + cb->r * c; + float g = ca->g + cb->g * c; + float b = ca->b + cb->b * c; + float a = ca->a + cb->a * c; + r = r > 1.0 ? 1.0 : r; + g = g > 1.0 ? 1.0 : g; + b = b > 1.0 ? 1.0 : b; + a = a > 1.0 ? 1.0 : a; + r_dst=Color(r, g, b, a); + } return; + default:{ r_dst = c<0.5 ? a : b; } return; + } +} + void Variant::interpolate(const Variant& a, const Variant& b, float c,Variant &r_dst) { if (a.type!=b.type) { |