-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Add bevy_camera_controllers crate and move freecam implementation into it #20215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bevy_camera_controllers crate and move freecam implementation into it #20215
Conversation
Module docs Hook up new crate to bevy_internal Stub for fly_cam camera controller Steal existing free-cam controller
This comment was marked as duplicate.
This comment was marked as duplicate.
i worry a bit about the added friction of having to run some examples with |
This comment was marked as duplicate.
This comment was marked as duplicate.
I think it's ok, there is some minor friction but the required-features should prompt people well enough and may add to discoverability of how to add FreeCam for your own project. |
Co-authored-by: atlv <[email protected]>
Yeah, the prompt is very helpful. I don't like having to add it, but the alternative is to add it to the default features. Since 99% of games won't want to ship with this in production, the only way to reclaim that binary size / compile speed will be to turn off Bevy's default features and slowly build it back up. |
The generated |
I have some feedback and improvements in mind for this code, but as per the "notes for reviewers", I think it would mostly be out of scope for this initial PR. Should I wait until this PR is merged to follow-up on it, or is there an appropriate way to share the feedback immediately? |
Leave your feedback here for now, and then we can come back to this thread for notes when merged :) |
On line 183 (Github won't let me comment on that line directly because it's outside of the diff), the scroll delta is divided by 16 if the unit is pixels, and not if the unit is lines. This seems odd to me, both because it's undocumented, and because no other use of mouse scrolling I could find in Bevy cares about the scroll units. The PR that added this was #11921, and reading the comments there reveals that the choice of 16 as the divisor was both arbitrary and untested. Someone should actually test pixel scrolling, and either confirm that 16 is fine, or update it to something better (and also document it either way). Alternatively, the special-casing based on the units could just be removed entirely. |
Co-authored-by: Jan Hohenheim <[email protected]> Co-authored-by: atlv <[email protected]>
… into bevy-camera-controllers
4282ae6
to
b61287a
Compare
//! A camera controller that allows the user to move freely around the scene. | ||
//! | ||
//! Unlike other examples, which demonstrate an application, this demonstrates a plugin library. | ||
//! Free cams are helpful for exploring large scenes, level editors and for debugging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These docs are gone now from docs.rs due to the module not being pub, FYI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, that's so sad. Reverting.
This reverts commit 4316669.
…ler (#21450) # Objective As noted in #20215 (comment) by @BigWingBeat, the conversion factor used in the free cam camera controller code that was added in #11921 arbitrary and untested. This is a problem that users have stumbled across elsewhere, including in #21140 and myself when writing leafwing-input-manager! ## Solution 1. Define a constant with the correct conversion factor, at least as reported in #21140. This goes in `bevy_input` as it's broadly useful. 2. Use that constant in bevy_camera_controller::free_cam. 3. Approximately scale the default value on the camera controller to compensate. ## Testing We use this controller in a number of our examples. I chose `3d_gizmos`, which worked just about the same before and after. The scroll wheel controls your "walking speed".
# Objective As pointed out by @BigWingBeat in #20215 (comment) the default mouse sensitivity of the free_cam controller is crazy high. ## Solution Divide the sensitivity value by 5. 10 was too much, but 5 feels about right for a "careful and controlled scene editor". ## Testing `cargo run --example 3d_gizmos --features="free_cam"`
# Objective The `solari` example does not compile when run with the required-features following #20215. ## Solution Require the new free_cam feature. ## Testing `cargo build --example solari --features="bevy_solari https free_cam"`
Objective
Moving the camera around is really important to validate that our scenes are rendered correctly.
Bevy engine devs currently do this via a fairly cursed "library example" which includes a basic freecam controller (which is technically distinct from a flycam apparently). This has three problems:
Solution
Create a new
bevy_camera_controllers
crate, and move the existing freecam implementation into it, nearly verbatim.This cleans up some ugly tech debt in how we do this, makes it easier to add a camera controller to other examples, and also gives us a scaffold for future camera controllers.
This PR has been marked
X-Blessed
, as I went over this plan with @cart in a meeting on 2025-06-23, and we both agreed that this was the right first step.Testing
I've tested the examples that rely on this camera controller: they work just like before.
Notes for reviewers
TODO
Future work