Closed hongkai-dai closed 5 years ago
This is not how ccd_list works and if you have tried to run tests that are there, you would find that your changes would cause segfaults.
But you are maybe right that ccd_pt_vertex_t.edges is not used for anything meaningful. It is used just for checking whether we can delete a vertex and, I think, we could do this more efficiently...
In the struct
ccd_pt_vertex_t
, it has a fieldedges
. I assume this field means all the edges connecting to this vertex.The
edges
of a vertex is changed in functionccdPtAddEdge(ccd_pt_t* p, ccd_pt_vertex_t* v1, ccd_pt_vertex* v2)
. Hereedge->vertex_list[0]
is appended tov1->edges
, andedge->vertex_list[1]
is appended tov2->edges
.I am confused by these two lines, for two reasons
edge
tov1->edges
andv2->edges
.edge->vertex_list[0]
noredge->vertex_list[1]
were properly initialized, since the creation ofedge
, soedge->vertex_list[0]
andedge->vertex_list[1]
just contain garbage values. Why we want to append garbage values tov1->edges
andv2->edges
?It is worth noting that
ccd_pt_vertex_t.edges
is not really used in the code, so it doesn't cause any damage, but still I think it is better to assign meaningful values to these variables.I can submit a PR for this issue.