diff --git a/crates/avian2d/examples/kinematic_character_2d/main.rs b/crates/avian2d/examples/kinematic_character_2d/main.rs index 88c92e83..732502e6 100644 --- a/crates/avian2d/examples/kinematic_character_2d/main.rs +++ b/crates/avian2d/examples/kinematic_character_2d/main.rs @@ -11,7 +11,7 @@ //! //! For a dynamic character controller, see the `dynamic_character_2d` example. //! -//! ## Warning +//! # Warning //! //! Note that this is *not* intended to be a fully featured character controller, //! and the collision logic is quite basic. diff --git a/crates/avian2d/examples/one_way_platform_2d.rs b/crates/avian2d/examples/one_way_platform_2d.rs index 253ee229..303f0f3d 100644 --- a/crates/avian2d/examples/one_way_platform_2d.rs +++ b/crates/avian2d/examples/one_way_platform_2d.rs @@ -190,6 +190,7 @@ fn pass_through_one_way_platform( /// > which means you won't need to filter collisions at all. /// /// #### When an entity is known to already be passing through the [`OneWayPlatform`] +/// /// Any time an entity begins passing through a [`OneWayPlatform`], it is added to the /// [`OneWayPlatform`]'s set of currently active penetrations, and will be allowed to /// continue to pass through the platform until it is no longer penetrating the platform. @@ -201,6 +202,7 @@ fn pass_through_one_way_platform( /// have stopped, the entity is forgotten about and the logic falls through to the next part. /// /// #### When an entity is NOT known to be passing through the [`OneWayPlatform`] +/// /// Depending on the setting of [`PassThroughOneWayPlatform`], the entity may be allowed to /// pass through. /// diff --git a/crates/avian3d/examples/kinematic_character_3d/main.rs b/crates/avian3d/examples/kinematic_character_3d/main.rs index 651e8cf4..02d60ec1 100644 --- a/crates/avian3d/examples/kinematic_character_3d/main.rs +++ b/crates/avian3d/examples/kinematic_character_3d/main.rs @@ -12,7 +12,7 @@ //! //! For a dynamic character controller, see the `dynamic_character_3d` example. //! -//! ## Warning +//! # Warning //! //! Note that this is *not* intended to be a fully featured character controller, //! and the collision logic is quite basic. diff --git a/src/collision/collider/backend.rs b/src/collision/collider/backend.rs index 99877ca1..4f80e93d 100644 --- a/src/collision/collider/backend.rs +++ b/src/collision/collider/backend.rs @@ -22,7 +22,7 @@ use mass_properties::OnChangeColliderMassProperties; /// /// This plugin should typically be used together with the [`ColliderHierarchyPlugin`]. /// -/// ## Custom collision backends +/// # Custom Collision Backends /// /// By default, [`PhysicsPlugins`] adds this plugin for the [`Collider`] component. /// You can also create custom collider backends by implementing the [`AnyCollider`] diff --git a/src/collision/collider/constructor.rs b/src/collision/collider/constructor.rs index c7b316ee..76fd36f9 100644 --- a/src/collision/collider/constructor.rs +++ b/src/collision/collider/constructor.rs @@ -18,15 +18,15 @@ use bevy::utils::HashMap; /// This component will only override a pre-existing [`Collider`] component on a descendant entity /// when it has been explicitly mentioned in the `config`. /// -/// ## See also +/// # See Also /// /// For inserting colliders on the same entity, use [`ColliderConstructor`]. /// -/// ## Caveats +/// # Caveats /// /// When a component has multiple ancestors with [`ColliderConstructorHierarchy`], the insertion order is undefined. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -240,16 +240,16 @@ pub struct ColliderConstructorHierarchyConfig { /// /// This component will never override a pre-existing [`Collider`] component on the same entity. /// -/// ## See also +/// # See Also /// /// For inserting colliders on an entity's descendants, use [`ColliderConstructorHierarchy`]. /// -/// ## Panics +/// # Panics /// /// The system handling the generation of colliders will panic if the specified [`ColliderConstructor`] /// requires a mesh, but the entity does not have a `Handle` component. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/collision/collider/mod.rs b/src/collision/collider/mod.rs index 88fd550c..242f22e8 100644 --- a/src/collision/collider/mod.rs +++ b/src/collision/collider/mod.rs @@ -118,7 +118,7 @@ pub trait ScalableCollider: AnyCollider { /// This component is added and updated automatically based on entity hierarchies and should not /// be modified directly. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -230,7 +230,7 @@ impl From for ColliderTransform { /// /// Sensor colliders do *not* contribute to the mass properties of rigid bodies. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -435,7 +435,7 @@ pub struct CollisionMargin(pub Scalar); /// Requires the [`ContactReportingPlugin`] (included in [`PhysicsPlugins`]) /// to be enabled for this component to be updated. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/collision/collider/parry/mod.rs b/src/collision/collider/parry/mod.rs index 841c7de5..5753b64b 100644 --- a/src/collision/collider/parry/mod.rs +++ b/src/collision/collider/parry/mod.rs @@ -215,7 +215,7 @@ impl From for parry::shape::TriMeshFlags { /// A collider used for detecting collisions and generating contacts. /// -/// ## Creation +/// # Creation /// /// `Collider` has tons of methods for creating colliders of various shapes: /// @@ -274,7 +274,7 @@ impl From for parry::shape::TriMeshFlags { doc = "Colliders can also be generated automatically for meshes and scenes. See [`ColliderConstructor`] and [`ColliderConstructorHierarchy`]." )] /// -/// ### Multiple colliders +/// ## Multiple Colliders /// /// It can often be useful to attach multiple colliders to the same rigid body. /// @@ -332,7 +332,7 @@ impl From for parry::shape::TriMeshFlags { /// [friction](Friction), [restitution](Restitution), [collision layers](CollisionLayers), /// and other configuration options, and they send separate [collision events](ContactReportingPlugin#collision-events). /// -/// ## See more +/// # See More /// /// - [Rigid bodies](RigidBody) /// - [Density](ColliderDensity) @@ -349,7 +349,7 @@ impl From for parry::shape::TriMeshFlags { /// - [Accessing, filtering and modifying collisions](Collisions) /// - [Manual contact queries](contact_query) /// -/// ## Advanced usage +/// # Advanced Usage /// /// Internally, `Collider` uses the shapes provided by `parry`. If you want to create a collider /// using these shapes, you can simply use `Collider::from(SharedShape::some_method())`. @@ -561,7 +561,7 @@ impl Collider { /// /// The returned tuple is in the format `(time_of_impact, normal)`. /// - /// ## Arguments + /// # Arguments /// /// - `ray_origin`: Where the ray is cast from. /// - `ray_direction`: What direction the ray is cast in. @@ -588,7 +588,7 @@ impl Collider { /// Tests whether the given ray intersects `self` transformed by `translation` and `rotation`. /// - /// ## Arguments + /// # Arguments /// /// - `ray_origin`: Where the ray is cast from. /// - `ray_direction`: What direction the ray is cast in. @@ -910,7 +910,7 @@ impl Collider { /// The [`CollisionMargin`] component can be used to add thickness to the shape if needed. /// For thin shapes like triangle meshes, it can help improve collision stability and performance. /// - /// ## Example + /// # Example /// /// ``` /// use avian3d::prelude::*; @@ -944,7 +944,7 @@ impl Collider { /// The [`CollisionMargin`] component can be used to add thickness to the shape if needed. /// For thin shapes like triangle meshes, it can help improve collision stability and performance. /// - /// ## Example + /// # Example /// /// ``` /// use avian3d::prelude::*; @@ -967,7 +967,7 @@ impl Collider { /// Creates a collider with a convex polygon shape obtained from the convex hull of a `Mesh`. /// - /// ## Example + /// # Example /// /// ``` /// use avian3d::prelude::*; @@ -989,7 +989,7 @@ impl Collider { /// Creates a compound shape obtained from the decomposition of a `Mesh`. /// - /// ## Example + /// # Example /// /// ``` /// use avian3d::prelude::*; @@ -1013,7 +1013,7 @@ impl Collider { /// Creates a compound shape obtained from the decomposition of a `Mesh` /// with the given [`VhacdParameters`] passed to the decomposition algorithm. /// - /// ## Example + /// # Example /// /// ``` /// use avian3d::prelude::*; diff --git a/src/collision/contact_query.rs b/src/collision/contact_query.rs index 0d7246e2..cd59d0f0 100644 --- a/src/collision/contact_query.rs +++ b/src/collision/contact_query.rs @@ -26,7 +26,7 @@ pub type UnsupportedShape = Unsupported; /// Returns `None` if the colliders are separated by a distance greater than `prediction_distance` /// or if the given shapes are invalid. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -116,7 +116,7 @@ pub fn contact( /// Returns an empty vector if the colliders are separated by a distance greater than `prediction_distance` /// or if the given shapes are invalid. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -282,7 +282,7 @@ pub enum ClosestPoints { /// /// Returns `Err(UnsupportedShape)` if either of the collider shapes is not supported. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -377,7 +377,7 @@ pub fn closest_points( /// Returns `0.0` if the colliders are touching or penetrating, and `Err(UnsupportedShape)` /// if either of the collider shapes is not supported. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -445,7 +445,7 @@ pub fn distance( /// /// Returns `Err(UnsupportedShape)` if either of the collider shapes is not supported. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -538,7 +538,7 @@ pub struct TimeOfImpact { /// Returns `Ok(None)` if the time of impact is greater than `max_time_of_impact` /// and `Err(UnsupportedShape)` if either of the collider shapes is not supported. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] diff --git a/src/collision/contact_reporting.rs b/src/collision/contact_reporting.rs index 6a7c7239..6e43df99 100644 --- a/src/collision/contact_reporting.rs +++ b/src/collision/contact_reporting.rs @@ -7,7 +7,7 @@ use bevy::prelude::*; /// Sends collision events and updates [`CollidingEntities`]. /// -/// ## Collision events +/// # Collision Events /// /// If the [`ContactReportingPlugin`] is enabled (the default), the following /// collision events are sent each frame in [`PhysicsStepSet::ReportContacts`]: @@ -59,7 +59,7 @@ impl Plugin for ContactReportingPlugin { /// A [collision event](ContactReportingPlugin#collision-events) /// that is sent for each collision. /// -/// ## Example +/// # Example /// /// ```no_run #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -90,7 +90,7 @@ pub struct Collision(pub Contacts); /// A [collision event](ContactReportingPlugin#collision-events) /// that is sent when two entities start colliding. /// -/// ## Example +/// # Example /// /// ```no_run #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -121,7 +121,7 @@ pub struct CollisionStarted(pub Entity, pub Entity); /// A [collision event](ContactReportingPlugin#collision-events) /// that is sent when two entities stop colliding. /// -/// ## Example +/// # Example /// /// ```no_run #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/collision/layers.rs b/src/collision/layers.rs index 4e52cf2f..b8d56266 100644 --- a/src/collision/layers.rs +++ b/src/collision/layers.rs @@ -257,7 +257,7 @@ impl Not for LayerMask { /// /// [bitmasks]: https://en.wikipedia.org/wiki/Mask_(computing) /// -/// ## Creation +/// # Creation /// /// Collision layers store memberships and filters using [`LayerMask`]s. A [`LayerMask`] can be created using /// bitmasks, or by creating an enum that implements [`PhysicsLayer`]. @@ -328,7 +328,7 @@ impl Not for LayerMask { /// } /// ``` /// -/// ## Modifying layers +/// # Modifying Layers /// /// Existing [`CollisionLayers`] can be modified by simply accessing the `memberships` and `filters` /// and changing their [`LayerMask`]s. @@ -434,7 +434,7 @@ impl Default for CollisionLayers { #[cfg(test)] mod tests { - // Needed for PhysicsLayer derive macro + // Needed for `PhysicsLayer` derive macro #[cfg(feature = "2d")] use crate as avian2d; #[cfg(feature = "3d")] diff --git a/src/collision/mod.rs b/src/collision/mod.rs index 6a37fece..c4d32d5e 100644 --- a/src/collision/mod.rs +++ b/src/collision/mod.rs @@ -49,13 +49,13 @@ use indexmap::IndexMap; /// Each colliding entity pair is associated with [`Contacts`] that can be accessed and modified /// using the various associated methods. /// -/// ## Usage +/// # Usage /// /// [`Collisions`] can be accessed at almost anytime, but for modifying and filtering collisions, /// it is recommended to use the [`PostProcessCollisions`] schedule. See its documentation /// for more information. /// -/// ### Querying collisions +/// ## Querying Collisions /// /// The following methods can be used for querying existing collisions: /// @@ -68,7 +68,7 @@ use indexmap::IndexMap; /// The collisions can be accessed at any time, but modifications to contacts should be performed /// in the [`PostProcessCollisions`] schedule. Otherwise, the physics solver will use the old contact data. /// -/// ### Filtering and removing collisions +/// ## Filtering and Removing Collisions /// /// The following methods can be used for filtering or removing existing collisions: /// @@ -79,7 +79,7 @@ use indexmap::IndexMap; /// Collision filtering and removal should be done in the [`PostProcessCollisions`] schedule. /// Otherwise, the physics solver will use the old contact data. /// -/// ### Adding new collisions +/// ## Adding New Collisions /// /// The following methods can be used for adding new collisions: /// @@ -89,7 +89,7 @@ use indexmap::IndexMap; /// The most convenient place for adding new collisions is in the [`PostProcessCollisions`] schedule. /// Otherwise, the physics solver might not have access to them in time. /// -/// ## Implementation details +/// # Implementation Details /// /// Internally, the collisions are stored in an `IndexMap` that contains collisions from both the current frame /// and the previous frame, which is used for things like [collision events](ContactReportingPlugin#collision-events). diff --git a/src/debug_render/configuration.rs b/src/debug_render/configuration.rs index 1b377e47..1703b8ab 100644 --- a/src/debug_render/configuration.rs +++ b/src/debug_render/configuration.rs @@ -378,7 +378,7 @@ impl PhysicsGizmos { /// /// This overwrites the global [`PhysicsGizmos`] for this specific entity. /// -/// ## Example +/// # Example /// /// ```no_run #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/dynamics/integrator/mod.rs b/src/dynamics/integrator/mod.rs index 2062e01f..3ecaed2a 100644 --- a/src/dynamics/integrator/mod.rs +++ b/src/dynamics/integrator/mod.rs @@ -98,7 +98,7 @@ pub enum IntegrationSet { /// You can also control how gravity affects a specific [rigid body](RigidBody) using the [`GravityScale`] /// component. The magnitude of the gravity will be multiplied by this scaling factor. /// -/// ## Example +/// # Example /// /// ```no_run #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/dynamics/mod.rs b/src/dynamics/mod.rs index 9f8fe0d8..a15a227a 100644 --- a/src/dynamics/mod.rs +++ b/src/dynamics/mod.rs @@ -19,7 +19,7 @@ //! - Elasticity (soft bodies) //! - Plasticity (permanent deformation) //! -//! ## Plugins +//! # Plugins //! //! | Plugin | Description | //! | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | @@ -28,7 +28,7 @@ //! | [`CcdPlugin`] | Performs sweep-based [Continuous Collision Detection](dynamics::ccd) for bodies with the [`SweptCcd`] component to prevent tunneling. | //! | [`SleepingPlugin`] | Manages sleeping and waking for bodies, automatically deactivating them to save computational resources. | //! -//! ## Accuracy +//! # Accuracy //! //! The engine uses iterative algorithms to approximate the simulation. //! Thus, results may not be perfectly accurate: diff --git a/src/dynamics/rigid_body/forces.rs b/src/dynamics/rigid_body/forces.rs index 6a5cb0cf..d71bd66c 100644 --- a/src/dynamics/rigid_body/forces.rs +++ b/src/dynamics/rigid_body/forces.rs @@ -27,7 +27,7 @@ impl FloatZero for Scalar { /// By default, the force persists across frames. You can clear the force manually using /// [`clear`](Self::clear) or set `persistent` to false. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -60,7 +60,7 @@ impl FloatZero for Scalar { /// } /// ``` /// -/// ## Local forces +/// # Local Forces /// /// The force stored in `ExternalForce` is in world space. /// @@ -203,7 +203,7 @@ impl ExternalForce { /// By default, the torque persists across frames. You can clear the torque manually using /// [`clear`](Self::clear) or set `persistent` to false. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -316,7 +316,7 @@ impl ExternalTorque { /// By default, the impulse is cleared every frame. You can set `persistent` to true in order to persist /// the impulse across frames. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -349,7 +349,7 @@ impl ExternalTorque { /// } /// ``` /// -/// ## Local impulses +/// # Local Impulses /// /// The impulse stored in `ExternalImpulse` is in world space. /// @@ -491,7 +491,7 @@ impl ExternalImpulse { /// By default, the angular impulse is cleared every frame. You can set `persistent` to true in order to persist /// the impulse across frames. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] diff --git a/src/dynamics/rigid_body/locked_axes.rs b/src/dynamics/rigid_body/locked_axes.rs index 8b157467..d7495083 100644 --- a/src/dynamics/rigid_body/locked_axes.rs +++ b/src/dynamics/rigid_body/locked_axes.rs @@ -9,7 +9,7 @@ use crate::prelude::*; /// specific axes is to use methods like [`lock_translation_x`](Self::lock_translation_x), but you can also /// use bits directly with the [`from_bits`](Self::from_bits) and [`to_bits`](Self::to_bits) methods. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/dynamics/rigid_body/mass_properties/components.rs b/src/dynamics/rigid_body/mass_properties/components.rs index fb5fe0c4..1b7075f3 100644 --- a/src/dynamics/rigid_body/mass_properties/components.rs +++ b/src/dynamics/rigid_body/mass_properties/components.rs @@ -17,7 +17,7 @@ pub enum MassError { /// /// [rigid body]: RigidBody /// -/// ## Representation +/// # Representation /// /// Internally, the mass is actually stored as the inverse mass `1.0 / mass`. /// This is because most physics calculations operate on the inverse mass, and storing it directly @@ -170,7 +170,7 @@ pub enum AngularInertiaError { /// /// [rigid body]: RigidBody /// -/// ## Representation +/// # Representation /// /// Internally, the angular inertia is actually stored as the inverse angular inertia `1.0 / angular_inertia`. /// This is because most physics calculations operate on the inverse angular inertia, and storing it directly @@ -347,7 +347,7 @@ impl From for AngularInertia { /// /// [rigid body]: RigidBody /// -/// ## Representation +/// # Representation /// /// Internally, the angular inertia is actually stored as the inverse angular inertia tensor `angular_inertia_matrix.inverse()`. /// This is because most physics calculations operate on the inverse angular inertia, and storing it directly @@ -716,7 +716,7 @@ impl CenterOfMass { /// A bundle containing mass properties. /// -/// ## Example +/// # Example /// /// The easiest way to create a new bundle is to use the [`new_computed`](Self::new_computed) method /// that computes the mass properties based on a given [`Collider`] and density. @@ -777,7 +777,7 @@ impl MassPropertiesBundle { /// The density of a [`Collider`], 1.0 by default. This is used for computing /// the [`ColliderMassProperties`] for each collider. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -824,7 +824,7 @@ impl From for ColliderDensity { /// These mass properties will be added to the [rigid body's](RigidBody) actual [`Mass`], /// [`AngularInertia`] and [`CenterOfMass`] components. /// -/// ## Example +/// # Example /// /// ```no_run #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/dynamics/rigid_body/mod.rs b/src/dynamics/rigid_body/mod.rs index 76481041..6be5fa74 100644 --- a/src/dynamics/rigid_body/mod.rs +++ b/src/dynamics/rigid_body/mod.rs @@ -25,7 +25,7 @@ use derive_more::From; /// A non-deformable body used for the simulation of most physics objects. /// -/// ## Rigid body types +/// # Rigid Body Types /// /// A rigid body can be either dynamic, kinematic or static. /// @@ -33,7 +33,7 @@ use derive_more::From; /// - **Kinematic bodies** can only be moved programmatically, which is useful for things like character controllers and moving platforms. /// - **Static bodies** can not move, so they can be good for objects in the environment like the ground and walls. /// -/// ## Creation +/// # Creation /// /// Creating a rigid body is as simple as adding the [`RigidBody`] component: /// @@ -70,7 +70,7 @@ use derive_more::From; /// By default, rigid bodies will get a mass based on the attached colliders and their densities. /// See [mass properties](#mass-properties). /// -/// ## Movement +/// # Movement /// /// A rigid body can be moved in three ways: by modifying its position directly, /// by changing its velocity, or by applying forces or impulses. @@ -121,7 +121,7 @@ use derive_more::From; /// [`basic_dynamic_character`]: https://github.com/Jondolf/avian/blob/42fb8b21c756a7f4dd91071597dc251245ddaa8f/crates/avian3d/examples/basic_dynamic_character.rs /// [`basic_kinematic_character`]: https://github.com/Jondolf/avian/blob/42fb8b21c756a7f4dd91071597dc251245ddaa8f/crates/avian3d/examples/basic_kinematic_character.rs /// -/// ## Mass properties +/// # Mass Properties /// /// The mass properties of a rigid body consist of its [`Mass`], [`AngularInertia`] /// and local [`CenterOfMass`]. They control how forces and torques impact a rigid body @@ -216,7 +216,7 @@ use derive_more::From; /// /// ``` /// -/// ## See more +/// # See More /// /// - [Colliders](Collider) /// - [Gravity] and [gravity scale](GravityScale) @@ -338,7 +338,7 @@ pub struct AccumulatedTranslation(pub Vector); /// The linear velocity of a [rigid body](RigidBody). /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -351,6 +351,12 @@ pub struct AccumulatedTranslation(pub Vector); /// } /// } /// ``` +/// +/// # Related Components +/// +/// - [`ExternalForce`]: Applies a force to a dynamic body. +/// - [`LinearDamping`]: Reduces the linear velocity of a body over time, similar to air resistance. +/// - [`MaxLinearSpeed`]: Clamps the linear velocity of a body. #[derive(Reflect, Clone, Copy, Component, Debug, Default, Deref, DerefMut, PartialEq, From)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))] @@ -428,7 +434,7 @@ pub(crate) struct PreSolveLinearVelocity(pub Vector); /// The angular velocity of a [rigid body](RigidBody) in radians per second. /// Positive values will result in counterclockwise rotation. /// -/// ## Example +/// # Example /// /// ``` /// use avian2d::prelude::*; @@ -440,6 +446,12 @@ pub(crate) struct PreSolveLinearVelocity(pub Vector); /// } /// } /// ``` +/// +/// # Related Components +/// +/// - [`ExternalTorque`]: Applies a torque to a dynamic body. +/// - [`AngularDamping`]: Reduces the angular velocity of a body over time, similar to air resistance. +/// - [`MaxAngularSpeed`]: Clamps the angular velocity of a body. #[cfg(feature = "2d")] #[derive(Reflect, Clone, Copy, Deref, DerefMut, Component, Debug, Default, PartialEq, From)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] @@ -450,7 +462,7 @@ pub struct AngularVelocity(pub Scalar); /// The angular velocity of a [rigid body](RigidBody) as a rotation axis /// multiplied by the angular speed in radians per second. /// -/// ## Example +/// # Example /// /// ``` /// use avian3d::prelude::*; @@ -462,6 +474,12 @@ pub struct AngularVelocity(pub Scalar); /// } /// } /// ``` +/// +/// # Related Components +/// +/// - [`ExternalTorque`]: Applies a torque to a dynamic body. +/// - [`AngularDamping`]: Reduces the angular velocity of a body over time, similar to air resistance. +/// - [`MaxAngularSpeed`]: Clamps the angular velocity of a body. #[cfg(feature = "3d")] #[derive(Reflect, Clone, Copy, Component, Debug, Default, Deref, DerefMut, PartialEq, From)] #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] @@ -497,19 +515,16 @@ pub(crate) struct PreSolveAngularVelocity(pub Vector); /// A gravity scale of `0.0` will disable gravity, while `2.0` will double the gravity. /// Using a negative value will flip the direction of the gravity. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] #[cfg_attr(feature = "3d", doc = "use avian3d::prelude::*;")] /// use bevy::prelude::*; /// -/// // Spawn a body with 1.5 times the normal gravity +/// // Spawn a dynamic body with `1.5` times the normal gravity. /// fn setup(mut commands: Commands) { -/// commands.spawn(( -/// RigidBody::Dynamic, -/// GravityScale(1.5), -/// )); +/// commands.spawn((RigidBody::Dynamic, GravityScale(1.5))); /// } /// ``` #[derive(Component, Reflect, Debug, Clone, Copy, PartialEq, PartialOrd, Deref, DerefMut, From)] @@ -529,7 +544,7 @@ impl Default for GravityScale { /// /// The default linear damping coefficient is `0.0`, which corresponds to no damping. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -537,10 +552,7 @@ impl Default for GravityScale { /// use bevy::prelude::*; /// /// fn setup(mut commands: Commands) { -/// commands.spawn(( -/// RigidBody::Dynamic, -/// LinearDamping(0.8), -/// )); +/// commands.spawn((RigidBody::Dynamic, LinearDamping(0.8))); /// } /// ``` #[derive( @@ -556,7 +568,7 @@ pub struct LinearDamping(pub Scalar); /// /// The default angular damping coefficient is `0.0`, which corresponds to no damping. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -564,10 +576,7 @@ pub struct LinearDamping(pub Scalar); /// use bevy::prelude::*; /// /// fn setup(mut commands: Commands) { -/// commands.spawn(( -/// RigidBody::Dynamic, -/// AngularDamping(1.6), -/// )); +/// commands.spawn((RigidBody::Dynamic, AngularDamping(1.6))); /// } /// ``` #[derive( @@ -588,14 +597,14 @@ pub struct AngularDamping(pub Scalar); /// Note that static and kinematic bodies will always have a higher dominance value /// than dynamic bodies regardless of the value of this component. /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] #[cfg_attr(feature = "3d", doc = "use avian3d::prelude::*;")] /// use bevy::prelude::*; /// -/// // Player dominates all dynamic bodies with a dominance lower than 5 +/// // Player dominates all dynamic bodies with a dominance lower than `5`. /// fn spawn_player(mut commands: Commands) { /// commands.spawn(( /// RigidBody::Dynamic, diff --git a/src/dynamics/solver/joints/mod.rs b/src/dynamics/solver/joints/mod.rs index c6ae9e6c..6623b1e3 100644 --- a/src/dynamics/solver/joints/mod.rs +++ b/src/dynamics/solver/joints/mod.rs @@ -2,7 +2,7 @@ //! They act as [constraints](dynamics::solver::xpbd#constraints) that restrict different *Degrees Of Freedom* //! depending on the joint type. //! -//! ## Degrees Of Freedom (DOF) +//! # Degrees of Freedom (DOF) //! //! In 3D, entities can normally translate and rotate along the `X`, `Y` and `Z` axes. //! Therefore, they have 3 translational DOF and 3 rotational DOF, which is a total of 6 DOF. @@ -23,7 +23,7 @@ doc = "| [`SphericalJoint`] | 1 Rotation | 3 Rotations |" )] //! -//! ## Using joints +//! # Using Joints //! //! In Avian, joints are modeled as components. You can create a joint by simply spawning //! an entity and adding the joint component you want, giving the connected entities as arguments @@ -43,33 +43,33 @@ //! } //! ``` //! -//! ### Stiffness +//! ## Stiffness //! //! You can control the stiffness of a joint with the `with_compliance` method. //! *Compliance* refers to the inverse of stiffness, so using a compliance of 0 corresponds to //! infinite stiffness. //! -//! ### Attachment positions +//! ## Attachment Positions //! //! By default, joints are connected to the centers of entities, but attachment positions can be used to change this. //! //! You can use `with_local_anchor_1` and `with_local_anchor_2` to set the attachment positions on the first //! and second entity respectively. //! -//! ### Damping +//! ## Damping //! //! You can configure the linear and angular damping caused by joints using the `with_linear_velocity_damping` and //! `with_angular_velocity_damping` methods. Increasing the damping values will cause the velocities //! of the connected entities to decrease faster. //! -//! ### Other configuration +//! ## Other Configuration //! //! Different joints may have different configuration options. Many joints allow you to change the axis of allowed //! translation or rotation, and they may have distance or angle limits along these axes. //! //! Take a look at the documentation and methods of each joint to see all of the configuration options. //! -//! ## Custom joints +//! # Custom Joints //! //! Joints are [constraints](dynamics::solver::xpbd#constraints) that implement [`Joint`] and [`XpbdConstraint`]. //! diff --git a/src/dynamics/solver/mod.rs b/src/dynamics/solver/mod.rs index d6dc77c9..4e86dcaa 100644 --- a/src/dynamics/solver/mod.rs +++ b/src/dynamics/solver/mod.rs @@ -20,7 +20,7 @@ use self::{ /// /// Note that the [`ContactConstraints`] are currently generated by tbe [`NarrowPhasePlugin`]. /// -/// ## Implementation +/// # Implementation /// /// The solver primarily uses TGS Soft, an impulse-based solver with substepping and [soft constraints](softness_parameters). /// Warm starting is used to improve convergence, along with a relaxation pass to reduce overshooting. @@ -31,7 +31,7 @@ use self::{ /// [Joints](joints) and user constraints are currently solved using [Extended Position-Based Dynamics (XPBD)](xpbd). /// In the future, they may transition to an impulse-based approach as well. /// -/// ## Steps +/// # Steps /// /// Below are the main steps of the `SolverPlugin`. /// @@ -288,7 +288,7 @@ impl Default for PhysicsLengthUnit { /// System sets for the constraint solver. /// -/// ## Steps +/// # Steps /// /// Below is the core solver loop. /// @@ -319,7 +319,7 @@ pub enum SolverSet { /// System sets for the substepped part of the constraint solver. /// -/// ## Steps +/// # Steps /// /// 1. Integrate velocity ([`IntegrationSet::Velocity`]) /// 2. Warm start ([`SubstepSolverSet::WarmStart`]) diff --git a/src/dynamics/solver/xpbd/mod.rs b/src/dynamics/solver/xpbd/mod.rs index df97ec39..f03375de 100644 --- a/src/dynamics/solver/xpbd/mod.rs +++ b/src/dynamics/solver/xpbd/mod.rs @@ -330,7 +330,7 @@ pub trait XpbdConstraint: MapEntities { /// Note that this system only works for constraints that are modeled as entities. /// If you store constraints in a resource, you must create your own system for solving them. /// -/// ## User constraints +/// # User Constraints /// /// To create a new constraint, implement [`XpbdConstraint`] for a component, get the [`SubstepSchedule`] and add this system into /// the [`SubstepSolverSet::SolveUserConstraints`](super::SubstepSolverSet::SolveUserConstraints) set. diff --git a/src/lib.rs b/src/lib.rs index 4835d6ee..7b912afe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -511,6 +511,8 @@ use prelude::*; /// A plugin group containing all of Avian's plugins. /// +/// # Plugins +/// /// By default, the following plugins will be added: /// /// | Plugin | Description | @@ -540,7 +542,7 @@ use prelude::*; /// /// Refer to the documentation of the plugins for more information about their responsibilities and implementations. /// -/// ## World scale +/// # World Scale /// /// The [`PhysicsLengthUnit`] resource is a units-per-meter scaling factor /// that adjusts the engine's internal properties to the scale of the world. @@ -573,7 +575,7 @@ use prelude::*; /// # fn main() {} // Doc test needs main /// ``` /// -/// ## Custom schedule +/// # Custom Schedule /// /// You can run the [`PhysicsSchedule`] in any schedule you want by specifying the schedule when adding the plugin group: /// @@ -590,7 +592,7 @@ use prelude::*; /// } /// ``` /// -/// ## Custom plugins +/// # Custom Plugins /// /// First, create a new plugin. If you want to run your systems in the engine's schedules, get either the [`PhysicsSchedule`] /// or the [`SubstepSchedule`]. Then you can add your systems to that schedule and control system ordering with system sets like diff --git a/src/position.rs b/src/position.rs index 8d519f04..8f0bc3f2 100644 --- a/src/position.rs +++ b/src/position.rs @@ -9,7 +9,7 @@ use crate::math::Matrix; /// The global position of a [rigid body](RigidBody) or a [collider](Collider). /// -/// ## Relation to `Transform` and `GlobalTransform` +/// # Relation to `Transform` and `GlobalTransform` /// /// [`Position`] is used for physics internally and kept in sync with `Transform` /// by the [`SyncPlugin`]. It rarely needs to be used directly in your own code, as `Transform` can still @@ -20,7 +20,7 @@ use crate::math::Matrix; /// The reasons why the engine uses a separate [`Position`] component can be found /// [here](crate#why-are-there-separate-position-and-rotation-components). /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] @@ -124,7 +124,7 @@ pub(crate) type RotationValue = Quaternion; /// /// The rotation angle is wrapped to be within the `(-pi, pi]` range. /// -/// ## Relation to `Transform` and `GlobalTransform` +/// # Relation to `Transform` and `GlobalTransform` /// /// [`Rotation`] is used for physics internally and kept in sync with `Transform` /// by the [`SyncPlugin`]. It rarely needs to be used directly in your own code, as `Transform` can still @@ -135,7 +135,7 @@ pub(crate) type RotationValue = Quaternion; /// The reasons why the engine uses a separate [`Rotation`] component can be found /// [here](crate#why-are-there-separate-position-and-rotation-components). /// -/// ## Example +/// # Example /// /// ``` /// use avian2d::prelude::*; @@ -636,7 +636,7 @@ impl core::ops::Mul<&mut Vector3> for &mut Rotation { /// The global physics rotation of a [rigid body](RigidBody) or a [collider](Collider). /// -/// ## Relation to `Transform` and `GlobalTransform` +/// # Relation to `Transform` and `GlobalTransform` /// /// [`Rotation`] is used for physics internally and kept in sync with `Transform` /// by the [`SyncPlugin`]. It rarely needs to be used directly in your own code, as `Transform` can still @@ -647,7 +647,7 @@ impl core::ops::Mul<&mut Vector3> for &mut Rotation { /// The reasons why the engine uses a separate [`Rotation`] component can be found /// [here](crate#why-are-there-separate-position-and-rotation-components). /// -/// ## Example +/// # Example /// /// ``` /// use avian3d::prelude::*; diff --git a/src/schedule/mod.rs b/src/schedule/mod.rs index 69f253b4..718f3ac3 100644 --- a/src/schedule/mod.rs +++ b/src/schedule/mod.rs @@ -20,7 +20,7 @@ use bevy::{ /// Sets up the default scheduling, system set configuration, and time resources for physics. /// -/// ## Schedules and sets +/// # Schedules and Sets /// /// This plugin initializes and configures the following schedules and system sets: /// @@ -145,7 +145,7 @@ pub struct SubstepSchedule; /// The schedule is empty by default and runs in /// [`NarrowPhaseSet::PostProcess`](collision::narrow_phase::NarrowPhaseSet::PostProcess). /// -/// ## Example +/// # Example /// /// Below is an example of how you could add a system that filters collisions. /// @@ -185,7 +185,7 @@ pub struct PostProcessCollisions; /// 3. `Sync`: Responsible for synchronizing physics components with other data, like keeping [`Position`] /// and [`Rotation`] in sync with `Transform`. /// -/// ## See also +/// # See Also /// /// - [`PhysicsSchedule`]: Responsible for advancing the simulation in [`PhysicsSet::StepSimulation`]. /// - [`PhysicsStepSet`]: System sets for the steps of the actual physics simulation loop, like @@ -264,7 +264,7 @@ pub enum PhysicsStepSet { /// feature as shown in the [getting started guide](crate#getting-started) to avoid floating point /// precision problems. /// -/// ## Example +/// # Example /// /// You can change the number of substeps by inserting the [`SubstepCount`] resource: /// diff --git a/src/schedule/time.rs b/src/schedule/time.rs index 34898f7d..729a167d 100644 --- a/src/schedule/time.rs +++ b/src/schedule/time.rs @@ -11,7 +11,9 @@ use bevy::prelude::*; /// [`Time`](Physics) is automatically set as the generic [`Time`] resource for /// the [`PhysicsSchedule`]. /// -/// ### Physics speed +/// # Usage +/// +/// ## Physics Speed /// /// The relative speed of [`Time`](Physics) can be configured at startup /// using [`with_relative_speed`], or when the app is running using [`set_relative_speed`]: @@ -33,7 +35,7 @@ use bevy::prelude::*; /// [`with_relative_speed`]: PhysicsTime::with_relative_speed /// [`set_relative_speed`]: PhysicsTime::set_relative_speed /// -/// ### Pausing, resuming, and stepping physics +/// ## Pausing, Resuming, and Stepping Physics /// /// [`Time`](Physics) can be used to pause and resume the simulation: /// @@ -70,7 +72,7 @@ use bevy::prelude::*; /// } /// ``` /// -/// ## When to multiply by delta time? +/// ## When to Multiply by Delta Time? /// /// Schedules like `Update` use a variable timestep, which can often cause frame rate dependent /// behavior when moving bodies. One way to help address the issue is by multiplying by delta time. diff --git a/src/spatial_query/mod.rs b/src/spatial_query/mod.rs index f4074ebb..03b6375a 100644 --- a/src/spatial_query/mod.rs +++ b/src/spatial_query/mod.rs @@ -14,7 +14,7 @@ //! [`ShapeCaster`] components. They enable performing casts every frame in a way that is often more convenient //! than the normal [`SpatialQuery`] methods. See their documentation for more information. //! -//! ## Raycasting +//! # Raycasting //! //! **Raycasting** is a spatial query that finds intersections between colliders and a half-line. This can be used for //! a variety of things like getting information about the environment for character controllers and AI, @@ -69,7 +69,7 @@ //! //! To specify which colliders should be considered in the query, use a [spatial query filter](`SpatialQueryFilter`). //! -//! ## Shapecasting +//! # Shapecasting //! //! **Shapecasting** or **sweep testing** is a spatial query that finds intersections between colliders and a shape //! that is travelling along a half-line. It is very similar to [raycasting](#raycasting), but instead of a "point" @@ -123,7 +123,7 @@ //! //! To specify which colliders should be considered in the query, use a [spatial query filter](`SpatialQueryFilter`). //! -//! ## Point projection +//! # Point projection //! //! **Point projection** is a spatial query that projects a point on the closest collider. It returns the collider's //! entity, the projected point, and whether the point is inside of the collider. @@ -133,7 +133,7 @@ //! //! To specify which colliders should be considered in the query, use a [spatial query filter](`SpatialQueryFilter`). //! -//! ## Intersection tests +//! # Intersection tests //! //! **Intersection tests** are spatial queries that return the entities of colliders that are intersecting a given //! shape or area. diff --git a/src/spatial_query/pipeline.rs b/src/spatial_query/pipeline.rs index 28f0e45e..79ce94bb 100644 --- a/src/spatial_query/pipeline.rs +++ b/src/spatial_query/pipeline.rs @@ -151,7 +151,7 @@ impl SpatialQueryPipeline { /// Casts a [ray](spatial_query#raycasting) and computes the closest [hit](RayHitData) with a collider. /// If there are no hits, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -182,7 +182,7 @@ impl SpatialQueryPipeline { /// Casts a [ray](spatial_query#raycasting) and computes the closest [hit](RayHitData) with a collider. /// If there are no hits, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -226,7 +226,7 @@ impl SpatialQueryPipeline { /// Note that the order of the results is not guaranteed, and if there are more hits than `max_hits`, /// some hits will be missed. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -266,7 +266,7 @@ impl SpatialQueryPipeline { /// /// Note that the order of the results is not guaranteed. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -323,7 +323,7 @@ impl SpatialQueryPipeline { /// /// For a more ECS-based approach, consider using the [`ShapeCaster`] component instead. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -364,7 +364,7 @@ impl SpatialQueryPipeline { /// /// For a more ECS-based approach, consider using the [`ShapeCaster`] component instead. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -432,7 +432,7 @@ impl SpatialQueryPipeline { /// Casts a [shape](spatial_query#shapecasting) with a given rotation and computes computes all [hits](ShapeHitData) /// in the order of the time of impact until `max_hits` is reached. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -480,7 +480,7 @@ impl SpatialQueryPipeline { /// in the order of the time of impact, calling the given `callback` for each hit. The shapecast stops when /// `callback` returns false or all hits have been found. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -565,7 +565,7 @@ impl SpatialQueryPipeline { /// Finds the [projection](spatial_query#point-projection) of a given point on the closest [collider](Collider). /// If one isn't found, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that should be projected. /// - `solid`: If true and the point is inside of a collider, the projection will be at the point. @@ -585,7 +585,7 @@ impl SpatialQueryPipeline { /// Finds the [projection](spatial_query#point-projection) of a given point on the closest [collider](Collider). /// If one isn't found, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that should be projected. /// - `solid`: If true and the point is inside of a collider, the projection will be at the point. @@ -619,7 +619,7 @@ impl SpatialQueryPipeline { /// An [intersection test](spatial_query#intersection-tests) that finds all entities with a [collider](Collider) /// that contains the given point. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that intersections are tested against. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. @@ -642,7 +642,7 @@ impl SpatialQueryPipeline { /// that contains the given point, calling the given `callback` for each intersection. /// The search stops when `callback` returns `false` or all intersections have been found. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that intersections are tested against. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. @@ -714,7 +714,7 @@ impl SpatialQueryPipeline { /// An [intersection test](spatial_query#intersection-tests) that finds all entities with a [`Collider`] /// that is intersecting the given `shape` with a given position and rotation. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape that intersections are tested against represented as a [`Collider`]. /// - `shape_position`: The position of the shape. @@ -747,7 +747,7 @@ impl SpatialQueryPipeline { /// that is intersecting the given `shape` with a given position and rotation, calling `callback` for each /// intersection. The search stops when `callback` returns `false` or all intersections have been found. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape that intersections are tested against represented as a [`Collider`]. /// - `shape_position`: The position of the shape. diff --git a/src/spatial_query/query_filter.rs b/src/spatial_query/query_filter.rs index af9d992b..d0273cb4 100644 --- a/src/spatial_query/query_filter.rs +++ b/src/spatial_query/query_filter.rs @@ -4,7 +4,7 @@ use crate::prelude::*; /// Rules that determine which colliders are taken into account in [spatial queries](crate::spatial_query). /// -/// ## Example +/// # Example /// /// ``` #[cfg_attr(feature = "2d", doc = "use avian2d::prelude::*;")] diff --git a/src/spatial_query/ray_caster.rs b/src/spatial_query/ray_caster.rs index 6a961f3d..6b5ea9ee 100644 --- a/src/spatial_query/ray_caster.rs +++ b/src/spatial_query/ray_caster.rs @@ -27,7 +27,7 @@ use parry::query::{ /// The [`RayCaster`] is the easiest way to handle simple raycasts. If you want more control and don't want to /// perform raycasts every frame, consider using the [`SpatialQuery`] system parameter. /// -/// ## Hit count and order +/// # Hit Count and Order /// /// The results of a raycast are in an arbitrary order by default. You can iterate over them in the order of /// time of impact with the [`RayHits::iter_sorted`] method. @@ -40,7 +40,7 @@ use parry::query::{ /// To guarantee that the closest hit is included, you should set `max_hits` to one or a value that /// is enough to contain all hits. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -340,7 +340,7 @@ fn on_add_ray_caster(mut world: DeferredWorld, entity: Entity, _component_id: Co /// /// The maximum number of hits depends on the value of `max_hits` in [`RayCaster`]. /// -/// ## Order +/// # Order /// /// By default, the order of the hits is not guaranteed. /// @@ -350,7 +350,7 @@ fn on_add_ray_caster(mut world: DeferredWorld, entity: Entity, _component_id: Co /// **Note**: When there are more hits than `max_hits`, **some hits /// will be missed**. If you want to guarantee that the closest hit is included, set `max_hits` to one. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] diff --git a/src/spatial_query/shape_caster.rs b/src/spatial_query/shape_caster.rs index a57be2b3..bd14ace6 100644 --- a/src/spatial_query/shape_caster.rs +++ b/src/spatial_query/shape_caster.rs @@ -25,7 +25,7 @@ use parry::query::{details::TOICompositeShapeShapeBestFirstVisitor, ShapeCastOpt /// The [`ShapeCaster`] is the easiest way to handle simple shapecasting. If you want more control and don't want /// to perform shapecasts on every frame, consider using the [`SpatialQuery`] system parameter. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -368,7 +368,7 @@ fn on_add_shape_caster(mut world: DeferredWorld, entity: Entity, _component_id: /// The maximum number of hits depends on the value of `max_hits` in [`ShapeCaster`]. By default only /// one hit is computed, as shapecasting for many results can be expensive. /// -/// ## Example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] diff --git a/src/spatial_query/system_param.rs b/src/spatial_query/system_param.rs index 30ec0b1a..4075ecd1 100644 --- a/src/spatial_query/system_param.rs +++ b/src/spatial_query/system_param.rs @@ -3,7 +3,7 @@ use bevy::{ecs::system::SystemParam, prelude::*}; /// A system parameter for performing [spatial queries](spatial_query). /// -/// ## Methods +/// # Methods /// /// - [Raycasting](spatial_query#raycasting): [`cast_ray`](SpatialQuery::cast_ray), /// [`ray_hits`](SpatialQuery::ray_hits), [`ray_hits_callback`](SpatialQuery::ray_hits_callback) @@ -21,7 +21,7 @@ use bevy::{ecs::system::SystemParam, prelude::*}; /// For simple raycasts and shapecasts, consider using the [`RayCaster`] and [`ShapeCaster`] components that /// provide a more ECS-based approach and perform casts on every frame. /// -/// ## Raycasting example +/// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -89,7 +89,7 @@ impl SpatialQuery<'_, '_> { /// Casts a [ray](spatial_query#raycasting) and computes the closest [hit](RayHitData) with a collider. /// If there are no hits, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -98,7 +98,7 @@ impl SpatialQuery<'_, '_> { /// Otherwise, the collider will be treated as hollow, and the hit point will be at the collider's boundary. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -136,7 +136,7 @@ impl SpatialQuery<'_, '_> { /// Casts a [ray](spatial_query#raycasting) and computes the closest [hit](RayHitData) with a collider. /// If there are no hits, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -147,7 +147,7 @@ impl SpatialQuery<'_, '_> { /// - `predicate`: A function with which the colliders are filtered. Given the Entity it should return false, if the /// entity should be ignored. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -201,7 +201,7 @@ impl SpatialQuery<'_, '_> { /// Note that the order of the results is not guaranteed, and if there are more hits than `max_hits`, /// some hits will be missed. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -211,7 +211,7 @@ impl SpatialQuery<'_, '_> { /// Otherwise, the collider will be treated as hollow, and the hit point will be at the collider's boundary. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -262,7 +262,7 @@ impl SpatialQuery<'_, '_> { /// /// Note that the order of the results is not guaranteed. /// - /// ## Arguments + /// # Arguments /// /// - `origin`: Where the ray is cast from. /// - `direction`: What direction the ray is cast in. @@ -272,7 +272,7 @@ impl SpatialQuery<'_, '_> { /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - `callback`: A callback function called for each hit. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -328,7 +328,7 @@ impl SpatialQuery<'_, '_> { /// /// For a more ECS-based approach, consider using the [`ShapeCaster`] component instead. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -340,7 +340,7 @@ impl SpatialQuery<'_, '_> { /// hit will be returned. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -390,7 +390,7 @@ impl SpatialQuery<'_, '_> { /// Casts a [shape](spatial_query#shapecasting) with a given rotation and computes computes all [hits](ShapeHitData) /// in the order of the time of impact until `max_hits` is reached. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -404,7 +404,7 @@ impl SpatialQuery<'_, '_> { /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - `callback`: A callback function called for each hit. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -461,7 +461,7 @@ impl SpatialQuery<'_, '_> { /// in the order of the time of impact, calling the given `callback` for each hit. The shapecast stops when /// `callback` returns false or all hits have been found. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape being cast represented as a [`Collider`]. /// - `origin`: Where the shape is cast from. @@ -474,7 +474,7 @@ impl SpatialQuery<'_, '_> { /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - `callback`: A callback function called for each hit. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -535,14 +535,14 @@ impl SpatialQuery<'_, '_> { /// Finds the [projection](spatial_query#point-projection) of a given point on the closest [collider](Collider). /// If one isn't found, `None` is returned. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that should be projected. /// - `solid`: If true and the point is inside of a collider, the projection will be at the point. /// Otherwise, the collider will be treated as hollow, and the projection will be at the collider's boundary. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -576,12 +576,12 @@ impl SpatialQuery<'_, '_> { /// An [intersection test](spatial_query#intersection-tests) that finds all entities with a [collider](Collider) /// that contains the given point. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that intersections are tested against. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -612,13 +612,13 @@ impl SpatialQuery<'_, '_> { /// that contains the given point, calling the given `callback` for each intersection. /// The search stops when `callback` returns `false` or all intersections have been found. /// - /// ## Arguments + /// # Arguments /// /// - `point`: The point that intersections are tested against. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - `callback`: A callback function called for each intersection. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -658,7 +658,7 @@ impl SpatialQuery<'_, '_> { /// An [intersection test](spatial_query#intersection-tests) that finds all entities with a [`ColliderAabb`] /// that is intersecting the given `aabb`. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -685,7 +685,7 @@ impl SpatialQuery<'_, '_> { /// that is intersecting the given `aabb`, calling `callback` for each intersection. /// The search stops when `callback` returns `false` or all intersections have been found. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -723,14 +723,14 @@ impl SpatialQuery<'_, '_> { /// An [intersection test](spatial_query#intersection-tests) that finds all entities with a [`Collider`] /// that is intersecting the given `shape` with a given position and rotation. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape that intersections are tested against represented as a [`Collider`]. /// - `shape_position`: The position of the shape. /// - `shape_rotation`: The rotation of the shape. /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] @@ -768,7 +768,7 @@ impl SpatialQuery<'_, '_> { /// that is intersecting the given `shape` with a given position and rotation, calling `callback` for each /// intersection. The search stops when `callback` returns `false` or all intersections have been found. /// - /// ## Arguments + /// # Arguments /// /// - `shape`: The shape that intersections are tested against represented as a [`Collider`]. /// - `shape_position`: The position of the shape. @@ -776,7 +776,7 @@ impl SpatialQuery<'_, '_> { /// - `query_filter`: A [`SpatialQueryFilter`] that determines which colliders are taken into account in the query. /// - `callback`: A callback function called for each intersection. /// - /// ## Example + /// # Example /// /// ``` /// # #[cfg(feature = "2d")] diff --git a/src/sync/mod.rs b/src/sync/mod.rs index 14c8e14f..7b41b2a0 100644 --- a/src/sync/mod.rs +++ b/src/sync/mod.rs @@ -16,7 +16,7 @@ pub mod ancestor_marker; /// Responsible for synchronizing physics components with other data, like keeping [`Position`] /// and [`Rotation`] in sync with `Transform`. /// -/// ## Syncing between [`Position`]/[`Rotation`] and [`Transform`] +/// # Syncing Between [`Position`]/[`Rotation`] and [`Transform`] /// /// By default, each body's `Transform` will be updated when [`Position`] or [`Rotation`] /// change, and vice versa. This means that you can use any of these components to move @@ -25,7 +25,7 @@ pub mod ancestor_marker; /// You can configure what data is synchronized and how it is synchronized /// using the [`SyncConfig`] resource. /// -/// ## `Transform` hierarchies +/// # `Transform` Hierarchies /// /// When synchronizing changes in [`Position`] or [`Rotation`] to `Transform`, /// the engine treats nested [rigid bodies](RigidBody) as a flat structure. This means that