Skip to content

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

Draft
Sigma1912 wants to merge 1 commit into
LinuxCNC:masterfrom
Sigma1912:Vismach_new_version
Draft

Sigma1912 wants to merge 1 commit 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 2. Dec. '26

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.

…ransparency

Consolidate static and HAL-driven Vismach primitives and transforms into
unified classes backed by pre-compiled bytecode/attribute evaluators,
multi-source expression support, and automatic two-pass transparency.

Key changes:
- Unified classes & aliases: Merge static (Translate, Rotate, Scale, Box,
  CylinderX/Y/Z, Sphere, TriangleXY/XZ/YZ, ArcX, AsciiSTL, AsciiOBJ) and
  Hal* classes into single implementations while retaining all Hal* names
  as aliases.
- Multi-source expressions & optional prefixes: Add ArgsBase with one-time
  caller-scope prefix caching for hal.component, hal module, and
  linuxcnc.stat. Support "prefix.attr" dot notation, "{prefix.attr}" math
  expressions, and zero-overhead static numeric fast-paths.
- Single stat.poll() per cycle: Register linuxcnc.stat instances across
  scene objects and user callbacks (main(..., function=...)) via
  poll_all_stats() so status is polled once per update cycle/redraw.
- Two-pass alpha transparency & Color glow: Extend Color to support
  (parts, color, glow=0), dynamic RGBA expressions, emission glow, and
  opaque-first / transparent-second traversal with back-face culling for
  0.0 < alpha < 1.0 (preserving legacy [R, G, B, 0] opaque parts).
- Dynamic mesh loading: Add path support and dynamic filename/path
  expressions to AsciiSTL and AsciiOBJ, freeing old OpenGL display lists
  with glDeleteLists() on reload.
- Upgraded Hud: Support linuxcnc.stat, mixed/conditional expressions,
  multi-value tuple unpacking in format strings, dynamic HUD colors, and
  non-crashing Vismach HUD Warning diagnostics.
- Bug fixes & math cleanup: Fix CylinderY dynamic initialization, HalGrid
  prefix handling, Python 3 floor division in O.redraw() backplot trimming,
  uncaptured Capture() guards, and replace copy.deepcopy() in invert()
  with scale-safe tuple unpacking.
- Backwards compatibility: Retain CoordsBase, legacy Color(color, parts)
  order, zero-arg coords()/get_values() subclass overrides, and dummy
  single-arg primitive calls (e.g., TriangleXZ(0)).
@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

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