I would like to represent directions in a single edge in a mesh similar to a curve.
However I cannot use curves themselves due to performance issues when dealing with huge amount of curves and not able to have more than 2 endpoints. Linked: Creating/Handling pathfinding large world waypoints in Blender
So I am thinking to represent the order of vertices in an edge as direction. Then I would simply either expose the direction via a gl draw or in the UI panel and also allow to invert the direction by deleting the edge and adding it again in opposite order.
For instance, I add a place using the following code
vertex1 = bm.verts.new((-0.5, -0.5, 0.0)) # 0
vertex2 = bm.verts.new( (0.5, -0.5, 0.0)) # 1
vertex3 = bm.verts.new( (0.5, 0.5, 0.0) ) # 2
vertex4 = bm.verts.new( (-0.5, 0.5, 0.0)) # 3
bm.verts.index_update()
# How to create edges
bm.edges.new( (vertex1, vertex2) ) # 0
bm.edges.new( (vertex2, vertex3) ) # 1
bm.edges.new( (vertex3, vertex4) ) # 2
bm.edges.new( (vertex4, vertex1) ) # 3
Later when I access the bmesh again, using
obj = bpy.context.edit_object
me = obj.data
bm = bmesh.from_edit_mesh(me)
# are the vertices stored in edge guarentee'd to be
# in order at the time they were added
bm.edges[0].verts[0] == bm.verts[0]
bm.edges[0].verts[1] == bm.verts[1]
I have tested it and it does seem correct for few of my test cases. However, I would like to be certain.