Skip to content

Commit f1eb879

Browse files
authored
Don't serialize PhantomData in adaptor curves (#20540)
# Objective Adaptor curves have `PhantomData` fields that are included when serializing. ## Solution Add `serde(skip)` to `PhantomData` fields. ## Testing Everything still compiles, the curves still work, and the `_phantom: ()` fields are no longer emitted.
1 parent c0eb89e commit f1eb879

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

crates/bevy_math/src/curve/adaptors.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ pub struct FunctionCurve<T, F> {
9191
pub(crate) domain: Interval,
9292
#[cfg_attr(feature = "bevy_reflect", reflect(ignore))]
9393
pub(crate) f: F,
94+
#[cfg_attr(feature = "serialize", serde(skip))]
9495
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
9596
pub(crate) _phantom: PhantomData<fn() -> T>,
9697
}
@@ -192,6 +193,7 @@ pub struct MapCurve<S, T, C, F> {
192193
pub(crate) preimage: C,
193194
#[cfg_attr(feature = "bevy_reflect", reflect(ignore))]
194195
pub(crate) f: F,
196+
#[cfg_attr(feature = "serialize", serde(skip))]
195197
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
196198
pub(crate) _phantom: PhantomData<(fn() -> S, fn(S) -> T)>,
197199
}
@@ -289,6 +291,7 @@ pub struct ReparamCurve<T, C, F> {
289291
pub(crate) base: C,
290292
#[cfg_attr(feature = "bevy_reflect", reflect(ignore))]
291293
pub(crate) f: F,
294+
#[cfg_attr(feature = "serialize", serde(skip))]
292295
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
293296
pub(crate) _phantom: PhantomData<fn() -> T>,
294297
}
@@ -383,6 +386,7 @@ pub struct LinearReparamCurve<T, C> {
383386
pub(crate) base: C,
384387
/// Invariants: This interval must always be bounded.
385388
pub(crate) new_domain: Interval,
389+
#[cfg_attr(feature = "serialize", serde(skip))]
386390
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
387391
pub(crate) _phantom: PhantomData<fn() -> T>,
388392
}
@@ -416,6 +420,7 @@ where
416420
pub struct CurveReparamCurve<T, C, D> {
417421
pub(crate) base: C,
418422
pub(crate) reparam_curve: D,
423+
#[cfg_attr(feature = "serialize", serde(skip))]
419424
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
420425
pub(crate) _phantom: PhantomData<fn() -> T>,
421426
}
@@ -448,6 +453,7 @@ where
448453
)]
449454
pub struct GraphCurve<T, C> {
450455
pub(crate) base: C,
456+
#[cfg_attr(feature = "serialize", serde(skip))]
451457
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
452458
pub(crate) _phantom: PhantomData<fn() -> T>,
453459
}
@@ -480,6 +486,7 @@ pub struct ZipCurve<S, T, C, D> {
480486
pub(crate) domain: Interval,
481487
pub(crate) first: C,
482488
pub(crate) second: D,
489+
#[cfg_attr(feature = "serialize", serde(skip))]
483490
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
484491
pub(crate) _phantom: PhantomData<fn() -> (S, T)>,
485492
}
@@ -520,6 +527,7 @@ where
520527
pub struct ChainCurve<T, C, D> {
521528
pub(crate) first: C,
522529
pub(crate) second: D,
530+
#[cfg_attr(feature = "serialize", serde(skip))]
523531
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
524532
pub(crate) _phantom: PhantomData<fn() -> T>,
525533
}
@@ -569,6 +577,7 @@ where
569577
)]
570578
pub struct ReverseCurve<T, C> {
571579
pub(crate) curve: C,
580+
#[cfg_attr(feature = "serialize", serde(skip))]
572581
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
573582
pub(crate) _phantom: PhantomData<fn() -> T>,
574583
}
@@ -611,6 +620,7 @@ where
611620
pub struct RepeatCurve<T, C> {
612621
pub(crate) domain: Interval,
613622
pub(crate) curve: C,
623+
#[cfg_attr(feature = "serialize", serde(skip))]
614624
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
615625
pub(crate) _phantom: PhantomData<fn() -> T>,
616626
}
@@ -669,6 +679,7 @@ where
669679
)]
670680
pub struct ForeverCurve<T, C> {
671681
pub(crate) curve: C,
682+
#[cfg_attr(feature = "serialize", serde(skip))]
672683
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
673684
pub(crate) _phantom: PhantomData<fn() -> T>,
674685
}
@@ -723,6 +734,7 @@ where
723734
)]
724735
pub struct PingPongCurve<T, C> {
725736
pub(crate) curve: C,
737+
#[cfg_attr(feature = "serialize", serde(skip))]
726738
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
727739
pub(crate) _phantom: PhantomData<fn() -> T>,
728740
}
@@ -780,6 +792,7 @@ pub struct ContinuationCurve<T, C, D> {
780792
pub(crate) second: D,
781793
// cache the offset in the curve directly to prevent triple sampling for every sample we make
782794
pub(crate) offset: T,
795+
#[cfg_attr(feature = "serialize", serde(skip))]
783796
#[cfg_attr(feature = "bevy_reflect", reflect(ignore, clone))]
784797
pub(crate) _phantom: PhantomData<fn() -> T>,
785798
}

0 commit comments

Comments
 (0)