-
-
Notifications
You must be signed in to change notification settings - Fork 292
Physics context with arguments from PhysicsPipeline::step #796
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
Open
Vrixyz
wants to merge
12
commits into
dimforge:master
Choose a base branch
from
Vrixyz:uber_physics_context
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
27bcbeb
wip uber physics context
Vrixyz c6484df
fix clippy
Vrixyz 69922aa
implement physicsContext collider, rigidbody and query pipeline metho…
Vrixyz 488cda3
update testbed code to use new PhysicsContext
Vrixyz 69c2c79
fix clippy
Vrixyz d06cabb
fix clippy
Vrixyz bf95c02
Merge branch 'master' into uber_physics_context
Vrixyz 56cdd6c
Merge branch 'master' into uber_physics_context
Vrixyz 393900c
fix clippy
Vrixyz f09a884
fix compiling
Vrixyz bb410f4
use physics context directly rather than using an indirection
Vrixyz eaee063
cargo fmt
Vrixyz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use crate::prelude::*; | ||
|
||
/// Contains all arguments to be passed to [`PhysicsPipeline::step`] | ||
#[allow(missing_docs)] | ||
pub struct PhysicsContext<PH: PhysicsHooks = (), EV: EventHandler = ()> { | ||
pub gravity: Vector<Real>, | ||
pub integration_parameters: IntegrationParameters, | ||
pub physics_pipeline: PhysicsPipeline, | ||
pub island_manager: IslandManager, | ||
pub broad_phase: DefaultBroadPhase, | ||
pub narrow_phase: NarrowPhase, | ||
pub bodies: RigidBodySet, | ||
pub colliders: ColliderSet, | ||
pub impulse_joint_set: ImpulseJointSet, | ||
pub multibody_joint_set: MultibodyJointSet, | ||
pub ccd_solver: CCDSolver, | ||
pub query_pipeline: Option<QueryPipeline>, | ||
pub hooks: PH, | ||
pub events: EV, | ||
} | ||
|
||
impl<PH: PhysicsHooks + Default, EV: EventHandler + Default> Default for PhysicsContext<PH, EV> { | ||
fn default() -> Self { | ||
Self { | ||
gravity: Vector::<Real>::default(), | ||
integration_parameters: IntegrationParameters::default(), | ||
physics_pipeline: PhysicsPipeline::new(), | ||
island_manager: IslandManager::new(), | ||
broad_phase: BroadPhaseMultiSap::new(), | ||
narrow_phase: NarrowPhase::new(), | ||
bodies: RigidBodySet::new(), | ||
colliders: ColliderSet::new(), | ||
impulse_joint_set: ImpulseJointSet::new(), | ||
multibody_joint_set: MultibodyJointSet::new(), | ||
ccd_solver: CCDSolver::new(), | ||
query_pipeline: Some(QueryPipeline::new()), | ||
hooks: PH::default(), | ||
events: EV::default(), | ||
} | ||
} | ||
} | ||
|
||
impl<PH: PhysicsHooks, EV: EventHandler> PhysicsContext<PH, EV> { | ||
/// Create a new physics context with given hooks and event handling. | ||
pub fn default_with(hooks: PH, events: EV) -> Self { | ||
Self { | ||
gravity: Vector::<Real>::default(), | ||
integration_parameters: IntegrationParameters::default(), | ||
physics_pipeline: PhysicsPipeline::new(), | ||
island_manager: IslandManager::new(), | ||
broad_phase: DefaultBroadPhase::new(), | ||
narrow_phase: NarrowPhase::new(), | ||
bodies: RigidBodySet::new(), | ||
colliders: ColliderSet::new(), | ||
impulse_joint_set: ImpulseJointSet::new(), | ||
multibody_joint_set: MultibodyJointSet::new(), | ||
ccd_solver: CCDSolver::new(), | ||
query_pipeline: Some(QueryPipeline::new()), | ||
hooks, | ||
events, | ||
} | ||
} | ||
|
||
/// Shortcut to [`PhysicsPipeline::step`] | ||
pub fn step(&mut self) { | ||
self.physics_pipeline.step( | ||
&self.gravity, | ||
&self.integration_parameters, | ||
&mut self.island_manager, | ||
&mut self.broad_phase, | ||
&mut self.narrow_phase, | ||
&mut self.bodies, | ||
&mut self.colliders, | ||
&mut self.impulse_joint_set, | ||
&mut self.multibody_joint_set, | ||
&mut self.ccd_solver, | ||
self.query_pipeline.as_mut(), | ||
&self.hooks, | ||
&self.events, | ||
); | ||
} | ||
} | ||
Vrixyz marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.