-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simulations run at proper speed now, still no display
- Loading branch information
1 parent
27b7865
commit cdab266
Showing
8 changed files
with
230 additions
and
168 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1120" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "D4AC68B3245CF43F00917569" | ||
BuildableName = "Foil.app" | ||
BlueprintName = "Foil" | ||
ReferencedContainer = "container:Foil.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "D4AC68B3245CF43F00917569" | ||
BuildableName = "Foil.app" | ||
BlueprintName = "Foil" | ||
ReferencedContainer = "container:Foil.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "D4AC68B3245CF43F00917569" | ||
BuildableName = "Foil.app" | ||
BlueprintName = "Foil" | ||
ReferencedContainer = "container:Foil.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
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
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 |
---|---|---|
@@ -1,34 +1,46 @@ | ||
import simd | ||
|
||
func generate_random_vector(min: Float, max: Float) -> vector_float3 { | ||
let range = max - min; | ||
enum FoilMath { | ||
static func generateRandomNormalizedVector(_ min: Float, _ max: Float, _ maxlength: Float) -> vector_float3 { | ||
var rand = vector_float3() | ||
|
||
let x = Float.random(in: 0..<1) * range + min; | ||
let y = Float.random(in: 0..<1) * range + min; | ||
let z = Float.random(in: 0..<1) * range + min; | ||
repeat { | ||
rand = generateRandomVector(min, max); | ||
} while(simd_length(rand) > maxlength) | ||
|
||
return vector_float3(x, y, z) | ||
} | ||
return simd_normalize(rand) | ||
} | ||
|
||
func matrix_ortho_left_hand( | ||
left: Float, right: Float, bottom: Float, top: Float, nearZ: Float, farZ: Float | ||
) -> matrix_float4x4 { | ||
return matrix_make_rows( | ||
2 / (right - left), 0, 0, (left + right) / (left - right), | ||
0, 2 / (top - bottom), 0, (top + bottom) / (bottom - top), | ||
0, 0, 1 / (farZ - nearZ), nearZ / (nearZ - farZ), | ||
0, 0, 0, 1 ); | ||
} | ||
static func generateRandomVector(_ min: Float, _ max: Float) -> vector_float3 { | ||
let range = max - min; | ||
|
||
let x = Float.random(in: 0..<1) * range + min; | ||
let y = Float.random(in: 0..<1) * range + min; | ||
let z = Float.random(in: 0..<1) * range + min; | ||
|
||
return vector_float3(x, y, z) | ||
} | ||
|
||
static func matrixOrthoLeftHand( | ||
left: Float, right: Float, bottom: Float, top: Float, nearZ: Float, farZ: Float | ||
) -> matrix_float4x4 { | ||
return matriMakeRows( | ||
2 / (right - left), 0, 0, (left + right) / (left - right), | ||
0, 2 / (top - bottom), 0, (top + bottom) / (bottom - top), | ||
0, 0, 1 / (farZ - nearZ), nearZ / (nearZ - farZ), | ||
0, 0, 0, 1 ); | ||
} | ||
|
||
func matrix_make_rows( | ||
_ m00: Float, _ m10: Float, _ m20: Float, _ m30: Float, | ||
_ m01: Float, _ m11: Float, _ m21: Float, _ m31: Float, | ||
_ m02: Float, _ m12: Float, _ m22: Float, _ m32: Float, | ||
_ m03: Float, _ m13: Float, _ m23: Float, _ m33: Float | ||
) -> matrix_float4x4 { | ||
return matrix_float4x4([ | ||
[ m00, m01, m02, m03 ], // each line here provides column data | ||
[ m10, m11, m12, m13 ], | ||
[ m20, m21, m22, m23 ], | ||
[ m30, m31, m32, m33 ] ] ) | ||
static func matriMakeRows( | ||
_ m00: Float, _ m10: Float, _ m20: Float, _ m30: Float, | ||
_ m01: Float, _ m11: Float, _ m21: Float, _ m31: Float, | ||
_ m02: Float, _ m12: Float, _ m22: Float, _ m32: Float, | ||
_ m03: Float, _ m13: Float, _ m23: Float, _ m33: Float | ||
) -> matrix_float4x4 { | ||
return matrix_float4x4([ | ||
[ m00, m01, m02, m03 ], // each line here provides column data | ||
[ m10, m11, m12, m13 ], | ||
[ m20, m21, m22, m23 ], | ||
[ m30, m31, m32, m33 ] ] ) | ||
} | ||
} |
Oops, something went wrong.