Skip to content
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

Insert gizmo configuration #11569

Closed
Jondolf opened this issue Jan 27, 2024 · 3 comments · Fixed by #11580
Closed

Insert gizmo configuration #11569

Jondolf opened this issue Jan 27, 2024 · 3 comments · Fixed by #11580
Labels
A-Gizmos Visual editor and debug gizmos C-Feature A new feature, making something new possible

Comments

@Jondolf
Copy link
Contributor

Jondolf commented Jan 27, 2024

What problem does this solve or what need does it fill?

With Bevy's new support for multiple gizmo configurations (#10342), it's possible to initialize configurations using init_gizmo_group. However, there doesn't seem to be an API to initialize it with a specific value.

The only way that I found outside of scheduling a startup system (which I can't do in my case) is to do this:

// In a plugin's build method

app.init_gizmo_group::<PhysicsGizmos>();

let mut store = app.world.resource_mut::<GizmoConfigStore>();
let config = store.config_mut::<PhysicsGizmos>().0;
config.line_width = 1.5;

which is not ideal. I think it also has issues if the plugin is added before the GizmoPlugin.

My use case is that bevy_xpbd has a PhysicsDebugConfig resource and a PhysicsDebugRenderer system parameter that renders colliders, joints, contacts, and so on. With the new gizmo API, I'm combining these into a single PhysicsGizmos gizmo config group that stores the config that was previously stored in PhysicsDebugConfig and has some methods for e.g. rendering colliders.

I need to (1) configure some properties of the GizmoConfig to non-default values, and (2) give people an easy API to configure PhysicsGizmos for e.g. disabling collider rendering. This should be doable during initialization, not just in a system. I can not make a Startup system for it as it could conflict with users' systems that use GizmoConfigStore in that schedule.

What solution would you like?

Add an insert_gizmo_group method to App:

app.insert_gizmo_group(PhysicsGizmos {
    // ...
});

There must also be a way to set the GizmoConfig associated with the gizmo group. This could be an insert_gizmo_config or configure_gizmo_config method:

app.insert_gizmo_config::<PhysicsGizmos>(GizmoConfig {
    // ...
});
@Jondolf Jondolf added C-Feature A new feature, making something new possible A-Gizmos Visual editor and debug gizmos labels Jan 27, 2024
@pablo-lua
Copy link
Contributor

I think it also has issues if the plugin is added before the GizmoPlugin.

About this, this error doesn't seen to happen after #11420, or is there another error in this fields? 🤔

@Jondolf
Copy link
Contributor Author

Jondolf commented Jan 27, 2024

Ah, I didn't actually try if it errors there, I just assumed that it wouldn't add the group if done before the GizmoPlugin. Cool if it works!

@alice-i-cecile
Copy link
Member

I like the naming, and think this should exist.

github-merge-queue bot pushed a commit that referenced this issue Jan 28, 2024
# Objective

- Fixes #11569 

## Solution

- Add new methods to the Ext Trait 

---

## Changelog

### Added
- Added new methods to the trait `AppGizmoBuilder`

---------

Co-authored-by: Alice Cecile <[email protected]>
tjamaan pushed a commit to tjamaan/bevy that referenced this issue Feb 6, 2024
# Objective

- Fixes bevyengine#11569 

## Solution

- Add new methods to the Ext Trait 

---

## Changelog

### Added
- Added new methods to the trait `AppGizmoBuilder`

---------

Co-authored-by: Alice Cecile <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Gizmos Visual editor and debug gizmos C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants