[vtkusers] vtkTransform::Identity() where it gets wrong?

David Gobbi david.gobbi at gmail.com
Tue Sep 18 12:12:00 EDT 2018


Thanks for the report.  That vtkTransform code was actually written before
ModifiedEvent even existed.

I've submitted a patch:
https://gitlab.kitware.com/vtk/vtk/merge_requests/4680

Be careful with how you use ModifiedEvent. The events in vtkCommand.h are
handled synchronously, so if you have a callback bound to the ModifiedEvent
for an object, then any code that modifies that object has to sit and wait
until your callback finished running.

The Modified() method was initially designed to do only one thing: change
the object's timestamp.  VTK was designed from the ground up to be a pull
pipeline: the pipeline is meant to be driven by either user interaction
(mouse, keyboard, I/O) or by timer events (e.g. for animation); the
pipeline checks timestamps to see what has changed since the last time it
executed.  Driving actions from ModifiedEvent goes against this and will
lead to less efficient code, and can cause instability depending on how
your ModifiedEvent callback changes the pipeline state.

I recommend using ModifiedEvent only for logging, debugging, or simple
bookkeeping.  I'll stop ranting now :)

Thanks again for the bug report,

 - David


On Tue, Sep 18, 2018 at 9:12 AM Anka Kochanowska <anka at bic.mni.mcgill.ca>
wrote:

> void vtkTransform::Identity()
>
> {
>
>   this->Concatenation->Identity();
>
>   this->Modified();
>
>
>   // support for the legacy hack in InternalUpdate
>
>   if (this->Matrix->GetMTime() > this->MatrixUpdateMTime)
>
>   {
>
>     this->Matrix->Identity();
>
>   }
>
> }
>
> Modified() is called before the matrix is reset to Identity.
>
> Should it be called at the end?
>
>
> My code reacts to Modified event and promptly uses matrix that was not yet changed.
>
> I patch it by calling transform->Modified() after transform->Identity();
>
>
> Anka
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180918/953e674e/attachment.html>


More information about the vtkusers mailing list