[vtk-developers] GetActiveCamera() change

Sebastien BARRE sebastien.barre at kitware.com
Fri Aug 26 12:13:38 EDT 2005


Hello,

I'm about to introduce a change to vtkRenderer::GetActiveCamera() in the CVS.

The previous behaviour was the following: if you called 
GetActiveCamera(), it would return the renderer's active camera 
(vtkCamera) OR create a new one if the renderer had none so far. Fair enough.

Now in the later case, it would also *reset* this new camera by 
calling vtkRenderer::ResetCamera(). This actually would trigger a lot 
of code, as ResetCamera() basically would need to compute the bounds 
of each props, which in turn would call UpdateInformation() pretty 
much everywhere in the pipeline, eventually invoking readers, disk 
activity, etc. This could be computer intensive at a location in your 
code where you would not be expecting it, or produce 
warnings/errors/crashes if your pipeline was not setup properly at this point.

Also (and maybe more importantly), any code like the following:
   renderer->GetActiveCamera()->Elevation(30) ;
would result in two different/inconsistent camera situations 
depending on whether or not the renderer already had a camera!

I've changed GetActiveCamera so that it does not reset the camera 
anymore when it is automatically created.

The rational is: if you use GetActiveCamera(), then you are about to 
set its parameters anyway, and you should be in full control of it, 
instead of relying on / being subjected to initial conditions 
resulting from the side effect of a new camera being created and reset.

I've updated the rendering code though so that if you do not bother 
with the camera, the old nice behaviour still remains: the first time 
a Render() occurs, an active camera is still created for you, and is 
reset appropriately.

Comments welcome.
Thank you.

--
Sebastien Barre




More information about the vtk-developers mailing list