From 3b0d25646407e9b1d7e39dee1005d9a24e09ab66 Mon Sep 17 00:00:00 2001 From: rezural Date: Thu, 8 Jul 2021 11:04:06 +1000 Subject: make collider Option<> on EntityWithGraphics --- src_testbed/objects/node.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src_testbed/objects') diff --git a/src_testbed/objects/node.rs b/src_testbed/objects/node.rs index 47c9b41..9bbece2 100644 --- a/src_testbed/objects/node.rs +++ b/src_testbed/objects/node.rs @@ -23,7 +23,7 @@ pub struct EntityWithGraphics { pub entity: Entity, pub color: Point3, pub base_color: Point3, - pub collider: ColliderHandle, + pub collider: Option, pub delta: Isometry, pub opacity: f32, material: Handle, @@ -36,7 +36,7 @@ impl EntityWithGraphics { materials: &mut Assets, prefab_meshs: &HashMap>, shape: &dyn Shape, - collider: ColliderHandle, + collider: Option, collider_pos: Isometry, delta: Isometry, color: Point3, @@ -136,7 +136,7 @@ impl EntityWithGraphics { } pub fn update(&mut self, colliders: &ColliderSet, components: &mut Query<(&mut Transform,)>) { - if let Some(co) = colliders.get(self.collider) { + if let Some(Some(co)) = self.collider.map(|c| colliders.get(c)) { if let Ok(mut pos) = components.get_component_mut::(self.entity) { let co_pos = co.position() * self.delta; pos.translation.x = co_pos.translation.vector.x; @@ -159,7 +159,7 @@ impl EntityWithGraphics { } } - pub fn object(&self) -> ColliderHandle { + pub fn object(&self) -> Option { self.collider } -- cgit