mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed volume mount orientation
This commit is contained in:
parent
9127d6cbf2
commit
4fa799e7c7
@ -227,7 +227,7 @@
|
|||||||
13: Air(Window1, 2),
|
13: Air(Window1, 2),
|
||||||
14: Air(Crate, 0),
|
14: Air(Crate, 0),
|
||||||
15: Air(Cauldron, 2),
|
15: Air(Cauldron, 2),
|
||||||
16: Air(Tent, 0),
|
16: Air(ChairSingle, 0),
|
||||||
17: Air(CookingPot, 0),
|
17: Air(CookingPot, 0),
|
||||||
18: Air(WallLampSmall, 4),
|
18: Air(WallLampSmall, 4),
|
||||||
19: Air(Lantern, 4),
|
19: Air(Lantern, 4),
|
||||||
|
BIN
assets/common/voxel/carriage/structure.vox
(Stored with Git LFS)
BIN
assets/common/voxel/carriage/structure.vox
(Stored with Git LFS)
Binary file not shown.
@ -211,10 +211,11 @@ impl VolumePos {
|
|||||||
uid_allocator: &UidAllocator,
|
uid_allocator: &UidAllocator,
|
||||||
mut read_pos_and_ori: impl FnMut(Entity) -> Option<(comp::Pos, comp::Ori)>,
|
mut read_pos_and_ori: impl FnMut(Entity) -> Option<(comp::Pos, comp::Ori)>,
|
||||||
colliders: &ReadStorage<comp::Collider>,
|
colliders: &ReadStorage<comp::Collider>,
|
||||||
) -> Option<(Mat4<f32>, Block)> {
|
) -> Option<(Mat4<f32>, comp::Ori, Block)> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
Volume::Terrain => Some((
|
Volume::Terrain => Some((
|
||||||
Mat4::translation_3d(self.pos.as_()),
|
Mat4::translation_3d(self.pos.as_()),
|
||||||
|
comp::Ori::default(),
|
||||||
*terrain.get(self.pos).ok()?,
|
*terrain.get(self.pos).ok()?,
|
||||||
)),
|
)),
|
||||||
Volume::Entity(uid) => {
|
Volume::Entity(uid) => {
|
||||||
@ -234,7 +235,7 @@ impl VolumePos {
|
|||||||
let trans = Mat4::from(ori.to_quat()).translated_3d(pos.0)
|
let trans = Mat4::from(ori.to_quat()).translated_3d(pos.0)
|
||||||
* Mat4::<f32>::translation_3d(local_translation);
|
* Mat4::<f32>::translation_3d(local_translation);
|
||||||
|
|
||||||
Some((trans, block))
|
Some((trans, ori, block))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -642,7 +642,9 @@ pub fn handle_orientation(
|
|||||||
// very rough guess
|
// very rough guess
|
||||||
let ticks_from_target_guess = ori_absdiff(&update.ori, &target_ori) / half_turns_per_tick;
|
let ticks_from_target_guess = ori_absdiff(&update.ori, &target_ori) / half_turns_per_tick;
|
||||||
let instantaneous = ticks_from_target_guess < 1.0;
|
let instantaneous = ticks_from_target_guess < 1.0;
|
||||||
update.ori = if instantaneous {
|
update.ori = if data.volume_mount_data.is_some() {
|
||||||
|
update.ori
|
||||||
|
} else if instantaneous {
|
||||||
target_ori
|
target_ori
|
||||||
} else {
|
} else {
|
||||||
let target_fraction = {
|
let target_fraction = {
|
||||||
|
@ -103,7 +103,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
// For each volume rider.
|
// For each volume rider.
|
||||||
for (entity, is_volume_rider) in (&entities, &is_volume_riders).join() {
|
for (entity, is_volume_rider) in (&entities, &is_volume_riders).join() {
|
||||||
if let Some((mut mat, _)) = is_volume_rider.pos.get_block_and_transform(
|
if let Some((mut mat, volume_ori, _)) = is_volume_rider.pos.get_block_and_transform(
|
||||||
&terrain,
|
&terrain,
|
||||||
&uid_allocator,
|
&uid_allocator,
|
||||||
|e| positions.get(e).copied().zip(orientations.get(e).copied()),
|
|e| positions.get(e).copied().zip(orientations.get(e).copied()),
|
||||||
@ -114,21 +114,27 @@ impl<'a> System<'a> for Sys {
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ori) = is_volume_rider.block.get_ori() {
|
let mount_block_ori = if let Some(ori) = is_volume_rider.block.get_ori() {
|
||||||
mat *= Mat4::identity()
|
mat *= Mat4::identity()
|
||||||
.translated_3d(mount_offset)
|
.translated_3d(mount_offset)
|
||||||
.rotated_z(std::f32::consts::PI * 0.25 * ori as f32)
|
.rotated_z(std::f32::consts::PI * 0.25 * ori as f32)
|
||||||
.translated_3d(Vec3::new(0.5, 0.5, 0.0));
|
.translated_3d(Vec3::new(0.5, 0.5, 0.0));
|
||||||
|
ori
|
||||||
} else {
|
} else {
|
||||||
mat *= Mat4::identity().translated_3d(mount_offset + Vec3::new(0.5, 0.5, 0.0));
|
mat *= Mat4::identity().translated_3d(mount_offset + Vec3::new(0.5, 0.5, 0.0));
|
||||||
}
|
0
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(pos) = positions.get_mut(entity) {
|
if let Some(pos) = positions.get_mut(entity) {
|
||||||
pos.0 = mat.mul_point(Vec3::zero());
|
pos.0 = mat.mul_point(Vec3::zero());
|
||||||
}
|
}
|
||||||
if let Some(ori) = orientations.get_mut(entity) {
|
if let Some(ori) = orientations.get_mut(entity) {
|
||||||
*ori = Ori::from_unnormalized_vec(mat.mul_direction(mount_dir))
|
*ori = volume_ori.rotated(
|
||||||
.unwrap_or_default();
|
Ori::from_unnormalized_vec(mount_dir)
|
||||||
|
.unwrap_or_default()
|
||||||
|
.to_quat()
|
||||||
|
.rotated_z(std::f32::consts::PI * 0.25 * mount_block_ori as f32),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let v = match is_volume_rider.pos.kind {
|
let v = match is_volume_rider.pos.kind {
|
||||||
|
@ -158,7 +158,7 @@ pub fn handle_mount_volume(server: &mut Server, rider: EcsEntity, volume_pos: Vo
|
|||||||
&state.read_storage(),
|
&state.read_storage(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some((mat, block)) = block_transform
|
if let Some((mat, _, block)) = block_transform
|
||||||
&& let Some(mount_offset) = block.mount_offset() {
|
&& let Some(mount_offset) = block.mount_offset() {
|
||||||
let mount_pos = (mat * mount_offset.0.with_w(1.0)).xyz();
|
let mount_pos = (mat * mount_offset.0.with_w(1.0)).xyz();
|
||||||
let within_range = {
|
let within_range = {
|
||||||
|
@ -801,7 +801,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
|||||||
},
|
},
|
||||||
&state.read_storage(),
|
&state.read_storage(),
|
||||||
)
|
)
|
||||||
.map(|(mat, _)| mat.mul_point(Vec3::broadcast(0.5)))
|
.map(|(mat, _, _)| mat.mul_point(Vec3::broadcast(0.5)))
|
||||||
});
|
});
|
||||||
if !in_range {
|
if !in_range {
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -2042,7 +2042,7 @@ impl Hud {
|
|||||||
|
|
||||||
// Render overtime for an interactable block
|
// Render overtime for an interactable block
|
||||||
if let Some(Interactable::Block(block, pos, interaction)) = interactable
|
if let Some(Interactable::Block(block, pos, interaction)) = interactable
|
||||||
&& let Some((mat, _)) = pos.get_block_and_transform(
|
&& let Some((mat, _, _)) = pos.get_block_and_transform(
|
||||||
&ecs.read_resource(),
|
&ecs.read_resource(),
|
||||||
&ecs.read_resource(),
|
&ecs.read_resource(),
|
||||||
|e| ecs.read_storage::<vcomp::Interpolated>().get(e).map(|interpolated| (comp::Pos(interpolated.pos), interpolated.ori)),
|
|e| ecs.read_storage::<vcomp::Interpolated>().get(e).map(|interpolated| (comp::Pos(interpolated.pos), interpolated.ori)),
|
||||||
@ -4751,7 +4751,7 @@ impl Hud {
|
|||||||
},
|
},
|
||||||
&client.state().read_storage(),
|
&client.state().read_storage(),
|
||||||
)
|
)
|
||||||
.map_or(false, |(mat, block)| {
|
.map_or(false, |(mat, _, block)| {
|
||||||
block.get_sprite() == Some(*sprite)
|
block.get_sprite() == Some(*sprite)
|
||||||
&& mat.mul_point(Vec3::broadcast(0.5)).distance(player_pos)
|
&& mat.mul_point(Vec3::broadcast(0.5)).distance(player_pos)
|
||||||
< MAX_PICKUP_RANGE
|
< MAX_PICKUP_RANGE
|
||||||
|
Loading…
Reference in New Issue
Block a user