Hey there Memo,
Thanks for the really detailed response. I'd already wondered about the keypress issue, and set up a boolean switch as you suggested into update(). So that wasn't the issue.
I've implemented both of the above suggestions (and the alternative .data() init, which is handy, thanks!)
They both run, and work as expected... right up until I hit the keypress. Arg. The fact that I'm still crashing does suggest that initBuffer was working fine and releasing the allocated buffers, as you expected. So my hunch on memory may be wrong.
One frustrating issue is that the problem seems to freeze Xcode/everything on my screen except the mouse movement. So I can't read any error messages; and I have to force restart the machine to continue. That in itself may be a clue?
So..... after a bit of trial and error commenting out lines, and numerous force restarts(!), I think the crash may be happening when I set the newly initiated buffer as the Kernel argument. i.e. when the final line in the following is called:
When I comment out that line, the app runs through the keypress until it gets to the kernel run line i.e. run1D(). And then it has an EXC_BAD_ACCESS issue, which I guess is to be expected if there is a buffer not set.
So why would setting the kernel arguments cause a stall? Perhaps I need to end, delete and restart the whole kernel?
Thanks for the help so far, anyhow!
p.s.. in the above, planToOctree() contains all of the plan resampling and buffer re-initialising as discussed.
p.p.s. one type on the make_shared line, which I think should be:
octreeGPU = make_shared< msa::OpenCLBufferManagedT <node> >() ;