Skip to content

Commit

Permalink
Merge pull request #3 from eugenebokhan/fix-warnings
Browse files Browse the repository at this point in the history
fix warnings
  • Loading branch information
s1ddok authored Mar 26, 2019
2 parents fdcfd7a + 3808a71 commit d1ae058
Show file tree
Hide file tree
Showing 16 changed files with 463 additions and 463 deletions.
4 changes: 2 additions & 2 deletions Sources/Matrix3x3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

public extension Matrix3x3f {
/// Returns the identity matrix
public static let identity = Matrix3x3f(diagonal: vec3(1.0))
static let identity = Matrix3x3f(diagonal: vec3(1.0))

/// Creates a new instance from the values provided in row-major order
public init(
init(
_ m00: Float, _ m01: Float, _ m02: Float,
_ m10: Float, _ m11: Float, _ m12: Float,
_ m20: Float, _ m21: Float, _ m22: Float) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Matrix4x4+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

public extension Matrix4x4f {
public func translated(by v: Vector3f) -> Matrix4x4f {
func translated(by v: Vector3f) -> Matrix4x4f {
let col3 = self * vec4(v)

return Matrix4x4f(
Expand All @@ -34,7 +34,7 @@ public extension Matrix4x4f {
/// - returns:
/// A new vector created by first multiplying the matrix by the
/// vector and then performing perspective division on the result vector.
public func multiplyAndProject(v: Vector3f) -> Vector3f {
func multiplyAndProject(v: Vector3f) -> Vector3f {
var r = self * Vector4f(v)
r *= 1.0/r.w
return Vector3f(r.x, r.y, r.z)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Matrix4x4+simd.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public struct Matrix4x4f {
}

public extension matrix_float4x4 {
public init(_ mat4x4f: Matrix4x4f) {
init(_ mat4x4f: Matrix4x4f) {
self = mat4x4f.d
}
}
Expand Down
38 changes: 19 additions & 19 deletions Sources/Matrix4x4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

public extension Matrix4x4f {
/// Returns the identity matrix
public static let identity = Matrix4x4f(diagonal: vec4(1.0))
static let identity = Matrix4x4f(diagonal: vec4(1.0))

/// Creates a new instance from the values provided in row-major order
public init(
init(
_ m00: Float, _ m01: Float, _ m02: Float, _ m03: Float,
_ m10: Float, _ m11: Float, _ m12: Float, _ m13: Float,
_ m20: Float, _ m21: Float, _ m22: Float, _ m23: Float,
Expand All @@ -26,11 +26,11 @@ public extension Matrix4x4f {

//MARK: matrix operations

public static func lookAt(eye: Vector3f, at: Vector3f, up: Vector3f = Vector3f(0.0, 1.0, 0.0)) -> Matrix4x4f {
static func lookAt(eye: Vector3f, at: Vector3f, up: Vector3f = Vector3f(0.0, 1.0, 0.0)) -> Matrix4x4f {
return lookAtLH(eye: eye, at: at, up: up)
}

public static func lookAtLH(eye: Vector3f, at: Vector3f, up: Vector3f) -> Matrix4x4f {
static func lookAtLH(eye: Vector3f, at: Vector3f, up: Vector3f) -> Matrix4x4f {
let view = (at - eye).normalized
return lookAt(eye: eye, view: view, up: up)
}
Expand All @@ -48,14 +48,14 @@ public extension Matrix4x4f {
}

/// Creates a left-handed perspective projection matrix
public static func proj(fovy: Angle, aspect: Float, near: Float, far: Float) -> Matrix4x4f {
static func proj(fovy: Angle, aspect: Float, near: Float, far: Float) -> Matrix4x4f {
let height = 1.0 / tan(fovy * 0.5)
let width = height * 1.0/aspect;
return projLH(x: 0, y: 0, w: width, h: height, near: near, far: far)
}

/// Creates a left-handed perspective projection matrix
public static func projLH(x: Float, y: Float, w: Float, h: Float, near: Float, far: Float) -> Matrix4x4f {
static func projLH(x: Float, y: Float, w: Float, h: Float, near: Float, far: Float) -> Matrix4x4f {
let diff = far - near
let aa = far / diff
let bb = near * aa
Expand All @@ -73,7 +73,7 @@ public extension Matrix4x4f {
}

/// Creates a right-handed perspective projection matrix
public static func projRH(x: Float, y: Float, w: Float, h: Float, near: Float, far: Float) -> Matrix4x4f {
static func projRH(x: Float, y: Float, w: Float, h: Float, near: Float, far: Float) -> Matrix4x4f {
let diff = far - near
let aa = far / diff
let bb = near * aa
Expand All @@ -91,12 +91,12 @@ public extension Matrix4x4f {
}

/// Creates a left-handed orthographic projection matrix
public static func ortho(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float) -> Matrix4x4f {
static func ortho(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float) -> Matrix4x4f {
return orthoLH(left: left, right: right, bottom: bottom, top: top, near: near, far: far)
}

/// Creates a left-handed orthographic projection matrix
public static func orthoLH(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float, offset: Float = 0.0) -> Matrix4x4f {
static func orthoLH(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float, offset: Float = 0.0) -> Matrix4x4f {
let aa = 2.0 / (right - left)
let bb = 2.0 / (top - bottom)
let cc = 1.0 / (far - near)
Expand All @@ -117,7 +117,7 @@ public extension Matrix4x4f {
}

/// Creates a right-handed orthographic projection matrix
public static func orthoRH(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float, offset: Float = 0.0) -> Matrix4x4f {
static func orthoRH(left: Float, right: Float, bottom: Float, top: Float, near: Float, far: Float, offset: Float = 0.0) -> Matrix4x4f {
let aa = 2.0 / (right - left)
let bb = 2.0 / (top - bottom)
let cc = 1.0 / (far - near)
Expand All @@ -139,11 +139,11 @@ public extension Matrix4x4f {

//MARK: matrix operations

public static func scale(sx: Float, sy: Float, sz: Float) -> Matrix4x4f {
static func scale(sx: Float, sy: Float, sz: Float) -> Matrix4x4f {
return Matrix4x4f(diagonal: vec4(sx, sy, sz, 1.0))
}

public static func translate(tx: Float, ty: Float, tz: Float) -> Matrix4x4f {
static func translate(tx: Float, ty: Float, tz: Float) -> Matrix4x4f {
return Matrix4x4f(
vec4(1.0, 0.0, 0.0, 0.0),
vec4(0.0, 1.0, 0.0, 0.0),
Expand All @@ -158,7 +158,7 @@ public extension Matrix4x4f {
/// - parameter x: angle
///
/// - returns: a new rotation matrix
public static func rotate(x: Angle) -> Matrix4x4f {
static func rotate(x: Angle) -> Matrix4x4f {
let (sin: sx, cos: cx) = sincos(x)

var r = Matrix4x4f()
Expand All @@ -173,7 +173,7 @@ public extension Matrix4x4f {
}

/// Returns a transformation matrix that rotates around the y axis
public static func rotate(y: Angle) -> Matrix4x4f {
static func rotate(y: Angle) -> Matrix4x4f {
let (sin: sy, cos: cy) = sincos(y)

var r = Matrix4x4f()
Expand All @@ -188,7 +188,7 @@ public extension Matrix4x4f {
}

/// Returns a transformation matrix that rotates around the z axis
public static func rotate(z: Angle) -> Matrix4x4f {
static func rotate(z: Angle) -> Matrix4x4f {
let (sin: sz, cos: cz) = sincos(z)

var r = Matrix4x4f()
Expand All @@ -203,7 +203,7 @@ public extension Matrix4x4f {
}

/// Returns a transformation matrix that rotates around the x and then y axes
public static func rotate(x: Angle, y: Angle) -> Matrix4x4f {
static func rotate(x: Angle, y: Angle) -> Matrix4x4f {
let (sin: sx, cos: cx) = sincos(x)
let (sin: sy, cos: cy) = sincos(y)

Expand All @@ -216,7 +216,7 @@ public extension Matrix4x4f {
}

/// Returns a transformation matrix that rotates around the x, y and then z axes
public static func rotate(x: Angle, y: Angle, z: Angle) -> Matrix4x4f {
static func rotate(x: Angle, y: Angle, z: Angle) -> Matrix4x4f {
let (sin: sx, cos: cx) = sincos(x)
let (sin: sy, cos: cy) = sincos(y)
let (sin: sz, cos: cz) = sincos(z)
Expand All @@ -237,7 +237,7 @@ public extension Matrix4x4f {
}

/// Returns a transformation matrix that rotates around the z, y and then x axes
public static func rotate(z: Angle, y: Angle, x: Angle) -> Matrix4x4f {
static func rotate(z: Angle, y: Angle, x: Angle) -> Matrix4x4f {
let (sin: sx, cos: cx) = sincos(x)
let (sin: sy, cos: cy) = sincos(y)
let (sin: sz, cos: cz) = sincos(z)
Expand All @@ -258,7 +258,7 @@ public extension Matrix4x4f {
}

/// Returns a transformation matrix which can be used to scale, rotate and translate vectors
public static func scaleRotateTranslate(sx _sx: Float, sy _sy: Float, sz _sz: Float,
static func scaleRotateTranslate(sx _sx: Float, sy _sy: Float, sz _sz: Float,
ax: Angle, ay: Angle, az: Angle,
tx: Float, ty: Float, tz: Float) -> Matrix4x4f {
let (sin: sx, cos: cx) = sincos(ax)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Point.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public typealias Point = Vector2f
public typealias p2d = Point

public extension Rect {
public nonmutating func contains(point: Point) -> Bool {
nonmutating func contains(point: Point) -> Bool {
let x = point.x
let y = point.y
return x >= minX && x <= maxX && y >= minY && y <= maxY
Expand Down
22 changes: 11 additions & 11 deletions Sources/Rect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public typealias Size = Vector2f

public extension Size {
public var width: Float {
var width: Float {
get {
return x
}
Expand All @@ -18,7 +18,7 @@ public extension Size {
}
}

public var height: Float {
var height: Float {
get {
return y
}
Expand All @@ -27,11 +27,11 @@ public extension Size {
}
}

public init(width: Float, height: Float) {
init(width: Float, height: Float) {
self.init(width, height)
}

public init(width: Int, height: Int) {
init(width: Int, height: Int) {
self.init(Float(width), Float(height))
}
}
Expand All @@ -40,7 +40,7 @@ public extension Size {
/**
Check if a size has power of two dimensions.
*/
public var isPOT: Bool {
var isPOT: Bool {
let w = UInt(width)
let h = UInt(height)
return w == w.nextPOT && h == h.nextPOT
Expand Down Expand Up @@ -99,15 +99,15 @@ extension Rect: Equatable {
}

public extension Rect {
public func sizeScaled(by s: Float) -> Rect {
func sizeScaled(by s: Float) -> Rect {
return Rect(origin: origin, size: size * s)
}

public func originScaled(by s: Float) -> Rect {
func originScaled(by s: Float) -> Rect {
return Rect(origin: origin * s, size: size)
}

public func scaled(by s: Float) -> Rect {
func scaled(by s: Float) -> Rect {
return Rect(origin: origin * s, size: size * s)
}
}
Expand All @@ -119,7 +119,7 @@ public extension Rect {
consists solely of scales, flips and translations, then the returned
rectangle coincides with the rectangle constructed from the four
transformed corners. */
public nonmutating func applying(matrix: Matrix4x4f) -> Rect {
nonmutating func applying(matrix: Matrix4x4f) -> Rect {
let bl = matrix * bottomLeft
let br = matrix * bottomRight
let tl = matrix * topLeft
Expand Down Expand Up @@ -147,7 +147,7 @@ public extension Rect {
* Returns an array of 2d points which repsent triangles,
* ordered in counter-clockwise manner
*/
public var triangles: [Vector2f] {
var triangles: [Vector2f] {
return [
origin, topLeft, bottomRight,
bottomRight, topLeft, topRight
Expand All @@ -158,7 +158,7 @@ public extension Rect {
* Returns an array of 2d points which represent a triangle strip
* First triangle is ordered in counter-clockwise manner
*/
public var triangleStrip: [Vector2f] {
var triangleStrip: [Vector2f] {
return [
origin, topLeft, bottomRight, topRight
]
Expand Down
6 changes: 3 additions & 3 deletions Sources/String+Math.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation
internal extension String {
internal var floatArray: [Float] {
var floatArray: [Float] {
let ignoredCharacters = CharacterSet(charactersIn: "{} ,")
let components = self.components(separatedBy: ignoredCharacters)
return components.filter { $0.count > 0 }
Expand All @@ -18,7 +18,7 @@ internal extension String {

public extension Vector2f {
// String should be {p.x, p.y}
public init(_ string: String) {
init(_ string: String) {
let components = string.floatArray

if components.count == 2 {
Expand All @@ -31,7 +31,7 @@ public extension Vector2f {

public extension Rect {
// String should be {o.x, o.y, s.w, s.h}
public init(_ string: String) {
init(_ string: String) {
let components = string.floatArray

if components.count == 2 {
Expand Down
Loading

0 comments on commit d1ae058

Please sign in to comment.