92 {
93 const int c = GetBasicColor();
94
95 auto v01 = Dir(fVertices[0], fVertices[1]);
96 auto v02 = Dir(fVertices[0], fVertices[2]);
97 auto v03 = Dir(fVertices[0], fVertices[3]);
98
99 auto v12 = Dir(fVertices[1], fVertices[2]);
100 auto v13 = Dir(fVertices[1], fVertices[3]);
101 auto v10 = Dir(fVertices[1], fVertices[0]);
102
103 auto v23 = Dir(fVertices[2], fVertices[3]);
104 auto v20 = Dir(fVertices[2], fVertices[0]);
105 auto v21 = Dir(fVertices[2], fVertices[1]);
106
107 auto v30 = Dir(fVertices[3], fVertices[0]);
108 auto v31 = Dir(fVertices[3], fVertices[1]);
109 auto v32 = Dir(fVertices[3], fVertices[2]);
110
111 std::vector<std::array<int, 3> > faces;
112 if (Dot(Cross(v01, v02), v03) > 0) {
113 faces.push_back({1, 0, 2});
114 } else {
115 faces.push_back({0, 1, 2});
116 }
117
118 if (Dot(Cross(v12, v13), v10) > 0) {
119 faces.push_back({2, 1, 3});
120 } else {
121 faces.push_back({1, 2, 3});
122 }
123
124 if (Dot(Cross(v23, v20), v21) > 0) {
125 faces.push_back({3, 2, 0});
126 } else {
127 faces.push_back({2, 3, 0});
128 }
129
130 if (Dot(Cross(v30, v31), v32) > 0) {
131 faces.push_back({0, 3, 1});
132 } else {
133 faces.push_back({3, 0, 1});
134 }
135
136 size_t ind = 0;
137 for (const auto& face : faces) {
138 buff.fSegs[ind++] = c;
139 buff.fSegs[ind++] = face[0];
140 buff.fSegs[ind++] = face[1];
141 buff.fSegs[ind++] = c;
142 buff.fSegs[ind++] = face[1];
143 buff.fSegs[ind++] = face[2];
144 buff.fSegs[ind++] = c;
145 buff.fSegs[ind++] = face[2];
146 buff.fSegs[ind++] = face[0];
147 }
148
149 ind = 0;
150 for (size_t i = 0; i < 4; ++i) {
151 buff.fPols[ind++] = c;
152 buff.fPols[ind++] = 3;
153 buff.fPols[ind++] = 3 * i;
154 buff.fPols[ind++] = 3 * i + 1;
155 buff.fPols[ind++] = 3 * i + 2;
156 }
157}