Agartha-Software / Agartha-Software/Cevy

[Bug] Mouse motion breaks when click release outside of window

未关闭
#23 0 条评论 0 个 reaction 已指派 1 人 已被 @Arthur-Aillet 认领 在 GitHub 查看
bug
主要语言
C++
星标
15
派生
2
PR 合并指标
30 天内没有已合并 PR

描述

## Problem:
EventReader events are all {0, 0}, but are still arriving

Expected behavior:
these events should have non-zero value

## Repro:
- hold any mouse button
- move mouse outside the window
- release click
- events now bricked

## code:
```cpp
void rotate_camera(Query cam_q,
Resource> mouse_buttons,
cevy::ecs::EventReader mouse_motion_reader) {
static glm::vec2 rotation = {0 * glm::pi(), glm::pi() * 0.3f};

if (mouse_buttons->is_pressed(input::MouseButton::Right)) {
std::cout << "mousing!" << std::endl;
for (const auto &mouse_motion : mouse_motion_reader) {
if (mouse_motion.delta.has_value()) {
rotation.x -= mouse_motion.delta.value().x * 0.005;
rotation.y -= mouse_motion.delta.value().y * 0.005;
rotation.y = glm::clamp(rotation.y, 0.f, glm::pi());
std::cout << "motion!" << mouse_motion.delta.value().x << " " << mouse_motion.delta.value().y << std::endl;
}
auto xQuat = glm::quat({0., 0., rotation.x});
auto yQuat = glm::quat({rotation.y, 0., 0.});
for (auto [_, transform] : cam_q) {
transform.rotation = xQuat * yQuat;
}
}
}
}
```

## Env:
branch: `/feat/assets`, equivalent to `/dev` with regards to inputs
commit: 9e55987119105395036efb593edf35d2af3d716a
modules: DeferredRenderer, no Editor

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。