pub trait HitDataExtra:
Any
+ Send
+ Sync
+ Debug { }Expand description
Extra data attached to a HitData by a picking backend.
Use this for backend-specific data like triangle indices, UVs, or material
information.
Any Send + Sync + fmt::Debug + 'static type implements this trait
automatically. Clone is not required: extra data is stored in an Arc,
so HitData can still implement Clone. Clone requires knowing the
size of the type, which is not possible with dynamically dispatched types,
so it cannot be used for dyn HitDataExtra.
#[derive(Debug)]
struct MyHitInfo { triangle_index: u32 }Read it back with HitData::extra_as:
fn read_extra(hit: &HitData) {
if let Some(info) = hit.extra_as::<MyHitInfo>() {
println!("Hit triangle {}", info.triangle_index);
}
}Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".