⚡ Speed Optimization

Performance Tuning for Heavy Operations

Overview

Heavy solid modeling operations (blade profile generation, boolean operations, face removal) can be significantly slowed by continuous OpenGL rendering updates. This document covers techniques to minimize rendering overhead while maintaining user feedback through the NucleoSphere progress indicator.

Key Finding

Hiding solids during heavy operations provides 3-4x speedup (from ~4 seconds to ~1 second for 20 iterations of sphere animation). The optimal approach uses sld vis hid 1 combined with selective sld show body to keep the progress sphere visible.

Solid Visibility Commands

SolidCut CAD provides several methods to control solid visibility:

CommandEffectSelective Show After?Notes
sld hide all Blanket hide - stops ALL rendering ❌ No Fastest, but sld show body cannot punch through
sld show all Show all bodies Restores from sld hide all
sld hide body N Hide individual body Requires tracking each body ID
sld show body N Show individual body Works to restore individually hidden bodies
sld vis hid 1 Workspace toggle - hide all ✅ Yes RECOMMENDED - allows selective show
sld vis hid 0 Workspace toggle - show all Restores original visibility state

⚠️ Critical Difference

sld hide all creates a blanket block that prevents ANY rendering. Even sld show body N cannot make a body visible through this block.

sld vis hid 1 sets a visibility flag on each body individually, so sld show body N CAN selectively make specific bodies visible.

SLD Command Reference

Complete reference for solid visibility and rendering control commands discovered through testing.

Visibility Control Commands

CommandSyntaxDescription
sld hide all sld hide all Blanket hide - completely stops all solid rendering. Creates a global block that prevents ANY body from being displayed, even with sld show body. Fastest for complete suppression.
sld show all sld show all Restores all bodies hidden by sld hide all. Does NOT restore bodies hidden individually with sld hide body.
sld hide body sld hide body i_bodyID Hides a specific body by ID. Body remains hidden until explicitly shown with sld show body. Useful for selective hiding but requires tracking each body.
sld show body sld show body i_bodyID Shows a specific body by ID. Works after sld hide body or sld vis hid 1, but NOT after sld hide all.
sld vis hid 1 sld vis hid 1 RECOMMENDED. Workspace-level visibility toggle - hides all bodies but allows selective sld show body to punch through. Different mechanism than sld hide all.
sld vis hid 0 sld vis hid 0 Restores workspace visibility. All bodies return to their previous visibility state.

Material & Appearance Commands

CommandSyntaxDescription
sld material set body sld material set body -i_body R G B R G B R G B alpha shininess i_ret Sets body color and transparency. Negative body ID required. RGB values 0-255. Alpha=transparency (0=opaque, 255=invisible). Shininess=0 makes body invisible.
sld description set sld description set i_body $_text i_ret Sets tooltip/description text for a body. Appears on hover in viewport.

Body Query Commands

CommandSyntaxDescription
sld pic all bod sld pic all bod i_setNum i_count Picks all bodies into a VDM set. Returns count of bodies found. Note: May return duplicate IDs in some cases.
sld get bod sld get bod i_setNum i_index i_bodyID Gets body ID at index from a set. Index is 0-based.
sld body extent sld body extent i_body w_xMin w_yMin w_zMin w_xMax w_yMax w_zMax Gets bounding box of a body. Also available as sld bod ext.
sld ask bod las sld ask bod las i_bodyID Gets the ID of the last created body. Useful after boolean operations.

Body Transformation Commands

CommandSyntaxDescription
sld body transform sld body transform i_body m_matrix i_ret Applies a transformation matrix to a body. Matrix must be created with set m1 and operations like translate, rotate.
sld copy body sld copy body i_src i_dst i_ret Creates a copy of a body. New body ID returned in i_dst.
sld delete sld delete i_body i_ret Deletes a body from the workspace.

Error Handling

CommandSyntaxDescription
sld ret sld ret i_errorVar Sets error capture variable. Subsequent SLD commands store error codes here instead of aborting. Use sld ret (no param) to disable.

Graphics Control Commands

CommandSyntaxDescription
ogl don dra set ogl don dra set 1 / ogl don dra set 0 Disables/enables OpenGL drawing. 1=disable, 0=enable. Use to batch operations without intermediate redraws.
ogl ruler set ogl ruler set 0 i_visible Shows/hides the scale ruler. 0=viewport index, i_visible=i_TRUE/i_FALSE.
red -1 red -1 Forces a redraw of all viewports. Use sparingly during loops.
window window 0 / window 1 Disables/enables window updates. 0=disable, 1=enable. Faster than ogl don dra set for some operations.

Camera/View Commands

CommandSyntaxDescription
ogl get camera ogl get camera -1 i_view w_eyeX w_eyeY w_eyeZ w_ctrX w_ctrY w_ctrZ w_upX w_upY w_upZ w_scale Gets current camera state. -1=current viewport. Save before zoom operations.
ogl set camera ogl set camera i_view w_eyeX w_eyeY w_eyeZ w_ctrX w_ctrY w_ctrZ w_upX w_upY w_upZ w_scale Sets camera state. Use to restore saved view or zoom to specific area.
ogl get view ogl get view -1 i_vis i_view i_x i_y i_w i_h i_style w_xDiv w_yDiv Gets viewport configuration. -1=current viewport.
view current view current Refreshes the current view after camera changes.

