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

Don't overwrite schedules when adding plugin #236

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 52 additions & 58 deletions src/plugins/setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,77 +129,71 @@ impl Plugin for PhysicsSetupPlugin {
.before(TransformSystem::TransformPropagate),
);

// Create physics schedule, the schedule that advances the physics simulation
let mut physics_schedule = Schedule::new(PhysicsSchedule);

physics_schedule
.set_executor_kind(ExecutorKind::SingleThreaded)
.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Error,
..default()
});

physics_schedule.configure_sets(
(
PhysicsStepSet::BroadPhase,
PhysicsStepSet::Substeps,
PhysicsStepSet::ReportContacts,
PhysicsStepSet::Sleeping,
PhysicsStepSet::SpatialQuery,
)
.chain(),
);

app.add_schedule(physics_schedule);
// Set up the physics schedule, the schedule that advances the physics simulation
app.edit_schedule(PhysicsSchedule, |schedule| {
schedule
.set_executor_kind(ExecutorKind::SingleThreaded)
.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Error,
..default()
});

schedule.configure_sets(
(
PhysicsStepSet::BroadPhase,
PhysicsStepSet::Substeps,
PhysicsStepSet::ReportContacts,
PhysicsStepSet::Sleeping,
PhysicsStepSet::SpatialQuery,
)
.chain(),
);
});

app.add_systems(
schedule,
run_physics_schedule.in_set(PhysicsSet::StepSimulation),
);

// Create substep schedule, the schedule that runs the inner substepping loop
let mut substep_schedule = Schedule::new(SubstepSchedule);

substep_schedule
.set_executor_kind(ExecutorKind::SingleThreaded)
.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Error,
..default()
});

substep_schedule.configure_sets(
(
SubstepSet::Integrate,
SubstepSet::NarrowPhase,
SubstepSet::PostProcessCollisions,
SubstepSet::SolveConstraints,
SubstepSet::SolveUserConstraints,
SubstepSet::UpdateVelocities,
SubstepSet::SolveVelocities,
SubstepSet::ApplyTranslation,
)
.chain(),
);

app.add_schedule(substep_schedule);
// Set up the substep schedule, the schedule that runs the inner substepping loop
app.edit_schedule(SubstepSchedule, |schedule| {
schedule
.set_executor_kind(ExecutorKind::SingleThreaded)
.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Error,
..default()
});

schedule.configure_sets(
(
SubstepSet::Integrate,
SubstepSet::NarrowPhase,
SubstepSet::PostProcessCollisions,
SubstepSet::SolveConstraints,
SubstepSet::SolveUserConstraints,
SubstepSet::UpdateVelocities,
SubstepSet::SolveVelocities,
SubstepSet::ApplyTranslation,
)
.chain(),
);
});

app.add_systems(
PhysicsSchedule,
run_substep_schedule.in_set(PhysicsStepSet::Substeps),
);

// Create the PostProcessCollisions schedule for user-defined systems
// Set up the PostProcessCollisions schedule for user-defined systems
// that filter and modify collisions.
let mut post_process_collisions_schedule = Schedule::new(PostProcessCollisions);

post_process_collisions_schedule
.set_executor_kind(ExecutorKind::SingleThreaded)
.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Error,
..default()
});

app.add_schedule(post_process_collisions_schedule);
app.edit_schedule(PostProcessCollisions, |schedule| {
schedule
.set_executor_kind(ExecutorKind::SingleThreaded)
.set_build_settings(ScheduleBuildSettings {
ambiguity_detection: LogLevel::Error,
..default()
});
});

app.add_systems(
SubstepSchedule,
Expand Down