I need to store unique indices of vertices and I can’t use GSet because it only stores pointers.
1 Like
GSet can be used with integers as keys. See how it’s done with GHash and BLI_ghash_int_new_ex
, GSet can work similarly.
Is this correct ?
Adding to it:
intptr_t idx = vi.vert_indices[vi.gx];
BLI_gset_add(vert_idxs, (void *) idx);
Reading it:
GSet *v_idxs = ss->vert_layers[i].vert_idxs;
void *idx;
GSET_FOREACH_BEGIN (void *, idx, v_idxs) {
mask_data[(intptr_t) idx] = mask_amount;
};
GSET_FOREACH_END();
PS: Will Blender ever be C++, so I can use that sweet standard library ?
Seems right, you should use to SET_INT_IN_POINTER()
and GET_INT_FROM_POINTER()
macros to make the casting more explicit.
Some Blender modules use C++, but I don’t know of any concrete plans to convert the core to it as well. It would be convenient for things like this.
2 Likes