Post

Replies

Boosts

Views

Activity

ModelIO primitives undocumented and inconsistent.
There are no images on the basic primitives used in ModelIO that I've found so far. If these primitives are meant to be used by apps as starter content, then they should follow consistent modeling and uv wrapping rules. The sphere has uv coordinates where the u direction wraps counterclockwise. The capsule has the same problem. This is the opposite of the cube which fits u clockwise on each face. Solution was to flip x with 1-uv.x. The sphere reports 306 vertices on latest Big Sur, but after vertex 289 the rest of the vertex data is garbage data. The uv seam on the sphere is rotated by -45 degrees from the capsule. I had to flip the bitangent sign too in my app. This seemed to be reversed, but could be from shader issues. On my MBP 16" I'm getting uv's that are non-zero, but all zero derivatives. I don't know yet if this is from 2. Here's part of what I did to fix the mesh. This doesn't include the call to generate tangents and bitangent sign, and then flip the sign. mdlMesh = [MDLMesh newEllipsoidWithRadii:(vector_float3){0.5, 0.5, 0.5} radialSegments:16 verticalSegments:16 geometryType:MDLGeometryTypeTriangles inwardNormals:NO hemisphere:NO allocator:_metalAllocator]; float angle = M_PI * 0.5;   float2 cosSin = float2m(cos(angle), sin(angle));       {     mdlMesh.vertexDescriptor = _mdlVertexDescriptor;           id<MDLMeshBuffer> pos = mdlMesh.vertexBuffers[BufferIndexMeshPosition];     MDLMeshBufferMap *posMap = [pos map];     packed_float3* posData = (packed_float3*)posMap.bytes;           id<MDLMeshBuffer> normals = mdlMesh.vertexBuffers[BufferIndexMeshNormal];     MDLMeshBufferMap *normalsMap = [normals map];     packed_float3* normalData = (packed_float3*)normalsMap.bytes;           // vertexCount reports 306, but vertex 289+ are garbage     uint32_t numVertices = 289; // mdlMesh.vertexCount           for (uint32_t i = 0; i < numVertices; ++i) {       {         auto& pos = posData[i];                 // dumb rotate about Y-axis         auto copy = pos;                   pos.x = copy.x * cosSin.x - copy.z * cosSin.y;         pos.z = copy.x * cosSin.y + copy.z * cosSin.x;       }               {         auto& normal = normalData[i];         auto copy = normal;         normal.x = copy.x * cosSin.x - copy.z * cosSin.y;         normal.z = copy.x * cosSin.y + copy.z * cosSin.x;       }     }           // Hack - knock out all bogus vertices on the sphere     for (uint32_t i = numVertices; i < mdlMesh.vertexCount; ++i) {       auto& pos = posData[i];       pos.x = NAN;     }           }
1
0
701
Jun ’21
QuickLook preview never displays NSImageView
I have an NSImageView-based preview appex plugin for macOS in Objective-C. It's based off the sample template that you can add to an app. It completely makes it through preparePreviewOfFileAtURL, and I stuff pixel data into a CGImage, then that into an NSImage and that onto an NSImageView that is self.view from the storyboard. I can see all data via qlManager -p, since it will print error messages for caveman debugging. I have no idea and there are no docs on using the "Quick Look Simulator" which appears to do nothing. I set background color of the NSImageView.layer to red, and it shows up red. So I know the NSImageView is visible, just not the image that it also points to. About 30% of the time, only the red shows up, and the other 70% of the time nothing shows up in preview just smokey blurred version of the icons underneath in Finder. My only recourse, is to disable the extension list for the preview appex, and let the thumbnailer appex provide the preview. There are no samples of this for macOS, and the default templates aren't a working version of this either.
1
0
805
Feb ’22
NSTableView doesn't gap vertically from top
I have an scrolling NSTableView that has an isFlipped MTKView as the parent. No matter how I set the growth constraints, frame.y (which seems to offset from bottom left still) or adjust the height, I can't get a gap from the top. I have a hud that this then clobbers over. I want to offset from the top-left so this doesn't happen. What is the magic to do this?
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
667
May ’22
Metal compiler fails on valid usage of depth2d<half> references
I'm working on a parser which translates HLSL to HLSL/MSL. But valid MSL isn't compiling when passing the depth2d to a class and class ctor. The ctor use allows globals to be referenced as member variables by the MSL which typically passes it's parameters from call to call. This reports the following which makes no sense. The code is fine with use of texture2d and references, so seems to be a metal compiler bug. It's saying the ctor input needs to be device space, but it's already decleared as such. This limits any use of depth style textures in MSL. DepthTest.metal:31:16: error: no matching constructor for initialization of 'SamplePSNS'   SamplePSNS shader(shadowMap, sampleBorder);         ^   ~~~~~~~~~~~~~~~~~~~~~~~ DepthTest.metal:18:5: note: candidate constructor not viable: address space mismatch in 1st argument ('depth2d<float>'), parameter type must be 'device depth2d<float> &'   SamplePSNS(   ^ DepthTest.metal:5:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided struct SamplePSNS {     ^ DepthTest.metal:5:8: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided #include <metal_stdlib> using namespace metal; struct SamplePSNS {   struct InputPS {     float4 position [[position]];   };       device depth2d<float>& shadowMap;   thread sampler& sampleBorder;       float4 SamplePS(InputPS input) {     return shadowMap.sample_compare(sampleBorder, input.position.xy, input.position.z);   };       SamplePSNS(    device depth2d<float>& shadowMap,    thread sampler& sampleBorder)     : shadowMap(shadowMap),      sampleBorder(sampleBorder)   {} }; fragment float4 SamplePS(   SamplePSNS::InputPS input [[stage_in]],   depth2d<float> shadowMap [[texture(0)]],   sampler sampleBorder [[sampler(0)]]) {   SamplePSNS shader(shadowMap, sampleBorder);   return shader.SamplePS(input); }
1
0
700
Mar ’23
HDR seems broken for iOS on macOS using M2 MBP.
Trying to test HDR running an EDR-capable iOS app on macOS. This is running on the same M2 MBP. On macOS, NSScreen.maximumPotentialExtendedDynamciRangeColorComponentValue returns 16. That's what I'd expect on a mini-led display like this one. On iOS on macOS, UIScreen.potentialEDRHeadroom reports 1.0. That's not correct.
1
0
807
Jun ’23
AppKit does not allow directory to be selected
I have a UTI for "public.directory" and can drag-drop folders onto my app and open them. I also added this to the Info.plist to say the app supported directoryies. But the default "Open" command seems to popup up an NSOpenPanel with folders not selectable. The "Open" button stays disabled. How do I change this? I tried implementing "openDocument", but then it lets through any file type, not just the ones in my Info.plist. So I'd like to just use the default implementation, but need an override for the NSOpenPanel. (IBAction)openDocument:(id)sender { NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setCanChooseFiles:YES]; [panel setCanChooseDirectories:YES]; [panel setAllowsMultipleSelection:NO]; ... }
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
584
Oct ’23
WKWebView changes page off "delete" key
I have the following set, but the WKWebView is losing the page content that I'm updating in a given page whenever the user presses the "delete" key. This is in SwiftUI, and I see no way to intercept and block this key. webView.allowsBackForwardNavigationGestures = false Isn't the whole point of setting this flag, to not just have "swipe" navigation stop, but all back/forward support stop? Also with the backForwardList immutable, it's not like I can delete an entry from it.
1
0
628
Mar ’24
Getting SwiftUI macOS app to have fullscreen menu option.
Not sure why this has to be so obscure. But somehow adding the call into toggleFullscreen, even though this appDelegate doesn't have a window set, adds a menu item with the fn+F menu item. Posting this to save other pain. Plus the View menu doesn't even have a reference, and is empty otherwise. Pretty hard to polish something shippable with these unfixed outstanding flaws in the API. CommandGroup(after: .toolbar) { // must call through NSWindow Button("See Below") { // Window isn't set in AppDelegate, so menu item is skipped. // But add fn+F menu item into app. Suo many stupid hacks. appDelegate.window?.toggleFullScreen(nil) } }
1
1
785
Mar ’24
Don't understand how to access heavyweight WKWebView from NSViewRepresentable
I create @State holding a WKWebView (heavyweight object), and then wrap that in a VKViewRepresentable, then @State var myWebView = newWebView(request: URLRequest(url:URL(string: request)!)) This is the only way I can then reference the webView late on to run javascript queries on it. Otherwise, it's embedded in the View/ContentView hierarchy. So then when I moved from Window to WindowGroup, only one of these WKWebView is created. This looks bad to have an empty detail panel in the previous Window. The docs on WindowGroup state that it makes new state to go with each Window in the WindowGroup, but in this case, that's not the case here.
1
0
525
Mar ’24
Xcode 16 doesn't open file with warning/error (C++)
Xcode 16 breaks fundamental feature of error/warning clickthrough to a given header or .cpp file. The issues list will jump to the point of include, instead of the actual error/warning. There's not even a highlighted line since these files aren't the source of the error. Not really sure how this one got through QA since Apple uses Xcode internally. Now I'm constantly having to scour the report navigator, open the items, and then manually jump to file/line.
1
1
490
Oct ’24
How to receive keyboard/mouse on VisionOS?
I tried using the GameController APIs for this, but they didn't seem to work. Is that the recommended API for handling keyboard/mouse? The notifications for mouse and keyboard connect/disconnect don't seem to be defined for visionOS. The visionOS 2.0 touts keyboard and mouse support. The simulator can even forward keyboard/mouse to the app. But there don't seem to be any sample code of how to programatically receive either of these. The game controller works fine (on device, not on Simulator).
1
0
582
Nov ’24
Why can't Xcode projects be opened in multiple workspaces
So Xcode has projects. And I breakup my code/libraries/targets into those. So why after 20 years of Xcode, can a workspace, that holds projects not display the same project opened in another workspace? The workspace redirects all output the project would normally generate in DerivedData to a completely different folder by default. What this means is I have to shut one workspace, and then open the other workspace with a different set of projects to see the ones that are shared. The workspace can't build because it can't open the project shared with another one that is open. VS sln files don't have this issue, so why do workspace files.
1
0
81
Jun ’25
Xcode new build system doesn't recognize relative paths for error/warning clickthrough
When we switched from the old to new build system, that broke all of our error/warning clickthrough to headers. These are reported as ../../folder/file.h but clicking on the messages doesn't bring up the offending line. The .cpp files clickthrough fine, since they are full paths. My understanding is that the old build system resolve these to full paths, and the new build system does not. What is the solution here? Our Visual Studio projects work and VC++ has a compile option /Fc to force full paths in all diagnostic message.
0
0
579
Mar ’21
Occlusion query and instance buffers
So the underutilized boolean and counting occlusion queries look ideal for predicated rendering given no API support. This should work for 5s and above. generate a set of indexes in an instance buffer have occlusion query write an 8-byte value to that indexed buffer location read the buffer location from each instance. in vertex shader, lookup buffer value at index, and vertkill all instance vertices if 8-byte value is 0 Seems like this should work. This means the instance buffer is dynamically changed on the gpu after it is submitted. The buffer would need to be "private" space for gpu writes, but could be "shared" on iOS. Does this seem viable? One thing that would be useful as an extension to occlusion only write 0, and not any positive values to knock out instance counts. be able to write to 4 bytes instead of 8 to knock out ICB values being able to submit instanced boxes with queries on each one. The current queries require a scoped draw per box which is a lot of commands submitted
0
0
611
May ’21