From 2d4cec0cb637e4af2d8954e6ed10336552a627e9 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 15 Feb 2015 11:26:31 -0300 Subject: [PATCH 1/3] fix return value of slide and reflect closes #1311 --- core/variant_call.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 3f2800494d9..50a60390e57 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1263,8 +1263,8 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC1(VECTOR2,VECTOR2,Vector2,snapped,VECTOR2,"by",varray()); ADDFUNC0(VECTOR2,REAL,Vector2,get_aspect,varray()); ADDFUNC1(VECTOR2,REAL,Vector2,dot,VECTOR2,"with",varray()); - ADDFUNC1(VECTOR2,REAL,Vector2,slide,VECTOR2,"vec",varray()); - ADDFUNC1(VECTOR2,REAL,Vector2,reflect,VECTOR2,"vec",varray()); + ADDFUNC1(VECTOR2,VECTOR2,Vector2,slide,VECTOR2,"vec",varray()); + ADDFUNC1(VECTOR2,VECTOR2,Vector2,reflect,VECTOR2,"vec",varray()); //ADDFUNC1(VECTOR2,REAL,Vector2,cross,VECTOR2,"with",varray()); ADDFUNC0(RECT2,REAL,Rect2,get_area,varray()); From 4333aa240c68f22b235981bed56d11a592fdfd1d Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 15 Feb 2015 12:38:25 -0300 Subject: [PATCH 2/3] Godot UI is quick and snappy again! Changed linked listed sort to use auxiliary memory this fixes user interface performance issues. --- core/list.h | 56 +++++++++++++++++++++++++++++++++++++++++-- scene/gui/control.cpp | 2 ++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/core/list.h b/core/list.h index f581feb7356..0e4ba71ac49 100644 --- a/core/list.h +++ b/core/list.h @@ -30,7 +30,7 @@ #define GLOBALS_LIST_H #include "os/memory.h" - +#include "sort.h" /** * Generic Templatized Linked List Implementation. @@ -551,7 +551,7 @@ public: } template - void sort_custom() { + void sort_custom_inplace() { if(size()<2) return; @@ -603,6 +603,58 @@ public: _data->last=to; } + template + struct AuxiliaryComparator { + + C compare; + _FORCE_INLINE_ bool operator()(const Element *A,const Element* B) const { + + return compare(A->value,B->value); + } + }; + + template + void sort_custom() { + + //this version uses auxiliary memory for speed. + //if you don't want to use auxiliary memory, use the in_place version + + int s = size(); + if(s<2) + return; + + + Element **aux_buffer = memnew_arr(Element*,s); + + int idx=0; + for(Element *E=front();E;E=E->next_ptr) { + + aux_buffer[idx]=E; + idx++; + } + + SortArray > sort; + sort.sort(aux_buffer,s); + + _data->first=aux_buffer[0]; + aux_buffer[0]->prev_ptr=NULL; + aux_buffer[0]->next_ptr=aux_buffer[1]; + + _data->last=aux_buffer[s-1]; + aux_buffer[s-1]->prev_ptr=aux_buffer[s-2]; + aux_buffer[s-1]->next_ptr=NULL; + + for(int i=1;iprev_ptr=aux_buffer[i-1]; + aux_buffer[i]->next_ptr=aux_buffer[i+1]; + + } + + memdelete_arr(aux_buffer); + } + + /** * copy constructor for the list */ diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4d32c7ea9a3..a8070be91d0 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2267,8 +2267,10 @@ void Control::_window_sort_subwindows() { if (!window->subwindow_order_dirty) return; + window->modal_stack.sort_custom(); window->subwindows.sort_custom(); + window->subwindow_order_dirty=false; } From 2478935f9654de9b516f61a43e1b0e0f0d97fb26 Mon Sep 17 00:00:00 2001 From: Felix Laurie von Massenbach Date: Sun, 15 Feb 2015 18:09:11 +0000 Subject: [PATCH 3/3] Fix a shadow declaration. --- core/list.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/list.h b/core/list.h index 0e4ba71ac49..ef30e43d216 100644 --- a/core/list.h +++ b/core/list.h @@ -607,9 +607,9 @@ public: struct AuxiliaryComparator { C compare; - _FORCE_INLINE_ bool operator()(const Element *A,const Element* B) const { + _FORCE_INLINE_ bool operator()(const Element *a,const Element* b) const { - return compare(A->value,B->value); + return compare(a->value,b->value); } };