Rename Algorithm -> TerrainGenerator

This commit is contained in:
Eryn Wells 2018-11-10 13:16:22 -05:00
parent c62ae41fc0
commit a58241cd13
2 changed files with 7 additions and 7 deletions

View file

@ -14,7 +14,7 @@ enum KernelError: Error {
case textureCreationFailed
}
protocol Algorithm {
protocol TerrainGenerator {
var name: String { get }
var outTexture: MTLTexture { get }
@ -75,7 +75,7 @@ class Kernel {
}
/// "Compute" zero for every value of the height map.
class ZeroAlgorithm: Kernel, Algorithm {
class ZeroAlgorithm: Kernel, TerrainGenerator {
let name = "Zero"
init?(device: MTLDevice, library: MTLLibrary) {
@ -93,7 +93,7 @@ class ZeroAlgorithm: Kernel, Algorithm {
}
/// Randomly generate heights that are independent of all others.
class RandomAlgorithm: Kernel, Algorithm {
class RandomAlgorithm: Kernel, TerrainGenerator {
let name = "Random"
private var uniforms: UnsafeMutablePointer<RandomAlgorithmUniforms>
@ -124,7 +124,7 @@ class RandomAlgorithm: Kernel, Algorithm {
/// Implementation of the Diamond-Squares algorithm.
/// - https://en.wikipedia.org/wiki/Diamond-square_algorithm
public class DiamondSquareAlgorithm: Algorithm {
public class DiamondSquareAlgorithm: TerrainGenerator {
public struct Box {
public typealias Point = (x: Int, y: Int)
public typealias Size = (w: Int, h: Int)

View file

@ -75,7 +75,7 @@ class Terrain: NSObject {
let vertexDescriptor: MTLVertexDescriptor
let mesh: MTKMesh
var algorithm: Algorithm
var generator: TerrainGenerator
init?(dimensions dim: float2, segments seg: uint2, device: MTLDevice, library: MTLLibrary) {
dimensions = dim
@ -89,11 +89,11 @@ class Terrain: NSObject {
return nil
}
guard let alg = RandomAlgorithm(device: device, library: library) else {
guard let gen = RandomAlgorithm(device: device, library: library) else {
print("Couldn't create algorithm")
return nil
}
algorithm = alg
generator = gen
super.init()
}