Merge pull request #173 from DasEtwas/must-use-pub

Add #[must_use] to builders, expose more fields
This commit is contained in:
Sébastien Crozet
2021-06-02 17:37:13 +02:00
committed by GitHub
2 changed files with 28 additions and 13 deletions

View File

@@ -704,21 +704,35 @@ impl RigidBody {
} }
/// A builder for rigid-bodies. /// A builder for rigid-bodies.
#[derive(Clone, Debug, PartialEq)]
#[must_use = "Builder functions return the updated builder"]
pub struct RigidBodyBuilder { pub struct RigidBodyBuilder {
position: Isometry<Real>, /// The initial position of the rigid-body to be built.
linvel: Vector<Real>, pub position: Isometry<Real>,
angvel: AngVector<Real>, /// The linear velocity of the rigid-body to be built.
gravity_scale: Real, pub linvel: Vector<Real>,
linear_damping: Real, /// The angular velocity of the rigid-body to be built.
angular_damping: Real, 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, rb_type: RigidBodyType,
mprops_flags: RigidBodyMassPropsFlags, mprops_flags: RigidBodyMassPropsFlags,
mass_properties: MassProperties, /// The additional mass properties of the rigid-body being built. See [`RigidBodyBuilder::additional_mass_properties`] for more information.
can_sleep: bool, pub mass_properties: MassProperties,
sleeping: bool, /// Whether or not the rigid-body to be created can sleep if it reaches a dynamic equilibrium.
ccd_enabled: bool, pub can_sleep: bool,
dominance_group: i8, /// Whether or not the rigid-body is to be created asleep.
user_data: u128, 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 { impl RigidBodyBuilder {
@@ -962,7 +976,7 @@ impl RigidBodyBuilder {
self 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 { pub fn ccd_enabled(mut self, enabled: bool) -> Self {
self.ccd_enabled = enabled; self.ccd_enabled = enabled;
self self

View File

@@ -275,6 +275,7 @@ impl Collider {
/// A structure responsible for building a new collider. /// A structure responsible for building a new collider.
#[derive(Clone)] #[derive(Clone)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
#[must_use = "Builder functions return the updated builder"]
pub struct ColliderBuilder { pub struct ColliderBuilder {
/// The shape of the collider to be built. /// The shape of the collider to be built.
pub shape: SharedShape, pub shape: SharedShape,