pub struct SplatmapData {
pub dims: [u32; 2],
pub version: u64,
/* private fields */
}Expand description
Per-channel layer weights painted across the terrain.
rgba is held behind an Arc so consumers can clone the
SplatmapData per frame without copying the underlying bytes.
Edit by building a new Vec<u8> and calling
SplatmapData::replace, or by Arc::make_muting in place; in
either case bump version so the renderer
detects the change and re-uploads the texture.
Fields§
§dims: [u32; 2]Splatmap resolution (width, height).
version: u64Bumped by the consumer when rgba changes. The renderer
compares the stored version against the last upload to decide
whether to push new texture data; no byte-level comparison or
hashing happens on the hot path.
Implementations§
Source§impl SplatmapData
impl SplatmapData
Sourcepub fn new(rgba: Vec<u8>, dims: [u32; 2]) -> Self
pub fn new(rgba: Vec<u8>, dims: [u32; 2]) -> Self
Construct from an owned byte vector. The vector is moved into
an Arc<[u8]> so subsequent clones of the SplatmapData
share the bytes.
Sourcepub fn replace(&mut self, rgba: Vec<u8>, dims: [u32; 2])
pub fn replace(&mut self, rgba: Vec<u8>, dims: [u32; 2])
Replace the bytes with a new buffer. Bumps version so the
renderer re-uploads on the next frame.
Sourcepub fn empty() -> Self
pub fn empty() -> Self
A 1x1 splatmap with all-zero channels. Use this for the second splatmap when a terrain only uses layers 0..4.
Sourcepub fn solid_layer0() -> Self
pub fn solid_layer0() -> Self
A 1x1 splatmap that selects layer 0 (channel R) everywhere.
Sourcepub fn pack_layers(per_layer: &[Vec<u8>], dims: [u32; 2]) -> Option<[Self; 2]>
pub fn pack_layers(per_layer: &[Vec<u8>], dims: [u32; 2]) -> Option<[Self; 2]>
Pack per-layer single-channel weight maps into the two-splatmap DRAKE layout.
per_layer is one byte buffer per layer, each of length
dims[0] * dims[1], holding u8 weights in [0, 255]. Up to
the first eight layers are packed: layers 0..4 land in splatmap
A (channels R, G, B, A in that order); layers 4..8 land in
splatmap B. Missing trailing layers are zero-filled.
Returns None if any provided buffer has the wrong length or
per_layer is empty.
Trait Implementations§
Source§impl Clone for SplatmapData
impl Clone for SplatmapData
Source§fn clone(&self) -> SplatmapData
fn clone(&self) -> SplatmapData
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SplatmapData
impl RefUnwindSafe for SplatmapData
impl Send for SplatmapData
impl Sync for SplatmapData
impl Unpin for SplatmapData
impl UnsafeUnpin for SplatmapData
impl UnwindSafe for SplatmapData
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.