+ if(vertices.size()>1 && !vertices.back().smooth)
+ vertices.push_back(vertices.back());
+
+ Vertex v;
+ v.pos = p;
+ v.smooth = (!vertices.empty() && smooth);
+
+ if(!vertices.empty())
+ {
+ Vector span = p-vertices.back().pos;
+ span.normalize();
+ v.normal.x = span.y;
+ v.normal.y = -span.x;
+
+ if(vertices.back().smooth)
+ {
+ Vector &n = vertices.back().normal;
+ n += v.normal;
+ n.normalize();
+ }
+ else
+ vertices.back().normal = v.normal;
+ }
+
+ vertices.push_back(v);
+
+ if(vertices.size()==1)