Skip to content

RFC vismach: unify static/HAL classes, add mixed expressions & transparency - #4932

Draft
Sigma1912 wants to merge 4 commits into
LinuxCNC:masterfrom
Sigma1912:Vismach_new_version
Draft

Sigma1912 wants to merge 4 commits into
LinuxCNC:masterfrom
Sigma1912:Vismach_new_version

Conversation

@Sigma1912

@Sigma1912 Sigma1912 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Request for comment - Not meant for detailed review -
This is a drop-in replacement for the current 'vismach.py' and contains enhancements and changes that I have found useful for creating machine simulations over the years.

Update 4. Dec. '26

This RFC reflects the combined changes up to and including Step 4.

As suggested I will split it like this:

  • 1. Merge the static and Hal* classes, no behaviour change.
  • 2. Prefix and expression syntax, plus the once-per-redraw stat polling.
  • 3. Two-pass transparency and glow.
  • 4. STL/OBJ reloading and the Hud changes.
  • 5. Retire legacy OpenGL and move to OpenGL 3.3 using shaders

@Sigma1912
Sigma1912 marked this pull request as draft November 29, 2026 15:19
@BsAtHome

Copy link
Copy Markdown
Contributor

Not commenting on technical content or merit...
In the doc you removed the introduction of what this module is about. That I think is not a good idea. You should always start your doc with a short form introductory fashion of what it is, what it does for you and why you want it.

@Sigma1912

Copy link
Copy Markdown
Contributor Author

Thanks for the comment.
Agreed on the introduction, I'll make a note to add that if this goes into the next stage.

@grandixximo

Copy link
Copy Markdown
Contributor

I'm in favour. Simpler sim configs for multiaxis machines would help a lot, especially driving parts from expressions on stat values instead of extra HAL glue.

For review I'd split it roughly like this, each step with its own docs:

  1. Merge the static and Hal* classes, no behaviour change.
  2. Prefix and expression syntax, plus the once-per-redraw stat polling.
  3. Two-pass transparency and glow.
  4. STL/OBJ reloading and the Hud changes.

Step 1 is the big diff, so it would be easiest to check on its own against the in-tree models.

@Sigma1912

Copy link
Copy Markdown
Contributor Author

Thank you.
I will take your suggested roadmap and will prepare a PR for step 1.
In addition I also propose a further step 5 that will remove all legacy OpenGL 1.x / GLU calls and move to OpenGL 3.3

Consolidate separate static and HAL-animated transform and geometry classes
into single unified implementations while maintaining full backwards
compatibility:

- Merge Translate, Scale, Rotate, RotateEuler, and Show to accept both
  static values and an optional hal.component with HAL pin names.
- Merge Line, Grid, Plane, and Coords primitives to support origin, normal,
  and normal+direction modes with optional HAL component arguments.
- Consolidate CylinderX, CylinderY, and CylinderZ using a shared
  _CylinderAxis base class.
- Retain all legacy Hal* class names as aliases for backwards compatibility.
- Update vismach.adoc to document the unified classes and legacy aliases.
- Also fixed along the way is a double import hal
Extend argument resolution across transforms, primitives, Color, and Track
to support dynamic dot-notation references and compiled math/conditional
expressions without requiring an explicit HAL component argument:

- Add "prefix.attr" dot-notation and "{prefix.attr}" math/conditional
  expression compilation in ArgsBase (with CoordsBase alias) across
  hal.component, hal module, linuxcnc.stat, and Python dict objects.
- Support hyphenated HAL pin names inside "{...}" tokens and evaluate
  compiled expressions with __builtins__ disabled and pre-allocated
  math environments.
- Register referenced linuxcnc.stat instances automatically and poll them
  once per update/redraw cycle via poll_all_stats().
- Support coordinate expressions in Track, Capture.world_pos(world), both
  Color argument orders, and an optional update callback function in main().
- Cache Collection traversal callables and optimize matrix inversion in
  invert().
- Update vismach.adoc to document prefix syntax, expressions, Track,
  Capture.world_pos(), and main(..., function=...).
Render translucent parts in a second pass after opaque geometry and add
configurable emissive glow to Color:

- Render opaque geometry (alpha >= 1.0) first with depth writes enabled,
  followed by a second blended pass (alpha < 1.0) with depth writes
  disabled so internal components remain visible through translucent parts.
- Keep legacy Color(color, parts) strictly backwards-compatible as
  opaque-only (forcing alpha to 1.0 without transparency or glow).
- Add optional glow parameter (0.0..1.0) to Color(parts, [prefix,]
  color[, glow]) supporting static values, "prefix.attr" paths, and
  "{prefix.attr}" expressions via GL_EMISSION.
- Update vismach.adoc to document two-pass transparency, legacy Color
  behavior, and glow.
@Sigma1912
Sigma1912 force-pushed the Vismach_new_version branch from c2d19ce to 618f3cd Compare December 4, 2026 12:18
…pressions

Unify STL and OBJ mesh loaders with runtime change-detected reloading
and modernize Hud text and conditions with prefix/expression support:

- Unify STL and OBJ under _MeshBase (with legacy AsciiSTL and AsciiOBJ
  aliases), adding automatic Binary STL detection, quad/polygon OBJ
  triangulation, fallback face-normal calculation, and change-detected
  reload(filename=None, data=None, force=False).
- Support "{prefix.attr}" template expressions (including nested braces
  and format specifiers) in Hud.add_txt() and prefix/expression
  evaluation in Hud.add_pin(), show_tag_if_same(), show_tags_in_pin(),
  and hide_all() while keeping legacy HAL pin fallback.
- Update vismach.adoc to document STL/OBJ reload() and Hud expression
  templates.
@Sigma1912
Sigma1912 force-pushed the Vismach_new_version branch from 618f3cd to 04fb9f5 Compare December 4, 2026 12:28
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