MCPcopy Create free account
hub / github.com/MyGUI/mygui / setPoints

Method setPoints

MyGUIEngine/src/MyGUI_PolygonalSkin.cpp:27–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 }
26
27 void PolygonalSkin::setPoints(const std::vector<FloatPoint>& _points)
28 {
29 if (_points.size() < 2)
30 {
31 mVertexCount = 0;
32 mResultVerticiesPos.clear();
33 mResultVerticiesUV.clear();
34 mLinePoints = _points;
35 return;
36 }
37
38 VectorFloatPoint finalPoints;
39 finalPoints.reserve(_points.size());
40
41 mLineLength = 0.0f;
42 FloatPoint point0 = _points[0];
43 finalPoints.push_back(point0);
44 // ignore repeating points
45 for (const auto& point : _points)
46 {
47 if (point0 != point)
48 {
49 finalPoints.push_back(point);
50 mLineLength += len(point.left - point0.left, point.top - point0.top);
51 point0 = point;
52 }
53 }
54
55 mLinePoints = finalPoints;
56
57#ifdef MYGUI_NO_POLYGONAL_SKIN_CROPPING
58 size_t count = (mLinePoints.size() - 1) * VertexQuad::VertexCount * 2;
59#else
60 // it's too hard to calculate maximum possible verticies count and worst
61 // approximation gives 7 times more verticies than in not cropped geometry
62 // so we multiply count by 2, because this looks enough
63 size_t count = (mLinePoints.size() - 1) * VertexQuad::VertexCount * 2 * 2;
64#endif
65 if (count > mVertexCount)
66 {
67 mVertexCount = count;
68 if (nullptr != mRenderItem)
69 mRenderItem->reallockDrawItem(this, mVertexCount);
70 }
71
72 _updateView();
73 }
74
75 void PolygonalSkin::setWidth(float _width)
76 {

Callers 2

drawSplineMethod · 0.80
updateSplineMethod · 0.80

Calls 7

_updateViewFunction · 0.85
reallockDrawItemMethod · 0.80
lenFunction · 0.70
sizeMethod · 0.45
clearMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected