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

Upgrade to Bevy 0.15 #221

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Upgrade to Bevy 0.15 #221

wants to merge 9 commits into from

Conversation

Vrixyz
Copy link
Contributor

@Vrixyz Vrixyz commented Nov 6, 2024

I chose to rely mostly on PartialReflect, even though I imagine in practice everything is Reflect ; I'm not sure it's possible to rely on Reflect exclusively because when we're cloning the value, errors are handled in another function.

I imagine we could either unwrap, or bubble the errors up, but I fear that would make a lot of changes for not much benefits ; also, I believe relaxing trait bounds is always interesting.

@Vrixyz Vrixyz changed the title Bevy 0.15 Upgrade to Bevy 0.15 Nov 6, 2024
@Vrixyz Vrixyz force-pushed the bevy_0.15 branch 2 times, most recently from a00cec9 to 335d678 Compare November 6, 2024 10:39
@Vrixyz Vrixyz force-pushed the bevy_0.15 branch 2 times, most recently from f64d1af to 645eb99 Compare November 6, 2024 14:20
@Vrixyz Vrixyz marked this pull request as ready for review November 6, 2024 14:23
@@ -75,7 +75,7 @@ pub fn ui_for_value(value: &mut dyn Reflect, ui: &mut egui::Ui, world: &mut Worl
queue: Some(&mut queue),
};
let mut env = InspectorUi::for_bevy(&type_registry, &mut cx);
let changed = env.ui_for_reflect(value, ui);
let changed = env.ui_for_reflect(value.as_partial_reflect_mut(), ui);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you changed the signature of ui_for_value to take a &mut dyn PartialReflect, would you still be able to call it like .ui_for_value(val) where val: &mut dyn Reflect without &*val or something like that? 🤔

Copy link
Contributor Author

@Vrixyz Vrixyz Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait mmh; is your question a concern about breaking changes ?

crates/bevy-inspector-egui/src/bevy_inspector/mod.rs Outdated Show resolved Hide resolved
Comment on lines 1023 to 1024
// TODO: display error ? Is entering here even possible ?
continue;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhhh... this is an edge case in an edge case but I think I would just return None here as well, since this for loop should only work if you're multi-editing a bunch of Handles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a warn! would be interesting 🤔

crates/bevy-inspector-egui/src/bevy_inspector/mod.rs Outdated Show resolved Hide resolved
@@ -25,14 +26,15 @@ macro_rules! vec_ui_many {
$(

let same = super::iter_all_eq(values.iter_mut().map(|value| {
projector(*value).downcast_ref::<$ty>().unwrap().$component
// FIXME: scary to change a macro
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good to me, I think it was just a name change of the method

Copy link
Contributor Author

@Vrixyz Vrixyz Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try_downcast_ref from PartialReflect actually does 2 things: try_as_reflect (new); then downcast_ref (existing code from main).

I think the new behaviour from other places in this PR is to ignore a failure of try_as_reflect

crates/bevy-inspector-egui/src/inspector_egui_impls/mod.rs Outdated Show resolved Hide resolved
crates/bevy-inspector-egui/src/reflect_inspector/mod.rs Outdated Show resolved Hide resolved
crates/bevy-inspector-egui/src/reflect_inspector/mod.rs Outdated Show resolved Hide resolved
crates/bevy-inspector-egui/src/reflect_inspector/mod.rs Outdated Show resolved Hide resolved
Comment on lines +1204 to +1206
// FIXME: is the id passed here correct?
let value_changed =
self.ui_for_reflect_with_options(v.as_mut(), ui, id, options);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this requires an id ; it doesn´t seem related to the rest of the data as it's a draft, but I'm not sure.

Comment on lines +1322 to +1326
value_to_check.borrow(),
ui,
// FIXME: is the id passed here correct?
id.with(i),
options,
Copy link
Contributor Author

@Vrixyz Vrixyz Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's correct ; but I'm not exactly sure, egui docs state that egui tracks widgets frame-to-frame using [Id]s. ; hashset values are not guaranteed to iter over the same order everytime, so we could either:

  • provide an id derived from the reflect_value_hash ?
  • sort the values (somehow, based on display or hash or smth 🤔).
  • both 😈

I think both makes the most sense.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I know that if you run

let hashset = todo!();

for val in hashset {
}

the iteration order is not defined but I'm pretty sure that for a given instantiation of a hashset, consecutive iteration will have the same order.

let hashset = todo!();

for val in hashset {}
for val in hashset {} // same

Copy link
Contributor Author

@Vrixyz Vrixyz Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My worry is more towards:

let hashset = todo!();

for val in hashset {}

for val in hashset {} // same

hashset.insert("new value leading to recomputation of the set inner representation");

for val in hashset {} // not same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants