mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
feature: hud (#37)
* build: replace FetchContent with direct includes for glm * build(deps): replace SOIL2 with stb for image and vorbis decoding * build: replace FetchContent with direct includes for toml++ * refactor(texture): bump block texture size to 512 and disable items tab * feat: add hotbar system with ItemStack and RowLayout * fix(ui): restrict Ctrl key handling to typing mode * feat(ui): add widget border support and highlight selected hotbar slot * fix(ui): update borders on scale change and correct Image width - Added update_border() calls in set_scale() for Button, ChatBox, Image, Label, and TextField. - Fixed Image::width() to multiply by width instead of height. - Added early return in Widget::update_border() if border is not supported. * feat(ui): add border visual feedback on slider drag * feat(ui): add ItemSlot widget and refactor hotbar to use it * feat(world_scene): add inventory UI and pause type enum * feat(ui): add item slot tooltip and make window size static * fix(ui label): account for background offset in width/height * refactor(ui): centralize item info label in inventory and add update * feat(ui): add hotbar interaction in inventory UI * fix(inventory-ui): correct row creation logic for first item The loop starting at index 0 created a new row on the first iteration (i % 10 == 0). Shift the loop to start at 1 and adjust modulus condition to create rows correctly every 10 items. * feat(block): add name_key for localized block names Add `name_key` field to all block TOML definitions, enabling per-block localization. Update `BlockData` struct and `BlockManager` with `local_name()` method that returns a localized string via the translation system. Add corresponding entries to `en_US.json` and `zh_CN.json`. Modify inventory UI to use the localized name when displaying block info, and fix a bug where emptying a hotbar slot did not clear the item locally. * fix(ui): change inventory item slot color from white to gray * fix(ui): add missing include for std::array
This commit is contained in:
75
include/glm/gtx/fast_square_root.inl
Normal file
75
include/glm/gtx/fast_square_root.inl
Normal file
@@ -0,0 +1,75 @@
|
||||
/// @ref gtx_fast_square_root
|
||||
|
||||
namespace glm
|
||||
{
|
||||
// fastSqrt
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastSqrt(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fastSqrt' only accept floating-point input");
|
||||
|
||||
return genType(1) / fastInverseSqrt(x);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastSqrt(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::functor1<vec, L, T, T, Q>::call(fastSqrt, x);
|
||||
}
|
||||
|
||||
// fastInversesqrt
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastInverseSqrt(genType x)
|
||||
{
|
||||
return detail::compute_inversesqrt<1, genType, lowp, detail::is_aligned<lowp>::value>::call(vec<1, genType, lowp>(x)).x;
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastInverseSqrt(vec<L, T, Q> const& x)
|
||||
{
|
||||
return detail::compute_inversesqrt<L, T, Q, detail::is_aligned<Q>::value>::call(x);
|
||||
}
|
||||
|
||||
// fastLength
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLength(genType x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fastLength' only accept floating-point inputs");
|
||||
|
||||
return abs(x);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T fastLength(vec<L, T, Q> const& x)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559 || GLM_CONFIG_UNRESTRICTED_FLOAT, "'fastLength' only accept floating-point inputs");
|
||||
|
||||
return fastSqrt(dot(x, x));
|
||||
}
|
||||
|
||||
// fastDistance
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastDistance(genType x, genType y)
|
||||
{
|
||||
return fastLength(y - x);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER T fastDistance(vec<L, T, Q> const& x, vec<L, T, Q> const& y)
|
||||
{
|
||||
return fastLength(y - x);
|
||||
}
|
||||
|
||||
// fastNormalize
|
||||
template<typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastNormalize(genType x)
|
||||
{
|
||||
return x > genType(0) ? genType(1) : -genType(1);
|
||||
}
|
||||
|
||||
template<length_t L, typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER vec<L, T, Q> fastNormalize(vec<L, T, Q> const& x)
|
||||
{
|
||||
return x * fastInverseSqrt(dot(x, x));
|
||||
}
|
||||
}//namespace glm
|
||||
Reference in New Issue
Block a user