Agartha-Software / Agartha-Software/Cevy
[Bug] Mouse motion breaks when click release outside of window
- 主要语言
- 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 还没有评估数据。