Loading gfx/include/gfx/ui/ui_element.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -365,7 +365,7 @@ struct LineTextEdit : public UiElement { } void set_cursor_index(int new_idx, scalar new_cursorX) { m_cursor_idx = std::clamp(new_idx, -1, (int)m_text.size() - 1); m_cursor_idx = clamp(new_idx, -1, (int)m_text.size() - 1); m_cursor_props.prevCursorX = m_cursor_props.cursorX; m_cursor_props.cursorX = new_cursorX; on_cursor_changed(new_idx, new_cursorX); Loading gfx/src/ui/anchor.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -9,10 +9,10 @@ Anchor::~Anchor() { } void Anchor::set_anchors(scalar new_bottom, scalar new_left, scalar new_top, scalar new_right) { m_bottom = std::clamp(new_bottom, 0.f, 1.0f); m_left = std::clamp(new_left, 0.f, 1.0f); m_top = std::clamp(new_top, 0.f, 1.0f); m_right = std::clamp(new_right, 0.f, 1.0f); m_bottom = clamp(new_bottom, 0.f, 1.0f); m_left = clamp(new_left, 0.f, 1.0f); m_top = clamp(new_top, 0.f, 1.0f); m_right = clamp(new_right, 0.f, 1.0f); m_init = true; notify_content_changed(); } Loading gfx/src/ui/ui_element.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -90,13 +90,13 @@ void UiElement::on_anchor_changed(Anchor* anchor) { scalar origin_y = (1.0f - anchor->get_top() - anchor->get_bottom()) / 2.0f * parent_size.y + anchor->get_bottom() * parent_size.y; if (m_parent != nullptr) { origin_x = std::clamp(origin_x, 0.f, parent_size.x); origin_y = std::clamp(origin_y, 0.f, parent_size.y); origin_x = clamp(origin_x, 0.f, parent_size.x); origin_y = clamp(origin_y, 0.f, parent_size.y); origin_x -= parent_size.x / 2.f; origin_y -= parent_size.y / 2.f; } else { origin_x = std::clamp(origin_x, half_sizes.x, parent_size.x - half_sizes.x); origin_y = std::clamp(origin_y, half_sizes.y, parent_size.y - half_sizes.y); origin_x = clamp(origin_x, half_sizes.x, parent_size.x - half_sizes.x); origin_y = clamp(origin_y, half_sizes.y, parent_size.y - half_sizes.y); } if (half_sizes.x != get_normalized_size().hi.x || half_sizes.y != get_normalized_size().hi.y || Loading Loading @@ -1278,7 +1278,7 @@ void Slider::on_mouse_moved(vec2 position) { low_value = get_transform()->get_aabb().lo.y; high_value = get_transform()->get_aabb().hi.y; } set_value(std::clamp((new_value - low_value) / (high_value - low_value), 0.0f, 1.0f)); set_value(clamp((new_value - low_value) / (high_value - low_value), 0.0f, 1.0f)); } } Loading math/include/math/math.hpp +5 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ inline bool equal(vec4 const u, vec4 const v, scalar const epsilon = Num::epsilo equal(get<3>(u), get<3>(v), epsilon) ; } template<class T> constexpr const T& clamp(const T& v, const T& lo, const T& hi) { return std::min(hi, std::max(lo, v)); } inline std::ostream &operator<<(std::ostream &stream, const vec3 &v) { Loading @@ -61,7 +66,6 @@ inline std::ostream &operator<<(std::ostream &stream, const quat &q) return stream; } struct basis3 { basis3() Loading phx/CMakeLists.txt +0 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,6 @@ set(THIS_TARGET_NAME phx) file(GLOB_RECURSE "${THIS_TARGET_NAME}_HPP" "./include/${THIS_TARGET_NAME}/*.hpp") file(GLOB_RECURSE "${THIS_TARGET_NAME}_CPP" "./src/*.cpp") #add_compile_definitions(USE_BULLET_PHX) add_library(${THIS_TARGET_NAME} "${${THIS_TARGET_NAME}_HPP}" "${${THIS_TARGET_NAME}_CPP}" Loading Loading
gfx/include/gfx/ui/ui_element.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -365,7 +365,7 @@ struct LineTextEdit : public UiElement { } void set_cursor_index(int new_idx, scalar new_cursorX) { m_cursor_idx = std::clamp(new_idx, -1, (int)m_text.size() - 1); m_cursor_idx = clamp(new_idx, -1, (int)m_text.size() - 1); m_cursor_props.prevCursorX = m_cursor_props.cursorX; m_cursor_props.cursorX = new_cursorX; on_cursor_changed(new_idx, new_cursorX); Loading
gfx/src/ui/anchor.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -9,10 +9,10 @@ Anchor::~Anchor() { } void Anchor::set_anchors(scalar new_bottom, scalar new_left, scalar new_top, scalar new_right) { m_bottom = std::clamp(new_bottom, 0.f, 1.0f); m_left = std::clamp(new_left, 0.f, 1.0f); m_top = std::clamp(new_top, 0.f, 1.0f); m_right = std::clamp(new_right, 0.f, 1.0f); m_bottom = clamp(new_bottom, 0.f, 1.0f); m_left = clamp(new_left, 0.f, 1.0f); m_top = clamp(new_top, 0.f, 1.0f); m_right = clamp(new_right, 0.f, 1.0f); m_init = true; notify_content_changed(); } Loading
gfx/src/ui/ui_element.cpp +5 −5 Original line number Diff line number Diff line Loading @@ -90,13 +90,13 @@ void UiElement::on_anchor_changed(Anchor* anchor) { scalar origin_y = (1.0f - anchor->get_top() - anchor->get_bottom()) / 2.0f * parent_size.y + anchor->get_bottom() * parent_size.y; if (m_parent != nullptr) { origin_x = std::clamp(origin_x, 0.f, parent_size.x); origin_y = std::clamp(origin_y, 0.f, parent_size.y); origin_x = clamp(origin_x, 0.f, parent_size.x); origin_y = clamp(origin_y, 0.f, parent_size.y); origin_x -= parent_size.x / 2.f; origin_y -= parent_size.y / 2.f; } else { origin_x = std::clamp(origin_x, half_sizes.x, parent_size.x - half_sizes.x); origin_y = std::clamp(origin_y, half_sizes.y, parent_size.y - half_sizes.y); origin_x = clamp(origin_x, half_sizes.x, parent_size.x - half_sizes.x); origin_y = clamp(origin_y, half_sizes.y, parent_size.y - half_sizes.y); } if (half_sizes.x != get_normalized_size().hi.x || half_sizes.y != get_normalized_size().hi.y || Loading Loading @@ -1278,7 +1278,7 @@ void Slider::on_mouse_moved(vec2 position) { low_value = get_transform()->get_aabb().lo.y; high_value = get_transform()->get_aabb().hi.y; } set_value(std::clamp((new_value - low_value) / (high_value - low_value), 0.0f, 1.0f)); set_value(clamp((new_value - low_value) / (high_value - low_value), 0.0f, 1.0f)); } } Loading
math/include/math/math.hpp +5 −1 Original line number Diff line number Diff line Loading @@ -48,6 +48,11 @@ inline bool equal(vec4 const u, vec4 const v, scalar const epsilon = Num::epsilo equal(get<3>(u), get<3>(v), epsilon) ; } template<class T> constexpr const T& clamp(const T& v, const T& lo, const T& hi) { return std::min(hi, std::max(lo, v)); } inline std::ostream &operator<<(std::ostream &stream, const vec3 &v) { Loading @@ -61,7 +66,6 @@ inline std::ostream &operator<<(std::ostream &stream, const quat &q) return stream; } struct basis3 { basis3() Loading
phx/CMakeLists.txt +0 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,6 @@ set(THIS_TARGET_NAME phx) file(GLOB_RECURSE "${THIS_TARGET_NAME}_HPP" "./include/${THIS_TARGET_NAME}/*.hpp") file(GLOB_RECURSE "${THIS_TARGET_NAME}_CPP" "./src/*.cpp") #add_compile_definitions(USE_BULLET_PHX) add_library(${THIS_TARGET_NAME} "${${THIS_TARGET_NAME}_HPP}" "${${THIS_TARGET_NAME}_CPP}" Loading