feat: center of gravity marker for every object - #828
Open
samuelcomeau6 wants to merge 1 commit into
Open
samuelcomeau6 wants to merge 1 commit into
samuelcomeau6 wants to merge 1 commit into
Conversation
Adds a per-object center of gravity marker to the sliced preview, as a preview option in the legend which is hidden by default. - GCodeViewer::ObjectsCoG walks the G-code moves once, attributes every extrusion to the printable object instance whose 2D convex hull it falls into, and accumulates a mass weighted centroid. Mass uses mm3_per_mm and the per filament density, so multi material objects get a correct center of gravity. The Z of a segment is taken half a layer below the nozzle, where the material actually sits. - Nothing is computed while slicing or while the preview loads. The markers are built on the first frame after the user switches them on, so the pass stays off the memory peak of slicing and costs nothing for the users who never turn it on. A new preview only discards the old markers. The update stands down while m_loading is armed, since load() pumps the event loop while holding the non-recursive gcode result lock. - Skirt, brim, support material, the prime tower and custom G-code are left out, so a marker matches the part that comes off the plate. - A standalone G-code file (no print objects) falls back to a single marker for the whole plate. - The marker is the standard center of gravity symbol: a quartered black and white disc, turned to face the camera so it reads the same from any angle and drawn on top of the toolpaths, since the center of gravity is inside the object. Its size in pixels stays constant while zooming. - 'Center of Gravity' sits with the other preview options, in the Line Type view and in the Filament view, with the same eye toggle. The legend row draws the symbol itself through a new EItemType::CoG, so it reads as the glyph rather than a flat swatch. Off by default, remembered in the application config as show_objects_cog. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVXhqDzbHafBk96nYK2xKS
samuelcomeau6
force-pushed
the
per-object-cog
branch
from
September 7, 2026 14:25
1ba52b9 to
eae25ce
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a per-object center of gravity marker to the sliced preview, as a preview option in the legend which is hidden by default.
Screenshots/Recordings/Graphs
Tests
No unit tests: the change is a rendering pass over an in-memory G-code result
plus a legend row, neither of which is reachable from the libslic3r test suite.
Verification
Build allgreen on windows-2022, macos-14 (arm64),ubuntu-24.04 and both Flatpak targets.
object and near half height. L-shaped part — marker sits toward the heavy leg,
outside the bounding-box center.
one per printed instance.
not move.
off on a fresh config; survives restart via
show_objects_cog.