Skip to content

Commit 6971335

Browse files
Switch from using deprecated float3-style names to SIMD3<Float> in overlays. (#24743)
1 parent 2a87b68 commit 6971335

File tree

6 files changed

+67
-71
lines changed

6 files changed

+67
-71
lines changed

stdlib/public/Darwin/GameplayKit/GameplayKit.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import simd
2020
@available(tvOS, introduced: 9.0)
2121
extension GKPath {
2222
/// Creates a path from an array of points
23-
/// - Parameter points: an array of simd.float2 points to make a path from
23+
/// - Parameter points: an array of SIMD2<Float> points to make a path from
2424
/// - Parameter radius: radius of the path to create
2525
/// - Parameter cyclical: if the path is of a cycle that loops back on itself
26-
public convenience init(points: [simd.float2], radius: Float, cyclical: Bool) {
26+
public convenience init(points: [SIMD2<Float>], radius: Float, cyclical: Bool) {
2727
var variablePoints = points
2828
self.init(__points: &variablePoints, count: points.count, radius: radius, cyclical: cyclical)
2929
}
@@ -35,10 +35,10 @@ extension GKPath {
3535
@available(tvOS, introduced: 10.0)
3636
extension GKPath {
3737
/// Creates a path from an array of points
38-
/// - Parameter points: an array of simd.float3 points to make a path from
38+
/// - Parameter points: an array of SIMD3<Float> points to make a path from
3939
/// - Parameter radius: the radius of the path to create
4040
/// - Parameter cyclical: if the path is of a cycle that loops back on itself
41-
public convenience init(points: [simd.float3], radius: Float, cyclical: Bool) {
41+
public convenience init(points: [SIMD3<Float>], radius: Float, cyclical: Bool) {
4242
var variablePoints = points
4343
self.init(__float3Points: &variablePoints, count: points.count, radius: radius, cyclical: cyclical)
4444
}
@@ -50,7 +50,7 @@ extension GKPath {
5050
extension GKPolygonObstacle {
5151
/// Creates a polygon obstacle with an array of points.
5252
/// - Parameter points: array of points in counter-clockwise order that are the vertices of a convex polygon
53-
public convenience init(points: [simd.float2]) {
53+
public convenience init(points: [SIMD2<Float>]) {
5454
var variablePoints = points
5555
self.init(__points: &variablePoints, count: points.count)
5656
}

stdlib/public/Darwin/ModelIO/ModelIO.swift

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -112,47 +112,47 @@ extension MDLAnimatedScalarArray {
112112
@available(iOS, introduced: 11.0)
113113
@available(tvOS, introduced: 11.0)
114114
extension MDLAnimatedVector3Array {
115-
@nonobjc public func set(float3Array array:[float3], atTime time: TimeInterval){
115+
@nonobjc public func set(float3Array array:[SIMD3<Float>], atTime time: TimeInterval){
116116
__setFloat3(array, count: array.count, atTime: time)
117117
}
118118

119-
@nonobjc public func set(double3Array array:[double3], atTime time: TimeInterval){
119+
@nonobjc public func set(double3Array array:[SIMD3<Double>], atTime time: TimeInterval){
120120
__setDouble3(array, count: array.count, atTime: time)
121121
}
122122

123-
@nonobjc public func float3Array(atTime time: TimeInterval) -> [float3] {
124-
var values = [float3](repeating: float3(), count: Int(elementCount))
123+
@nonobjc public func float3Array(atTime time: TimeInterval) -> [SIMD3<Float>] {
124+
var values = [SIMD3<Float>](repeating: SIMD3<Float>(), count: Int(elementCount))
125125
__getFloat3Array(&values[0], maxCount: elementCount, atTime: time)
126126
return values
127127
}
128128

129-
@nonobjc public func double3Array(atTime time: TimeInterval) -> [double3] {
130-
var values = [double3](repeating: double3(), count: Int(elementCount))
129+
@nonobjc public func double3Array(atTime time: TimeInterval) -> [SIMD3<Double>] {
130+
var values = [SIMD3<Double>](repeating: SIMD3<Double>(), count: Int(elementCount))
131131
__getDouble3Array(&values[0], maxCount: elementCount, atTime: time)
132132
return values
133133
}
134134

135-
@nonobjc public func reset(float3Array array:[float3], atTimes times: [TimeInterval]){
135+
@nonobjc public func reset(float3Array array:[SIMD3<Float>], atTimes times: [TimeInterval]){
136136
__reset(withFloat3Array: array, count: array.count, atTimes: times, count: times.count)
137137
}
138138

139-
@nonobjc public func reset(double3Array array:[double3], atTimes times: [TimeInterval]){
139+
@nonobjc public func reset(double3Array array:[SIMD3<Double>], atTimes times: [TimeInterval]){
140140
__reset(withDouble3Array: array, count: array.count, atTimes: times, count: times.count)
141141
}
142142

143-
@nonobjc public var float3Array: [float3] {
143+
@nonobjc public var float3Array: [SIMD3<Float>] {
144144
get {
145145
let count = elementCount * timeSampleCount
146-
var values = [float3](repeating: float3(), count: Int(count))
146+
var values = [SIMD3<Float>](repeating: SIMD3<Float>(), count: Int(count))
147147
__getFloat3Array(&values[0], maxCount: count)
148148
return values
149149
}
150150
}
151151

152-
@nonobjc public var double3Array: [double3] {
152+
@nonobjc public var double3Array: [SIMD3<Double>] {
153153
get {
154154
let count = elementCount * timeSampleCount
155-
var values = [double3](repeating: double3(), count: Int(count))
155+
var values = [SIMD3<Double>](repeating: SIMD3<Double>(), count: Int(count))
156156
__getDouble3Array(&values[0], maxCount: count)
157157
return values
158158
}
@@ -243,25 +243,25 @@ extension MDLAnimatedScalar {
243243
@available(iOS, introduced: 11.0)
244244
@available(tvOS, introduced: 11.0)
245245
extension MDLAnimatedVector2 {
246-
@nonobjc public func reset(float2Array array:[float2], atTimes times: [TimeInterval]){
246+
@nonobjc public func reset(float2Array array:[SIMD2<Float>], atTimes times: [TimeInterval]){
247247
__reset(withFloat2Array: array, atTimes: times, count: times.count)
248248
}
249249

250-
@nonobjc public func reset(double2Array array:[double2], atTimes times: [TimeInterval]){
250+
@nonobjc public func reset(double2Array array:[SIMD2<Double>], atTimes times: [TimeInterval]){
251251
__reset(withDouble2Array: array, atTimes: times, count: times.count)
252252
}
253253

254-
@nonobjc public var float2Array: [float2] {
254+
@nonobjc public var float2Array: [SIMD2<Float>] {
255255
get {
256-
var values = [float2](repeating: float2(), count: Int(timeSampleCount))
256+
var values = [SIMD2<Float>](repeating: SIMD2<Float>(), count: Int(timeSampleCount))
257257
__getFloat2Array(&values[0], maxCount: timeSampleCount)
258258
return values
259259
}
260260
}
261261

262-
@nonobjc public var double2Array: [double2] {
262+
@nonobjc public var double2Array: [SIMD2<Double>] {
263263
get {
264-
var values = [double2](repeating: double2(), count: Int(timeSampleCount))
264+
var values = [SIMD2<Double>](repeating: SIMD2<Double>(), count: Int(timeSampleCount))
265265
__getDouble2Array(&values[0], maxCount: timeSampleCount)
266266
return values
267267
}
@@ -272,25 +272,25 @@ extension MDLAnimatedVector2 {
272272
@available(iOS, introduced: 11.0)
273273
@available(tvOS, introduced: 11.0)
274274
extension MDLAnimatedVector3 {
275-
@nonobjc public func reset(float3Array array:[float3], atTimes times: [TimeInterval]){
275+
@nonobjc public func reset(float3Array array:[SIMD3<Float>], atTimes times: [TimeInterval]){
276276
__reset(withFloat3Array: array, atTimes: times, count: times.count)
277277
}
278278

279-
@nonobjc public func reset(double3Array array:[double3], atTimes times: [TimeInterval]){
279+
@nonobjc public func reset(double3Array array:[SIMD3<Double>], atTimes times: [TimeInterval]){
280280
__reset(withDouble3Array: array, atTimes: times, count: times.count)
281281
}
282282

283-
@nonobjc public var float3Array: [float3] {
283+
@nonobjc public var float3Array: [SIMD3<Float>] {
284284
get {
285-
var values = [float3](repeating: float3(), count: Int(timeSampleCount))
285+
var values = [SIMD3<Float>](repeating: SIMD3<Float>(), count: Int(timeSampleCount))
286286
__getFloat3Array(&values[0], maxCount: timeSampleCount)
287287
return values
288288
}
289289
}
290290

291-
@nonobjc public var double3Array: [double3] {
291+
@nonobjc public var double3Array: [SIMD3<Double>] {
292292
get {
293-
var values = [double3](repeating: double3(), count: Int(timeSampleCount))
293+
var values = [SIMD3<Double>](repeating: SIMD3<Double>(), count: Int(timeSampleCount))
294294
__getDouble3Array(&values[0], maxCount: timeSampleCount)
295295
return values
296296
}
@@ -301,25 +301,25 @@ extension MDLAnimatedVector3 {
301301
@available(iOS, introduced: 11.0)
302302
@available(tvOS, introduced: 11.0)
303303
extension MDLAnimatedVector4 {
304-
@nonobjc public func reset(float4Array array:[float4], atTimes times: [TimeInterval]){
304+
@nonobjc public func reset(float4Array array:[SIMD4<Float>], atTimes times: [TimeInterval]){
305305
__reset(withFloat4Array: array, atTimes: times, count: times.count)
306306
}
307307

308-
@nonobjc public func reset(double4Array array:[double4], atTimes times: [TimeInterval]){
308+
@nonobjc public func reset(double4Array array:[SIMD4<Double>], atTimes times: [TimeInterval]){
309309
__reset(withDouble4Array: array, atTimes: times, count: times.count)
310310
}
311311

312-
@nonobjc public var float4Array: [float4] {
312+
@nonobjc public var float4Array: [SIMD4<Float>] {
313313
get {
314-
var values = [float4](repeating: float4(), count: Int(timeSampleCount))
314+
var values = [SIMD4<Float>](repeating: SIMD4<Float>(), count: Int(timeSampleCount))
315315
__getFloat4Array(&values[0], maxCount: timeSampleCount)
316316
return values
317317
}
318318
}
319319

320-
@nonobjc public var double4Array: [double4] {
320+
@nonobjc public var double4Array: [SIMD4<Double>] {
321321
get {
322-
var values = [double4](repeating: double4(), count: Int(timeSampleCount))
322+
var values = [SIMD4<Double>](repeating: SIMD4<Double>(), count: Int(timeSampleCount))
323323
__getDouble4Array(&values[0], maxCount: timeSampleCount)
324324
return values
325325
}

stdlib/public/Darwin/SceneKit/SceneKit.swift.gyb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ extension SCNVector3 {
4343
public init(_ x: Int, _ y: Int, _ z: Int) {
4444
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z))
4545
}
46-
public init(_ v: float3) {
46+
public init(_ v: SIMD3<Float>) {
4747
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z))
4848
}
49-
public init(_ v: double3) {
49+
public init(_ v: SIMD3<Double>) {
5050
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z))
5151
}
5252
}
@@ -78,10 +78,10 @@ extension SCNVector4 {
7878
public init(_ x: Int, _ y: Int, _ z: Int, _ w: Int) {
7979
self.init(SCNFloat(x), SCNFloat(y), SCNFloat(z), SCNFloat(w))
8080
}
81-
public init(_ v: float4) {
81+
public init(_ v: SIMD4<Float>) {
8282
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z), SCNFloat(v.w))
8383
}
84-
public init(_ v: double4) {
84+
public init(_ v: SIMD4<Double>) {
8585
self.init(SCNFloat(v.x), SCNFloat(v.y), SCNFloat(v.z), SCNFloat(v.w))
8686
}
8787
}
@@ -120,21 +120,21 @@ extension SCNMatrix4 {
120120
extension float4x4 {
121121
public init(_ m: SCNMatrix4) {
122122
self.init([
123-
float4(Float(m.m11), Float(m.m12), Float(m.m13), Float(m.m14)),
124-
float4(Float(m.m21), Float(m.m22), Float(m.m23), Float(m.m24)),
125-
float4(Float(m.m31), Float(m.m32), Float(m.m33), Float(m.m34)),
126-
float4(Float(m.m41), Float(m.m42), Float(m.m43), Float(m.m44))
123+
SIMD4<Float>(Float(m.m11), Float(m.m12), Float(m.m13), Float(m.m14)),
124+
SIMD4<Float>(Float(m.m21), Float(m.m22), Float(m.m23), Float(m.m24)),
125+
SIMD4<Float>(Float(m.m31), Float(m.m32), Float(m.m33), Float(m.m34)),
126+
SIMD4<Float>(Float(m.m41), Float(m.m42), Float(m.m43), Float(m.m44))
127127
])
128128
}
129129
}
130130

131131
extension double4x4 {
132132
public init(_ m: SCNMatrix4) {
133133
self.init([
134-
double4(Double(m.m11), Double(m.m12), Double(m.m13), Double(m.m14)),
135-
double4(Double(m.m21), Double(m.m22), Double(m.m23), Double(m.m24)),
136-
double4(Double(m.m31), Double(m.m32), Double(m.m33), Double(m.m34)),
137-
double4(Double(m.m41), Double(m.m42), Double(m.m43), Double(m.m44))
134+
SIMD4<Double>(Double(m.m11), Double(m.m12), Double(m.m13), Double(m.m14)),
135+
SIMD4<Double>(Double(m.m21), Double(m.m22), Double(m.m23), Double(m.m24)),
136+
SIMD4<Double>(Double(m.m31), Double(m.m32), Double(m.m33), Double(m.m34)),
137+
SIMD4<Double>(Double(m.m41), Double(m.m42), Double(m.m43), Double(m.m44))
138138
])
139139
}
140140
}

stdlib/public/Darwin/SpriteKit/SpriteKit.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extension SKWarpGeometryGrid {
6262
/// - Parameter rows: the number of rows to initialize the SKWarpGeometryGrid with
6363
/// - Parameter sourcePositions: the source positions for the SKWarpGeometryGrid to warp from
6464
/// - Parameter destinationPositions: the destination positions for SKWarpGeometryGrid to warp to
65-
public convenience init(columns: Int, rows: Int, sourcePositions: [simd.float2] = [float2](), destinationPositions: [simd.float2] = [float2]()) {
65+
public convenience init(columns: Int, rows: Int, sourcePositions: [SIMD2<Float>] = [SIMD2<Float>](), destinationPositions: [SIMD2<Float>] = [SIMD2<Float>]()) {
6666
let requiredElementsCount = (columns + 1) * (rows + 1)
6767
switch (destinationPositions.count, sourcePositions.count) {
6868
case (0, 0):
@@ -79,11 +79,11 @@ extension SKWarpGeometryGrid {
7979
}
8080
}
8181

82-
public func replacingBySourcePositions(positions source: [simd.float2]) -> SKWarpGeometryGrid {
82+
public func replacingBySourcePositions(positions source: [SIMD2<Float>]) -> SKWarpGeometryGrid {
8383
return self.__replacingSourcePositions(source)
8484
}
8585

86-
public func replacingByDestinationPositions(positions destination: [simd.float2]) -> SKWarpGeometryGrid {
86+
public func replacingByDestinationPositions(positions destination: [SIMD2<Float>]) -> SKWarpGeometryGrid {
8787
return self.__replacingDestPositions(destination)
8888
}
8989
}

stdlib/public/Darwin/simd/Quaternion.swift.gyb

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import Darwin
1818

1919
%for scalar in ['Float','Double']:
2020
% quat = 'simd_quat' + ('f' if scalar == 'Float' else 'd')
21-
% vec3 = str.lower(scalar) + '3'
22-
% vec4 = str.lower(scalar) + '4'
2321
% mat3 = 'simd_' + str.lower(scalar) + '3x3'
2422
% mat4 = 'simd_' + str.lower(scalar) + '4x4'
2523

@@ -34,13 +32,13 @@ extension ${quat} {
3432
/// - r: The real (scalar) part.
3533
@_transparent
3634
public init(ix: ${scalar}, iy: ${scalar}, iz: ${scalar}, r: ${scalar}) {
37-
self.init(vector: ${vec4}(ix, iy, iz, r))
35+
self.init(vector: SIMD4<${scalar}>(ix, iy, iz, r))
3836
}
3937

4038
/// Construct a quaternion from real and imaginary parts.
4139
@_transparent
42-
public init(real: ${scalar}, imag: ${vec3}) {
43-
self.init(vector: simd_make_${vec4}(imag, real))
40+
public init(real: ${scalar}, imag: SIMD3<${scalar}>) {
41+
self.init(vector: simd_make_${str.lower(scalar)}4(imag, real))
4442
}
4543

4644
/// A quaternion whose action is a rotation by `angle` radians about `axis`.
@@ -49,13 +47,13 @@ extension ${quat} {
4947
/// - angle: The angle to rotate by measured in radians.
5048
/// - axis: The axis to rotate around.
5149
@_transparent
52-
public init(angle: ${scalar}, axis: ${vec3}) {
50+
public init(angle: ${scalar}, axis: SIMD3<${scalar}>) {
5351
self = simd_quaternion(angle, axis)
5452
}
5553
5654
/// A quaternion whose action rotates the vector `from` onto the vector `to`.
5755
@_transparent
58-
public init(from: ${vec3}, to: ${vec3}) {
56+
public init(from: SIMD3<${scalar}>, to: SIMD3<${scalar}>) {
5957
self = simd_quaternion(from, to)
6058
}
6159
@@ -80,11 +78,11 @@ extension ${quat} {
8078
}
8179
8280
/// The imaginary (vector) part of `self`.
83-
public var imag: ${vec3} {
81+
public var imag: SIMD3<${scalar}> {
8482
@_transparent
85-
get { return simd_make_${vec3}(vector) }
83+
get { return simd_make_${str.lower(scalar)}3(vector) }
8684
@_transparent
87-
set { vector = simd_make_${vec4}(newValue, vector.w) }
85+
set { vector = simd_make_${str.lower(scalar)}4(newValue, vector.w) }
8886
}
8987
9088
/// The angle (in radians) by which `self`'s action rotates.
@@ -95,7 +93,7 @@ extension ${quat} {
9593

9694
/// The normalized axis about which `self`'s action rotates.
9795
@_transparent
98-
public var axis: ${vec3} {
96+
public var axis: SIMD3<${scalar}> {
9997
return simd_axis(self)
10098
}
10199

@@ -126,7 +124,7 @@ extension ${quat} {
126124
/// Applies the rotation represented by a unit quaternion to the vector and
127125
/// returns the result.
128126
@_transparent
129-
public func act(_ vector: ${vec3}) -> ${vec3} {
127+
public func act(_ vector: SIMD3<${scalar}>) -> SIMD3<${scalar}> {
130128
return simd_act(self, vector)
131129
}
132130
}

stdlib/public/Darwin/simd/simd.swift.gyb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ floating_types = ['Float','Double']
4949

5050
%for scalar in scalar_types:
5151
% for count in [2, 3, 4]:
52-
% vectype = ctype[scalar] + str(count)
52+
% vectype = "SIMD" + str(count) + "<" + scalar + ">"
5353
% vecsize = (8 if scalar == 'Double' else 4) * (4 if count == 3 else count)
5454
% vecalign = (16 if vecsize > 16 else vecsize)
5555
% is_floating = scalar in floating_types
5656
% is_signed = scalar[0] != 'U'
5757
% wrap = "" if is_floating else "&"
5858
5959
@available(swift, deprecated: 5.1, message: "Use SIMD${count}<${scalar}>")
60-
public typealias ${vectype} = SIMD${count}<${scalar}>
60+
public typealias ${ctype[scalar]}${count} = ${vectype}
6161
6262
% if is_signed:
6363
/// Elementwise absolute value of a vector. The result is a vector of the same
@@ -337,17 +337,15 @@ public func step(_ x: ${scalar}, edge: ${scalar}) -> ${scalar} {
337337
/// Interprets two two-dimensional vectors as three-dimensional vectors in the
338338
/// xy-plane and computes their cross product, which lies along the z-axis.
339339
@_transparent
340-
public func cross(_ x: ${ctype[scalar]}2, _ y: ${ctype[scalar]}2)
341-
-> ${ctype[scalar]}3 {
340+
public func cross(_ x: SIMD2<${scalar}>, _ y: SIMD2<${scalar}>) -> SIMD3<${scalar}> {
342341
return simd_cross(x,y)
343342
}
344343
345344
/// Cross-product of two three-dimensional vectors. The resulting vector is
346345
/// perpendicular to the plane determined by `x` and `y`, with length equal to
347346
/// the oriented area of the parallelogram they determine.
348347
@_transparent
349-
public func cross(_ x: ${ctype[scalar]}3, _ y: ${ctype[scalar]}3)
350-
-> ${ctype[scalar]}3 {
348+
public func cross(_ x: SIMD3<${scalar}>, _ y: SIMD3<${scalar}>) -> SIMD3<${scalar}> {
351349
return simd_cross(x,y)
352350
}
353351
@@ -359,9 +357,9 @@ public func cross(_ x: ${ctype[scalar]}3, _ y: ${ctype[scalar]}3)
359357
% for cols in [2,3,4]:
360358
% mattype = 'simd_' + ctype[type] + str(cols) + 'x' + str(rows)
361359
% diagsize = rows if rows < cols else cols
362-
% coltype = ctype[type] + str(rows)
363-
% rowtype = ctype[type] + str(cols)
364-
% diagtype = ctype[type] + str(diagsize)
360+
% coltype = "SIMD" + str(rows) + "<" + type + ">"
361+
% rowtype = "SIMD" + str(cols) + "<" + type + ">"
362+
% diagtype = "SIMD" + str(diagsize) + "<" + type + ">"
365363
% transtype = ctype[type] + str(rows) + 'x' + str(cols)
366364

367365
public typealias ${ctype[type]}${cols}x${rows} = ${mattype}

0 commit comments

Comments
 (0)