Class MortonCode

java.lang.Object
com.hypixel.hytale.component.spatial.MortonCode

public class MortonCode extends Object
Morton code (Z-order curve) utility for spatial indexing.

Converts 3D coordinates into 64-bit Morton codes that preserve spatial locality.

Thhe Morton code interleaves the bits of x, y, z coordinates. z_20 y_20 x_20 z_19 y_19 x_19 ... z_1 y_1 x_1 z_0 y_0 x_0

This ensures that points close in 3D space have similar Morton codes.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static long
    encode(double x, double y, double z, double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
    Encodes 3D coordinates into a 64-bit Morton code.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MortonCode

      public MortonCode()
  • Method Details

    • encode

      public static long encode(double x, double y, double z, double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
      Encodes 3D coordinates into a 64-bit Morton code.

      The position is normalized to the given bounding box [min, max] before encoding.

      Parameters:
      x - x-coordinate
      y - y-coordinate
      z - z-coordinate
      minX - minimum x bound (for normalization)
      minY - minimum y bound (for normalization)
      minZ - minimum z bound (for normalization)
      maxX - maximum x bound (for normalization)
      maxY - maximum y bound (for normalization)
      maxZ - maximum z bound (for normalization)
      Returns:
      64-bit Morton code