Skip to content

Commit cb49b12

Browse files
committed
fix: block collisions on edge of block
1 parent 5a0698c commit cb49b12

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/hyperion/src/simulation/handlers.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ fn try_change_position(
120120
is_within_speed_limits(**position, proposed)?;
121121

122122
// Only check collision if we're starting outside a block
123-
if !has_collision(position, size, blocks) && has_collision(&proposed, size, blocks) {
123+
if !has_block_collision(position, size, blocks) && has_block_collision(&proposed, size, blocks)
124+
{
124125
return Err(anyhow::anyhow!("Cannot move into solid blocks"));
125126
}
126127

@@ -138,7 +139,7 @@ fn is_within_speed_limits(current: Vec3, proposed: Vec3) -> anyhow::Result<()> {
138139
Ok(())
139140
}
140141

141-
fn has_collision(position: &Vec3, size: EntitySize, blocks: &Blocks) -> bool {
142+
fn has_block_collision(position: &Vec3, size: EntitySize, blocks: &Blocks) -> bool {
142143
use std::ops::ControlFlow;
143144

144145
let (min, max) = block_bounds(*position, size);
@@ -421,7 +422,7 @@ pub fn player_interact_block(
421422

422423
// todo(hack): technically players can do some crazy position stuff to abuse this probably
423424
// let player_aabb = query.position.bounding.shrink(0.01);
424-
let player_aabb = aabb(**query.position, *query.size).shrink(0.01);
425+
let player_aabb = aabb(**query.position, *query.size);
425426

426427
let collides_player = block_state
427428
.collision_shapes()

0 commit comments

Comments
 (0)