SceneKit 对象在它们的边界框而不是沿着网格发生碰撞

SceneKit objects collide at their bounding box instead of along the mesh

我正在使用“DAE”模型作为 SCNGeometry。

尝试将其用作物理体形:

    let url = Bundle.main.url(forResource: "art.scnassets/half", withExtension: "dae")
    let sceneSource = SCNSceneSource(url: url!, options: nil)
    let tubeGeometry = (sceneSource?.entryWithIdentifier("Cube-mesh", withClass: SCNGeometry.self ))! as SCNGeometry
    
    tubeNode = SCNNode(geometry: tubeGeometry)
    tubeNode.position = SCNVector3(0, 1, 0)
    tubeNode.eulerAngles = SCNVector3Make(1.5, 2, 0)

    let tubeShape = SCNPhysicsShape(geometry: tubeGeometry, options: nil)
    let tubeBody = SCNPhysicsBody(type: .static, shape: tubeShape)
    tubeNode.physicsBody = tubeBody
    scene.rootNode.addChildNode(tubeNode)

不感知几何对象属性(边、面等)。 感知立方体的外观。 因此,球与一个不可见的平面发生碰撞,该平面不是我的对象,但必须向内落,如下面的屏幕截图所示:

有什么想法/建议吗? 请帮我解决这个问题...

提前致谢!

您需要将物理 body 形状配置为 "SCNPhysicsShapeTypeConcavePolyhedron"(默认为凸面)。您可以使用 SCNView 的 debugOptions 可视化物理形状