Hi, I'm newbie of swift, iOS and this forum.
Although I've just already same reply in the following issue, my reply doesn't appear. So please let me ask here.
https://developer.apple.com/forums/thread/127384
GKOctree doesn't work at all. There seems to be many problems.
Here is reproduction code.
It generates these results in the following.
Results report that each point which added to GKOctree are not in each GTKOctreeNode.box.
And when code specifies box to get elements, it doesn't return any elements at all.
Would there be any wrong in above code?
I think It may be bugs.
Platform: iOS 14.2, Playground
Although I've just already same reply in the following issue, my reply doesn't appear. So please let me ask here.
https://developer.apple.com/forums/thread/127384
GKOctree doesn't work at all. There seems to be many problems.
Here is reproduction code.
Code Block swift import GameplayKit class point: NSObject { var vec: simd_float3 init(x: Float, y: Float, z: Float) { self.vec = simd_float3(x,y,z) } } func test () { let points = [ point(x: 1, y: 1, z: 2), point(x: 2, y: 2, z: 1), point(x: 2, y: 1, z: 1) ] let min = point(x:0, y: 0, z: 0) let max = point(x:3, y: 3, z: 3) let box = GKBox(boxMin: min.vec, boxMax: max.vec) let tree = GKOctree<point>(boundingBox: box, minimumCellSize: 0.01) print("=== registering ===") for p in points { let node = tree.add(p, at: p.vec) print("at:", p.vec, "box:", node.box) } // All print("=== list in elements(at:) ===") for p in tree.elements(at: points[0].vec) { print(p.vec) } print("=== elements(in:) ===") for p in tree.elements(in: box) { print(p.vec) } }
It generates these results in the following.
Code Block swift === registering === at: SIMD3<Float>(1.0, 1.0, 2.0) box: GKBox(boxMin: SIMD3<Float>(0.4921875, 0.99609375, 1.9921875), boxMax: SIMD3<Float>(0.50390625, 1.0078125, 2.0039062)) at: SIMD3<Float>(2.0, 2.0, 1.0) box: GKBox(boxMin: SIMD3<Float>(0.99609375, 1.9921875, 0.99609375), boxMax: SIMD3<Float>(1.0078125, 2.0039062, 1.0078125)) at: SIMD3<Float>(2.0, 1.0, 1.0) box: GKBox(boxMin: SIMD3<Float>(2.4960938, 0.99609375, 0.4921875), boxMax: SIMD3<Float>(2.5078125, 1.0078125, 0.50390625)) === list in elements(at:) === SIMD3<Float>(1.0, 1.0, 2.0) === elements(in:) ===
Results report that each point which added to GKOctree are not in each GTKOctreeNode.box.
And when code specifies box to get elements, it doesn't return any elements at all.
Would there be any wrong in above code?
I think It may be bugs.
Platform: iOS 14.2, Playground