mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
* 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
182 lines
4.6 KiB
C++
182 lines
4.6 KiB
C++
/// @ref core
|
|
/// @file glm/detail/func_geometric_simd.inl
|
|
|
|
#include "../simd/geometric.h"
|
|
|
|
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
|
|
|
|
namespace glm{
|
|
namespace detail
|
|
{
|
|
template<qualifier Q>
|
|
struct compute_length<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& v)
|
|
{
|
|
return _mm_cvtss_f32(glm_vec4_length(v.data));
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_distance<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& p0, vec<4, float, Q> const& p1)
|
|
{
|
|
return _mm_cvtss_f32(glm_vec4_distance(p0.data, p1.data));
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_dot<vec<4, float, Q>, float, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& x, vec<4, float, Q> const& y)
|
|
{
|
|
return _mm_cvtss_f32(glm_vec1_dot(x.data, y.data));
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_dot<vec<3, float, Q>, float, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<3, float, Q> const& a, vec<3, float, Q> const& b)
|
|
{
|
|
vec<4, float, Q> aa = xyz0(a);
|
|
vec<4, float, Q> bb = xyz0(b);
|
|
return _mm_cvtss_f32(glm_vec1_dot(aa.data, bb.data));
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_cross<float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static vec<3, float, Q> call(vec<3, float, Q> const& a, vec<3, float, Q> const& b)
|
|
{
|
|
vec<4, float, Q> aa = xyzz(a);
|
|
vec<4, float, Q> bb = xyzz(b);
|
|
__m128 const xpd0 = glm_vec4_cross(aa.data, bb.data);
|
|
|
|
vec<3, float, Q> Result;
|
|
Result.data = xpd0;
|
|
return Result;
|
|
}
|
|
|
|
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& a, vec<4, float, Q> const& b)
|
|
{
|
|
vec<4, float, Q> Result;
|
|
Result.data = glm_vec4_cross(a.data, b.data);
|
|
return Result;
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_normalize<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
|
|
{
|
|
vec<4, float, Q> Result;
|
|
Result.data = glm_vec4_normalize(v.data);
|
|
return Result;
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_faceforward<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& N, vec<4, float, Q> const& I, vec<4, float, Q> const& Nref)
|
|
{
|
|
vec<4, float, Q> Result;
|
|
Result.data = glm_vec4_faceforward(N.data, I.data, Nref.data);
|
|
return Result;
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_reflect<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& I, vec<4, float, Q> const& N)
|
|
{
|
|
vec<4, float, Q> Result;
|
|
Result.data = glm_vec4_reflect(I.data, N.data);
|
|
return Result;
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_refract<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& I, vec<4, float, Q> const& N, float eta)
|
|
{
|
|
vec<4, float, Q> Result;
|
|
Result.data = glm_vec4_refract(I.data, N.data, _mm_set1_ps(eta));
|
|
return Result;
|
|
}
|
|
};
|
|
}//namespace detail
|
|
}//namespace glm
|
|
|
|
#elif GLM_ARCH & GLM_ARCH_NEON_BIT
|
|
namespace glm{
|
|
namespace detail
|
|
{
|
|
template<qualifier Q>
|
|
struct compute_length<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& v)
|
|
{
|
|
return sqrt(compute_dot<vec<4, float, Q>, float, true>::call(v, v));
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_distance<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& p0, vec<4, float, Q> const& p1)
|
|
{
|
|
return compute_length<4, float, Q, true>::call(p1 - p0);
|
|
}
|
|
};
|
|
|
|
|
|
template<qualifier Q>
|
|
struct compute_dot<vec<4, float, Q>, float, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static float call(vec<4, float, Q> const& x, vec<4, float, Q> const& y)
|
|
{
|
|
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
|
float32x4_t v = vmulq_f32(x.data, y.data);
|
|
return vaddvq_f32(v);
|
|
#else // Armv7a with Neon
|
|
float32x4_t p = vmulq_f32(x.data, y.data);
|
|
float32x2_t v = vpadd_f32(vget_low_f32(p), vget_high_f32(p));
|
|
v = vpadd_f32(v, v);
|
|
return vget_lane_f32(v, 0);
|
|
#endif
|
|
}
|
|
};
|
|
|
|
template<qualifier Q>
|
|
struct compute_normalize<4, float, Q, true>
|
|
{
|
|
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
|
|
{
|
|
float32x4_t p = vmulq_f32(v.data, v.data);
|
|
#if GLM_ARCH & GLM_ARCH_ARMV8_BIT
|
|
p = vpaddq_f32(p, p);
|
|
p = vpaddq_f32(p, p);
|
|
#else
|
|
float32x2_t t = vpadd_f32(vget_low_f32(p), vget_high_f32(p));
|
|
t = vpadd_f32(t, t);
|
|
p = vcombine_f32(t, t);
|
|
#endif
|
|
|
|
float32x4_t vd = vrsqrteq_f32(p);
|
|
vec<4, float, Q> Result;
|
|
Result.data = vmulq_f32(v.data, vd);
|
|
return Result;
|
|
}
|
|
};
|
|
}//namespace detail
|
|
}//namespace glm
|
|
|
|
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
|