Skip to content

Commit 7bbc4a9

Browse files
committed
feat: fixed ray perspective
1 parent 8fa2db0 commit 7bbc4a9

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/player.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use crate::{
1313
const SENSITIVITY: f32 = 0.001;
1414
const CAMERA_SPEED: f32 = 10.0;
1515
const GRAVITY: f32 = 10.0;
16-
pub static PLAYER_VIEW_OFFSET: Vec3 = vec3(0.4, 2.0, 0.4); /* this is kind of a hack, we should fix the camera's eye */
16+
pub static PLAYER_VIEW_OFFSET: Vec3 = vec3(0.4, 1.0, 0.4); /* this is kind of a hack, we should fix the camera's eye */
17+
1718
lazy_static! {
1819
static ref JUMP_DURATION: Duration = Duration::from_secs_f32(0.1);
1920
}
@@ -52,7 +53,7 @@ impl Player {
5253
pub fn get_collision(&self) -> crate::collision::CollisionBox {
5354
crate::collision::CollisionBox::new(
5455
self.camera.eye.x - 0.4,
55-
self.camera.eye.y - 1.0,
56+
self.camera.eye.y - 1.8,
5657
self.camera.eye.z - 0.4,
5758
0.8,
5859
2.0,
@@ -69,7 +70,7 @@ impl Player {
6970

7071
let ray = crate::collision::Ray {
7172
direction: forward,
72-
origin: self.camera.eye,
73+
origin: self.camera.eye + PLAYER_VIEW_OFFSET,
7374
};
7475

7576
for collision in collisions.iter() {

src/world.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@ use std::{
33
thread,
44
};
55

6-
use crate::player::PLAYER_VIEW_OFFSET;
7-
use crate::{
8-
blocks::block::Block,
9-
chunk::{BlockVec, Chunk},
10-
collision::CollisionBox,
11-
player::Player,
12-
utils::threadpool::ThreadPool,
13-
};
6+
use crate::{blocks::block::Block, chunk::Chunk, player::Player, utils::threadpool::ThreadPool};
147

158
pub const CHUNK_SIZE: u32 = 16;
169
pub const CHUNK_HEIGHT: u8 = u8::MAX;

0 commit comments

Comments
 (0)