Merge branch 'zesterer/sceptre-raycast' into 'master'

Added raycast check to beams

See merge request veloren/veloren!1970
This commit is contained in:
Marcel 2021-03-23 09:43:46 +00:00
commit e73f634506
2 changed files with 14 additions and 2 deletions

View File

@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Server kicks old client when a user is trying to log in again (often the case when a user's original connection gets dropped) - Server kicks old client when a user is trying to log in again (often the case when a user's original connection gets dropped)
- Added a raycast check to beams to prevent their effect applying through walls
## [0.9.0] - 2021-03-20 ## [0.9.0] - 2021-03-20

View File

@ -6,14 +6,16 @@ use common::{
}, },
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
resources::{DeltaTime, Time}, resources::{DeltaTime, Time},
terrain::TerrainGrid,
uid::{Uid, UidAllocator}, uid::{Uid, UidAllocator},
vol::ReadVol,
GroupTarget, GroupTarget,
}; };
use common_ecs::{Job, Origin, ParMode, Phase, System}; use common_ecs::{Job, Origin, ParMode, Phase, System};
use rayon::iter::ParallelIterator; use rayon::iter::ParallelIterator;
use specs::{ use specs::{
saveload::MarkerAllocator, shred::ResourceId, Entities, Join, ParJoin, Read, ReadStorage, saveload::MarkerAllocator, shred::ResourceId, Entities, Join, ParJoin, Read, ReadExpect,
SystemData, World, WriteStorage, ReadStorage, SystemData, World, WriteStorage,
}; };
use std::time::Duration; use std::time::Duration;
use vek::*; use vek::*;
@ -24,6 +26,7 @@ pub struct ReadData<'a> {
server_bus: Read<'a, EventBus<ServerEvent>>, server_bus: Read<'a, EventBus<ServerEvent>>,
time: Read<'a, Time>, time: Read<'a, Time>,
dt: Read<'a, DeltaTime>, dt: Read<'a, DeltaTime>,
terrain: ReadExpect<'a, TerrainGrid>,
uid_allocator: Read<'a, UidAllocator>, uid_allocator: Read<'a, UidAllocator>,
uids: ReadStorage<'a, Uid>, uids: ReadStorage<'a, Uid>,
positions: ReadStorage<'a, Pos>, positions: ReadStorage<'a, Pos>,
@ -138,6 +141,14 @@ impl<'a> System<'a> for Sys {
// Collision shapes // Collision shapes
&& sphere_wedge_cylinder_collision(pos.0, frame_start_dist, frame_end_dist, *ori.look_dir(), beam_segment.angle, pos_b.0, rad_b, height_b); && sphere_wedge_cylinder_collision(pos.0, frame_start_dist, frame_end_dist, *ori.look_dir(), beam_segment.angle, pos_b.0, rad_b, height_b);
// Finally, ensure that a hit has actually occurred by performing a raycast. We do this last because
// it's likely to be the most expensive operation.
let tgt_dist = pos.0.distance(pos_b.0);
let hit = hit && read_data.terrain
.ray(pos.0, pos.0 + *ori.look_dir() * (tgt_dist + 1.0))
.until(|b| b.is_filled())
.cast().0 >= tgt_dist;
if hit { if hit {
// See if entities are in the same group // See if entities are in the same group
let same_group = group let same_group = group