Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ hematite-nbt = "0.4.1"
byteorder = "1.3.2"
nalgebra-glm = "0.4.0"
derive_more = "0.15.0"
smallvec = "0.6.10"
smallvec = "0.6.10"
hash32 = "0.1.0"
hash32-derive = "0.1.0"
2 changes: 2 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ extern crate feather_codegen;
extern crate num_derive;
#[macro_use]
extern crate smallvec;
#[macro_use]
extern crate hash32_derive;

extern crate nalgebra_glm as glm;

Expand Down
30 changes: 28 additions & 2 deletions core/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ impl Position {

glm::vec3(x, y, z)
}

pub fn as_vec(&self) -> DVec3 {
(*self).into()
}
}

impl Add<Vec3> for Position {
Expand All @@ -97,6 +101,17 @@ impl Add<Vec3> for Position {
}
}

impl Add<DVec3> for Position {
type Output = Position;

fn add(mut self, rhs: DVec3) -> Self::Output {
self.x += rhs.x;
self.y += rhs.y;
self.z += rhs.z;
self
}
}

impl Add<Position> for Position {
type Output = Position;

Expand All @@ -121,6 +136,17 @@ impl Sub<Vec3> for Position {
}
}

impl Sub<DVec3> for Position {
type Output = Position;

fn sub(mut self, vec: DVec3) -> Self::Output {
self.x -= vec.x;
self.y -= vec.y;
self.z -= vec.z;
self
}
}

impl Sub<Position> for Position {
type Output = Position;

Expand Down Expand Up @@ -170,13 +196,13 @@ fn square(x: f64) -> f64 {
x * x
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default, new)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Hash32, Default, new)]
pub struct ChunkPosition {
pub x: i32,
pub z: i32,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default, new)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Hash32, Default, new)]
pub struct BlockPosition {
pub x: i32,
pub y: i32,
Expand Down
1 change: 1 addition & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ base64 = "0.10.1"
bumpalo = "2.6.0"
thread_local = "0.3.6"
parking_lot = "0.9.0"
heapless = "0.5.0"

[features]
nightly = ["specs/nightly", "parking_lot/nightly"]
2 changes: 1 addition & 1 deletion server/src/entity/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> System<'a> for ItemSpawnSystem {
let mut pos = {
let player_pos = positions.get(event.player).unwrap().current
+ glm::vec3(0.0, PLAYER_EYE_HEIGHT, 0.0);
player_pos - glm::vec3(0.0, 0.3, 0.0)
player_pos - glm::vec3(0.0f64, 0.3, 0.0)
};

pos.on_ground = false;
Expand Down
2 changes: 1 addition & 1 deletion server/src/physics/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn bbox_for_type(ty: EntityType) -> Option<AABB<f64>> {
}

/// Returns a bounding box with the given width and height.
fn bbox(size_xz: f64, size_y: f64) -> AABB<f64> {
pub fn bbox(size_xz: f64, size_y: f64) -> AABB<f64> {
AABB::new(
glm::vec3(0.0, 0.0, 0.0).into(),
glm::vec3(size_xz, size_y, size_xz).into(),
Expand Down
Loading