💡 Discovery Notes

These commands were discovered through systematic testing in January 2026. Key findings:

  • sld vis hid 1/0 uses a different mechanism than sld hide all - this is why selective show works
  • sld pic all bod may return duplicate body IDs - always validate
  • window 0/1 is sometimes faster than ogl don dra set 1/0
  • Negative body ID required for sld material set body - positive ID fails silently

Performance Test Results

Testing with fxIntegrationTest blade generation (Mode 99 benchmark, body 80):

Benchmark Results (11 Jan 2026)

Note: These tests were run with fxNucleoShellsMatchColors=1 (2 shells). Results may vary with 8 shells.

TestSuppress GfxLimit ViewSphereTimeSpeedup
1 - Baseline OFF OFF ON (2 shells) 4 sec 1.00x
2 - Suppress Gfx ON OFF ON (2 shells) 4 sec 1.00x
3 - Limit View OFF ON ON (2 shells) 4 sec 1.00x
4 - Both ON ON ON (2 shells) 3 sec 1.33x
5 - No Sphere ON OFF OFF 2 sec 2.00x

✅ Recommended Production Settings

  • i_FX_SUPPRESS_GRAPHICS = 1 + i_FX_LIMIT_VIEW_MODE = 1 - Combined gives 1.33x speedup
  • i_FX_SHOW_PROGRESS = 0 for batch processing - 2x speedup
  • With more shells (8), individual optimizations may help more

Key Findings

  • With 2 shells: Individual optimizations (suppress OR limit view) show no measurable improvement
  • With 2 shells: Combined optimizations (suppress + limit view) give 1.33x speedup
  • Disabling the progress sphere (i_FX_SHOW_PROGRESS = 0) gives 2x total speedup
  • The sphere itself has overhead - disable for batch/headless processing
  • More shells (8) may show greater benefit from individual optimizations

Hide/Show Mode Comparison (Sphere Animation Only)

Testing with NucleoSphere animation (20 iterations of rotation updates):

ModeTimeSpeedupSphere VisibleMethod
0 3-4 sec 1x (baseline) ✅ Yes No hide/show
1 1 sec 3-4x ❌ No sld hide all / sld show all
2 1-2 sec 2-3x ✅ Yes sld hide body / sld show body (individual)
3 1 sec 3-4x ❌ No sld vis hid 1 / sld vis hid 0
4 1 sec 3-4x ✅ Yes sld vis hid 1 + sld show body for sphere

✅ Recommended: Mode 4

Use sld vis hid 1 to hide all bodies, then sld show body for each NucleoSphere shell. This provides maximum speedup while keeping the progress indicator visible.

Implementation Pattern

Visibility Helper Macros (Standalone Files)

Each macro is in its own .ovm file so it can be called from anywhere (macros fall out of scope when included):

FileMacroDescription
fxHideAllSolids.ovm fxHideAllSolids sld hide all - hide everything (fastest, no sphere visible)
fxShowAllSolids.ovm fxShowAllSolids sld show all - show everything
fxHideAllExceptSphere.ovm fxHideAllExceptSphere sld vis hid 1 + show sphere shells (recommended)
fxRestoreHiddenBodies.ovm fxRestoreHiddenBodies sld vis hid 0 - restore visibility
fxEnsureSolidsVisible.ovm fxEnsureSolidsVisible Error recovery - restore if hidden

Location: modeling\

Usage WITH Sphere Visualization

'*** Initialize sphere
call fxNucleoSphere -1 i_NOT_SET 8 0 0 1

'*** Hide all bodies, keep sphere visible
call fxHideAllExceptSphere
window 0

'*** ... heavy operations (sphere rotates during fxMakeWatertight, etc) ...

window 1
call fxRestoreHiddenBodies
red -1

'*** Cleanup sphere
call fxNucleoSphere i_NOT_SET i_NOT_SET 8 0 0 1

Usage WITHOUT Sphere (Fastest)

'*** Hide all bodies
call fxHideAllSolids
window 0

'*** ... heavy operations ...

window 1
call fxShowAllSolids
red -1

fxMakeWatertight with Progress

🆕 v1.3 Feature

fxMakeWatertight (v1.3) has built-in NucleoSphere progress calls during face processing.

  • Two-pass mode: 0-50% for cylinders, 50-100% for planes
  • Single-pass mode: 0-100% for specified face type
  • If sphere is NOT initialized, progress calls are no-ops (no overhead)
'*** To see progress during watertight creation:
call fxNucleoSphere -1 i_NOT_SET 8 0 0 1    '*** Init sphere first
call fxHideAllExceptSphere
window 0
call fxMakeWatertight i_partBody 0 0       '*** Sphere rotates automatically
window 1
call fxRestoreHiddenBodies
red -1
call fxNucleoSphere i_NOT_SET i_NOT_SET 8 0 0 1  '*** Cleanup

