Skip to content

Support for use within Bevy's FixedUpdate schedule? #263

@Architector4

Description

@Architector4

I'm doing a bunch of logic before, within, and after the FixedUpdate schedule in Bevy, on the fixed timestep. I'd like to run XPBD physics within the FixedUpdate schedule, to ensure that I can record all entity transforms how they are before the physics step, and record them after they have been adjusted by the physics step after it, so that I can catch the difference and do my own logic with that.

Unfortunately, that doesn't seem to be doable. The Time<Physics> resource could be adjusted to use TimestepMode::FixedOnce right before the physics step, but there doesn't appear to be a way to ensure the physics engine is notified of removals of various components it tracks.

ComponentRemovals<T> only gives info about removals that happened in the same or previous app update, and so they are frequently missed in FixedUpdate if the fixed timestep is slow enough. As such, it'd be nice to be able to run XPBD's systems that use that data in a schedule I designate that I run every update, but it's not possible because it's hardcoded.

In particular, the detection only happens in PhysicsSchedule, which is used to step the entire simulation forward:

https://github.com/Jondolf/bevy_xpbd/blob/088facfe3761235f0b297bc1493927a12a6fe21b/src/plugins/prepare.rs#L96-L97

These systems themselves are private, and so they can't be run individually outside of the crate without stepping the simulation. The resource that handle_collider_storage_removals system uses, ColliderStorageMap, is also private, so it can't be notified of removals manually either.

I assume there may be other roadblocks that prevent my use case from being possible, but this is the one that I noticed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-SchedulingRelates to scheduling or system sets

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions