Skip to main content

loam_physics/
edit.rs

1use std::fmt;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq)]
4pub enum EditError {
5    StaleHandle,
6    NotFinite,
7    InvalidGravity,
8    InvalidTimeStep,
9    InvalidTime,
10    InvalidSolverTolerance,
11    InvalidGrabConfig,
12    InvalidStepTravel,
13    InvalidMass,
14    InvalidInertia,
15    InvalidRestitution,
16    InvalidBodyArena,
17    InvalidBody,
18    InvalidGeometry,
19    InvalidFieldBinding,
20    InvalidManifold,
21    UnsupportedCollider,
22    DynamicHalfSpace,
23    DynamicFieldAnchor,
24    FieldAnchorRemoval,
25    AnchorBindsOwnField,
26    FieldMismatch,
27    RegistrationMismatch,
28}
29
30impl fmt::Display for EditError {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        let text = match self {
33            Self::StaleHandle => "the body handle is stale",
34            Self::NotFinite => "the value is not finite",
35            Self::InvalidGravity => "gravity is not finite",
36            Self::InvalidTimeStep => "the time step is negative or not finite",
37            Self::InvalidTime => "the world time is negative or not finite",
38            Self::InvalidSolverTolerance => "the solver tolerance is negative or NaN",
39            Self::InvalidGrabConfig => "the grab configuration is invalid",
40            Self::InvalidStepTravel => "the adaptive step travel is not positive",
41            Self::InvalidMass => "the mass is negative, not finite, or too small to invert",
42            Self::InvalidInertia => "the inertia is negative, not finite, or too small to invert",
43            Self::InvalidRestitution => "the restitution is negative or not finite",
44            Self::InvalidBodyArena => "the body arena is inconsistent",
45            Self::InvalidBody => "a body has invalid state",
46            Self::InvalidGeometry => "the geometry store is inconsistent",
47            Self::InvalidFieldBinding => "a field binding is invalid",
48            Self::InvalidManifold => "a contact manifold is invalid",
49            Self::UnsupportedCollider => "the space cannot use this collider",
50            Self::DynamicHalfSpace => "a half-space collider needs zero mass",
51            Self::DynamicFieldAnchor => "a field anchor body needs zero mass",
52            Self::FieldAnchorRemoval => "a field anchor body cannot be removed",
53            Self::AnchorBindsOwnField => "a field's anchor cannot bind that field to itself",
54            Self::FieldMismatch => "the world's field anchors are not the snapshot's",
55            Self::RegistrationMismatch => "the narrowphase registrations are not the snapshot's",
56        };
57        f.write_str(text)
58    }
59}
60
61impl std::error::Error for EditError {}