-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from li3zhen1/dev
Add quad tree delegate
- Loading branch information
Showing
10 changed files
with
607 additions
and
51 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 |
---|---|---|
|
@@ -69,7 +69,6 @@ public protocol Force { | |
associatedtype N: Identifiable | ||
|
||
func apply(alpha: Float) | ||
func initialize() | ||
} | ||
|
||
|
||
|
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 |
---|---|---|
|
@@ -46,10 +46,6 @@ public class CenterForce<N> : Force where N : Identifiable { | |
} | ||
} | ||
|
||
public func initialize() { | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
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,32 +1,52 @@ | ||
// | ||
// File.swift | ||
// CollideForce.swift | ||
// | ||
// | ||
// Created by li3zhen1 on 10/1/23. | ||
// | ||
|
||
import Foundation | ||
import QuadTree | ||
|
||
enum CollideForceError: Error { | ||
case applyBeforeSimulationInitialized | ||
} | ||
|
||
|
||
public class CollideForce<N> where N : Identifiable { | ||
|
||
let radius: CollideRadius | ||
let iterationsPerTick: Int | ||
|
||
|
||
weak var simulation: Simulation<N>? | ||
|
||
public class CollideForce<N> : Force where N : Identifiable { | ||
internal init( | ||
radius: CollideRadius, | ||
iterationsPerTick: Int = 1 | ||
) { | ||
self.radius = radius | ||
self.iterationsPerTick = iterationsPerTick | ||
} | ||
} | ||
|
||
public enum CollideRadius { | ||
|
||
public extension CollideForce { | ||
enum CollideRadius{ | ||
case constant(Float) | ||
case varied( (N.ID) -> Float ) | ||
case polarCoordinatesOnRad( (Float, N.ID) -> Float ) | ||
} | ||
} | ||
|
||
weak var simulation: Simulation<N>? | ||
|
||
extension CollideForce: Force { | ||
public func apply(alpha: Float) { | ||
|
||
} | ||
guard let sim = self.simulation else { return } | ||
|
||
for _ in 0..<iterationsPerTick { | ||
// guard let quad = try? QuadTree(nodes: sim.simulationNodes.map { ($0, $0.position) }) else { break } | ||
|
||
public func initialize() { | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
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
Oops, something went wrong.