Skip to content

Commit

Permalink
unify the way Equatable is implemented for Vector3f in both SIMD and …
Browse files Browse the repository at this point in the history
…non-SIMD variants
  • Loading branch information
s1ddok committed Oct 12, 2017
1 parent 8795c1c commit 85f0118
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Sources/Vector3+nosimd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public struct Vector3f {
}
}

extension Vector3f: Equatable {
extension Vector3f {

public var lengthSquared: Float {
return x * x + y * y + z * z
Expand Down Expand Up @@ -118,10 +118,6 @@ extension Vector3f: Equatable {
return Vector3f(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs)
}

public static func ==(lhs: Vector3f, rhs: Vector3f) -> Bool {
return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z
}

public static func ~=(lhs: Vector3f, rhs: Vector3f) -> Bool {
return lhs.x ~= rhs.x && lhs.y ~= rhs.y && lhs.z ~= rhs.z
}
Expand All @@ -138,4 +134,10 @@ extension Vector3f: Equatable {
return rhs * lhs
}
}

extension Vector3f: Equatable {
public static func ==(lhs: Vector3f, rhs: Vector3f) -> Bool {
return lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z
}
}
#endif
6 changes: 6 additions & 0 deletions Sources/Vector3+simd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,10 @@ public extension Vector3f {
}
}

extension Vector3f: Equatable {
public static func ==(lhs: Vector3f, rhs: Vector3f) -> Bool {
return lhs.d == rhs.d
}
}

#endif

0 comments on commit 85f0118

Please sign in to comment.