From 18eed650f45da46ad0009d4433e7b08481581f3d Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 3 Apr 2021 14:50:06 -0400 Subject: [PATCH] Changed touch_entities from a vec to a hashset. --- common/src/comp/phys.rs | 3 ++- common/sys/src/phys.rs | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/common/src/comp/phys.rs b/common/src/comp/phys.rs index fb16b9e615..88a30b8040 100644 --- a/common/src/comp/phys.rs +++ b/common/src/comp/phys.rs @@ -1,4 +1,5 @@ use crate::uid::Uid; +use hashbrown::HashSet; use serde::{Deserialize, Serialize}; use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs_idvs::IdvStorage; @@ -124,7 +125,7 @@ pub struct PhysicsState { pub on_ground: bool, pub on_ceiling: bool, pub on_wall: Option>, - pub touch_entities: Vec, + pub touch_entities: HashSet, pub in_liquid: Option, // Depth pub ground_vel: Vec3, } diff --git a/common/sys/src/phys.rs b/common/sys/src/phys.rs index 6661d2f7a0..f090a6aaa6 100644 --- a/common/sys/src/phys.rs +++ b/common/sys/src/phys.rs @@ -398,7 +398,7 @@ impl<'a> PhysicsData<'a> { + z_limits_other.1 * previous_cache_other.scale { if !collided { - physics.touch_entities.push(*other); + physics.touch_entities.insert(*other); entity_entity_collisions += 1; } @@ -988,9 +988,6 @@ impl<'a> PhysicsData<'a> { .on_wall .map(|dir| ori_from.mul_direction(dir)) }); - physics_state - .touch_entities - .append(&mut physics_state_delta.touch_entities); physics_state.in_liquid = match ( physics_state.in_liquid, physics_state_delta.in_liquid,