Other Rendering Controls

Ruler Visibility

The scale ruler in the viewport can be hidden during operations:

ogl ruler set 0 i_FALSE    '*** Hide rulers
'*** ... operations ...
ogl ruler set 0 i_TRUE     '*** Restore rulers

Sheet Transparency

Cutting sheets can be made invisible in production mode:

if i_FX_DEBUG_LEVEL >= 1 then
   '*** Debug: semi-transparent green (alpha=128, shininess=80)
   sld material set body -i_sheetBody 0 255 0 0 255 0 0 255 0 128 80 i_ret
else
   '*** Production: invisible (shininess=0)
   sld material set body -i_sheetBody 0 255 0 0 255 0 0 255 0 128 0 i_ret
end if

View Limiting

The fxLimitViewArea macro focuses the view on a specific region:

  • Reduces rendering area during localized operations
  • Respects i_FX_SUPPRESS_GRAPHICS flag in headless mode
  • See: dialogs\fxLimitViewArea.ovm

Global Variables

Defined in modeling\fxGlobals.var:

Speed Optimization Controls

VariableDefaultPurpose
i_FX_SUPPRESS_GRAPHICS 1 Use Mode 4 hide pattern during heavy operations (recommended ON)
i_FX_LIMIT_VIEW_MODE 0 Zoom to sphere during operations (minimal benefit, skip)
i_FX_SHOW_PROGRESS 1 Enable NucleoSphere progress visualization (0 for batch mode)
i_FX_SOLIDS_HIDDEN 0 Tracks if solids are currently hidden (for error recovery)

NucleoSphere Appearance

VariableDefaultPurpose
w_FX_NUCLEO_RADIUS_PERCENT 0.10 Sphere radius as % of model size (10%)
i_FX_NUCLEO_TRANSPARENCY 50 Base shell transparency 0-100 (50 = 50% transparent)
w_FX_NUCLEO_MIN_TRANS_FRAC 0.3 Minimum transparency fraction for innermost shell (30%)
w_FX_PROGRESS_MIN_DELTA 5.0 Minimum % change before progress update (throttling)

INI File Settings

These settings are configured in the INI file (e.g., fxNucleoEvents.044):

SettingValuesPurpose
fxNucleoShellsMatchColors 0 or 1 0 = Cycle colors to fill 8 shells (2 colors → alternating 8 shells)
1 = Use color count as shell count (2 colors → only 2 shells)

Example: With fxNucleoShellsMatchColors,1 and St. Patrick's Day (2 colors: green, white), you get only 2 concentric shells instead of 8 alternating shells.

VDM Sets

VariableDefaultPurpose
i_VDM_FX_HIDDEN_BODIES 27825 VDM set for tracking hidden body IDs (defined in fixture_64.var)
i_FX_HIDDEN_BODY_COUNT 0 Count of bodies in hidden set

Progressive Transparency

The NucleoSphere uses progressive transparency from outer shell (100%) to inner shell (minimum). This creates a visual depth effect where outer shells are more opaque and inner shells are more transparent.

Formula: fraction = minFrac + (1-minFrac) * (idx-1)/(count-1)

Example with 5 shells and w_FX_NUCLEO_MIN_TRANS_FRAC = 0.3:

Shell1 (inner)2345 (outer)
Fraction30%47%65%82%100%
Transparency (base=50)1524324150

Test Harness

The performance test harness is located at: io\json\testing\fxTestHideAll.ovm

Running Tests

'*** Test all modes
call fxTestHideAll 0 80    '*** Baseline
call fxTestHideAll 1 80    '*** sld hide all
call fxTestHideAll 2 80    '*** Individual hide/show
call fxTestHideAll 3 80    '*** sld vis hid 1/0
call fxTestHideAll 4 80    '*** sld vis hid 1 + show sphere (RECOMMENDED)

Where 80 is the body ID of a test solid in the workspace.

Integration Test Modes

The integration test harness (fxIntegrationTest.ovm) includes sphere testing:

ModeSphereBladesVerboseDescription
0ON (forced)1OFFDemo mode
1OFF1OFFProduction - fastest
2OFF1ONDebug - extra output
3ON (forced)5OFFPresentation - multi-blade
99varies1OFFBENCHMARK - runs all optimization combos

Running the Benchmark

'*** Run full benchmark comparison
call fxIntegrationTest 99 80

This runs 5 test configurations and prints a comparison table with speedup ratios.

Best Practices

✅ Do

  • Use sld vis hid 1 + sld show body for best speed with progress
  • Always call fxRestoreHiddenBodies in cleanup/finally blocks
  • Track visibility state with i_FX_SOLIDS_HIDDEN for error recovery
  • Hide rulers with ogl ruler set 0 i_FALSE during heavy operations
  • Make cutting sheets invisible in production mode

❌ Don't

  • Use sld hide all if you need ANY visible elements (including progress)
  • Forget to restore visibility after operations (causes "invisible solids" bug)
  • Call red -1 (redraw) during heavy loops - let it batch updates
  • Assume sld show body works after sld hide all (it doesn't)