【问题标题】:Xcode 9: can't convert float3 to int3Xcode 9:无法将 float3 转换为 int3
【发布时间】:2017-06-07 15:56:34
【问题描述】:

尝试在 Xcode 9 中编译我的项目时,我收到从 float3int3 的转换错误。以下行现在无法编译:

var max : int3 = vector_int(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))

出现错误:

Use of unresolved identifier 'vector_int'

所以旧的转换函数vector_int 已经消失了。 “修复它”的建议也不起作用。

var max : int3 = vector_int3(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))

产量:

Cannot invoke initializer for type 'vector_int3' with an argument list of type '(float3)'

我可以编写自己的小转换函数,但肯定有内置的方法可以做到这一点,不是吗?

【问题讨论】:

    标签: swift xcode simd xcode9-beta


    【解决方案1】:

    vector_int 已被simd_int 取代:

    var max : int3 = simd_int(bounds.maxBounds * float3(1.0/8.0) + float3(1.0))
    

    【讨论】:

    • 要了解如何尽快学习和更新,我很好奇您是如何发现的?
    • @Honey,我使用了侦探技巧和运气。我在 Playground 中键入 vector_int3 并单击选项并看到: typealias vector_int3 = simd_int3 描述 三个 32 位有符号(二进制补码)整数的向量。这种类型已被弃用;您应该改用 simd_int3 或 simd::int3。 然后我想尝试使用 simd_int 代替 vector_int 并且它起作用了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-18
    • 2018-02-12
    • 1970-01-01
    • 2020-12-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多