Image:CocoaNav icon.png

PARMANOIR

Core Animation culling problems

While playing around with Scott Stevenson's NanoLife, I've wondered 'How would it look in 3d' ?

Unfortunately, it looks … pretty bad.

Image:Nanolife culling problem.jpg

Once you setup a projection matrix and give your layers a z position, Core Animation handles your layers as 3D objects. The problem here is culling : deciding which layers are visible on screen. In 2D the problem is trivial : just check the x,y position of the layer and test that against the NSView boundaries. In 3D, take x,y,zPosition of layers and project them using the projection matrix. You then get a x,y position on screen to render the layer. Rendering works fine — but Core Animation uses the original x,y position of layers to cull them.

Mini workaround

We can somewhat offset the problem by selecting one layer and making it big enough to take up the whole view. But layers will stil be culled to the view boundary according to their original position. Download the sample and check 'fix culling', then drag the dots to an edge : you'll see them disappearing almost all at once.

Image:iconZip.png Nanolife Culling

Core Animation

Scott Stevenson
2008 03 14

There's actually a "sphereContainer" sublayer that holds all of the floating orbs. I'm not sure what the exact effect was that you were going for, I changed this line:

mainLayer.sublayerTransform = transform;

To this:

sphereContainer.sublayerTransform = transform;

And it looks a lot better. I think Core Animation is actually doing the right thing. The NSView's backing layer had the sublayerTransform applied, so the sphereContainer layer was floating out in space.

Patrick Geiller
2008 03 16

Answered on your blog. Thanks !

2008 07 25Where in build phases is that file ?
2008 07 192Imagine clickable error messages
2008 07 18Succulent Stormhoek
2008 07 173Loving the for
2008 07 12(Parmanoir) Feed now validates
2008 07 108Telling classes from instances
2008 07 08Comma Trick
2008 07 06Using libffi
2008 07 04BridgeSupport's type and type64
2008 07 042Clickable Disabled MenuItems
2008 07 026Less bugs through compiler optimizations
2008 06 251CocoaNav JS, a light CocoaNav for Safari
2008 06 232NSWindow goodies : bottomCornerRounded, usesLightBottomGradient
2008 06 222Inspecting NSUndoManager's undo stack
2008 06 16Cocoa Regular Expressions via JavascriptCore
2008 06 15Crossing the WebKit bridge
2008 06 08Double and Triple Click
2008 06 05Photoshop-like compositing with Core Animation
2008 06 052One way binding to NSSlider
2008 05 30Threaded Core Animation, Part Deux
Image:rss.png
Image:rss.png

Powered by MediaWiki

Hi ! I'm learning Cocoa to (hopefully !) become an indie developer.

I've written software all my professional life, in C++, PHP, Javascript. I've designed websites and web interfaces. My last venture went into flames as clients were happy but didn't like paying very much.

I've had little luck in the B2B world, I'm hoping for a better future writing Mac applications.

Planet Cocoa