pub struct PerceptionSystem {
pub vision: VisionConfig,
pub hearing: HearingConfig,
pub smell: SmellConfig,
pub perceived: HashMap<u64, PerceivedEntity>,
pub confidence_decay: f32,
pub forget_threshold: f32,
pub observer_id: u64,
}Fields§
§vision: VisionConfig§hearing: HearingConfig§smell: SmellConfig§perceived: HashMap<u64, PerceivedEntity>§confidence_decay: f32§forget_threshold: f32§observer_id: u64Implementations§
Source§impl PerceptionSystem
impl PerceptionSystem
pub fn new(observer_id: u64) -> Self
Sourcepub fn can_see(
&self,
observer_pos: Vec3,
observer_forward: Vec3,
target_pos: Vec3,
target_velocity: Vec3,
obstacles: &[Aabb],
) -> (bool, f32)
pub fn can_see( &self, observer_pos: Vec3, observer_forward: Vec3, target_pos: Vec3, target_velocity: Vec3, obstacles: &[Aabb], ) -> (bool, f32)
Vision cone check with distance falloff
Sourcepub fn can_hear(
&self,
observer_pos: Vec3,
source_pos: Vec3,
sound_intensity: f32,
) -> (bool, f32)
pub fn can_hear( &self, observer_pos: Vec3, source_pos: Vec3, sound_intensity: f32, ) -> (bool, f32)
Hearing: sound attenuation model
Sourcepub fn can_smell(
&self,
observer_pos: Vec3,
source_pos: Vec3,
smell_intensity: f32,
) -> (bool, f32)
pub fn can_smell( &self, observer_pos: Vec3, source_pos: Vec3, smell_intensity: f32, ) -> (bool, f32)
Smell: wind-adjusted radius
pub fn update( &mut self, observer_pos: Vec3, observer_forward: Vec3, candidates: &[(u64, Vec3, Vec3, f32, f32, f32)], dt: f32, current_time: f32, obstacles: &[Aabb], )
pub fn most_threatening(&self) -> Option<&PerceivedEntity>
pub fn nearest_visible(&self, observer_pos: Vec3) -> Option<&PerceivedEntity>
Auto Trait Implementations§
impl Freeze for PerceptionSystem
impl RefUnwindSafe for PerceptionSystem
impl Send for PerceptionSystem
impl Sync for PerceptionSystem
impl Unpin for PerceptionSystem
impl UnsafeUnpin for PerceptionSystem
impl UnwindSafe for PerceptionSystem
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<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>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> 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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.