I found it is really difficult to add or modify the objects in MetalCPP with NS::Array,
and there is no NS::MutableArray.
I tried to use std::vector<MTL::AccelerationStructure*>* instead.
However, MTL::InstanceAccelerationStructureDescriptor setInstancedAccelerationStructures()
method needs to pass in a NS::Array
type! How can I convert between them?
I did all those in C++.
Hi QuintonQ,
Once you have your data in the std::vector
, you can create an NS::Array
using the CFArrayCreate
function:
NS::Array* pArray = (NS::Array*)CFArrayCreate(kCFAllocatorDefault, (const void **)accelStructures.data(), accelStructures.size(), &kCFTypeArrayCallBacks);
This function is defined in <CoreFoundation/CoreFoundation.h>
.
Because its name contains "Create", remember to release the array after your program no longer needs it.