[OMEdit] Distinguish length/radius scale invariance for vector visualizers #11663
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.
Related Issues
#9390 (comment)
Purpose
Split scale invariance of vectors into two attributes to accommodate for rotation/translation/zoom:
Following those definitions, users should be aware of which combinations of parameters are meaningful:
Approach
Split scale invariance parameter into two distinct parameters.
Cancel out appropriate dimensions of
AutoTransform
's scale in its cull callback.Alternative
The proposed implementation is probably not the most efficient because it requires to recompute the geometries of cylinder and cone(s) every time a scale value changes.
Instead, it may be possible to only modify the scale and post-translation components of the transform matrix, which is already updated at every cull traversal anyway.
However, this is not possible with a single
AutoTransform
because it would not preserve the aspect ratio between length and radius of the head(s).To avoid this deformation, two
AutoTransform
s shall be used, one for the shaft and one for the head(s), see this schema.The idea would be to define two geodes inside independent
AutoTransform
s and place their junction at the frame origin so that a scaling can be applied separately to each of the geodes.The head(s) would always scale all dimensions together in order to preserve the aspect ratio, whilst the shaft could be scaled along the direction of its axis (meaning, its length) differently than across the other dimensions (which correspond to its radius).
Then, an offset would be applied to reposition the geodes, either
+s
or-h
depending whether the tail or the head of the vector shall be placed at the frame origin.That can be achieved at very little cost by overriding the
AutoTransform
's method dedicated to computing the transform matrix, but should be done in two different versions so as to maintain compatibility with older versions of OpenSceneGraph (typically, v3.2.3 which is packaged by default in Ubuntu 18.04).Furthermore, having two geodes for the same visualizer would require to substantially rewrite the way its drawables are updated.
Hence this is too cumbersome to implement for the little benefit it could bring.
Test
Change these two methods to return either
true
orfalse
and simulate this simple model with animation:Then play with rotation, translation, zoom, and time.