@@ -86,10 +86,14 @@ val ChunkPos.center: ChunkPos
8686infix fun ChunkPos.dist (other : Vec3i ): Double = other dist this
8787infix fun ChunkPos.dist (other : Vec3d ): Double = other dist this
8888infix fun ChunkPos.dist (other : ChunkPos ): Double = sqrt((this distSq other).toDouble())
89+ infix fun ChunkPos.distCenter (other : Vec3i ): Double = sqrt((this distSqCenter other).toDouble())
90+ infix fun ChunkPos.distCenter (other : Vec3d ): Double = sqrt(this distSqCenter other)
8991infix fun ChunkPos.distCenter (other : ChunkPos ): Double = sqrt((this distSqCenter other).toDouble())
9092infix fun ChunkPos.distSq (other : Vec3i ): Int = other distSq this
9193infix fun ChunkPos.distSq (other : Vec3d ): Double = other distSq this
9294infix fun ChunkPos.distSq (other : ChunkPos ): Int = (other.x - x).sq + (other.z - z).sq
95+ infix fun ChunkPos.distSqCenter (other : Vec3i ): Int = (other.x - centerX).sq + (other.z - centerZ).sq
96+ infix fun ChunkPos.distSqCenter (other : Vec3d ): Double = (other.x - centerX).sq + (other.z - centerZ).sq
9397infix fun ChunkPos.distSqCenter (other : ChunkPos ): Int = (other.centerX - centerX).sq + (other.centerZ - centerZ).sq
9498
9599/* Vec3d */
@@ -117,7 +121,7 @@ infix fun Vec3d.dist(other: Vec3i): Double = sqrt(this distSq other)
117121infix fun Vec3d.dist (other : ChunkPos ): Double = sqrt(this distSq other)
118122infix fun Vec3d.distSq (other : Vec3d ): Double = (other.x - x).sq + (other.y - y).sq + (other.z - z).sq
119123infix fun Vec3d.distSq (other : Vec3i ): Double = (other.x - x).sq + (other.y - y).sq + (other.z - z).sq
120- infix fun Vec3d.distSq (other : ChunkPos ): Double = (other.x - x).sq + (other.z - z).sq
124+ infix fun Vec3d.distSq (other : ChunkPos ): Double = (other.x * 16 - x).sq + (other.z * 16 - z).sq
121125
122126infix operator fun Vec3d.plus (other : Vec3d ): Vec3d = add(other)
123127infix operator fun Vec3d.plus (other : Vec3i ): Vec3d = Vec3d (x + other.x, y + other.y, z + other.z)
@@ -166,7 +170,7 @@ infix fun Vec3i.dist(other: Vec3i): Double = sqrt((this distSq other).toDouble()
166170infix fun Vec3i.dist (other : ChunkPos ): Double = sqrt((this distSq other).toDouble())
167171infix fun Vec3i.distSq (other : Vec3d ): Double = getSquaredDistance(other)
168172infix fun Vec3i.distSq (other : Vec3i ): Int = (x - other.x).sq + (y - other.y).sq + (z - other.z).sq
169- infix fun Vec3i.distSq (other : ChunkPos ): Int = (other.x - x).sq + (other.z - z).sq
173+ infix fun Vec3i.distSq (other : ChunkPos ): Int = (other.x * 16 - x).sq + (other.z * 16 - z).sq
170174
171175infix operator fun Vec3i.plus (other : Vec3i ): Vec3i = add(other)
172176infix operator fun Vec3i.plus (other : Int ): Vec3i = add(other, other, other)
0 commit comments