Skip to content

Commit c852162

Browse files
committed
Fixed cylindrical
1 parent 387da2c commit c852162

File tree

3 files changed

+25
-24
lines changed

3 files changed

+25
-24
lines changed

pumpkin-world/src/cylindrical_chunk_iterator.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Cylindrical {
1919
old_cylindrical: Cylindrical,
2020
new_cylindrical: Cylindrical,
2121
mut newly_included: impl FnMut(Vector2<i32>),
22-
just_removed: impl FnMut(Vector2<i32>),
22+
mut just_removed: impl FnMut(Vector2<i32>),
2323
ignore: bool,
2424
) {
2525
let min_x = old_cylindrical.left().min(new_cylindrical.left());
@@ -29,26 +29,24 @@ impl Cylindrical {
2929

3030
for x in min_x..=max_x {
3131
for z in min_z..=max_z {
32-
// TODO
33-
// let old_is_within = if ignore {
34-
// false
35-
// } else {
36-
// old_cylindrical.is_within_distance(x, z)
37-
// };
38-
// let new_is_within = if ignore {
39-
// true
40-
// } else {
41-
// new_cylindrical.is_within_distance(x, z)
42-
// };
32+
let old_is_within = if ignore {
33+
false
34+
} else {
35+
old_cylindrical.is_within_distance(x, z)
36+
};
37+
let new_is_within = if ignore {
38+
true
39+
} else {
40+
new_cylindrical.is_within_distance(x, z)
41+
};
4342

44-
// if old_is_within != new_is_within {
45-
// if new_is_within {
46-
newly_included(Vector2::new(x, z));
47-
// } else {
48-
// dbg!("aa");
49-
// just_removed(Vector2::new(x, z));
50-
// }
51-
// }
43+
if old_is_within != new_is_within {
44+
if new_is_within {
45+
newly_included(Vector2::new(x, z));
46+
} else {
47+
just_removed(Vector2::new(x, z));
48+
}
49+
}
5250
}
5351
}
5452
}

pumpkin/src/entity/mod.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@ impl Entity {
101101
let block_pos = self.block_pos.load();
102102
let block_pos_vec = block_pos.0;
103103
if i != block_pos_vec.x || j != block_pos_vec.y || k != block_pos_vec.z {
104-
self.block_pos.store(WorldPosition(Vector3::new(i, j, k)));
104+
let new_block_pos = Vector3::new(i, j, k);
105+
self.block_pos.store(WorldPosition(new_block_pos));
105106

106107
let chunk_pos = self.chunk_pos.load();
107108
if get_section_cord(i) != chunk_pos.x || get_section_cord(k) != chunk_pos.z {
108109
self.chunk_pos.store(Vector2::new(
109-
get_section_cord(block_pos_vec.x),
110-
get_section_cord(block_pos_vec.z),
110+
get_section_cord(new_block_pos.x),
111+
get_section_cord(new_block_pos.z),
111112
));
112113
}
113114
}

pumpkin/src/world/player_chunker.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ pub async fn update_position(entity: &Entity, player: &Player) {
7979
view_distance,
8080
);
8181
let new_cylindrical =
82-
Cylindrical::new(Vector2::new(chunk_pos.x, chunk_pos.z), view_distance);
82+
Cylindrical::new(chunk_pos, view_distance);
83+
8384
player.watched_section.store(new_watched);
85+
8486
let mut loading_chunks = Vec::new();
8587
Cylindrical::for_each_changed_chunk(
8688
old_cylindrical,

0 commit comments

Comments
 (0)