-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matrix3x3+Codable #6
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b7e0b6
add codable conformance to matrix3x3
eugenebokhan 4af69df
Merge branch 'master' into matrix3x3-codable
eugenebokhan 347db1c
add equatable extension
eugenebokhan 9fde6ca
add float4x4 extension
eugenebokhan aab73c8
fix equatable
eugenebokhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// float3x3+Extensions.swift | ||
// org.SwiftGFX.SwiftMath | ||
// | ||
// Created by Eugene Bokhan on 28.02.20. | ||
// | ||
// | ||
|
||
#if !NOSIMD | ||
|
||
import Foundation | ||
import simd | ||
|
||
extension float3x3: Codable { | ||
public init(from decoder: Decoder) throws { | ||
let values = try decoder.container(keyedBy: CodingKeys.self) | ||
let c1 = try values.decode(SIMD3<Float>.self, forKey: .column1) | ||
let c2 = try values.decode(SIMD3<Float>.self, forKey: .column2) | ||
let c3 = try values.decode(SIMD3<Float>.self, forKey: .column3) | ||
|
||
self.init(c1, c2, c3) | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(self.columns.0, forKey: .column1) | ||
try container.encode(self.columns.1, forKey: .column2) | ||
try container.encode(self.columns.2, forKey: .column3) | ||
} | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case column1, column2, column3 | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// float4x4+Extensions.swift | ||
// org.SwiftGFX.SwiftMath | ||
// | ||
// Created by Eugene Bokhan on 28.02.20. | ||
// | ||
// | ||
|
||
#if !NOSIMD | ||
|
||
import Foundation | ||
import simd | ||
|
||
extension float4x4: Codable { | ||
public init(from decoder: Decoder) throws { | ||
let values = try decoder.container(keyedBy: CodingKeys.self) | ||
let c1 = try values.decode(SIMD4<Float>.self, forKey: .column1) | ||
let c2 = try values.decode(SIMD4<Float>.self, forKey: .column2) | ||
let c3 = try values.decode(SIMD4<Float>.self, forKey: .column3) | ||
let c4 = try values.decode(SIMD4<Float>.self, forKey: .column4) | ||
|
||
self.init(c1, c2, c3, c4) | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(self.columns.0, forKey: .column1) | ||
try container.encode(self.columns.1, forKey: .column2) | ||
try container.encode(self.columns.2, forKey: .column3) | ||
try container.encode(self.columns.3, forKey: .column4) | ||
} | ||
|
||
private enum CodingKeys: String, CodingKey { | ||
case column1, column2, column3, column4 | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's compare d