diff options
author | Ferenc Arn <tagcup@yahoo.com> | 2017-01-14 14:35:39 -0600 |
---|---|---|
committer | Ferenc Arn <tagcup@yahoo.com> | 2017-01-16 13:36:33 -0600 |
commit | 6f4f9aa6ded6da027c84cc466c767334dc3d3362 (patch) | |
tree | 4d45d7e600a069d7feb2a2dae3a70d6b9ddbf884 /scene/gui | |
parent | d13f2f9e25e380496e706b59720cd85eed299ca2 (diff) |
Overloaded basic math funcs (double and float variants). Use real_t rather than float or double in generic functions (core/math) whenever possible.
Also inlined some more math functions.
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/range.cpp | 10 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index d5c1034c9c..5ecafccaca 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -141,8 +141,8 @@ void Range::set_as_ratio(double p_value) { if (shared->exp_ratio && get_min()>0) { - double exp_min = Math::log(get_min())/Math::log(2); - double exp_max = Math::log(get_max())/Math::log(2); + double exp_min = Math::log(get_min())/Math::log((double)2); + double exp_max = Math::log(get_max())/Math::log((double)2); v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value); } else { @@ -160,9 +160,9 @@ double Range::get_as_ratio() const { if (shared->exp_ratio && get_min()>0) { - double exp_min = Math::log(get_min())/Math::log(2); - double exp_max = Math::log(get_max())/Math::log(2); - double v = Math::log(get_value())/Math::log(2); + double exp_min = Math::log(get_min())/Math::log((double)2); + double exp_max = Math::log(get_max())/Math::log((double)2); + double v = Math::log(get_value())/Math::log((double)2); return (v - exp_min) / (exp_max - exp_min); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index ec6be0d19d..8920f8f056 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -162,7 +162,7 @@ void SpinBox::_gui_input(const InputEvent& p_event) { if (drag.enabled) { float diff_y = drag.mouse_pos.y - cpos.y; - diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y); + diff_y=Math::pow(ABS(diff_y),1.8f)*SGN(diff_y); diff_y*=0.1; drag.mouse_pos=cpos; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 2cfebb7c1e..c52283ecde 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -943,7 +943,7 @@ void Tree::draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,cons bmsize.width=p_cell.icon_max_w; } - p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((rect.size.y-bmsize.y)/2)),bmsize); + p_cell.draw_icon(ci,rect.pos + Size2i(0,Math::floor((real_t)(rect.size.y-bmsize.y)/2)),bmsize); rect.pos.x+=bmsize.x+cache.hseparation; rect.size.x-=bmsize.x+cache.hseparation; @@ -1173,7 +1173,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& Ref<Texture> checked = cache.checked; Ref<Texture> unchecked = cache.unchecked; Point2i check_ofs=item_rect.pos; - check_ofs.y+=Math::floor((item_rect.size.y-checked->get_height())/2); + check_ofs.y+=Math::floor((real_t)(item_rect.size.y-checked->get_height())/2); if (p_item->cells[i].checked) { @@ -2321,7 +2321,7 @@ void Tree::_gui_input(InputEvent p_event) { TreeItem::Cell &c=popup_edited_item->cells[popup_edited_item_col]; float diff_y = -b.relative_y; - diff_y=Math::pow(ABS(diff_y),1.8)*SGN(diff_y); + diff_y=Math::pow(ABS(diff_y),1.8f)*SGN(diff_y); diff_y*=0.1; range_drag_base=CLAMP(range_drag_base + c.step * diff_y, c.min, c.max); popup_edited_item->set_range(popup_edited_item_col,range_drag_base); |