So, what sort of data structure is require for pseudo-vertices?
Pseudo-vertices are properties of an edge. When an edge is drawn, the number and coordinates of pseudo-vertices along its length must be known.
There are two ways I could store the coordinates. I could either specify the X and Y coordinates individually in two seperate matrices (first box is the edge ID, second box is the ID of the pseudo-vertex, value is the coordinate). Or, I could store a single value between 0 and 1 which represents the proportion of the length along the edge where the pseudo-vertex lies.
The latter approach results in one less matrix, but involves a lot more calculations as the proportion would need to be calculated once initially to establish the proportion, then again when it is rendering time to bounce out some actual coordinates. I think an additional data structure is probably preferable here.
Now, when we're storing coordinates...what do we store? Should it be 2D or 3D coordinates?
2D would be a cheaper calculation... but we want to calculate depth anyway to tell whether the pseudo-vertex should be disabled or not. 2D doesn't let us do that.... but still, I think 2D is the best approach. We can follow it up with a line intersecting plane calculation to determine whether a face or a pseudo-vertex is closer, that allows us to calculate the enabled/disabled state.
So, that means we'd have the following:
pseudovertex2dX[edgeID][pseudovertexID] = X-coordinate
pseudovertex2dY[edgeID][pseudovertexID] = Y-coordinate
pseudovertexenabled[edgeID][pseudovertexID] = boolean
vertexenabled[vertexID] = boolean
A key property of this data structure is that it has to expand or contract in size dynamically from frame to frame. In frame 200, there may be no overlapping edges at all, and thus no pseudo-vertices. In frame 250, maybe there are a bunch of overlapping edges and edge ID's 3 and 4 have 4 pseudo-vertices each. The engine must be able to handle this automatically.
How to do that?
for edgeID = 0,numberofedges do
-- check if any edges are overlapping any other edges
-- if found to overlap another edge, check that this edge is further away at the 2D point of overlap
-- assuming it IS further away, create a pseudo-vertex at the point where the overlap takes place
-- if it's not further away, don't create the pseudo-vertex for this edge (it will be created for the other edge instead when it is checked)
-- check if any edges are intersecting with a plane
-- if intersecting a plane, create a pseudo-vertex at the point of overlap
end
for pseudovertexID = 0,numberofpseudovertices do
-- check if this pseudo-vertex is inside a face
-- if not inside a face, set state to enabled.
-- if it IS inside a face, check if this pseudo-vertex is behind the face. if behind, set state to disabled
-- if in front, set state to enabled
end
for i = 0,numberofedges do
if i == 0 then
-- DrawFrom = EdgeFrom
end
for j = 0,NumberOfPseudoVerticesInThisEdge do
if
Hmm, that last part is going to be tricky. Not quite sure how to represent that in pseudo-code right now..