Repository navigation
Conversation
computeMatrix() used the prop's global mtime to decide whether to rebuild the matrix, so any modified() call - for example setVisibility() - made it stale and forced a recompute, both eagerly through the onModified subscription and lazily on the next access. Track the modification time of the transform inputs (origin, position, scale, rotation, userMatrix) in a dedicated transformsMTime and use it as the staleness check. The onModified subscription is kept so isIdentity stays up to date when a transform actually changes. fix Kitware#3378
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
vtkActor.onModifiedtriggerscomputeMatrix()on everymodified()event, even when only the visibility or pickability changes. The matrix is already recomputed lazily on access, so the eager recompute is wasted work.fix #3378
Results
Before:
setVisibility(),setPickable()or avtkPropertychange each rebuilt the actor's 4x4 matrix, once eagerly insideonModifiedand again on the nextgetMatrix()/computeBounds()/per-framecomputeMatrix()call from the OpenGL/WebGPU view nodes, because the staleness guard compared the prop's global mtime.After: the matrix is rebuilt only when a transform input (origin, position, scale, orientation/rotation, userMatrix) changes.
isIdentityis still refreshed on transform changes via the existingonModifiedsubscription, which now early-returns after a single timestamp comparison for unrelated modifications.Verified by a new regression test in
Sources/Rendering/Core/Prop3D/test/testComputeMatrix.js: aftersetVisibility(false),setPickable(false)and a property opacity change, the matrix's mtime is unchanged acrossgetMatrix()/computeMatrix(); aftersetPosition/setOrigin/setScale/rotateZ/setOrientationit advances and the matrix content is correct.Note on approach: the staleness check in
computeMatrix()was narrowed to a dedicated transform-inputs mtime rather than only removing theonModified(computeMatrix)subscription. Removing the subscription alone would leave the lazy path recomputing after unrelatedmodified()calls (the guard keyed on the global mtime), andgetIsIdentity()would go stale between a transform change and the next access. The subscription can still be removed if reviewers prefer.Changes
Sources/Rendering/Core/Prop3D/index.js,vtkProp3D.computeMatrix()compares a newmodel.transformsMTimeagainstmodel.matrixMTimeinstead of the prop's globalgetMTime().transformsMTimeis bumped bysetOrigin/setPosition/setScale(via_onXXXChangedmodel hooks, the same mechanismvtkImageDatauses) and byaddPosition,rotateX/Y/Z,rotateWXYZ,rotateQuaternion,setOrientation,setOrientationFromQuaternion,setUserMatrix.vtkFollower.computeMatrix()is unchanged: its matrix depends on the camera, which the transform mtime deliberately does not cover.PR Checklist
Sources/Rendering/Core/Prop3D/test/testComputeMatrix.js(fails without the fix:AssertionError: expected 10 to be 2).d.tsupdate needed)