ios - 使用类别位掩码无法阻止物理场与粒子系统相互作用

标签 ios swift xcode scenekit arkit

我想将具有相应场的多个粒子系统放置到一个场景中并在它们之间切换。这些场应该只与特定的粒子系统相互作用。我无法使用 Xcode SceneKit 文档生成器来执行此操作。

根据 Apple 文档:

To determine whether a field affects a physics body, SceneKit performs a bitwise AND operation on the field’s category bit mask and the body’s categoryBitMask property. If the result is a nonzero value, SceneKit computes and applies the force of the field on the body. To determine whether a field affects the particles spawned by an SCNParticleSystem object, SceneKit performs the same check using the categoryBitMask property of the node containing the particle system.

Use this property to create fields which affect only certain bodies in your scene. Reducing the number of bodies affected by fields can also improve simulation performance.

我创建了一个简单的场景文件,其中包含:

  • 线性重力场。它的类别位掩码在节点检查器中设置为 2。
  • 一个节点。它的类别位掩码在节点检查器中设置为 4。
  • 一个球形粒子系统,位于上述节点内。受物理场影响选项已选中。类别位掩码在节点检查器中保留为 1。

我将类别位掩码设置为什么并不重要。物理场总是与粒子系统相互作用。我还尝试在 Playground 中以编程方式将位掩码设置为具有 3 个粒子系统的单独文件,每个系统有一个字段,但没有成功。使用:

let effect1Mask = 0x1 << 1
let effect2Mask = 0x1 << 2
let effect3Mask = 0x1 << 3

最佳答案

我发现类别位掩码无法在场景图生成器内的物理场上设置,它不会公开。它必须以编程方式设置。我在物理场节点上设置了 mask ,因此它不起作用。

关于ios - 使用类别位掩码无法阻止物理场与粒子系统相互作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52211690/

相关文章:

ios - 为什么我不能在 XCode 4.1 中运行该项目?

ios - 滚动到启用分页的 UICollectionView 中的页面

ios - 如何在 SignalProducer 上映射值和错误

ios - UIView 中的 UISegmentedControl 不响应更改事件

iphone - 更改子类的方法名称

swift - 以编程方式触发的 segue 后显示的 View 不会立即更新

ios - Xcode 12.5 : SPM Dependency Cache Location

swift - 类似于 Finder 应用程序 NSOutlineView Cocoa Swift 的拖放

ios - 在 swift3 中看到 UILocalNotification 后如何取消或删除?

ios - 如何在 Swift 中使用dispatch_async?