discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

View All bug

NH
nop head
Wed, Aug 22, 2018 7:50 PM

The ViewAll button has always produced a view that nowhere nears fill the
window. There was a discussion recently that pointed out a cube at the
origin comes out a different size if it is centred or not. An extreme case
is this:

translate([0, 10000, 0])
cube([100,100,100], center = true);

A 100 cube far from the origin comes out tiny. The culprit seem to be this
line
https://github.com/openscad/openscad/blob/0904a3b3a5b56b16bb423b177972468eeca775a9/src/Camera.cc#L75

I don't understand what (bbox.center()-this->center).norm() is trying to
do. It is this that makes the view change size depending on where it is and
removing it solves the problem. A 100 cube is a constant size regardless of
where it is. Here is the same cube.

So I can submit a PR unless somebody can explain why that expression is
needed.

In general it doesn't give the optimum zoom but it does fit the scene in
the window unless you make the window thinner than it is tall. It basically
ensures the bounding sphere of the object doesn't exceed the height of the
screen regardless of how the object is oriented. It should really look at
the bounding rectangle of the projected 2D image compared with the window
dimensions.

The ViewAll button has always produced a view that nowhere nears fill the window. There was a discussion recently that pointed out a cube at the origin comes out a different size if it is centred or not. An extreme case is this: translate([0, 10000, 0]) cube([100,100,100], center = true); A 100 cube far from the origin comes out tiny. The culprit seem to be this line https://github.com/openscad/openscad/blob/0904a3b3a5b56b16bb423b177972468eeca775a9/src/Camera.cc#L75 I don't understand what (bbox.center()-this->center).norm() is trying to do. It is this that makes the view change size depending on where it is and removing it solves the problem. A 100 cube is a constant size regardless of where it is. Here is the same cube. So I can submit a PR unless somebody can explain why that expression is needed. In general it doesn't give the optimum zoom but it does fit the scene in the window unless you make the window thinner than it is tall. It basically ensures the bounding sphere of the object doesn't exceed the height of the screen regardless of how the object is oriented. It should really look at the bounding rectangle of the projected 2D image compared with the window dimensions.
NH
nop head
Wed, Aug 22, 2018 8:12 PM

The previous discussions was actually this issue:
https://github.com/openscad/openscad/issues/2386

On 22 August 2018 at 20:50, nop head nop.head@gmail.com wrote:

The ViewAll button has always produced a view that nowhere nears fill the
window. There was a discussion recently that pointed out a cube at the
origin comes out a different size if it is centred or not. An extreme case
is this:

translate([0, 10000, 0])
cube([100,100,100], center = true);

A 100 cube far from the origin comes out tiny. The culprit seem to be this
line https://github.com/openscad/openscad/blob/
0904a3b3a5b56b16bb423b177972468eeca775a9/src/Camera.cc#L75

I don't understand what (bbox.center()-this->center).norm() is trying to
do. It is this that makes the view change size depending on where it is and
removing it solves the problem. A 100 cube is a constant size regardless of
where it is. Here is the same cube.

So I can submit a PR unless somebody can explain why that expression is
needed.

In general it doesn't give the optimum zoom but it does fit the scene in
the window unless you make the window thinner than it is tall. It basically
ensures the bounding sphere of the object doesn't exceed the height of the
screen regardless of how the object is oriented. It should really look at
the bounding rectangle of the projected 2D image compared with the window
dimensions.

The previous discussions was actually this issue: https://github.com/openscad/openscad/issues/2386 On 22 August 2018 at 20:50, nop head <nop.head@gmail.com> wrote: > The ViewAll button has always produced a view that nowhere nears fill the > window. There was a discussion recently that pointed out a cube at the > origin comes out a different size if it is centred or not. An extreme case > is this: > > translate([0, 10000, 0]) > cube([100,100,100], center = true); > > > > A 100 cube far from the origin comes out tiny. The culprit seem to be this > line https://github.com/openscad/openscad/blob/ > 0904a3b3a5b56b16bb423b177972468eeca775a9/src/Camera.cc#L75 > > I don't understand what (bbox.center()-this->center).norm() is trying to > do. It is this that makes the view change size depending on where it is and > removing it solves the problem. A 100 cube is a constant size regardless of > where it is. Here is the same cube. > > > > So I can submit a PR unless somebody can explain why that expression is > needed. > > In general it doesn't give the optimum zoom but it does fit the scene in > the window unless you make the window thinner than it is tall. It basically > ensures the bounding sphere of the object doesn't exceed the height of the > screen regardless of how the object is oriented. It should really look at > the bounding rectangle of the projected 2D image compared with the window > dimensions. > > >
MK
Marius Kintel
Wed, Aug 22, 2018 9:44 PM

