git.iko.soy/metal-metaballs
on master help sign in
8 files changed+67−63
since splitsnapshots
unifiedsplit
PixelImage.xcodeproj/project.pbxproj+35−24 PixelImage/AppDelegate.swift+1−1 PixelImage/Interpolation.swift+2−1 PixelImage/Metal.swift+2−2 PixelImage/MetalMetaballRenderer.swift+15−16 PixelImage/SwiftSugar/Numeric.swift+5−12 PixelImage/ViewController.swift+5−5 Podfile.lock+2−2
PixelImage.xcodeproj/project.pbxproj+35−24
@@ -144,7 +144,6 @@
144144 242686811C63B72A00D62456 /* Frameworks */,
145145 242686821C63B72A00D62456 /* Resources */,
146146 3CA888DC160972BAEB74EC52 /* [CP] Embed Pods Frameworks */,
147− 47F9F13E3CB75C7B4B0136A5 /* [CP] Copy Pods Resources */,
148147 );
149148 buildRules = (
150149 );
@@ -162,13 +161,13 @@
162161 isa = PBXProject;
163162 attributes = {
164163 LastSwiftUpdateCheck = 0720;
165− LastUpgradeCheck = 0830;
164+ LastUpgradeCheck = 1020;
166165 ORGANIZATIONNAME = "Vinicius Vendramini";
167166 TargetAttributes = {
168167 242686831C63B72A00D62456 = {
169168 CreatedOnToolsVersion = 7.2;
170− DevelopmentTeam = HHT774898M;
171− LastSwiftMigration = 0830;
169+ DevelopmentTeam = 8J63JZYYHZ;
170+ LastSwiftMigration = 1020;
172171 };
173172 };
174173 };
@@ -177,6 +176,7 @@
177176 developmentRegion = English;
178177 hasScannedForEncodings = 0;
179178 knownRegions = (
179+ English,
180180 en,
181181 Base,
182182 );
@@ -210,13 +210,16 @@
210210 files = (
211211 );
212212 inputPaths = (
213+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
214+ "${PODS_ROOT}/Manifest.lock",
213215 );
214216 name = "[CP] Check Pods Manifest.lock";
215217 outputPaths = (
218+ "$(DERIVED_FILE_DIR)/Pods-PixelImage-checkManifestLockResult.txt",
216219 );
217220 runOnlyForDeploymentPostprocessing = 0;
218221 shellPath = /bin/sh;
219− shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
222+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
220223 showEnvVarsInLog = 0;
221224 };
222225 3CA888DC160972BAEB74EC52 /* [CP] Embed Pods Frameworks */ = {
@@ -225,30 +228,18 @@
225228 files = (
226229 );
227230 inputPaths = (
231+ "${SRCROOT}/Pods/Target Support Files/Pods-PixelImage/Pods-PixelImage-frameworks.sh",
232+ "${BUILT_PRODUCTS_DIR}/ChameleonFramework/ChameleonFramework.framework",
228233 );
229234 name = "[CP] Embed Pods Frameworks";
230235 outputPaths = (
236+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ChameleonFramework.framework",
231237 );
232238 runOnlyForDeploymentPostprocessing = 0;
233239 shellPath = /bin/sh;
234240 shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PixelImage/Pods-PixelImage-frameworks.sh\"\n";
235241 showEnvVarsInLog = 0;
236242 };
237− 47F9F13E3CB75C7B4B0136A5 /* [CP] Copy Pods Resources */ = {
238− isa = PBXShellScriptBuildPhase;
239− buildActionMask = 2147483647;
240− files = (
241− );
242− inputPaths = (
243− );
244− name = "[CP] Copy Pods Resources";
245− outputPaths = (
246− );
247− runOnlyForDeploymentPostprocessing = 0;
248− shellPath = /bin/sh;
249− shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PixelImage/Pods-PixelImage-resources.sh\"\n";
250− showEnvVarsInLog = 0;
251− };
252243/* End PBXShellScriptBuildPhase section */
253244
254245/* Begin PBXSourcesBuildPhase section */
@@ -299,18 +290,27 @@
299290 isa = XCBuildConfiguration;
300291 buildSettings = {
301292 ALWAYS_SEARCH_USER_PATHS = NO;
293+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
302294 CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
303295 CLANG_CXX_LIBRARY = "libc++";
304296 CLANG_ENABLE_MODULES = YES;
305297 CLANG_ENABLE_OBJC_ARC = YES;
298+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
306299 CLANG_WARN_BOOL_CONVERSION = YES;
300+ CLANG_WARN_COMMA = YES;
307301 CLANG_WARN_CONSTANT_CONVERSION = YES;
302+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
308303 CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
309304 CLANG_WARN_EMPTY_BODY = YES;
310305 CLANG_WARN_ENUM_CONVERSION = YES;
311306 CLANG_WARN_INFINITE_RECURSION = YES;
312307 CLANG_WARN_INT_CONVERSION = YES;
308+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
309+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
310+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
313311 CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
312+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
313+ CLANG_WARN_STRICT_PROTOTYPES = YES;
314314 CLANG_WARN_SUSPICIOUS_MOVE = YES;
315315 CLANG_WARN_UNREACHABLE_CODE = YES;
316316 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -338,6 +338,7 @@
338338 ONLY_ACTIVE_ARCH = YES;
339339 SDKROOT = iphoneos;
340340 SWIFT_OPTIMIZATION_LEVEL = "-Onone";
341+ SWIFT_SWIFT3_OBJC_INFERENCE = Off;
341342 TARGETED_DEVICE_FAMILY = "1,2";
342343 };
343344 name = Debug;
@@ -346,18 +347,27 @@
346347 isa = XCBuildConfiguration;
347348 buildSettings = {
348349 ALWAYS_SEARCH_USER_PATHS = NO;
350+ CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
349351 CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
350352 CLANG_CXX_LIBRARY = "libc++";
351353 CLANG_ENABLE_MODULES = YES;
352354 CLANG_ENABLE_OBJC_ARC = YES;
355+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
353356 CLANG_WARN_BOOL_CONVERSION = YES;
357+ CLANG_WARN_COMMA = YES;
354358 CLANG_WARN_CONSTANT_CONVERSION = YES;
359+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
355360 CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
356361 CLANG_WARN_EMPTY_BODY = YES;
357362 CLANG_WARN_ENUM_CONVERSION = YES;
358363 CLANG_WARN_INFINITE_RECURSION = YES;
359364 CLANG_WARN_INT_CONVERSION = YES;
365+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
366+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
367+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
360368 CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
369+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
370+ CLANG_WARN_STRICT_PROTOTYPES = YES;
361371 CLANG_WARN_SUSPICIOUS_MOVE = YES;
362372 CLANG_WARN_UNREACHABLE_CODE = YES;
363373 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -378,6 +388,7 @@
378388 MTL_ENABLE_DEBUG_INFO = NO;
379389 SDKROOT = iphoneos;
380390 SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
391+ SWIFT_SWIFT3_OBJC_INFERENCE = Off;
381392 TARGETED_DEVICE_FAMILY = "1,2";
382393 VALIDATE_PRODUCT = YES;
383394 };
@@ -388,12 +399,12 @@
388399 baseConfigurationReference = 6659D12A5984961F335BDF69 /* Pods-PixelImage.debug.xcconfig */;
389400 buildSettings = {
390401 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
391− DEVELOPMENT_TEAM = HHT774898M;
402+ DEVELOPMENT_TEAM = 8J63JZYYHZ;
392403 INFOPLIST_FILE = PixelImage/Info.plist;
393404 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
394405 PRODUCT_BUNDLE_IDENTIFIER = vinivendra.PixelImage;
395406 PRODUCT_NAME = "$(TARGET_NAME)";
396− SWIFT_VERSION = 3.0;
407+ SWIFT_VERSION = 5.0;
397408 };
398409 name = Debug;
399410 };
@@ -402,12 +413,12 @@
402413 baseConfigurationReference = 0C9CE70F7D2C2896912B7B14 /* Pods-PixelImage.release.xcconfig */;
403414 buildSettings = {
404415 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
405− DEVELOPMENT_TEAM = HHT774898M;
416+ DEVELOPMENT_TEAM = 8J63JZYYHZ;
406417 INFOPLIST_FILE = PixelImage/Info.plist;
407418 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
408419 PRODUCT_BUNDLE_IDENTIFIER = vinivendra.PixelImage;
409420 PRODUCT_NAME = "$(TARGET_NAME)";
410− SWIFT_VERSION = 3.0;
421+ SWIFT_VERSION = 5.0;
411422 };
412423 name = Release;
413424 };
PixelImage/AppDelegate.swift+1−1
@@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1313
1414 var window: UIWindow?
1515
16− func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
16+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
1717 // Override point for customization after application launch.
1818 return true
1919 }
PixelImage/Interpolation.swift+2−1
@@ -14,7 +14,8 @@ func interpolateSquareEaseOut<T: Numeric>(_ linear: T) -> T {
1414}
1515
1616func interpolateSmooth<T: Numeric>(_ linear: T) -> T {
17− return ((linear) * (linear) * (linear) * ((linear) * ((linear) * 6 - 15) + 10))
17+ let cube = (linear) * (linear) * (linear)
18+ return (cube * ((linear) * ((linear) * 6 - 15) + 10))
1819}
1920
2021func createStringKeyframes(_ bounces: Int = 2, elasticity: Double = 1.1, bounceSpeed: Double) -> [(time: Double, position: Double)] {
PixelImage/Metal.swift+2−2
@@ -8,8 +8,8 @@ class MTLContext {
88
99 init(device: MTLDevice = MTLCreateSystemDefaultDevice()!) {
1010 self.device = device
11− self.library = device.newDefaultLibrary()!
12− self.commandQueue = device.makeCommandQueue()
11+ self.library = device.makeDefaultLibrary()!
12+ self.commandQueue = device.makeCommandQueue()!
1313 }
1414}
1515
PixelImage/MetalMetaballRenderer.swift+15−16
@@ -45,15 +45,16 @@ import ChameleonFramework
4545 width: width,
4646 height: height,
4747 mipmapped: false)
48+ textureDescriptor.usage = .shaderWrite
4849
4950 let texture1 =
5051 context.device.makeTexture(descriptor: textureDescriptor)
5152 activeComputeContext = MTLComputeContext(size: targetView.size,
52− texture: texture1)
53+ texture: texture1!)
5354 let texture2 =
5455 context.device.makeTexture(descriptor: textureDescriptor)
5556 idleComputeContext = MTLComputeContext(size: targetView.size,
56− texture: texture2)
57+ texture: texture2!)
5758 }
5859
5960 internal func updateTargetView() {
@@ -62,9 +63,7 @@ import ChameleonFramework
6263
6364 state = .ending
6465
65− let userInteractiveQueue =
66− DispatchQueue.global(qos: DispatchQoS.QoSClass.userInteractive)
67− userInteractiveQueue.async { () -> Void in
66+ DispatchQueue.main.async { () -> Void in
6867 let computeContext = self.activeComputeContext
6968 swap(&self.activeComputeContext, &self.idleComputeContext)
7069
@@ -111,19 +110,19 @@ import ChameleonFramework
111110 // Send commands to metal and render
112111 let commandBuffer = context.commandQueue.makeCommandBuffer()
113112
114− let commandEncoder = commandBuffer.makeComputeCommandEncoder()
115− commandEncoder.setComputePipelineState(pipeline)
116− commandEncoder.setTexture(computeContext.texture, at: 0)
113+ let commandEncoder = commandBuffer!.makeComputeCommandEncoder()
114+ commandEncoder!.setComputePipelineState(pipeline)
115+ commandEncoder!.setTexture(computeContext.texture, index: 0)
117116 let metaballInfoBuffer = metaballBuffer()
118− commandEncoder.setBuffer(metaballInfoBuffer, offset: 0, at: 0)
117+ commandEncoder!.setBuffer(metaballInfoBuffer, offset: 0, index: 0)
119118 let edgesBuffer = metaballEdgesBuffer()
120− commandEncoder.setBuffer(edgesBuffer, offset: 0, at: 1)
121− commandEncoder.dispatchThreadgroups(threadGroups,
119+ commandEncoder!.setBuffer(edgesBuffer, offset: 0, index: 1)
120+ commandEncoder!.dispatchThreadgroups(threadGroups,
122121 threadsPerThreadgroup: threadGroupCounts)
123− commandEncoder.endEncoding()
122+ commandEncoder!.endEncoding()
124123
125− commandBuffer.commit()
126− commandBuffer.waitUntilCompleted()
124+ commandBuffer!.commit()
125+ commandBuffer!.waitUntilCompleted()
127126 } catch _ {
128127 assertionFailure()
129128 }
@@ -186,7 +185,7 @@ import ChameleonFramework
186185 length: bufferLength,
187186 options: MTLResourceOptions())
188187
189− return buffer
188+ return buffer!
190189 }
191190
192191 internal func metaballBuffer() -> MTLBuffer {
@@ -228,6 +227,6 @@ import ChameleonFramework
228227 length: bufferLength,
229228 options: MTLResourceOptions())
230229
231− return buffer
230+ return buffer!
232231 }
233232}
PixelImage/SwiftSugar/Numeric.swift+5−12
@@ -4,20 +4,13 @@ protocol DoubleValuable {
44 static func fromDouble(_ double: Double) -> Self
55}
66
7−postfix operator ++ { }
8−
9−protocol Incrementable {
10− postfix func ++ (_: inout Self) -> Self
11−}
12−
13−protocol Numeric: DoubleValuable, Incrementable, Comparable,
7+protocol Numeric: DoubleValuable, Comparable,
148 ExpressibleByIntegerLiteral {
159
16− @warn_unused_result func / (lhs: Self, rhs: Self) -> Self
17− @warn_unused_result func - (lhs: Self, rhs: Self) -> Self
18− @warn_unused_result func + (lhs: Self, rhs: Self) -> Self
19− @warn_unused_result func * (lhs: Self, rhs: Self) -> Self
20− postfix func ++ (_: inout Self) -> Self
10+ static func / (lhs: Self, rhs: Self) -> Self
11+ static func - (lhs: Self, rhs: Self) -> Self
12+ static func + (lhs: Self, rhs: Self) -> Self
13+ static func * (lhs: Self, rhs: Self) -> Self
2114}
2215
2316protocol FastNumeric: Numeric {}
PixelImage/ViewController.swift+5−5
@@ -80,7 +80,7 @@ class ViewController: UIViewController, MetaballDataSource {
8080 delay(4) {
8181 for i in 1...5 {
8282 UIView.animate(withDuration: 1.0, delay: 0,
83− options: UIViewAnimationOptions(),
83+ options: UIView.AnimationOptions(),
8484 animations: { () -> Void in
8585 let sine = sin(Double(i) * 2 * .pi / 5)
8686 let cosine = cos(Double(i) * 2 * .pi / 5)
@@ -98,7 +98,7 @@ class ViewController: UIViewController, MetaballDataSource {
9898 UIView.animate(withDuration: 1.0, delay: 0,
9999 usingSpringWithDamping: 0.5,
100100 initialSpringVelocity: 0,
101− options: UIViewAnimationOptions(),
101+ options: UIView.AnimationOptions(),
102102 animations: { () -> Void in
103103 let sine = sin(Double(i) * 2 * .pi / 5)
104104 let cosine = cos(Double(i) * 2 * .pi / 5)
@@ -136,7 +136,7 @@ class ViewController: UIViewController, MetaballDataSource {
136136 repeats: true)
137137 }
138138
139− func animateMetaball(withTimer timer: Timer) {
139+ @objc func animateMetaball(withTimer timer: Timer) {
140140 guard let userInfo = timer.userInfo as? VertexAnimationParameters else {
141141 preconditionFailure()
142142 }
@@ -174,7 +174,7 @@ class ViewController: UIViewController, MetaballDataSource {
174174 repeats: true)
175175 }
176176
177− func animateEdge(withTimer timer: Timer) {
177+ @objc func animateEdge(withTimer timer: Timer) {
178178 guard let userInfo = timer.userInfo as? EdgeAnimationParameters else {
179179 preconditionFailure()
180180 }
@@ -199,7 +199,7 @@ class ViewController: UIViewController, MetaballDataSource {
199199 renderer.state = .running
200200 }
201201
202− func handlePan(_ recognizer: UIPanGestureRecognizer) {
202+ @objc func handlePan(_ recognizer: UIPanGestureRecognizer) {
203203 let location = recognizer.location(in: metaballView)
204204
205205 if selectedMetaball == nil {
Podfile.lock+2−2
@@ -12,7 +12,7 @@ EXTERNAL SOURCES:
1212
1313CHECKOUT OPTIONS:
1414 ChameleonFramework:
15− :commit: acc480fbe023c6e5fe40f68593f4a70a8c4c7ad5
15+ :commit: 6dd284bde21ea2e7f9fd89bc36f40df16e16369d
1616 :git: https://github.com/ViccAlexander/Chameleon.git
1717
1818SPEC CHECKSUMS:
@@ -20,4 +20,4 @@ SPEC CHECKSUMS:
2020
2121PODFILE CHECKSUM: 01ad8f20bdbed983c319dde08426f855f26bc5a0
2222
23−COCOAPODS: 1.2.0
23+COCOAPODS: 1.5.2