Changed touch_entities from a vec to a hashset.

This commit is contained in:
Sam 2021-04-03 14:50:06 -04:00
parent 8d9f63404e
commit 18eed650f4
2 changed files with 3 additions and 5 deletions

View File

@ -1,4 +1,5 @@
use crate::uid::Uid; use crate::uid::Uid;
use hashbrown::HashSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use specs::{Component, DerefFlaggedStorage, NullStorage}; use specs::{Component, DerefFlaggedStorage, NullStorage};
use specs_idvs::IdvStorage; use specs_idvs::IdvStorage;
@ -124,7 +125,7 @@ pub struct PhysicsState {
pub on_ground: bool, pub on_ground: bool,
pub on_ceiling: bool, pub on_ceiling: bool,
pub on_wall: Option<Vec3<f32>>, pub on_wall: Option<Vec3<f32>>,
pub touch_entities: Vec<Uid>, pub touch_entities: HashSet<Uid>,
pub in_liquid: Option<f32>, // Depth pub in_liquid: Option<f32>, // Depth
pub ground_vel: Vec3<f32>, pub ground_vel: Vec3<f32>,
} }

View File

@ -398,7 +398,7 @@ impl<'a> PhysicsData<'a> {
+ z_limits_other.1 * previous_cache_other.scale + z_limits_other.1 * previous_cache_other.scale
{ {
if !collided { if !collided {
physics.touch_entities.push(*other); physics.touch_entities.insert(*other);
entity_entity_collisions += 1; entity_entity_collisions += 1;
} }
@ -988,9 +988,6 @@ impl<'a> PhysicsData<'a> {
.on_wall .on_wall
.map(|dir| ori_from.mul_direction(dir)) .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 = match (
physics_state.in_liquid, physics_state.in_liquid,
physics_state_delta.in_liquid, physics_state_delta.in_liquid,