@@ -92,7 +92,7 @@ fn find_face_collision(
9292 // Find a normal to the grid plane. Note that (t, 0, 0, x) is a normal of the plane whose closest point
9393 // to the origin is (x, 0, 0, t), and we use that fact here.
9494 let normal = math:: tuv_to_xyz ( t_axis, MVector :: new ( 1.0 , 0.0 , 0.0 , layout. grid_to_dual ( t) ) )
95- . lorentz_normalize ( ) ;
95+ . normalized ( ) ;
9696
9797 let Some ( new_tanh_distance) =
9898 ray. solve_sphere_plane_intersection ( & normal, collider_radius. sinh ( ) )
@@ -170,12 +170,12 @@ fn find_edge_collision(
170170 // Compute vectors Lorentz-orthogonal to the edge and to each other
171171 let edge_normal0 =
172172 math:: tuv_to_xyz ( t_axis, MVector :: new ( 0.0 , 1.0 , 0.0 , layout. grid_to_dual ( u) ) )
173- . lorentz_normalize ( ) ;
173+ . normalized ( ) ;
174174
175175 let edge_normal1 =
176176 math:: tuv_to_xyz ( t_axis, MVector :: new ( 0.0 , 0.0 , 1.0 , layout. grid_to_dual ( v) ) ) ;
177177 let edge_normal1 =
178- ( edge_normal1 - edge_normal0 * edge_normal0. mip ( & edge_normal1) ) . lorentz_normalize ( ) ;
178+ ( edge_normal1 - edge_normal0 * edge_normal0. mip ( & edge_normal1) ) . normalized ( ) ;
179179
180180 let Some ( new_tanh_distance) = ray. solve_sphere_line_intersection (
181181 & edge_normal0,
@@ -248,19 +248,17 @@ fn find_vertex_collision(
248248 }
249249
250250 // Compute vectors Lorentz-orthogonal to the vertex and to each other
251- let vertex_normal0 =
252- MVector :: new ( 1.0 , 0.0 , 0.0 , layout. grid_to_dual ( x) ) . lorentz_normalize ( ) ;
251+ let vertex_normal0 = MVector :: new ( 1.0 , 0.0 , 0.0 , layout. grid_to_dual ( x) ) . normalized ( ) ;
253252
254253 let vertex_normal1 = MVector :: new ( 0.0 , 1.0 , 0.0 , layout. grid_to_dual ( y) ) ;
255- let vertex_normal1 = ( vertex_normal1
256- - vertex_normal0 * vertex_normal0. mip ( & vertex_normal1) )
257- . lorentz_normalize ( ) ;
254+ let vertex_normal1 =
255+ ( vertex_normal1 - vertex_normal0 * vertex_normal0. mip ( & vertex_normal1) ) . normalized ( ) ;
258256
259257 let vertex_normal2 = MVector :: new ( 0.0 , 0.0 , 1.0 , layout. grid_to_dual ( z) ) ;
260258 let vertex_normal2 = ( vertex_normal2
261259 - vertex_normal0 * vertex_normal0. mip ( & vertex_normal2)
262260 - vertex_normal1 * vertex_normal1. mip ( & vertex_normal2) )
263- . lorentz_normalize ( ) ;
261+ . normalized ( ) ;
264262
265263 let Some ( new_tanh_distance) = ray. solve_sphere_point_intersection (
266264 & vertex_normal0,
@@ -283,7 +281,7 @@ fn find_vertex_collision(
283281 layout. grid_to_dual ( z) ,
284282 1.0 ,
285283 )
286- . lorentz_normalize ( ) ;
284+ . normalized ( ) ;
287285
288286 // A collision was found. Update the hit.
289287 let ray_endpoint = ray. ray_point ( new_tanh_distance) ;
@@ -306,7 +304,7 @@ fn voxel_is_solid(voxel_data: &VoxelData, layout: &ChunkLayout, coords: [u8; 3])
306304
307305#[ cfg( test) ]
308306mod tests {
309- use crate :: node:: VoxelData ;
307+ use crate :: { math :: MIsometry , node:: VoxelData } ;
310308
311309 use super :: * ;
312310
@@ -357,20 +355,20 @@ mod tests {
357355 ray_start_grid_coords[ 2 ] / ctx. layout . dual_to_grid_factor ( ) ,
358356 1.0 ,
359357 )
360- . lorentz_normalize ( ) ;
358+ . normalized ( ) ;
361359
362360 let ray_end = MVector :: new (
363361 ray_end_grid_coords[ 0 ] / ctx. layout . dual_to_grid_factor ( ) ,
364362 ray_end_grid_coords[ 1 ] / ctx. layout . dual_to_grid_factor ( ) ,
365363 ray_end_grid_coords[ 2 ] / ctx. layout . dual_to_grid_factor ( ) ,
366364 1.0 ,
367365 )
368- . lorentz_normalize ( ) ;
366+ . normalized ( ) ;
369367
370368 let ray = Ray :: new (
371369 ray_start,
372370 ( ( ray_end - ray_start) + ray_start * ray_start. mip ( & ( ray_end - ray_start) ) )
373- . lorentz_normalize ( ) ,
371+ . normalized ( ) ,
374372 ) ;
375373
376374 let tanh_distance = ( -ray_start. mip ( & ray_end) ) . acosh ( ) ;
@@ -511,14 +509,14 @@ mod tests {
511509 /// Ensures that the normal is pointing outward, opposite the ray direction.
512510 fn sanity_check_normal ( ray : & Ray , hit : & ChunkCastHit ) {
513511 // The ray we care about is after its start point has moved to the contact point.
514- let ray = math :: translate (
512+ let ray = MIsometry :: translation (
515513 & ray. position ,
516- & ray. ray_point ( hit. tanh_distance ) . lorentz_normalize ( ) ,
514+ & ray. ray_point ( hit. tanh_distance ) . normalized ( ) ,
517515 ) * ray;
518516
519517 // Project normal to be perpendicular to the ray's position
520518 let corrected_normal =
521- ( hit. normal + ray. position * hit. normal . mip ( & ray. position ) ) . lorentz_normalize ( ) ;
519+ ( hit. normal + ray. position * hit. normal . mip ( & ray. position ) ) . normalized ( ) ;
522520
523521 // Check that the normal and ray are pointing opposite directions
524522 assert ! ( corrected_normal. mip( & ray. direction) < 0.0 ) ;
0 commit comments