[MetaballsKit] Fix up didSet responder for Field.size
This commit is contained in:
parent
da5c664ee6
commit
22fbaed88c
1 changed files with 13 additions and 3 deletions
|
@ -36,9 +36,19 @@ public struct Ball {
|
||||||
public class Field {
|
public class Field {
|
||||||
public var size: CGSize {
|
public var size: CGSize {
|
||||||
didSet {
|
didSet {
|
||||||
// Remove balls that fall outside the new bounds.
|
if size != oldValue {
|
||||||
balls = balls.filter { bounds.contains($0.bounds) }
|
let numberOfBallsBeforeFilter = balls.count
|
||||||
updateThreadgroupSizes(withFieldSize: size)
|
|
||||||
|
// Remove balls that fall outside the new bounds.
|
||||||
|
balls = balls.filter { bounds.contains($0.bounds) }
|
||||||
|
|
||||||
|
// Update Metal state as needed.
|
||||||
|
updateThreadgroupSizes(withFieldSize: size)
|
||||||
|
sampleTexture = nil
|
||||||
|
if numberOfBallsBeforeFilter != balls.count {
|
||||||
|
ballBuffer = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue