Post

Replies

Boosts

Views

Activity

Reply to Filling in a MTLAccelerationStructureInstanceDescriptor
@OOPer, thx for sharing your code.  @JL, in a one-to-one port of Apple‘s ray tracer sample (Accelerating ray tracing using Metal) one would use the transpose of the matrix because the sample uses row-first order and MTLAccelerationStructureInstanceDescriptor.transformationMatrix expects column-first. anInstanceDescriptorPointer.pointee.transformationMatrix = MTLPackedFloat4x3(aNodeInstance.transform.transpose) Without transpose the render result seems to be a single Cornell Box but in fact are nine instances stacked at the same position.  A bit late, but in case anyone else will come across…
Dec ’22
Reply to Settings.bundle does not appear in Settings App
When adding resources using the menu item Insert from..., SP4 puts them into a Recources folder. If it does not exist SP4 creates that folder and adds an entry to Package.swift to process these resources when it builds the app. The entry is .process("Resources"). In my former 5.5 app I put Settings.bundle into the Resources folder and it worked as expected, that is the settings appeared in the Settings App. But in a newer version of SP4, the one with Swift 5.6 support, things seem to have changed. Settings.bundle has to be placed in the top-level folder of the app (as a folder-sibbling of Resources) and Package.swift needs one more entry: .process("Resources"), .copy("Settings.bundle")
Oct ’22
Reply to Task does not run when main defined in a type
Your reply makes perfect sense, but (as there is always a but) the six print statements in my example were actually supposed to give the task time to complete (and on my Winos box they do). If I substitute them with an infinite loop the behavior is the same: the task execs with main defined in extension Dummy and does not exec with main in struct Dummy. That infinite loop thing is quite close to the logic of my app which first starts an independent background task to create files and then loops forever processing these files as they occur. Task execs: struct Dummy {} @main extension Dummy { static func main() { _ = Task { print("in task in main") } var c = 0 while true { c += 1 } } } Task not exec'ing: @main struct Dummy { static func main() { _ = Task { print("in task in main") } var c = 0 while true { c += 1 } } } Inspired by your examples I found adding a rather short Task.sleep makes my task work with main defined in struct Dummy: @main struct Dummy { static func main() async { _ = Task { print("in task in main") } try? await Task.sleep(nanoseconds: 1) var c = 0 while true { c += 1 } } } It's somewhat academic but I really would like to know, well why...
Sep ’22
Reply to Swift Playgrounds - playground icons
I had the same question and found the following hack for those without access to Xcode (which would allow attaching icons to playgrounds, I assume). Here is how I did it after some investigation in one of the sample playgrounds: Close playground in question in SP4 Find playground folder on iCloud CD into and further down into Contents Create folder PrivateResources Copy your image into new folder Back in Contents edit Manifest.plist Add XML lines to top-level <dict> : <key>ImageReference</key> <string><your image file name></string> Open playground in question and edit (!). I found editing crucial as the icon didn't appear after just opened/ closed the playground without at least a minor edit. I did it all on my iPad using Textastic for folder creation, file copying, and editing.
Feb ’22