What does the “simd” prefix mean in SceneKit?

后端 未结 2 554
鱼传尺愫
鱼传尺愫 2020-12-13 05:17

There is a SCNNode category named SCNNode(SIMD), which declares some properties like simdPosition, simdRotation and so on

2条回答
  •  盖世英雄少女心
    2020-12-13 05:36

    SIMD is a small library built on top of vector types that you can import from . It allows for more expressive and more performant code.

    For instance using SIMD you can write

    simd_float3 result = a + 2.0 * b;
    

    instead of

    SCNVector3 result = SCNVector3Make(a.x + 2.0 * b.x, a.y + 2.0 * b.y, a.z + 2.0 * b.z);
    

    In Objective-C you can not overload methods. That is you can not have both

    @property(nonatomic) SCNVector3 position;
    @property(nonatomic) simd_float3 position API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0));
    

    The new SIMD-based API needed a different name, and that's why SceneKit exposes simdPosition.

提交回复
热议问题