Skip to content

Commit

Permalink
Fix buffer resize; Add visionOS/watchOS/tvOS targets
Browse files Browse the repository at this point in the history
  • Loading branch information
li3zhen1 committed Jan 8, 2024
1 parent 714091d commit 1bca90c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 6 additions & 5 deletions Sources/ForceSimulation/KDTree/BufferedKDTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,12 @@ where

let treeNodeOffset = (consume treeNode) - rootPointer
resizeIfNeededBeforeAllocation(for: Self.directionCount)

let spawnedDelegate = treeNode.pointee.delegate.spawn()
let center = treeNode.pointee.box.center


let newTreeNode = self.rootPointer + treeNodeOffset

let spawnedDelegate = newTreeNode.pointee.delegate.spawn()
let center = newTreeNode.pointee.box.center

let _box = newTreeNode.pointee.box
for j in 0..<Self.directionCount {
var __box = _box
Expand Down Expand Up @@ -366,4 +367,4 @@ extension BufferedKDTree {
) {
rootPointer.pointee.visit(shouldVisitChildren: shouldVisitChildren)
}
}
}
7 changes: 5 additions & 2 deletions Sources/Grape/Views/ForceDirectedGraph+View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ extension ForceDirectedGraph: View {
alpha: self.model.simulationContext.storage.kinetics.alpha
)
}
.onChange(of: self.isRunning, initial: false) { oldValue, newValue in
.onChange(
of: self.isRunning,
initial: false
) { oldValue, newValue in
guard oldValue != newValue else { return }
if newValue {
self.model.start()
Expand Down Expand Up @@ -65,9 +68,9 @@ extension ForceDirectedGraph: View {

// #endif

@inlinable
@MainActor
@ViewBuilder
@inlinable
var canvas: some View {
// #if DEBUG
// let _ = Self._printChanges()
Expand Down
3 changes: 2 additions & 1 deletion Tests/ForceSimulationTests/ForceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ final class ForceTests: XCTestCase {
forceField: myForce
)

for _ in 0...10 {
for i in 0...10 {

simulation.tick()
}

Expand Down

0 comments on commit 1bca90c

Please sign in to comment.