Open starwolfy opened 2 years ago
After further examination, it should also be said that v0.13.0 relies on render plugins to be added to the Bevy app or it will panick. So it is more than dependencies on the just Rust crates alone.
v0.12.0 Ran perfectly fine with only just these Bevy plugins: ScheduleRunnerPlugin
,LogPlugin
,TransformPlugin
.
Trying to run a Bevy app with physics without DefaultPlugins
added to the app, so without a render setup, gives:
thread 'main' panicked at 'Resource requested by bevy_rapier3d::plugin::systems::init_async_shapes does not exist: bevy_asset::assets::Assets<bevy_render::mesh::mesh::Mesh>', /home/starwolf/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.7.0/src/system/system_param.rs:319:17
I think this comes from the fact that we use Assets<Mesh>
, and the Bevy Aabb
type. Though both are not completely necessary for bevy_rapier
to work, so this could be fixed by putting their usages behind a feature gate.
You can have best of both worlds. By inserting a WgpuSettings ressource with its backend field set to None before adding the bevy RenderPlugin, you'll get full initialization of bevy without any rendering context.
This has been made possible with the sub_apps, as the render_app won't be added to bevy runtime if it has no wgpu backend set. The bevy children plugins also do setup work on the condition of the render_app being present.
Edit: You'll also need some default plugin config else you won't meet dependencies for the render plugin.
.add(bevy::window::WindowPlugin { add_primary_window: false, exit_on_close: false })
.add(bevy::asset::AssetPlugin)
.add(bevy::render::RenderPlugin);
Thank you @sethquantix this works, my project is once again renderless and is now initialized the way you've described!
However, requiring bevy_render
and bevy_window
as dependencies when you are not actually rendering is still a bit silly, because they are relatively large dependencies and as such including them also significantly increases the total project compile time, up to 40% longer compile time in my benchmarks. Admittedly this does seem more like a convenience issue.
You don't actually need to have the plugins running so can use this to disable them:
// Bevy 0.8
app.add_plugins_with(DefaultPlugins, |group| {
group.disable::<RenderPlugin>().disable::<WindowPlugin>()
});
// Bevy 0.9
app.add_plugins(
DefaultPlugins
.build()
.disable::<RenderPlugin>()
.disable::<WindowPlugin>()
);
// For 3D you also need to manually add the MeshPlugin
app.add_plugin(MeshPlugin);
Using these dependencies.
[dependencies]
bevy = {version = "0.9.0", default-features = false, features = ["bevy_render"]}
bevy_rapier2d = {version = "0.19.0", default-features = false, features = ["dim2", "simd-stable"]}
This removes the runtime dependency on a GPU which I needed as just changing the window settings still causes a panic on some systems.
Since Bevy 0.9.0 and bevy_rapier3d 0.19.0 I haven't been able to disable the GPU Bevy plugins.
@MJohnson459 Your setup doesn't work for me and throws the following error:
thread 'main' panicked at 'Requested resource bevy_window::windows::Windows does not exist in the `World`.
Did you forget to add it using `app.insert_resource` / `app.init_resource`?
Resources are also implicitly added via `app.add_event`,
and can be added by plugins.', /home/starwolf/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.9.0/src/world/world_cell.rs:245:21
Reproduction bevy_rapier_renderless.zip
@starwolfy sorry I was using 2D. It seems like 3D has an extra runtime dependency I can't get rid of either.
Edit: I updated the example with it working in 3D as well. It was just missing the bevy::render::mesh::MeshPlugin
.
@MJohnson459 Thank you for the swift response and updated solution. Does your updated solution work for you on the reproduction project? It doesn't work for me, it continues to complain about more missing plugins all the way until it requires the Render plugin again.
@starwolfy yes it worked for me. Did you limit the bevy dependency to remove the default features?
@starwolfy yes it worked for me. Did you limit the bevy dependency to remove the default features?
It works, thanks a bunch!!
The following cargo.toml configuration does not build anymore:
bevy_rapier3d = {version= "0.13.0" ,default-features = false, features = [ "dim3" ]}
Build output:
Reproduction: rapier-renderless.zip