diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/input_map.cpp | 6 | ||||
-rw-r--r-- | core/input_map.h | 2 | ||||
-rw-r--r-- | core/os/copymem.cpp | 42 | ||||
-rw-r--r-- | core/os/copymem.h | 87 | ||||
-rw-r--r-- | core/register_core_types.cpp | 2 | ||||
-rw-r--r-- | core/translation.cpp | 2 | ||||
-rw-r--r-- | core/variant.h | 1 | ||||
-rw-r--r-- | core/variant_op.cpp | 54 |
8 files changed, 69 insertions, 127 deletions
diff --git a/core/input_map.cpp b/core/input_map.cpp index 09cb7ce426..ad1403a64b 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -106,7 +106,7 @@ List<StringName> InputMap::get_actions() const { return actions; } -List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const { +List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore=false) const { for (List<InputEvent>::Element *E=p_list.front();E;E=E->next()) { @@ -122,7 +122,7 @@ List<InputEvent>::Element *InputMap::_find_event(List<InputEvent> &p_list,const case InputEvent::KEY: { - same=(e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod); + same=(e.key.scancode==p_event.key.scancode && (p_mod_ignore || e.key.mod == p_event.key.mod)); } break; case InputEvent::JOYSTICK_BUTTON: { @@ -229,7 +229,7 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac return p_event.action.action==E->get().id; } - return _find_event(E->get().inputs,p_event)!=NULL; + return _find_event(E->get().inputs,p_event,!p_event.is_pressed())!=NULL; } const Map<StringName, InputMap::Action>& InputMap::get_action_map() const { diff --git a/core/input_map.h b/core/input_map.h index 21c479588d..a974f6f103 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -46,7 +46,7 @@ private: mutable Map<StringName, Action> input_map; mutable Map<int,StringName> input_id_map; - List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event) const; + List<InputEvent>::Element *_find_event(List<InputEvent> &p_list,const InputEvent& p_event, bool p_mod_ignore) const; Array _get_action_list(const StringName& p_action); Array _get_actions(); diff --git a/core/os/copymem.cpp b/core/os/copymem.cpp deleted file mode 100644 index 49f53f1a51..0000000000 --- a/core/os/copymem.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************/ -/* copymem.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* http://www.godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2016 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 "copymem.h" - -#include <string.h> - -void movemem_system(void *to, void *from,int amount) { - - memmove(to,from,amount); - -} - -void zeromem(void* p_mem,size_t p_bytes) { - - memset(p_mem,0,p_bytes); -} diff --git a/core/os/copymem.h b/core/os/copymem.h index d7fc46aae4..4b9554519a 100644 --- a/core/os/copymem.h +++ b/core/os/copymem.h @@ -31,89 +31,18 @@ #include "typedefs.h" -///@TODO use optimized routines for this, depending on platform. these are just the standard ones +#ifdef PLATFORM_COPYMEM -#define copymem(m_to,m_from,m_count) \ - do { \ - unsigned char * _from=(unsigned char*)m_from; \ - unsigned char * _to=(unsigned char*)m_to; \ - int _count=m_count; \ - for (int _i=0;_i<_count;_i++) \ - _to[_i]=_from[_i]; \ - } while (0); - /* - case 0: *_dto++ = *_dfrom++; \ - case 7: *_dto++ = *_dfrom++; \ - case 6: *_dto++ = *_dfrom++; \ - case 5: *_dto++ = *_dfrom++; \ - case 4: *_dto++ = *_dfrom++; \ - case 3: *_dto++ = *_dfrom++; \ - case 2: *_dto++ = *_dfrom++; \ - case 1: *_dto++ = *_dfrom++; \ - */ -#define movemem_duff(m_to, m_from, m_count) \ - do { \ - if (m_to<m_from) { \ - unsigned char* _dto = (unsigned char*)m_to; \ - unsigned char* _dfrom = (unsigned char*)m_from; \ - int n = (m_count + 7) / 8; \ - switch (m_count % 8) { \ - do { \ - case 0: *_dto++ = *_dfrom++; \ - case 7: *_dto++ = *_dfrom++; \ - case 6: *_dto++ = *_dfrom++; \ - case 5: *_dto++ = *_dfrom++; \ - case 4: *_dto++ = *_dfrom++; \ - case 3: *_dto++ = *_dfrom++; \ - case 2: *_dto++ = *_dfrom++; \ - case 1: *_dto++ = *_dfrom++; \ - } while (--n > 0); \ - }; \ - } else if (m_to>m_from) { \ - unsigned char* _dto = &((unsigned char*)m_to)[m_count-1]; \ - unsigned char* _dfrom = &((unsigned char*)m_from)[m_count-1]; \ - int n = (m_count + 7) / 8; \ - switch (m_count % 8) { \ - do { \ - case 0: *_dto-- = *_dfrom--; \ - case 7: *_dto-- = *_dfrom--; \ - case 6: *_dto-- = *_dfrom--; \ - case 5: *_dto-- = *_dfrom--; \ - case 4: *_dto-- = *_dfrom--; \ - case 3: *_dto-- = *_dfrom--; \ - case 2: *_dto-- = *_dfrom--; \ - case 1: *_dto-- = *_dfrom--; \ - } while (--n > 0); \ - }; \ - } \ - } while(0) \ +#include "platform_copymem.h" // included from platform/<current_platform>/platform_copymem.h" -#define movemem_conventional(m_to,m_from,m_count) \ - do { \ - if (m_to<m_from) { \ - unsigned char * _from=(unsigned char*)m_from; \ - unsigned char * _to=(unsigned char*)m_to; \ - int _count=m_count; \ - for (int _i=0;_i<_count;_i++) \ - _to[_i]=_from[_i]; \ - \ - } else if (m_to>m_from) { \ - unsigned char * _from=(unsigned char*)m_from; \ - unsigned char * _to=(unsigned char*)m_to; \ - int _count=m_count; \ - while (_count--) \ - _to[_count]=_from[_count]; \ - \ - \ - } \ - } while (0); \ +#else -void movemem_system(void*,void*,int); +#include <string.h> -#define movemem movemem_system - - -void zeromem(void* p_mem,size_t p_bytes); +#define copymem(to,from,count) memcpy(to,from,count) +#define zeromem(to, count) memset(to, 0, count) +#define movemem(to, from, count) memmove(to, from, count) #endif +#endif diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 4c9d121781..3d15eb44aa 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -34,6 +34,7 @@ #include "os/main_loop.h" #include "io/packet_peer.h" #include "math/a_star.h" +#include "math/triangle_mesh.h" #include "globals.h" #include "object_type_db.h" #include "geometry.h" @@ -134,6 +135,7 @@ void register_core_types() { ObjectTypeDB::register_type<PHashTranslation>(); ObjectTypeDB::register_type<UndoRedo>(); ObjectTypeDB::register_type<HTTPClient>(); + ObjectTypeDB::register_type<TriangleMesh>(); ObjectTypeDB::register_virtual_type<ResourceInteractiveLoader>(); diff --git a/core/translation.cpp b/core/translation.cpp index 4d81073fe6..7d7edf086f 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -292,6 +292,7 @@ static const char* locale_list[]={ "pa_PK", // Panjabi (Pakistan) "pl", // Polish "pl_PL", // Polish (Poland) +"pr", // Pirate "ps_AF", // Pushto (Afghanistan) "pt", // Portuguese "pt_BR", // Portuguese (Brazil) @@ -650,6 +651,7 @@ static const char* locale_names[]={ "Panjabi (Pakistan)", "Polish", "Polish (Poland)", +"Pirate", "Pushto (Afghanistan)", "Portuguese", "Portuguese (Brazil)", diff --git a/core/variant.h b/core/variant.h index 90be593bd9..ccb8c5e3df 100644 --- a/core/variant.h +++ b/core/variant.h @@ -336,6 +336,7 @@ public: OP_MULTIPLY, OP_DIVIDE, OP_NEGATE, + OP_POSITIVE, OP_MODULE, OP_STRING_CONCAT, //bitwise diff --git a/core/variant_op.cpp b/core/variant_op.cpp index fd64b58bd5..73ed85db12 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -97,6 +97,12 @@ case m_name: {\ _RETURN( -p_a._data.m_type);\ }; +#define DEFAULT_OP_NUM_POS(m_name,m_type)\ +case m_name: {\ +\ + _RETURN( p_a._data.m_type);\ +}; + #define DEFAULT_OP_NUM_VEC(m_op,m_name,m_type)\ case m_name: {\ switch(p_b.type) {\ @@ -136,6 +142,10 @@ case m_name: {\ _RETURN( -*reinterpret_cast<const m_type*>(p_a._data._mem));\ } +#define DEFAULT_OP_LOCALMEM_POS(m_name,m_type)\ +case m_name: {\ + _RETURN( *reinterpret_cast<const m_type*>(p_a._data._mem));\ +} #define DEFAULT_OP_LOCALMEM_NUM(m_op,m_name,m_type)\ case m_name: {switch(p_b.type) {\ @@ -740,6 +750,48 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& } } break; + case OP_POSITIVE: { + // Simple case when user defines variable as +value. + switch(p_a.type) { + + DEFAULT_OP_FAIL(NIL); + DEFAULT_OP_FAIL(STRING); + DEFAULT_OP_FAIL(RECT2); + DEFAULT_OP_FAIL(MATRIX32); + DEFAULT_OP_FAIL(_AABB); + DEFAULT_OP_FAIL(MATRIX3); + DEFAULT_OP_FAIL(TRANSFORM); + DEFAULT_OP_NUM_POS(BOOL,_bool); + DEFAULT_OP_NUM_POS(INT,_int); + DEFAULT_OP_NUM_POS(REAL,_real); + DEFAULT_OP_LOCALMEM_POS(VECTOR3,Vector3); + DEFAULT_OP_LOCALMEM_POS(PLANE,Plane); + DEFAULT_OP_LOCALMEM_POS(QUAT,Quat); + DEFAULT_OP_LOCALMEM_POS(VECTOR2,Vector2); + + DEFAULT_OP_FAIL(COLOR); + DEFAULT_OP_FAIL(IMAGE); + DEFAULT_OP_FAIL(NODE_PATH); + DEFAULT_OP_FAIL(_RID); + DEFAULT_OP_FAIL(OBJECT); + DEFAULT_OP_FAIL(INPUT_EVENT); + DEFAULT_OP_FAIL(DICTIONARY); + DEFAULT_OP_FAIL(ARRAY); + DEFAULT_OP_FAIL(RAW_ARRAY); + DEFAULT_OP_FAIL(INT_ARRAY); + DEFAULT_OP_FAIL(REAL_ARRAY); + DEFAULT_OP_FAIL(STRING_ARRAY); + DEFAULT_OP_FAIL(VECTOR2_ARRAY); + DEFAULT_OP_FAIL(VECTOR3_ARRAY); + DEFAULT_OP_FAIL(COLOR_ARRAY); + case VARIANT_MAX: { + r_valid=false; + return; + + } break; + + } + } break; case OP_NEGATE: { switch(p_a.type) { @@ -778,9 +830,7 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& return; } break; - } - } break; case OP_MODULE: { if (p_a.type==INT && p_b.type==INT) { |