add line_width to ThinLines interfaces#201
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the ThinLines drawing APIs to support configuring line width (in pixels) across the C++ core and Python bindings, so callers can control ThinLines thickness without separate setter calls.
Changes:
- Add
line_widthsupport toglk::ThinLinesconstructors and Python bindings. - Add
line_width-aware overloads forupdate_thin_linesinLightViewerContextandAsyncLightViewerContext(C++ + Python). - Minor formatting cleanup in Python bindings (
check_valid_voxels, whitespace).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/python/guik.cpp |
Adds Python overloads for update_thin_lines(..., line_width, ...) for both sync/async viewer contexts. |
src/python/glk.cpp |
Extends Python glk.ThinLines constructors to accept line_width; includes some formatting fixes. |
src/guik/viewer/light_viewer_context_util.cpp |
Implements LightViewerContext::update_thin_lines overload that applies line_width. |
src/guik/viewer/async_light_viewer_context.cpp |
Implements async update_thin_lines overload with line_width (and forwards legacy overload). |
src/glk/thin_lines.cpp |
Updates glk::ThinLines constructors to take and store line_width. |
include/guik/viewer/light_viewer_context.hpp |
Declares new update_thin_lines overloads/templates including line_width. |
include/guik/viewer/async_light_viewer_context.hpp |
Declares new async overloads/templates including line_width. |
include/glk/thin_lines.hpp |
Updates glk::ThinLines public constructor signatures to include line_width (defaulting to 1.0f). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -177,17 +182,18 @@ void define_glk(py::module_& m) { | |||
| colors[i] = glk::colormapf(glk::COLORMAP::TURBO, c[i]); | |||
| } | |||
|
|
|||
| return std::make_shared<glk::ThinLines>(vertices.data(), colors[0].data(), size, line_strip); | |||
| return std::make_shared<glk::ThinLines>(vertices.data(), colors[0].data(), size, line_strip, line_width); | |||
There was a problem hiding this comment.
Fixed: c.size() is now included in the initial max and subsequent min computation for size, and the colors[0] access is guarded with size > 0. The redundant && i < c.size() in the loop condition was also removed since size is now bounded by c.size(). Commit: 8929991
| std::vector<float> colors_buffer; | ||
| if (colors) { | ||
| colors_buffer.assign(colors, colors + 4 * num_vertices); | ||
| } | ||
| std::vector<unsigned int> indices_buffer(indices, indices + num_indices); | ||
|
|
There was a problem hiding this comment.
Fixed: indices_buffer is now constructed only when indices != nullptr && num_indices > 0, eliminating the UB from null pointer arithmetic. Commit: 64f5904
| guik::viewer()->invoke([=] { | ||
| auto thin_lines = std::make_shared<glk::ThinLines>(vertices_buffer.data(), colors_buffer.data(), num_vertices, indices_buffer.data(), num_indices, line_strip); | ||
| thin_lines->set_line_width(line_width); |
There was a problem hiding this comment.
Fixed: nullptr is now passed to glk::ThinLines when colors_buffer or indices_buffer are empty, rather than relying on .data() returning nullptr for empty vectors. Commit: 64f5904
| int num_indices, | ||
| bool line_strip, | ||
| float line_width, | ||
| const ShaderSetting& shader_setting); |
There was a problem hiding this comment.
Added @param line_width Width of the lines in pixels. to the doc comment, consistent with async_light_viewer_context.hpp. Commit: 3d84c44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…context.hpp Agent-Logs-Url: https://github.com/koide3/iridescence/sessions/44514c31-be2a-4517-b17d-4363bfaa0973 Co-authored-by: koide3 <31344317+koide3@users.noreply.github.com>
…ewer_context.cpp Agent-Logs-Url: https://github.com/koide3/iridescence/sessions/9dde4cd6-e065-42bf-a21c-0bfde09f1d09 Co-authored-by: koide3 <31344317+koide3@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…but c non-empty Agent-Logs-Url: https://github.com/koide3/iridescence/sessions/5408ca4b-ee3e-4212-89fc-c9a3d387a27e Co-authored-by: koide3 <31344317+koide3@users.noreply.github.com>
|
@copilot review this PR |
The PR is in good shape. All six previously flagged issues have been addressed:
One minor observation: in |
No description provided.