git.iko.soy/metal-metaballs
on b88fbfc help sign in
8 files changed+63−67
since splitsnapshots
unifiedsplit
PixelImage.xcodeproj/project.pbxproj+24−35 PixelImage/AppDelegate.swift+1−1 PixelImage/Interpolation.swift+1−2 PixelImage/Metal.swift+2−2 PixelImage/MetalMetaballRenderer.swift+16−15 PixelImage/SwiftSugar/Numeric.swift+12−5 PixelImage/ViewController.swift+5−5 Podfile.lock+2−2
PixelImage.xcodeproj/project.pbxproj+24−35
@@ -144,6 +144,7 @@
144144 242686811C63B72A00D62456 /* Frameworks */,
145145 242686821C63B72A00D62456 /* Resources */,
146146 3CA888DC160972BAEB74EC52 /* [CP] Embed Pods Frameworks */,
147+ 47F9F13E3CB75C7B4B0136A5 /* [CP] Copy Pods Resources */,
147148 );
148149 buildRules = (
149150 );
@@ -161,13 +162,13 @@
161162 isa = PBXProject;
162163 attributes = {
163164 LastSwiftUpdateCheck = 0720;
164− LastUpgradeCheck = 1020;
165+ LastUpgradeCheck = 0830;
165166 ORGANIZATIONNAME = "Vinicius Vendramini";
166167 TargetAttributes = {
167168 242686831C63B72A00D62456 = {
168169 CreatedOnToolsVersion = 7.2;
169− DevelopmentTeam = 8J63JZYYHZ;
170− LastSwiftMigration = 1020;
170+ DevelopmentTeam = HHT774898M;
171+ LastSwiftMigration = 0830;
171172 };
172173 };
173174 };
@@ -176,7 +177,6 @@
176177 developmentRegion = English;
177178 hasScannedForEncodings = 0;
178179 knownRegions = (
179− English,
180180 en,
181181 Base,
182182 );
@@ -210,16 +210,13 @@
210210 files = (
211211 );
212212 inputPaths = (
213− "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
214− "${PODS_ROOT}/Manifest.lock",
215213 );
216214 name = "[CP] Check Pods Manifest.lock";
217215 outputPaths = (
218− "$(DERIVED_FILE_DIR)/Pods-PixelImage-checkManifestLockResult.txt",
219216 );
220217 runOnlyForDeploymentPostprocessing = 0;
221218 shellPath = /bin/sh;
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";
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";
223220 showEnvVarsInLog = 0;
224221 };
225222 3CA888DC160972BAEB74EC52 /* [CP] Embed Pods Frameworks */ = {
@@ -228,18 +225,30 @@
228225 files = (
229226 );
230227 inputPaths = (
231− "${SRCROOT}/Pods/Target Support Files/Pods-PixelImage/Pods-PixelImage-frameworks.sh",
232− "${BUILT_PRODUCTS_DIR}/ChameleonFramework/ChameleonFramework.framework",
233228 );
234229 name = "[CP] Embed Pods Frameworks";
235230 outputPaths = (
236− "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/ChameleonFramework.framework",
237231 );
238232 runOnlyForDeploymentPostprocessing = 0;
239233 shellPath = /bin/sh;
240234 shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-PixelImage/Pods-PixelImage-frameworks.sh\"\n";
241235 showEnvVarsInLog = 0;
242236 };
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+ };
243252/* End PBXShellScriptBuildPhase section */
244253
245254/* Begin PBXSourcesBuildPhase section */
@@ -290,27 +299,18 @@
290299 isa = XCBuildConfiguration;
291300 buildSettings = {
292301 ALWAYS_SEARCH_USER_PATHS = NO;
293− CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
294302 CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
295303 CLANG_CXX_LIBRARY = "libc++";
296304 CLANG_ENABLE_MODULES = YES;
297305 CLANG_ENABLE_OBJC_ARC = YES;
298− CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
299306 CLANG_WARN_BOOL_CONVERSION = YES;
300− CLANG_WARN_COMMA = YES;
301307 CLANG_WARN_CONSTANT_CONVERSION = YES;
302− CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
303308 CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
304309 CLANG_WARN_EMPTY_BODY = YES;
305310 CLANG_WARN_ENUM_CONVERSION = YES;
306311 CLANG_WARN_INFINITE_RECURSION = YES;
307312 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;
311313 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,7 +338,6 @@
338338 ONLY_ACTIVE_ARCH = YES;
339339 SDKROOT = iphoneos;
340340 SWIFT_OPTIMIZATION_LEVEL = "-Onone";
341− SWIFT_SWIFT3_OBJC_INFERENCE = Off;
342341 TARGETED_DEVICE_FAMILY = "1,2";
343342 };
344343 name = Debug;
@@ -347,27 +346,18 @@
347346 isa = XCBuildConfiguration;
348347 buildSettings = {
349348 ALWAYS_SEARCH_USER_PATHS = NO;
350− CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
351349 CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
352350 CLANG_CXX_LIBRARY = "libc++";
353351 CLANG_ENABLE_MODULES = YES;
354352 CLANG_ENABLE_OBJC_ARC = YES;
355− CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
356353 CLANG_WARN_BOOL_CONVERSION = YES;
357− CLANG_WARN_COMMA = YES;
358354 CLANG_WARN_CONSTANT_CONVERSION = YES;
359− CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
360355 CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
361356 CLANG_WARN_EMPTY_BODY = YES;
362357 CLANG_WARN_ENUM_CONVERSION = YES;
363358 CLANG_WARN_INFINITE_RECURSION = YES;
364359 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;
368360 CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
369− CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
370− CLANG_WARN_STRICT_PROTOTYPES = YES;
371361 CLANG_WARN_SUSPICIOUS_MOVE = YES;
372362 CLANG_WARN_UNREACHABLE_CODE = YES;
373363 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -388,7 +378,6 @@
388378 MTL_ENABLE_DEBUG_INFO = NO;
389379 SDKROOT = iphoneos;
390380 SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
391− SWIFT_SWIFT3_OBJC_INFERENCE = Off;
392381 TARGETED_DEVICE_FAMILY = "1,2";
393382 VALIDATE_PRODUCT = YES;
394383 };
@@ -399,12 +388,12 @@
399388 baseConfigurationReference = 6659D12A5984961F335BDF69 /* Pods-PixelImage.debug.xcconfig */;
400389 buildSettings = {
401390 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
402− DEVELOPMENT_TEAM = 8J63JZYYHZ;
391+ DEVELOPMENT_TEAM = HHT774898M;
403392 INFOPLIST_FILE = PixelImage/Info.plist;
404393 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
405394 PRODUCT_BUNDLE_IDENTIFIER = vinivendra.PixelImage;
406395 PRODUCT_NAME = "$(TARGET_NAME)";
407− SWIFT_VERSION = 5.0;
396+ SWIFT_VERSION = 3.0;
408397 };
409398 name = Debug;
410399 };
@@ -413,12 +402,12 @@
413402 baseConfigurationReference = 0C9CE70F7D2C2896912B7B14 /* Pods-PixelImage.release.xcconfig */;
414403 buildSettings = {
415404 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
416− DEVELOPMENT_TEAM = 8J63JZYYHZ;
405+ DEVELOPMENT_TEAM = HHT774898M;
417406 INFOPLIST_FILE = PixelImage/Info.plist;
418407 LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
419408 PRODUCT_BUNDLE_IDENTIFIER = vinivendra.PixelImage;
420409 PRODUCT_NAME = "$(TARGET_NAME)";
421− SWIFT_VERSION = 5.0;
410+ SWIFT_VERSION = 3.0;
422411 };
423412 name = Release;
424413 };
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: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
16+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1717 // Override point for customization after application launch.
1818 return true
1919 }
PixelImage/Interpolation.swift+1−2
@@ -14,8 +14,7 @@ func interpolateSquareEaseOut<T: Numeric>(_ linear: T) -> T {
1414}
1515
1616func interpolateSmooth<T: Numeric>(_ linear: T) -> T {
17− let cube = (linear) * (linear) * (linear)
18− return (cube * ((linear) * ((linear) * 6 - 15) + 10))
17+ return ((linear) * (linear) * (linear) * ((linear) * ((linear) * 6 - 15) + 10))
1918}
2019
2120func 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.makeDefaultLibrary()!
12− self.commandQueue = device.makeCommandQueue()!
11+ self.library = device.newDefaultLibrary()!
12+ self.commandQueue = device.makeCommandQueue()
1313 }
1414}
1515
PixelImage/MetalMetaballRenderer.swift+16−15
@@ -45,16 +45,15 @@ import ChameleonFramework
4545 width: width,
4646 height: height,
4747 mipmapped: false)
48− textureDescriptor.usage = .shaderWrite
4948
5049 let texture1 =
5150 context.device.makeTexture(descriptor: textureDescriptor)
5251 activeComputeContext = MTLComputeContext(size: targetView.size,
53− texture: texture1!)
52+ texture: texture1)
5453 let texture2 =
5554 context.device.makeTexture(descriptor: textureDescriptor)
5655 idleComputeContext = MTLComputeContext(size: targetView.size,
57− texture: texture2!)
56+ texture: texture2)
5857 }
5958
6059 internal func updateTargetView() {
@@ -63,7 +62,9 @@ import ChameleonFramework
6362
6463 state = .ending
6564
66− DispatchQueue.main.async { () -> Void in
65+ let userInteractiveQueue =
66+ DispatchQueue.global(qos: DispatchQoS.QoSClass.userInteractive)
67+ userInteractiveQueue.async { () -> Void in
6768 let computeContext = self.activeComputeContext
6869 swap(&self.activeComputeContext, &self.idleComputeContext)
6970
@@ -110,19 +111,19 @@ import ChameleonFramework
110111 // Send commands to metal and render
111112 let commandBuffer = context.commandQueue.makeCommandBuffer()
112113
113− let commandEncoder = commandBuffer!.makeComputeCommandEncoder()
114− commandEncoder!.setComputePipelineState(pipeline)
115− commandEncoder!.setTexture(computeContext.texture, index: 0)
114+ let commandEncoder = commandBuffer.makeComputeCommandEncoder()
115+ commandEncoder.setComputePipelineState(pipeline)
116+ commandEncoder.setTexture(computeContext.texture, at: 0)
116117 let metaballInfoBuffer = metaballBuffer()
117− commandEncoder!.setBuffer(metaballInfoBuffer, offset: 0, index: 0)
118+ commandEncoder.setBuffer(metaballInfoBuffer, offset: 0, at: 0)
118119 let edgesBuffer = metaballEdgesBuffer()
119− commandEncoder!.setBuffer(edgesBuffer, offset: 0, index: 1)
120− commandEncoder!.dispatchThreadgroups(threadGroups,
120+ commandEncoder.setBuffer(edgesBuffer, offset: 0, at: 1)
121+ commandEncoder.dispatchThreadgroups(threadGroups,
121122 threadsPerThreadgroup: threadGroupCounts)
122− commandEncoder!.endEncoding()
123+ commandEncoder.endEncoding()
123124
124− commandBuffer!.commit()
125− commandBuffer!.waitUntilCompleted()
125+ commandBuffer.commit()
126+ commandBuffer.waitUntilCompleted()
126127 } catch _ {
127128 assertionFailure()
128129 }
@@ -185,7 +186,7 @@ import ChameleonFramework
185186 length: bufferLength,
186187 options: MTLResourceOptions())
187188
188− return buffer!
189+ return buffer
189190 }
190191
191192 internal func metaballBuffer() -> MTLBuffer {
@@ -227,6 +228,6 @@ import ChameleonFramework
227228 length: bufferLength,
228229 options: MTLResourceOptions())
229230
230− return buffer!
231+ return buffer
231232 }
232233}
PixelImage/SwiftSugar/Numeric.swift+12−5
@@ -4,13 +4,20 @@ protocol DoubleValuable {
44 static func fromDouble(_ double: Double) -> Self
55}
66
7−protocol Numeric: DoubleValuable, Comparable,
7+postfix operator ++ { }
8+
9+protocol Incrementable {
10+ postfix func ++ (_: inout Self) -> Self
11+}
12+
13+protocol Numeric: DoubleValuable, Incrementable, Comparable,
814 ExpressibleByIntegerLiteral {
915
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
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
1421}
1522
1623protocol 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: UIView.AnimationOptions(),
83+ options: UIViewAnimationOptions(),
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: UIView.AnimationOptions(),
101+ options: UIViewAnimationOptions(),
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− @objc func animateMetaball(withTimer timer: Timer) {
139+ 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− @objc func animateEdge(withTimer timer: Timer) {
177+ 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− @objc func handlePan(_ recognizer: UIPanGestureRecognizer) {
202+ 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: 6dd284bde21ea2e7f9fd89bc36f40df16e16369d
15+ :commit: acc480fbe023c6e5fe40f68593f4a70a8c4c7ad5
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.5.2
23+COCOAPODS: 1.2.0