Skip to content

[BUG] let(p = parent()) ... restore(p) pattern kills preview times #2005

Description

@cidit

Describe the bug

Using the LPRP pattern (let(p = parent()) ... restore(p)) multiplies the time it takes to preview and render an otherwise simple script.

Code To Reproduce Bug

the bug can be seen in action here: https://github.com/cidit/swerve_drive/blob/ac8fb9ebee61840a5451bb43df0ff879bf9dbdd6/model/designs/planetary_simple.scad

Expected behavior

Commenting out the LPRPs at the end of the file like the following produces the expected render times.

chassis_plate()
  attach(TOP, BOT)
    washer() // let (save_pt = parent()) move_copies(gear_data[2][4]) washer() restore(save_pt)
          attach(TOP, BOT)
            stage()
              attach(TOP, BOT)
                washer() // let (save_pt = parent()) move_copies(gear_data[2][4]) washer() restore(save_pt)
                      attach(TOP, BOT)
                        stage()
                          attach(TOP, BOT)
                            washer(); //let (save_pt = parent()) move_copies(gear_data[2][4]) washer();

Additional context

I compared the console outputs that i added below for reference and noticed that the number of tree elements 12x'es from 64 to 736.

WITHOUT LPRP:

Compiling design (CSG Products generation)...
Geometries in cache: 28
Geometry cache size in bytes: 842496
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Compiling background (1 CSG Trees)...
Normalized tree has 64 elements!
Compile and preview finished.
Total rendering time: 0:00:03.037

WITH LPRP:

Compiling design (CSG Products generation)...
Geometries in cache: 28
Geometry cache size in bytes: 842496
CGAL Polyhedrons in cache: 0
CGAL cache size in bytes: 0
Compiling design (CSG Products normalization)...
Compiling background (1 CSG Trees)...
Normalized tree has 736 elements!
Compile and preview finished.
Total rendering time: 0:00:29.696

OpenSCAL version: 2026.07.01.fp (git 34a81df5b)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions