MCPcopy Create free account
hub / github.com/city-super/Scaffold-GS / circle

Method circle

SIBR_viewers/src/core/view/interface/InterfaceUtils.cpp:201–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199 }
200
201 void InterfaceUtilities::circle(const sibr::Vector3f & color, const UV11 & center, float radius, bool fill, float alpha, const sibr::Vector2f & scaling, int precision)
202 {
203
204 static int n;
205 static sibr::Mesh::Ptr circleMesh;
206 static sibr::Mesh::Ptr circleFilledMesh;
207 static sibr::Mesh::Triangles circleTriangles;
208 static sibr::Mesh::Triangles circleFillTriangles;
209 static int lastContextId = -1;
210
211 bool updateMeshes = (lastContextId != sibr::Window::contextId) || (n != precision);
212 if (updateMeshes) {
213 lastContextId = sibr::Window::contextId;
214 n = precision;
215 circleTriangles.resize(n);
216 circleFillTriangles.resize(n);
217 for (int i = 0; i < n; ++i) {
218 int next = (i + 1) % n;
219 circleTriangles[i] = sibr::Vector3u(i, i, next);
220 circleFillTriangles[i] = sibr::Vector3u(i, next, n);
221 }
222
223 sibr::Mesh::Vertices vertices(n + 1);
224 double base_angle = 2.0*M_PI / (double)n;
225 float rho = 0.5f*radius*(float)(1.0 + cos(0.5*base_angle));
226
227 for (int i = 0; i < n; ++i) {
228 double angle = i*base_angle;
229 vertices[i] = sibr::Vector3f((float)cos(angle), (float)sin(angle), (float)0.0);
230 }
231 vertices[n] = sibr::Vector3f(0, 0, 0);
232
233 circleMesh = std::make_shared<sibr::Mesh>(true);
234 circleFilledMesh = std::make_shared<sibr::Mesh>(true);
235 circleMesh->vertices(vertices);
236 circleFilledMesh->vertices(vertices);
237 circleMesh->triangles(circleTriangles);
238 circleFilledMesh->triangles(circleFillTriangles);
239 }
240
241 baseShader.begin();
242
243 translationGL.set(sibr::Vector2f(0, 0));
244
245 colorGL.set(color);
246 scalingGL.set(scaling);
247 translationGL.set(center);
248
249 if (fill) {
250 alphaGL.set(alpha);
251 glEnable(GL_BLEND);
252 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
253 glBlendEquation(GL_FUNC_ADD);
254 circleFilledMesh->render(false, false);
255 }
256
257 alphaGL.set(1.0f);
258 circleMesh->render(false, false, sibr::Mesh::LineRenderMode);

Callers

nothing calls this directly

Calls 7

verticesMethod · 0.60
trianglesMethod · 0.60
resizeMethod · 0.45
beginMethod · 0.45
setMethod · 0.45
renderMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected