aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2021-06-02 17:37:13 +0200
committerGitHub <noreply@github.com>2021-06-02 17:37:13 +0200
commitc7b876e2f7fc69d453faf5dc6ee162eeb079aca6 (patch)
treedeb154b1982b19407f39c40531c5b883f7c4c972
parentad2fcf755a750e279b730c660da438abc2803a9a (diff)
parent810c39d427d277a601d517e7119c6b67e6c33376 (diff)
downloadrapier-c7b876e2f7fc69d453faf5dc6ee162eeb079aca6.tar.gz
rapier-c7b876e2f7fc69d453faf5dc6ee162eeb079aca6.tar.bz2
rapier-c7b876e2f7fc69d453faf5dc6ee162eeb079aca6.zip
Merge pull request #173 from DasEtwas/must-use-pub
Add #[must_use] to builders, expose more fields
-rw-r--r--src/dynamics/rigid_body.rs40
-rw-r--r--src/geometry/collider.rs1
2 files changed, 28 insertions, 13 deletions
diff --git a/src/dynamics/rigid_body.rs b/src/dynamics/rigid_body.rs
index 63c2221..2086839 100644
--- a/src/dynamics/rigid_body.rs
+++ b/src/dynamics/rigid_body.rs
@@ -704,21 +704,35 @@ impl RigidBody {
}
/// A builder for rigid-bodies.
+#[derive(Clone, Debug, PartialEq)]
+#[must_use = "Builder functions return the updated builder"]
pub struct RigidBodyBuilder {
- position: Isometry<Real>,
- linvel: Vector<Real>,
- angvel: AngVector<Real>,
- gravity_scale: Real,
- linear_damping: Real,
- angular_damping: Real,
+ /// The initial position of the rigid-body to be built.
+ pub position: Isometry<Real>,
+ /// The linear velocity of the rigid-body to be built.
+ pub linvel: Vector<Real>,
+ /// The angular velocity of the rigid-body to be built.
+ pub angvel: AngVector<Real>,
+ /// The scale factor applied to the gravity affecting the rigid-body to be built, `1.0` by default.
+ pub gravity_scale: Real,
+ /// Damping factor for gradually slowing down the translational motion of the rigid-body, `0.0` by default.
+ pub linear_damping: Real,
+ /// Damping factor for gradually slowing down the angular motion of the rigid-body, `0.0` by default.
+ pub angular_damping: Real,
rb_type: RigidBodyType,
mprops_flags: RigidBodyMassPropsFlags,
- mass_properties: MassProperties,
- can_sleep: bool,
- sleeping: bool,
- ccd_enabled: bool,
- dominance_group: i8,
- user_data: u128,
+ /// The additional mass properties of the rigid-body being built. See [`RigidBodyBuilder::additional_mass_properties`] for more information.
+ pub mass_properties: MassProperties,
+ /// Whether or not the rigid-body to be created can sleep if it reaches a dynamic equilibrium.
+ pub can_sleep: bool,
+ /// Whether or not the rigid-body is to be created asleep.
+ pub sleeping: bool,
+ /// Whether continuous collision-detection is enabled for the rigid-body to be built.
+ pub ccd_enabled: bool,
+ /// The dominance group of the rigid-body to be built.
+ pub dominance_group: i8,
+ /// An arbitrary user-defined 128-bit integer associated to the rigid-bodies built by this builder.
+ pub user_data: u128,
}
impl RigidBodyBuilder {
@@ -962,7 +976,7 @@ impl RigidBodyBuilder {
self
}
- /// Enabled continuous collision-detection for this rigid-body.
+ /// Sets whether or not continuous collision-detection is enabled for this rigid-body.
pub fn ccd_enabled(mut self, enabled: bool) -> Self {
self.ccd_enabled = enabled;
self
diff --git a/src/geometry/collider.rs b/src/geometry/collider.rs
index c039ed5..44295c4 100644
--- a/src/geometry/collider.rs
+++ b/src/geometry/collider.rs
@@ -275,6 +275,7 @@ impl Collider {
/// A structure responsible for building a new collider.
#[derive(Clone)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
+#[must_use = "Builder functions return the updated builder"]
pub struct ColliderBuilder {
/// The shape of the collider to be built.
pub shape: SharedShape,