iOS 金属折线发散到某个遥远的点如何找到违规位置?

问题描述

我正在使用 Metal 渲染一百万个点的线条,并且它有效。但是,我看到随机线段发散到某个任意点(见截图)。

如何找到破坏线带渲染的点并将其从渲染中排除?

let particle = slice.rowParticleBuffer[pointIndex]

if particle.position.x.isNaN || particle.position.y.isNaN || particle.position.z.isNaN {
    print("x",terminator: "") //does not hit this
} else if fabsf(particle.position.x) > 10 || fabsf(particle.position.y) > 10 || fabsf(particle.position.z) > 10 {
    print("Z",terminator: "") //does not hit this either
} else {
    self.particlesBuffer[self.index] = slice.rowParticleBuffer[pointIndex]
    self.index += 1
}

enter image description here

enter image description here

解决方法

所以神奇的点变成了零,这是由索引错误引起的(代码跳过了一些索引,使主缓冲区的值为零)。

letparticle = slice.rowParticleBuffer[pointIndex]

Time     Count Hit
----     ----- ---
12:00 AM     2   
1:00 AM      2   
2:00 AM      1   

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...