pub struct Transformed<T, G> {
pub inner: T,
pub transform: G,
}Expand description
An item paired with an external transform represented by G.
inner retains its own representation while transform controls the
extracted geometry. Composition is explicit about order:
compose_outer:transform = outer * transform;compose_inner:transform = transform * inner.
Applying an H through ApplyTransform is outer composition and is only
available when H embeds into the existing storage type (G: From<H>).
Operations never widen the wrapper automatically. Widen explicitly with
Into::into when a more general storage type is required.
use ranim_core::{glam::DVec3, prelude::*};
let mut item = ().transformed(Similarity::IDENTITY);
// `Diag` does not embed into `Similarity`; choose `DAffine3` storage first.
item.scale(DVec3::new(2.0, 1.0, 1.0));Extraction and Aabb calculation convert G to [DAffine3] only at the
geometry boundary. Projective transforms remain outside the model-transform
system.
Fields§
§inner: TThe item expressed in its own coordinates.
transform: GThe external transform applied to inner.
Implementations§
Source§impl<T, G> Transformed<T, G>
impl<T, G> Transformed<T, G>
Sourcepub fn new(inner: T, transform: G) -> Self
pub fn new(inner: T, transform: G) -> Self
Pair inner with transform without converting either value.
Sourcepub fn map_inner<U, F>(self, f: F) -> Transformed<U, G>where
F: FnOnce(T) -> U,
pub fn map_inner<U, F>(self, f: F) -> Transformed<U, G>where
F: FnOnce(T) -> U,
Map the wrapped item to a new type, keeping transform unchanged.
Sourcepub fn map_transform<H, F>(self, f: F) -> Transformed<T, H>where
F: FnOnce(G) -> H,
pub fn map_transform<H, F>(self, f: F) -> Transformed<T, H>where
F: FnOnce(G) -> H,
Map the transform storage to a new type while keeping inner
unchanged.
This is the general form of converting between transform groups —
for example widening a placement or checked-narrowing an affine
storage back to a subgroup. Lossless upward conversions need no
closure at all: Transformed implements
From<Transformed<T, X>> for Transformed<T, Y> whenever X embeds
into Y, so prefer plain .into() there.
Sourcepub fn compose_outer<H>(&mut self, outer: H) -> &mut Selfwhere
G: TransformGroup + From<H>,
pub fn compose_outer<H>(&mut self, outer: H) -> &mut Selfwhere
G: TransformGroup + From<H>,
Compose outer on the left: transform = outer * transform.
Sourcepub fn compose_inner<H>(&mut self, inner: H) -> &mut Selfwhere
G: TransformGroup + From<H>,
pub fn compose_inner<H>(&mut self, inner: H) -> &mut Selfwhere
G: TransformGroup + From<H>,
Compose inner on the right: transform = transform * inner.
Sourcepub fn bake(self) -> Twhere
T: ApplyTransform<G>,
pub fn bake(self) -> Twhere
T: ApplyTransform<G>,
Bake the stored transform into inner and remove the wrapper.
This method exists only when T directly supports the wrapper’s exact
transform representation G.
Trait Implementations§
Source§impl<T, G> Aabb for Transformed<T, G>
impl<T, G> Aabb for Transformed<T, G>
Source§impl<T: Alignable, G: Clone> Alignable for Transformed<T, G>
impl<T: Alignable, G: Clone> Alignable for Transformed<T, G>
Source§fn is_aligned(&self, other: &Self) -> bool
fn is_aligned(&self, other: &Self) -> bool
Source§fn align_with(&mut self, other: &mut Self)
fn align_with(&mut self, other: &mut Self)
Source§impl<T, G, H> ApplyTransform<H> for Transformed<T, G>where
G: TransformGroup + From<H>,
impl<T, G, H> ApplyTransform<H> for Transformed<T, G>where
G: TransformGroup + From<H>,
Source§impl<T: Clone, G: Clone> Clone for Transformed<T, G>
impl<T: Clone, G: Clone> Clone for Transformed<T, G>
Source§fn clone(&self) -> Transformed<T, G>
fn clone(&self) -> Transformed<T, G>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T: Empty, G: TransformGroup> Empty for Transformed<T, G>
impl<T: Empty, G: TransformGroup> Empty for Transformed<T, G>
Source§fn empty() -> Self
fn empty() -> Self
Create an empty placeholder of a wrapped item.
The inner item contributes T::empty() while the pose is G::identity():
an empty placeholder carries no geometry, so there is no meaningful
placement to preserve — identity keeps it neutral for composition until
real content is placed on it.
Source§impl<T, G> Extract for Transformed<T, G>
impl<T, G> Extract for Transformed<T, G>
Source§impl<T: FillColor, G> FillColor for Transformed<T, G>
impl<T: FillColor, G> FillColor for Transformed<T, G>
Source§fn fill_color(&self) -> AlphaColor<Srgb>
fn fill_color(&self) -> AlphaColor<Srgb>
Source§fn set_fill_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self
fn set_fill_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self
Source§fn set_fill_opacity(&mut self, opacity: f32) -> &mut Self
fn set_fill_opacity(&mut self, opacity: f32) -> &mut Self
Source§impl<T> From<Transformed<T, Diag>> for Transformed<T, DAffine3>
impl<T> From<Transformed<T, Diag>> for Transformed<T, DAffine3>
Source§fn from(value: Transformed<T, Diag>) -> Self
fn from(value: Transformed<T, Diag>) -> Self
Source§impl<T> From<Transformed<T, Rigid>> for Transformed<T, Similarity>
impl<T> From<Transformed<T, Rigid>> for Transformed<T, Similarity>
Source§fn from(value: Transformed<T, Rigid>) -> Self
fn from(value: Transformed<T, Rigid>) -> Self
Source§impl<T> From<Transformed<T, Rigid>> for Transformed<T, DAffine3>
impl<T> From<Transformed<T, Rigid>> for Transformed<T, DAffine3>
Source§fn from(value: Transformed<T, Rigid>) -> Self
fn from(value: Transformed<T, Rigid>) -> Self
Source§impl<T> From<Transformed<T, Similarity>> for Transformed<T, DAffine3>
impl<T> From<Transformed<T, Similarity>> for Transformed<T, DAffine3>
Source§fn from(value: Transformed<T, Similarity>) -> Self
fn from(value: Transformed<T, Similarity>) -> Self
Source§impl<T> From<Transformed<T, Translation>> for Transformed<T, Rigid>
impl<T> From<Transformed<T, Translation>> for Transformed<T, Rigid>
Source§fn from(value: Transformed<T, Translation>) -> Self
fn from(value: Transformed<T, Translation>) -> Self
Source§impl<T> From<Transformed<T, Translation>> for Transformed<T, Similarity>
impl<T> From<Transformed<T, Translation>> for Transformed<T, Similarity>
Source§fn from(value: Transformed<T, Translation>) -> Self
fn from(value: Transformed<T, Translation>) -> Self
Source§impl<T> From<Transformed<T, Translation>> for Transformed<T, DAffine3>
impl<T> From<Transformed<T, Translation>> for Transformed<T, DAffine3>
Source§fn from(value: Transformed<T, Translation>) -> Self
fn from(value: Transformed<T, Translation>) -> Self
Source§impl<T: Interpolatable, G: Interpolatable> Interpolatable for Transformed<T, G>
impl<T: Interpolatable, G: Interpolatable> Interpolatable for Transformed<T, G>
Source§impl<T, G> Locate<Transformed<T, G>> for Centroid
impl<T, G> Locate<Transformed<T, G>> for Centroid
Source§fn locate(&self, target: &Transformed<T, G>) -> DVec3
fn locate(&self, target: &Transformed<T, G>) -> DVec3
Source§impl<T: Opacity, G> Opacity for Transformed<T, G>
impl<T: Opacity, G> Opacity for Transformed<T, G>
Source§fn set_opacity(&mut self, opacity: f32) -> &mut Self
fn set_opacity(&mut self, opacity: f32) -> &mut Self
Source§impl<T: Partial, G: Clone> Partial for Transformed<T, G>
impl<T: Partial, G: Clone> Partial for Transformed<T, G>
Source§fn get_partial(&self, range: Range<f64>) -> Self
fn get_partial(&self, range: Range<f64>) -> Self
Take a partial slice of the wrapped item, keeping the pose.
The range is forwarded to inner, so the partial geometry is taken in
the item’s own coordinates, while the stored transform G is cloned
unchanged. The wrapper therefore keeps its placement while the visible
geometry grows from the slice, which is what create-style animations
expect.
Source§fn get_partial_closed(&self, range: Range<f64>) -> Self
fn get_partial_closed(&self, range: Range<f64>) -> Self
Take a closed partial slice of the wrapped item, keeping the pose.
Like get_partial, but the inner slice is closed
so partially shown curves have caps at both ends; the wrapper’s
transform is preserved.
Source§impl<T: StrokeColor, G> StrokeColor for Transformed<T, G>
impl<T: StrokeColor, G> StrokeColor for Transformed<T, G>
Source§fn stroke_color(&self) -> AlphaColor<Srgb>
fn stroke_color(&self) -> AlphaColor<Srgb>
Source§fn set_stroke_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self
fn set_stroke_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self
Source§fn set_stroke_opacity(&mut self, opacity: f32) -> &mut Self
fn set_stroke_opacity(&mut self, opacity: f32) -> &mut Self
Source§impl<T: StrokeWidth, G> StrokeWidth for Transformed<T, G>
impl<T: StrokeWidth, G> StrokeWidth for Transformed<T, G>
Source§fn stroke_width(&self) -> f32
fn stroke_width(&self) -> f32
Source§fn apply_stroke_func(
&mut self,
f: impl for<'a> Fn(&'a mut [Width]),
) -> &mut Self
fn apply_stroke_func( &mut self, f: impl for<'a> Fn(&'a mut [Width]), ) -> &mut Self
Source§fn set_stroke_width(&mut self, width: f32) -> &mut Self
fn set_stroke_width(&mut self, width: f32) -> &mut Self
impl<T: PartialEq, G: PartialEq> StructuralPartialEq for Transformed<T, G>
Auto Trait Implementations§
impl<T, G> Freeze for Transformed<T, G>
impl<T, G> RefUnwindSafe for Transformed<T, G>where
T: RefUnwindSafe,
G: RefUnwindSafe,
impl<T, G> Send for Transformed<T, G>
impl<T, G> Sync for Transformed<T, G>
impl<T, G> Unpin for Transformed<T, G>
impl<T, G> UnsafeUnpin for Transformed<T, G>where
T: UnsafeUnpin,
G: UnsafeUnpin,
impl<T, G> UnwindSafe for Transformed<T, G>where
T: UnwindSafe,
G: UnwindSafe,
Blanket Implementations§
impl<T> AnyExtractCoreItem for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Color for T
impl<T> Color for T
Source§fn set_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self
fn set_color(&mut self, color: AlphaColor<Srgb>) -> &mut Self
impl<T> ConditionalSend for Twhere
T: Send,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> RotateTransform for T
impl<T> RotateTransform for T
Source§fn rotate_on_axis(&mut self, axis: DVec3, angle: f64) -> &mut T
fn rotate_on_axis(&mut self, axis: DVec3, angle: f64) -> &mut T
Source§fn rotate_on_x(&mut self, angle: f64) -> &mut Self
fn rotate_on_x(&mut self, angle: f64) -> &mut Self
Source§fn rotate_on_y(&mut self, angle: f64) -> &mut Self
fn rotate_on_y(&mut self, angle: f64) -> &mut Self
Source§fn rotate_on_z(&mut self, angle: f64) -> &mut Self
fn rotate_on_z(&mut self, angle: f64) -> &mut Self
Source§impl<T> ScaleTransform for T
impl<T> ScaleTransform for T
Source§impl<T> ScaleTransformExt for Twhere
T: ScaleTransform + ?Sized,
impl<T> ScaleTransformExt for Twhere
T: ScaleTransform + ?Sized,
Source§fn calc_scale_ratio(&self, hint: ScaleHint) -> DVec3where
Self: Aabb,
fn calc_scale_ratio(&self, hint: ScaleHint) -> DVec3where
Self: Aabb,
Source§fn scale_to(&mut self, hint: ScaleHint) -> &mut Selfwhere
Self: Aabb,
fn scale_to(&mut self, hint: ScaleHint) -> &mut Selfwhere
Self: Aabb,
Source§impl<T> ScaleTransformStrokeExt for T
impl<T> ScaleTransformStrokeExt for T
Source§fn scale_with_stroke(&mut self, scale: DVec3) -> &mut Self
fn scale_with_stroke(&mut self, scale: DVec3) -> &mut Self
Source§impl<T> ShiftTransform for T
impl<T> ShiftTransform for T
Source§impl<T> ShiftTransformExt for Twhere
T: ShiftTransform + ?Sized,
impl<T> ShiftTransformExt for Twhere
T: ShiftTransform + ?Sized,
Source§fn with_origin(
&mut self,
p: impl Locate<Self>,
f: impl FnOnce(&mut Self),
) -> &mut Self
fn with_origin( &mut self, p: impl Locate<Self>, f: impl FnOnce(&mut Self), ) -> &mut Self
Source§fn move_anchor_to<A>(&mut self, anchor: A, point: DVec3) -> &mut Selfwhere
A: Locate<Self>,
fn move_anchor_to<A>(&mut self, anchor: A, point: DVec3) -> &mut Selfwhere
A: Locate<Self>,
Source§impl<T> StaticAnim for Twhere
T: StaticAnimRequirement + 'static,
impl<T> StaticAnim for Twhere
T: StaticAnimRequirement + 'static,
impl<T> StaticAnimRequirement for Twhere
T: Clone + AnyExtractCoreItem,
Source§impl<T> TransformedExt for T
impl<T> TransformedExt for T
Source§fn transformed<G>(self, transform: G) -> Transformed<Self, G>
fn transformed<G>(self, transform: G) -> Transformed<Self, G>
self wrapped with transform stored exactly as G.Source§impl<T> UniformScaleTransform for T
impl<T> UniformScaleTransform for T
Source§fn scale_uniform(&mut self, s: f64) -> &mut T
fn scale_uniform(&mut self, s: f64) -> &mut T
s (at origin).