GeomVertexArrayFormat::add_column segfaults.

Hi all,

I’m extending my terrain system PGMM that it can calculate tangent and binormal vectors as well as normal vectors. Because Panda3D does not have a default vertexformat which involves tangent or binormal vectors, so I had to create one myself. This is my code to create the ArrayFormat:

PT(GeomVertexArrayFormat) array;
if(_has_color_map) {
array->add_column(InternalName::make("color"),4,Geom::NT_float32,Geom::C_color);
}
array->add_column(InternalName::make("vertex"),3,Geom::NT_float32,Geom::C_point);
array->add_column(InternalName::make("texcoord"),2,Geom::NT_float32,Geom::C_texcoord);
array->add_column(InternalName::make("tangent"),3,Geom::NT_float32,Geom::C_vector);
array->add_column(InternalName::make("normal"),3,Geom::NT_float32,Geom::C_vector);
array->add_column(InternalName::make("binormal"),3,Geom::NT_float32,Geom::C_vector);

Already at the first add_column it segfaults. Am I doing something wrong?
I tested the same thing in a python shell and it worked there.

EDIT: I just found out that if I don’t make it a PT() but just a normal GeomVertexArrayFormat, it passes, but I get assertion errors from referenceCount.I.

PT means “Pointer To” (with reference counting). So you’ve got an uninitialized pointer. Try this:

PT(GeomVertexArrayFormat) array = new GeomVertexArrayFormat();

Hmm. I must’ve overlooked that one :wink:
Thanks a lot, it works great now!