Skip to content

add line_width to ThinLines interfaces#201

Merged
koide3 merged 6 commits into
masterfrom
line_width
May 1, 2026
Merged

add line_width to ThinLines interfaces#201
koide3 merged 6 commits into
masterfrom
line_width

Conversation

@koide3

@koide3 koide3 commented May 1, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_width support to glk::ThinLines constructors and Python bindings.
  • Add line_width-aware overloads for update_thin_lines in LightViewerContext and AsyncLightViewerContext (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.

Comment thread src/python/glk.cpp Outdated
Comment on lines +181 to +185
@@ -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);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/python/guik.cpp Outdated
Comment thread src/python/guik.cpp Outdated
Comment on lines 195 to 200
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);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: indices_buffer is now constructed only when indices != nullptr && num_indices > 0, eliminating the UB from null pointer arithmetic. Commit: 64f5904

Comment on lines 201 to +203
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);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines +338 to +341
int num_indices,
bool line_strip,
float line_width,
const ShaderSetting& shader_setting);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copilot finished work on behalf of koide3 May 1, 2026 08:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@koide3

koide3 commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@copilot review this PR

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor

@copilot review this PR

The PR is in good shape. All six previously flagged issues have been addressed:

  • glk::ThinLines constructorsline_width (default 1.0f) added consistently across every overload in the header and implementation.
  • pyplot-like Python constructor (src/python/glk.cpp) — c.size() is now included in the max/min size computation; colors[0] access is guarded by size > 0.
  • async_light_viewer_context.cpp null-pointer UBcolors_buffer and indices_buffer are only populated when the input pointers are non-null, and nullptr is passed explicitly when the buffers are empty.
  • Python guik.cpp bindingsnullptr passed for empty colors/indices rather than relying on .data() of an empty container.
  • Docs@param line_width added to update_thin_lines in light_viewer_context.hpp.

One minor observation: in async_light_viewer_context.cpp the ThinLines object is constructed with the default line_width and then set_line_width(line_width) is called right after. It would be marginally cleaner to pass line_width directly to the constructor (removing the extra call), but it's functionally equivalent and not a correctness issue.

Copilot finished work on behalf of koide3 May 1, 2026 09:29
@koide3 koide3 merged commit 1260ee2 into master May 1, 2026
1 check passed
@koide3 koide3 deleted the line_width branch May 1, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants