discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Strange bug, cmd-line, projection, camera, unorthodox

N
neri-engineering
Fri, Nov 4, 2022 2:01 PM

I stumbled upon a strange bug which will probably seldom surface. First I'll describe the bug, then I'll explain little changes that make the bug go away, then I'll allude to a related bug which I don't have code for.

I'm using OpenSCAD 2021.01, the one bundled with Ubuntu 22.10.

To demonstrate the bug I have a ".scad" file and I have a UNIX shell script. The SCAD file, called "cutaway-bug.scad":

difference() {
cylinder(h=9, r=20, center=true, $fn=32);
translate([64, 64, 0]) {
cube(size=[128, 128, 128], center=true); }
}

And the shell script:

#!/bin/sh

openscad --imgsize=640,480
--preview
--projection="perspective"
--camera=127,46.3,-45,0,0,0
--colorscheme="DeepOcean"
-o "persp.png"
"cutaway-bug.scad"

I'm attaching two images; the first image, "persp.png", shows the bug - the cylinder does not have a cutout.

If we take the shell script above and change projection to "ortho", we get the second image attached, "ortho.png", which looks correct.

Please note, above I'm using the six-argument "--camera" option, which is likely seldom used, as opposed to the seven-argument "--camera" option. Both are documented on the UNIX man page for openscad. If I recall correctly simply switching to the seven-argument "--camera" fixes the problem also. Furthermore, changing the position of camera slightly in the six-arg camera above also fixes the problem.

One more thing, for which I don't have code that's simplified - If the object being rendered is changed from being a simple cylinder, to being something complex like a spur gear which uses linear_extrude(), then the object being rendered after the difference() seems to be an intersection() instead. Meaning, the gear that's rendered erroneously would be just the front quadrant and not the three-quarters of the gear that would remain after a difference(). I don't have code for this because it's more code to list here, and I am guessing that the two bugs are very related.

Once again, this bug happens only when the perspective projection is used with conjunction of the six-arg camera, when the camera is at certain locations, and probably only when OpenSCAD is used from command-line (which is a very useful feature in my opinion).

Sent with Proton Mail secure email.

I stumbled upon a strange bug which will probably seldom surface. First I'll describe the bug, then I'll explain little changes that make the bug go away, then I'll allude to a related bug which I don't have code for. I'm using OpenSCAD 2021.01, the one bundled with Ubuntu 22.10. To demonstrate the bug I have a ".scad" file and I have a UNIX shell script. The SCAD file, called "cutaway-bug.scad": difference() { cylinder(h=9, r=20, center=true, $fn=32); translate([64, 64, 0]) { cube(size=[128, 128, 128], center=true); } } And the shell script: #!/bin/sh openscad --imgsize=640,480 \ --preview \ --projection="perspective" \ --camera=127,46.3,-45,0,0,0 \ --colorscheme="DeepOcean" \ -o "persp.png" \ "cutaway-bug.scad" I'm attaching two images; the first image, "persp.png", shows the bug - the cylinder does not have a cutout. If we take the shell script above and change projection to "ortho", we get the second image attached, "ortho.png", which looks correct. Please note, above I'm using the six-argument "--camera" option, which is likely seldom used, as opposed to the seven-argument "--camera" option. Both are documented on the UNIX man page for openscad. If I recall correctly simply switching to the seven-argument "--camera" fixes the problem also. Furthermore, changing the position of camera slightly in the six-arg camera above also fixes the problem. One more thing, for which I don't have code that's simplified - If the object being rendered is changed from being a simple cylinder, to being something complex like a spur gear which uses linear_extrude(), then the object being rendered after the difference() seems to be an intersection() instead. Meaning, the gear that's rendered erroneously would be just the front quadrant and not the three-quarters of the gear that would remain after a difference(). I don't have code for this because it's more code to list here, and I am guessing that the two bugs are very related. Once again, this bug happens only when the perspective projection is used with conjunction of the six-arg camera, when the camera is at certain locations, and probably only when OpenSCAD is used from command-line (which is a very useful feature in my opinion). Sent with [Proton Mail](https://proton.me/) secure email.