mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
fix
This commit is contained in:
parent
3edd35aa42
commit
df87702875
5 changed files with 13 additions and 22 deletions
|
@ -132,10 +132,6 @@ fn update_hit_result_component(
|
|||
z: position.z,
|
||||
};
|
||||
let end_position = eye_position + view_vector * pick_range;
|
||||
println!(
|
||||
"eye_position: {:?}, end_position: {:?}",
|
||||
eye_position, end_position
|
||||
);
|
||||
let instance_lock = instance_container
|
||||
.get(world_name)
|
||||
.expect("entities must always be in a valid world");
|
||||
|
|
|
@ -243,14 +243,13 @@ impl AABB {
|
|||
|
||||
for aabb in boxes {
|
||||
dir = Self::get_direction(
|
||||
&aabb.move_relative(&pos.to_vec3()),
|
||||
&aabb.move_relative(&pos.to_vec3_floored()),
|
||||
from,
|
||||
&mut t,
|
||||
dir,
|
||||
&delta,
|
||||
);
|
||||
}
|
||||
println!("dir: {dir:?} delta: {delta:?}");
|
||||
let dir = dir?;
|
||||
Some(BlockHitResult {
|
||||
location: from + &(delta * t),
|
||||
|
@ -388,17 +387,17 @@ impl AABB {
|
|||
}
|
||||
|
||||
fn clip_point(opts: ClipPointOpts) -> Option<Direction> {
|
||||
let t_x = (opts.min_x - opts.start.x) / opts.delta.x;
|
||||
let t_y = (opts.start.y + t_x) * opts.delta.y;
|
||||
let t_z = (opts.start.z + t_x) * opts.delta.z;
|
||||
if 0.0 < t_x
|
||||
&& t_x < *opts.t
|
||||
&& opts.min_x - EPSILON < t_y
|
||||
&& t_y < opts.max_x + EPSILON
|
||||
&& opts.min_z - EPSILON < t_z
|
||||
&& t_z < opts.max_z + EPSILON
|
||||
let d = (opts.begin - opts.start.x) / opts.delta.x;
|
||||
let e = opts.start.y + d * opts.delta.y;
|
||||
let f = opts.start.z + d * opts.delta.z;
|
||||
if 0.0 < d
|
||||
&& d < *opts.t
|
||||
&& opts.min_x - EPSILON < e
|
||||
&& e < opts.max_x + EPSILON
|
||||
&& opts.min_z - EPSILON < f
|
||||
&& f < opts.max_z + EPSILON
|
||||
{
|
||||
*opts.t = t_x;
|
||||
*opts.t = d;
|
||||
Some(opts.result_dir)
|
||||
} else {
|
||||
opts.approach_dir
|
||||
|
@ -457,7 +456,7 @@ mod tests {
|
|||
max_y: 1.,
|
||||
max_z: 1.,
|
||||
}],
|
||||
&Vec3::new(0., 0., 0.),
|
||||
&Vec3::new(-1., -1., -1.),
|
||||
&Vec3::new(1., 1., 1.),
|
||||
&BlockPos::new(0, 0, 0),
|
||||
),
|
||||
|
|
|
@ -153,7 +153,7 @@ impl BlockPos {
|
|||
}
|
||||
|
||||
/// Convert the block position into a Vec3 without centering it.
|
||||
pub fn to_vec3(&self) -> Vec3 {
|
||||
pub fn to_vec3_floored(&self) -> Vec3 {
|
||||
Vec3 {
|
||||
x: self.x as f64,
|
||||
y: self.y as f64,
|
||||
|
|
|
@ -68,7 +68,6 @@ pub fn clip(chunk_storage: &ChunkStorage, context: ClipContext) -> BlockHitResul
|
|||
block_shape,
|
||||
&block_state,
|
||||
);
|
||||
println!("block_pos: {block_pos:?} block_hit_result: {block_hit_result:?}");
|
||||
// let block_distance = if let Some(block_hit_result) = block_hit_result {
|
||||
// context.from.distance_to_sqr(&block_hit_result.location)
|
||||
// } else {
|
||||
|
|
|
@ -394,12 +394,10 @@ impl VoxelShape {
|
|||
|
||||
pub fn clip(&self, from: &Vec3, to: &Vec3, block_pos: &BlockPos) -> Option<BlockHitResult> {
|
||||
if self.is_empty() {
|
||||
println!("empty");
|
||||
return None;
|
||||
}
|
||||
let vector = to - from;
|
||||
if vector.length_sqr() < EPSILON {
|
||||
println!("short {}", vector.length_sqr());
|
||||
return None;
|
||||
}
|
||||
let right_after_start = from + &(vector * 0.0001);
|
||||
|
@ -417,7 +415,6 @@ impl VoxelShape {
|
|||
miss: false,
|
||||
})
|
||||
} else {
|
||||
println!("clip iterable {}", vector.length_sqr());
|
||||
AABB::clip_iterable(&self.to_aabbs(), &from, &to, &block_pos)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue