Я хотел бы использовать некоторый существующий код C ++, NvTriStrip , в инструменте Python.
SWIG легко обрабатывает функции с простыми параметрами, но основная функция, GenerateStrips
, гораздо сложнее.
Что мне нужно поместить в файл интерфейса SWIG, чтобы указать, что primGroups
действительно является выходным параметром и что его необходимо очистить с помощью delete[]
?
///////////////////////////////////////////////////////////////////////////
// GenerateStrips()
//
// in_indices: input index list, the indices you would use to render
// in_numIndices: number of entries in in_indices
// primGroups: array of optimized/stripified PrimitiveGroups
// numGroups: number of groups returned
//
// Be sure to call delete[] on the returned primGroups to avoid leaking mem
//
bool GenerateStrips( const unsigned short* in_indices,
const unsigned int in_numIndices,
PrimitiveGroup** primGroups,
unsigned short* numGroups,
bool validateEnabled = false );
К вашему сведению, вот объявление PrimitiveGroup
:
enum PrimType
{
PT_LIST,
PT_STRIP,
PT_FAN
};
struct PrimitiveGroup
{
PrimType type;
unsigned int numIndices;
unsigned short* indices;
PrimitiveGroup() : type(PT_STRIP), numIndices(0), indices(NULL) {}
~PrimitiveGroup()
{
if(indices)
delete[] indices;
indices = NULL;
}
};