{"record":{"id":"dedc84e73f9d740b","repo":"bevyengine/bevy","slug":"cannot-create-an-evencore-over-an-unbounded-domain","errorCode":null,"errorMessage":"Cannot create an EvenCore over an unbounded domain","messagePattern":"Cannot create an EvenCore over an unbounded domain","errorType":"exception","errorClass":"EvenCoreError","httpStatus":null,"severity":"error","filePath":"crates/bevy_math/src/curve/cores.rs","lineNumber":150,"sourceCode":"    ///\n    /// # Invariants\n    /// This must always have a length of at least 2.\n    pub samples: Vec<T>,\n}\n\n/// An error indicating that an [`EvenCore`] could not be constructed.\n#[derive(Debug, Error)]\n#[error(\"Could not construct an EvenCore\")]\npub enum EvenCoreError {\n    /// Not enough samples were provided.\n    #[error(\"Need at least two samples to create an EvenCore, but {samples} were provided\")]\n    NotEnoughSamples {\n        /// The number of samples that were provided.\n        samples: usize,\n    },\n\n    /// Unbounded domains are not compatible with `EvenCore`.\n    #[error(\"Cannot create an EvenCore over an unbounded domain\")]\n    UnboundedDomain,\n}\n\n#[cfg(feature = \"alloc\")]\nimpl<T> EvenCore<T> {\n    /// Create a new [`EvenCore`] from the specified `domain` and `samples`. The samples are\n    /// regarded to be evenly spaced within the given domain interval, so that the outermost\n    /// samples form the boundary of that interval. An error is returned if there are not at\n    /// least 2 samples or if the given domain is unbounded.\n    #[inline]\n    pub fn new(\n        domain: Interval,\n        samples: impl IntoIterator<Item = T>,\n    ) -> Result<Self, EvenCoreError> {\n        let samples: Vec<T> = samples.into_iter().collect();\n        if samples.len() < 2 {\n            return Err(EvenCoreError::NotEnoughSamples {\n                samples: samples.len(),","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_math/src/curve/cores.rs#L132-L168","documentation":"EvenCoreError::UnboundedDomain is returned by EvenCore::new when the supplied Interval is unbounded — an endpoint of -INF or +INF (e.g. Interval::EVERYTHING). EvenCore must place samples at even fractions across the domain, which is impossible over an infinite span, so the domain must be a bounded interval.","triggerScenarios":"EvenCore::new(Interval::EVERYTHING, samples); passing an Interval built with infinite endpoints; deriving a domain from unclamped animation/physics times (t in 0..INF) and forwarding it into an even-sampled curve constructor.","commonSituations":"Using Interval::EVERYTHING as a 'default' domain; curves for animations without a defined duration; domains computed from a max time that came out as f32::INFINITY due to division by zero.","solutions":["Pass a bounded interval, e.g. Interval::new(0.0, duration)? where duration is finite.","If data is unbounded, clamp it first: pick the time window you actually care about and construct the core over that.","For arbitrary-time sparse samples, use UnevenCore instead, which has no bounded-domain requirement."],"exampleFix":"// before\nlet core = EvenCore::new(Interval::EVERYTHING, samples); // Err(UnboundedDomain)\n\n// after\nlet domain = Interval::new(0.0, samples.len() as f32 - 1.0)?; // bounded span\nlet core = EvenCore::new(domain, samples)?;","handlingStrategy":"validation","validationCode":"if domain.is_bounded() {\n    let core = EvenCore::new(domain, samples)?;\n} // else clamp to a finite window first","typeGuard":null,"tryCatchPattern":"let core = match EvenCore::new(domain, samples) {\n    Ok(core) => core,\n    Err(EvenCoreError::UnboundedDomain) => {\n        let window = Interval::new(0.0, 1.0)?; // fall back to a sane finite window\n        EvenCore::new(window, samples)?\n    }\n    Err(e) => return Err(e.into()),\n};","preventionTips":["Check `interval.is_bounded()` before passing domains into even-sampled constructors.","Never use Interval::EVERYTHING as a default for interpolated curves.","Clamp durations/times computed from gameplay to finite values before deriving domains."],"tags":["rust","bevy","math","curve","interval","runtime"],"backgroundTag":"unbounded-curve-domain","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}