Allow resizing the grid cells via [ and ]
This commit is contained in:
parent
9cbfed136c
commit
9c0e3dccbd
2 changed files with 22 additions and 2 deletions
|
@ -97,7 +97,20 @@ class ViewController: NSViewController, RendererDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func keyDown(with event: NSEvent) {
|
override func keyDown(with event: NSEvent) {
|
||||||
print("key down: \(event)")
|
switch event.charactersIgnoringModifiers {
|
||||||
|
case .some("["):
|
||||||
|
let size = marchingSquares.sampleGridSize
|
||||||
|
if size.x > 2 {
|
||||||
|
marchingSquares.sampleGridSize = Size(size.x / 2)
|
||||||
|
}
|
||||||
|
case .some("]"):
|
||||||
|
let size = marchingSquares.sampleGridSize
|
||||||
|
if size.x < 32 {
|
||||||
|
marchingSquares.sampleGridSize = Size(size.x * 2)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
print("key down: \(event)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override var acceptsFirstResponder: Bool {
|
override var acceptsFirstResponder: Bool {
|
||||||
|
|
|
@ -12,11 +12,18 @@ import simd
|
||||||
|
|
||||||
class MarchingSquares {
|
class MarchingSquares {
|
||||||
private var field: Field
|
private var field: Field
|
||||||
private var sampleGridSize = Size(16)
|
|
||||||
|
var sampleGridSize = Size(16) {
|
||||||
|
didSet {
|
||||||
|
fieldDidResize()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var semaphore: DispatchSemaphore
|
private var semaphore: DispatchSemaphore
|
||||||
|
|
||||||
|
/// Compute pipeline for sampling the field.
|
||||||
private var samplingPipeline: MTLComputePipelineState?
|
private var samplingPipeline: MTLComputePipelineState?
|
||||||
|
/// Compute pipeline for calculating the contours based on a grid of samples.
|
||||||
private var contouringPipeline: MTLComputePipelineState?
|
private var contouringPipeline: MTLComputePipelineState?
|
||||||
|
|
||||||
private var parametersBuffer: MTLBuffer?
|
private var parametersBuffer: MTLBuffer?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue