最佳答案
我认为您必须使用 continuousCollisionDetectionThreshold
实例属性。该值为您提供了 body 必须移动的最小距离,SceneKit 才能应用更精确(但 CPU/GPU 成本更高)的算法来检测与其他 body 的接触。
var continuousCollisionDetectionThreshold: CGFloat { get set }
SceneKit's physics engine can employ two kinds of collision detection:
With
discrete collision
detection, when SceneKit simulates physics before rendering each frame (see timeStep and SCNSceneRendererDelegate), it updates the position of each physics body based on the body's velocity during that time interval, then checks to see whether the body at its new position intersects other bodies.With
continuous collision
detection, SceneKit calculates the volume that will be traversed by a body during each frame, then checks to see whether that volume intersects other bodies. This property's valuedefaults to 0.0
, resulting in discrete collision detection at all times. When this value is nonzero, SceneKit applies continuous collision whenever the body travels more than the specified distance within one timeStep.
离散碰撞检测提供了高性能,但对于小型、快速移动的物体可能会导致不准确的结果。连续碰撞检测具有性能成本并且仅适用于球形物理形状,但提供更准确的结果。
关于ios - SceneKit - 几何渗透,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55757715/