Accessing raw loop array

I’m working on creating a C++ mesh exporter for appleseed. I’ve got basic vertex and face export functional but I was wondering how to access the mesh loop array for exporting split normals in a similar way.

For instance, for vertex export I use the as_pointer() method to find the first vertex pointer and then reinterpret_cast it into a recreated MVert structure pointer in appleseed in order to be able to navigate through it properly (based on suggestions from the Lux team). For the loop array I can pass the same pointer to the first loop, but I can’t for the life of me figure out what the struct used in the array looks like and if I’m able to pull the split normal data from it. This stage is by far the slowest part of our export so if I can speed it up by hooking directly into the Blender arrays that would be awesome.

I can’t see any way to access those normals with as_pointer() in the current API. The loop normals are not exposed as an array, though this could be implemented.

The fastest currently alternative may be foreach_get, which avoids some Python overhead but not all.
https://docs.blender.org/api/2.79b/bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection.foreach_get

Hey Brecht. That’s the same conclusion I came to after digging into the source code.

Turns out the vertex normals produce the same result as the loop normals after running a calc_normals() and split_faces() on the mesh, so I ended up using those instead (through the MVert struct). Worked like a charm.

Thanks for the reply. I know you guys are busy.