diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/image.cpp | 33 | ||||
-rw-r--r-- | core/image.h | 3 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 5 | ||||
-rw-r--r-- | core/io/packet_peer.cpp | 3 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 5 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 4 | ||||
-rw-r--r-- | core/math/quat.h | 2 | ||||
-rw-r--r-- | core/os/os.cpp | 11 | ||||
-rw-r--r-- | core/ring_buffer.h | 8 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 30 | ||||
-rw-r--r-- | core/script_debugger_remote.h | 18 | ||||
-rw-r--r-- | core/variant_call.cpp | 2 | ||||
-rw-r--r-- | core/variant_op.cpp | 18 |
13 files changed, 126 insertions, 16 deletions
diff --git a/core/image.cpp b/core/image.cpp index 4c0a23492b..06b7a78488 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -34,6 +34,33 @@ #include "print_string.h" #include <stdio.h> + +const char* Image::format_names[Image::FORMAT_MAX]={ + "Grayscale", + "Intensity", + "GrayscaleAlpha", + "RGB", + "RGBA", + "Indexed", + "IndexedAlpha", + "YUV422", + "YUV444", + "BC1", + "BC2", + "BC3", + "BC4", + "BC5", + "PVRTC2", + "PVRTC2Alpha", + "PVRTC4", + "PVRTC4Alpha", + "ETC", + "ATC", + "ATCAlphaExp", + "ATCAlphaInterp", + +}; + SavePNGFunc Image::save_png_func = NULL; void Image::_put_pixel(int p_x,int p_y, const BColor& p_color, unsigned char *p_data) { @@ -2355,6 +2382,12 @@ void Image::fix_alpha_edges() { } +String Image::get_format_name(Format p_format) { + + ERR_FAIL_INDEX_V(p_format,FORMAT_MAX,String()); + return format_names[p_format]; +} + Image::Image(const uint8_t* p_png,int p_len) { width=0; diff --git a/core/image.h b/core/image.h index 4461e97144..a155823af7 100644 --- a/core/image.h +++ b/core/image.h @@ -87,6 +87,7 @@ public: FORMAT_MAX }; + static const char* format_names[FORMAT_MAX]; enum Interpolation { INTERPOLATE_NEAREST, @@ -352,6 +353,8 @@ public: Image get_rect(const Rect2& p_area) const; static void set_compress_bc_func(void (*p_compress_func)(Image *)); + static String get_format_name(Format p_format); + Image(const uint8_t* p_mem_png, int p_len=-1); Image(const char **p_xpm); ~Image(); diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 1e76e2b4b2..62ccd81489 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -36,7 +36,10 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * const uint8_t * buf=p_buffer; int len=p_len; - ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); + if (len<4) { + + ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); + } uint32_t type=decode_uint32(buf); diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 875cace368..f6d526b512 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -156,7 +156,6 @@ Error PacketPeerStream::_poll_buffer() const { Error err = peer->get_partial_data(&temp_buffer[0], ring_buffer.space_left(), read); if (err) return err; - if (read==0) return OK; @@ -202,7 +201,7 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer,int &r_buffer_size) uint8_t lbuf[4]; ring_buffer.copy(lbuf,0,4); remaining-=4; - uint32_t len = decode_uint32(lbuf); + uint32_t len = decode_uint32(lbuf); ERR_FAIL_COND_V(remaining<(int)len,ERR_UNAVAILABLE); ring_buffer.read(lbuf,4); //get rid of first 4 bytes diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 60bb8b658e..1a0552e8d1 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -2172,10 +2172,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_ save_unicode_string("local://"+itos(r->get_subindex())); if (takeover_paths) { - r->set_path(p_path+"::"+itos(ofs_pos.size()),true); + r->set_path(p_path+"::"+itos(r->get_subindex()),true); } - } else + } else { save_unicode_string(r->get_path()); //actual external + } ofs_pos.push_back(f->get_pos()); f->store_64(0); //offset in 64 bits } diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 9019b4e3c0..66ae014dbc 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -2056,8 +2056,8 @@ Error ResourceFormatLoaderXML::rename_dependencies(const String &p_path,const Ma void ResourceFormatSaverXMLInstance::escape(String& p_str) { p_str=p_str.replace("&","&"); - p_str=p_str.replace("<",">"); - p_str=p_str.replace(">","<"); + p_str=p_str.replace("<","<"); + p_str=p_str.replace(">",">"); p_str=p_str.replace("'","'"); p_str=p_str.replace("\"","""); for (char i=1;i<32;i++) { diff --git a/core/math/quat.h b/core/math/quat.h index de4aedaeec..f161e35074 100644 --- a/core/math/quat.h +++ b/core/math/quat.h @@ -73,7 +73,7 @@ public: -x * v.x - y * v.y - z * v.z); } - _FORCE_INLINE_ Vector3 xform(const Vector3& v) { + _FORCE_INLINE_ Vector3 xform(const Vector3& v) const { Quat q = *this * v; q *= this->inverse(); diff --git a/core/os/os.cpp b/core/os/os.cpp index ee9f12b79d..8caf95e4d1 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -61,9 +61,16 @@ void OS::debug_break() { void OS::print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type) { + const char* err_type; + switch(p_type) { + case ERR_ERROR: err_type="**ERROR**"; break; + case ERR_WARNING: err_type="**WARNING**"; break; + case ERR_SCRIPT: err_type="**SCRIPT ERROR**"; break; + } + if (p_rationale && *p_rationale) - print("**ERROR**: %s\n ",p_rationale); - print("**ERROR**: At: %s:%i:%s() - %s\n",p_file,p_line,p_function,p_code); + print("%s: %s\n ",err_type,p_rationale); + print("%s: At: %s:%i:%s() - %s\n",err_type,p_file,p_line,p_function,p_code); } void OS::print(const char* p_format, ...) { diff --git a/core/ring_buffer.h b/core/ring_buffer.h index de33de0c76..3cf9cf9064 100644 --- a/core/ring_buffer.h +++ b/core/ring_buffer.h @@ -141,15 +141,15 @@ public: inline int space_left() { int left = read_pos - write_pos; if (left < 0) { - return size() + left; + return size() + left - 1; }; if (left == 0) { - return size(); + return size()-1; }; - return left; + return left -1; }; inline int data_left() { - return size() - space_left(); + return size() - space_left() - 1; }; inline int size() { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index d42f879441..d72c9f7532 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -31,6 +31,28 @@ #include "io/ip.h" #include "globals.h" +void ScriptDebuggerRemote::_send_video_memory() { + + List<ResourceUsage> usage; + if (resource_usage_func) + resource_usage_func(&usage); + + usage.sort(); + + packet_peer_stream->put_var("message:video_mem"); + packet_peer_stream->put_var(usage.size()*4); + + + for(List<ResourceUsage>::Element *E=usage.front();E;E=E->next()) { + + packet_peer_stream->put_var(E->get().path); + packet_peer_stream->put_var(E->get().type); + packet_peer_stream->put_var(E->get().format); + packet_peer_stream->put_var(E->get().vram); + } + +} + Error ScriptDebuggerRemote::connect_to_host(const String& p_host,uint16_t p_port) { @@ -248,6 +270,9 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { if (request_scene_tree) request_scene_tree(request_scene_tree_ud); + } else if (command=="request_video_mem") { + + _send_video_memory(); } else if (command=="breakpoint") { bool set = cmd[3]; @@ -531,6 +556,9 @@ void ScriptDebuggerRemote::_poll_events() { if (request_scene_tree) request_scene_tree(request_scene_tree_ud); + } else if (command=="request_video_mem") { + + _send_video_memory(); } else if (command=="breakpoint") { bool set = cmd[3]; @@ -652,6 +680,8 @@ void ScriptDebuggerRemote::set_live_edit_funcs(LiveEditFuncs *p_funcs) { live_edit_funcs=p_funcs; } +ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func=NULL; + ScriptDebuggerRemote::ScriptDebuggerRemote() { tcp_client = StreamPeerTCP::create_ref(); diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index c2642782a9..973fa23212 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -34,6 +34,7 @@ #include "io/stream_peer_tcp.h" #include "io/packet_peer.h" #include "list.h" + class ScriptDebuggerRemote : public ScriptDebugger { struct Message { @@ -42,6 +43,8 @@ class ScriptDebuggerRemote : public ScriptDebugger { Array data; }; + + Ref<StreamPeerTCP> tcp_client; Ref<PacketPeerStream> packet_peer_stream; @@ -90,6 +93,7 @@ class ScriptDebuggerRemote : public ScriptDebugger { RequestSceneTreeMessageFunc request_scene_tree; void *request_scene_tree_ud; + void _send_video_memory(); LiveEditFuncs *live_edit_funcs; ErrorHandlerList eh; @@ -98,6 +102,20 @@ class ScriptDebuggerRemote : public ScriptDebugger { public: + struct ResourceUsage { + + String path; + String format; + String type; + RID id; + int vram; + bool operator<(const ResourceUsage& p_img) const { return vram==p_img.vram ? id<p_img.id : vram > p_img.vram; } + }; + + typedef void (*ResourceUsageFunc)(List<ResourceUsage>*); + + static ResourceUsageFunc resource_usage_func; + Error connect_to_host(const String& p_host,uint16_t p_port); virtual void debug(ScriptLanguage *p_script,bool p_can_continue=true); virtual void idle_poll(); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 222618ffa0..7bbb18225d 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -409,6 +409,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(Quat,normalized); VCALL_LOCALMEM0R(Quat,inverse); VCALL_LOCALMEM1R(Quat,dot); + VCALL_LOCALMEM1R(Quat,xform); VCALL_LOCALMEM2R(Quat,slerp); VCALL_LOCALMEM2R(Quat,slerpni); VCALL_LOCALMEM4R(Quat,cubic_slerp); @@ -1361,6 +1362,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(QUAT,QUAT,Quat,normalized,varray()); ADDFUNC0(QUAT,QUAT,Quat,inverse,varray()); ADDFUNC1(QUAT,REAL,Quat,dot,QUAT,"b",varray()); + ADDFUNC1(QUAT,VECTOR3,Quat,xform,VECTOR3,"v",varray()); ADDFUNC2(QUAT,QUAT,Quat,slerp,QUAT,"b",REAL,"t",varray()); ADDFUNC2(QUAT,QUAT,Quat,slerpni,QUAT,"b",REAL,"t",varray()); ADDFUNC4(QUAT,QUAT,Quat,cubic_slerp,QUAT,"b",QUAT,"pre_a",QUAT,"post_b",REAL,"t",varray()); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 1cdf6d7319..eabd647837 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -586,7 +586,21 @@ void Variant::evaluate(const Operator& p_op, const Variant& p_a, const Variant& } break; DEFAULT_OP_LOCALMEM_NUM(*,VECTOR3,Vector3); DEFAULT_OP_FAIL(PLANE); - DEFAULT_OP_FAIL(QUAT); + case QUAT: { + + switch(p_b.type) { + case VECTOR3: { + + _RETURN( reinterpret_cast<const Quat*>(p_a._data._mem)->xform( *(const Vector3*)p_b._data._mem) ); + } break; + case QUAT: { + + _RETURN( *reinterpret_cast<const Quat*>(p_a._data._mem) * *reinterpret_cast<const Quat*>(p_b._data._mem) ); + } break; + }; + r_valid=false; + return; + } break; DEFAULT_OP_FAIL(_AABB); case MATRIX3: { @@ -2573,7 +2587,7 @@ bool Variant::in(const Variant& p_index, bool *r_valid) const { String idx=p_index; const String *str=reinterpret_cast<const String*>(_data._mem); - return str->find("idx")!=-1; + return str->find(idx)!=-1; } } break; |