Change widthSegmentCount/heightSegmentCount on SCNPlane doesn't change vertex immediately
Originator: | JustZht | ||
Number: | rdar://39027796 | Date Originated: | March 30 2018, 1:33 PM |
Status: | DUPLICATE OF 22764475 | Resolved: | |
Product: | IOS SDK | Product Version: | 11.2.5 |
Classification: | Engineering has determined that your bug report is a duplicate of another issue and will be closed. | Reproducible: | YES |
Area: SceneKit Summary: I want to do terrain deform and I created a SCNPlane, change its segments on width & height to 149, the vertex count should be 150*150, but it returns 4. If I put a "Thread.Sleep" between the call, I get 22500. Steps to Reproduce: let GOLF_SITE_SQUARE_MESH_SEGMENTS_COUNT : Int = 149 let GOLF_SITE_SQUARE_MESH_SIZE : Float = 16000.0 var planeMeshGeometry : SCNPlane = SCNPlane(width: CGFloat(GOLF_SITE_SQUARE_MESH_SIZE), height: CGFloat(GOLF_SITE_SQUARE_MESH_SIZE)) planeMeshGeometry.widthSegmentCount = GOLF_SITE_SQUARE_MESH_SEGMENTS_COUNT planeMeshGeometry.heightSegmentCount = GOLF_SITE_SQUARE_MESH_SEGMENTS_COUNT planeMeshGeometry.cornerRadius = 0.0 //Thread.sleep(forTimeInterval: 0.1) var vertexSources : [SCNGeometrySource] = planeMeshGeometry.sources(for: .vertex) let vertexSource : SCNGeometrySource = vertexSources[0] var texCoordSources : [SCNGeometrySource] = planeMeshGeometry.sources(for: .texcoord) let texCorrdSource : SCNGeometrySource = texCoordSources[0] let stride : Int = vertexSource.dataStride let offest : Int = vertexSource.dataOffset let componentsPerVector : Int = vertexSource.componentsPerVector let bytesPerVector : Int = componentsPerVector * vertexSource.bytesPerComponent let vectorCount : Int = vertexSource.vectorCount print(vectorCount) var vertices : [SCNVector3] = [SCNVector3](repeatElement(SCNVector3(0,0,0), count: vectorCount)) for i in 0..<vectorCount { var vectorData : [Float] = [Float](repeatElement(0.0, count: 3)) let byteRange : NSRange = NSMakeRange(i * stride + offest, bytesPerVector) let vertexData = vertexSource.data as NSData vertexData.getBytes(&vectorData, range: byteRange) let x : Float = vectorData[0] let y : Float = vectorData[1] let xNormalized : Float = x / GOLF_SITE_SQUARE_MESH_SIZE + 0.5 let yNormalized : Float = 1 - (y / GOLF_SITE_SQUARE_MESH_SIZE + 0.5) let vectorToSample : vector_int2 = vector2(Int32(Int(xNormalized * Float(NOISE_SAMPLE_COUNT))), Int32(yNormalized * Float(NOISE_SAMPLE_COUNT))) let noiseValue : Float = (JZNoiseMapManager.shared.noiseMap.value(at: vectorToSample)) / 2.0 + 0.5 let newVector : SCNVector3 = SCNVector3 (vectorData[0],vectorData[1],noiseValue*GOLF_SITE_SQUARE_MESH_SIZE / 2.0*GOLF_SITE_HEIGHT_MULTIPIER) vertices[i] = newVector } Expected Results: print(vectorCount) should output 22500 on matter if the Thread.Sleep exists. Actual Results: print(vectorCount) = 4 when no sleep. print(vectorCount) = 22500 when sleep. Version/Build: Xcode 9.2 iOS 11.2.5 Configuration:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!