On Aug 22, 2018, at 3:50 PM, nop head nop.head@gmail.com wrote:

I don't understand what (bbox.center()-this->center).norm() is trying to do. It is this that makes the view change size depending on where it is and removing it solves the problem. A 100 cube is a constant size regardless of where it is. Here is the same cube.

I cannot remember the details, but there’s an ‘autocenter’ flag in that class, which could influence how the camera distance is calculated for View All.

-Marius

> On Aug 22, 2018, at 3:50 PM, nop head <nop.head@gmail.com> wrote: > > I don't understand what (bbox.center()-this->center).norm() is trying to do. It is this that makes the view change size depending on where it is and removing it solves the problem. A 100 cube is a constant size regardless of where it is. Here is the same cube. > I cannot remember the details, but there’s an ‘autocenter’ flag in that class, which could influence how the camera distance is calculated for View All. -Marius
NH
nop head
Thu, Aug 23, 2018 10:20 AM

Yes it looks like (bbox.center()-this->center).norm() is needed when the
camera is not looking at the centre of the bounding box. I think that only
happens when using the command line because
QGLView::viewAll() forces the camera to look at the center without
setting autocenter by setting the transformation itself.
https://github.com/openscad/openscad/blob/a84da9a110b46543520f7e2e73e69b0f071c90db/src/QGLView.cc#L94
.

Camera::center is initialised to [0,0,0] in the constructor and
autocenter false,
so in view all in the GUI they remain at those values hence it looks at the
object's centre but calculates the distance as if it is looking at the
origin, so the origin is always in view as well. the size of the object
depends on its offset from the origin.

I think the correct fix is to set camera->autocenter in QGLView::viewAll()
instead of setting cam.object_trans. That will cause Camera::ViewAll() to
set the transformation but it should also set Camera::center to match. That
should fix the GUI and also the command line when using autocentre with the
gimble camera.

I am not sure why the command line has viewall and autocenter as separate
options when they are always together in the GUI. Also I don't think
viewall without autocenter will work currently with the gimble camera
because nothing sets Camera::centre in that case.

On 22 August 2018 at 22:44, Marius Kintel marius@kintel.net wrote:

On Aug 22, 2018, at 3:50 PM, nop head nop.head@gmail.com wrote:

I don't understand what (bbox.center()-this->center).norm() is trying

to do. It is this that makes the view change size depending on where it is
and removing it solves the problem. A 100 cube is a constant size
regardless of where it is. Here is the same cube.

I cannot remember the details, but there’s an ‘autocenter’ flag in that
class, which could influence how the camera distance is calculated for View
All.

-Marius


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Yes it looks like (bbox.center()-this->center).norm() is needed when the camera is not looking at the centre of the bounding box. I think that only happens when using the command line because QGLView::*viewAll*() forces the camera to look at the center without setting autocenter by setting the transformation itself. https://github.com/openscad/openscad/blob/a84da9a110b46543520f7e2e73e69b0f071c90db/src/QGLView.cc#L94 . Camera::center is initialised to [0,0,0] in the constructor and autocenter false, so in view all in the GUI they remain at those values hence it looks at the object's centre but calculates the distance as if it is looking at the origin, so the origin is always in view as well. the size of the object depends on its offset from the origin. I think the correct fix is to set camera->autocenter in QGLView::*viewAll*() instead of setting cam.object_trans. That will cause Camera::ViewAll() to set the transformation but it should also set Camera::center to match. That should fix the GUI and also the command line when using autocentre with the gimble camera. I am not sure why the command line has viewall and autocenter as separate options when they are always together in the GUI. Also I don't think viewall without autocenter will work currently with the gimble camera because nothing sets Camera::centre in that case. On 22 August 2018 at 22:44, Marius Kintel <marius@kintel.net> wrote: > > On Aug 22, 2018, at 3:50 PM, nop head <nop.head@gmail.com> wrote: > > > > I don't understand what (bbox.center()-this->center).norm() is trying > to do. It is this that makes the view change size depending on where it is > and removing it solves the problem. A 100 cube is a constant size > regardless of where it is. Here is the same cube. > > > I cannot remember the details, but there’s an ‘autocenter’ flag in that > class, which could influence how the camera distance is calculated for View > All. > > -Marius > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >