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

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.

Is there a general interest in this? If so how would this single commit need to be split?

  • Consolidate static and Hal* primitives/transforms into unified classes
    with pre-compiled bytecode/attribute evaluators (ArgsBase) and static
    numeric fast-paths, keeping all Hal* names as aliases.
  • Support optional prefixes via "prefix.attr" dot notation and
    "{prefix.attr}" math/conditional expressions across hal.component,
    hal module, and linuxcnc.stat.
  • Poll linuxcnc.stat instances once per update cycle/redraw via
    poll_all_stats(), including user callbacks (main(..., function=...)).
  • Add automatic two-pass rendering (opaque first, transparent second with
    back-face culling for 0.0 < alpha < 1.0) and emission glow to Color.
  • Add dynamic path/filename loading with display list cleanup to
    AsciiSTL/AsciiOBJ, plus multi-value formatting and graceful warnings to Hud.
  • Fully backwards compatible. All in-tree models in current master work without errors.

@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.

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