@@ -269,12 +269,20 @@ public <S extends SubLevelAccess> boolean findIncludingSubLevels(final Level lev
269269 );
270270 }
271271
272+ @ Override
273+ public double distanceSquaredWithSubLevels (final Level level , final Vector3dc a , final Vector3dc b ) {
274+ final Vector3dc globalA = this .projectOutOfSubLevel (level , a , new Vector3d ());
275+ final Vector3dc globalB = this .projectOutOfSubLevel (level , b , new Vector3d ());
276+
277+ return globalA .distanceSquared (globalB );
278+ }
279+
272280 @ Override
273281 public double distanceSquaredWithSubLevels (final Level level , final Position a , final Position b ) {
274- final Vec3 globalA = this .projectOutOfSubLevel (level , a );
275- final Vec3 globalB = this .projectOutOfSubLevel (level , b );
282+ final Vector3dc globalA = this .projectOutOfSubLevel (level , JOMLConversion . toJOML ( a ) );
283+ final Vector3dc globalB = this .projectOutOfSubLevel (level , JOMLConversion . toJOML ( b ) );
276284
277- return globalA .distanceToSqr (globalB );
285+ return globalA .distanceSquared (globalB );
278286 }
279287
280288 @ Override
@@ -301,12 +309,51 @@ public double distanceSquaredWithSubLevels(final Level level, final double aX, f
301309 return globalA .distanceSquared (globalB );
302310 }
303311
312+ private static double rectilinearDistance (final Vector3dc a , final Vector3dc b ) {
313+ final double d0 = Math .abs (b .x () - a .x ());
314+ final double d1 = Math .abs (b .y () - a .y ());
315+ final double d2 = Math .abs (b .z () - a .z ());
316+ return Math .max (d0 , Math .max (d1 , d2 ));
317+ }
318+
304319 @ Override
305- public double distanceSquaredWithSubLevels (final Level level , final Vector3dc a , final Vector3dc b ) {
320+ public double rectilinearDistanceWithSubLevels (final Level level , final Vector3dc a , final Vector3dc b ) {
306321 final Vector3dc globalA = this .projectOutOfSubLevel (level , a , new Vector3d ());
307322 final Vector3dc globalB = this .projectOutOfSubLevel (level , b , new Vector3d ());
308323
309- return globalA .distanceSquared (globalB );
324+ return rectilinearDistance (globalA , globalB );
325+ }
326+
327+ @ Override
328+ public double rectilinearDistanceWithSubLevels (final Level level , final Position a , final Position b ) {
329+ final Vector3dc globalA = this .projectOutOfSubLevel (level , JOMLConversion .toJOML (a ));
330+ final Vector3dc globalB = this .projectOutOfSubLevel (level , JOMLConversion .toJOML (b ));
331+
332+ return rectilinearDistance (globalA , globalB );
333+ }
334+
335+ @ Override
336+ public double rectilinearDistanceWithSubLevels (final Level level , final Vector3dc a , final double bX , final double bY , final double bZ ) {
337+ final Vector3dc globalA = this .projectOutOfSubLevel (level , a , new Vector3d ());
338+ final Vector3dc globalB = this .projectOutOfSubLevel (level , new Vector3d (bX , bY , bZ ));
339+
340+ return rectilinearDistance (globalA , globalB );
341+ }
342+
343+ @ Override
344+ public double rectilinearDistanceWithSubLevels (final Level level , final Position a , final double bX , final double bY , final double bZ ) {
345+ final Vector3dc globalA = this .projectOutOfSubLevel (level , JOMLConversion .toJOML (a ));
346+ final Vector3dc globalB = this .projectOutOfSubLevel (level , new Vector3d (bX , bY , bZ ));
347+
348+ return rectilinearDistance (globalA , globalB );
349+ }
350+
351+ @ Override
352+ public double rectilinearDistanceWithSubLevels (final Level level , final double aX , final double aY , final double aZ , final double bX , final double bY , final double bZ ) {
353+ final Vector3dc globalA = this .projectOutOfSubLevel (level , new Vector3d (aX , aY , aZ ));
354+ final Vector3dc globalB = this .projectOutOfSubLevel (level , new Vector3d (bX , bY , bZ ));
355+
356+ return rectilinearDistance (globalA , globalB );
310357 }
311358
312359 @ Override
0 commit comments