Freestyle: Fix for destructive view map modifications during chaining operations.
The view map is mostly treated as a read-only data structure by line stylization operations (i.e., selection, chaining, splitting, sorting and stroke creation). The only exception is the chaining operation in some cases where insertion of extra FEdge objects is necessary to ensure the continuity of underlying FEdges from which a chain is constructed. The present revision addresses the removal of extra FEdges so to keep the view map clean and suitable for reuse in subsequent render frames.
This commit is contained in:
@@ -63,6 +63,30 @@ ViewMap::~ViewMap()
|
||||
_VEdges.clear();
|
||||
}
|
||||
|
||||
void ViewMap::Clean()
|
||||
{
|
||||
vector<FEdge*> tmpEdges;
|
||||
|
||||
for (vector<ViewShape*>::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; vs++) {
|
||||
vector<FEdge*>& edges = (*vs)->sshape()->getEdgeList();
|
||||
for (vector<FEdge*>::iterator it = edges.begin(), itend = edges.end(); it != itend; it++) {
|
||||
if ((*it)->isTemporary()) {
|
||||
(*it)->setTemporary(false); // avoid being counted multiple times
|
||||
tmpEdges.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (vector<FEdge*>::iterator it = tmpEdges.begin(), itend = tmpEdges.end(); it != itend; it++) {
|
||||
for (vector<ViewShape*>::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; vs++) {
|
||||
(*vs)->sshape()->RemoveEdge(*it);
|
||||
}
|
||||
(*it)->vertexA()->RemoveFEdge(*it);
|
||||
(*it)->vertexB()->RemoveFEdge(*it);
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
|
||||
ViewShape *ViewMap::viewShape(unsigned id)
|
||||
{
|
||||
int index = _shapeIdToIndex[id];
|
||||
|
||||
Reference in New Issue
Block a user