New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[OMEdit] Heuristics for scaling vector visualizers #9389
[OMEdit] Heuristics for scaling vector visualizers #9389
Conversation
@adeas31 May I ask you to please have a look? This should go in v1.20 since animation of Vector will be introduced there. Any feedback will be appreciated! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
So the pending messages thing is only for debugging and is not actually used at the moment, right?
Please re-run the PR. @adrpo has fixed the CMake build.
2b33aa8
to
4718a55
Compare
Are you missing some dependency? |
4718a55
to
4185d3c
Compare
Yeah, unfortunately I have to make a direct call to |
Well, now that I am thinking of it, it may be possible to actually set the clear mask on the OSG render stage, or using its ClearNode, instead of calling |
I tried both ideas but could not make them work. Anyway, how I did is probably the most efficient way (despite having to explicitly link GL) so let's keep it like that. |
And because the first commit changed the dumping of |
Maybe you need to fix the Windows libs linking as well. I added the Windows build. Lets see. |
4185d3c
to
b12262b
Compare
It passed all the builds, but I don't have a Windows installation to check that it works in practice. |
Exactly. I could have been more explicit in the documentation but it would have become a bit verbose. This would typically be used for dumping the values of computed scales, or also (I had not thought about this before, but it is very unlikely) to raise warnings for the user and give hints on how to solve a problem. Basically, it is crucial that the AutoTransform's scale is not changed during the whole adjustment process. Meaning, we must not go through a cull traversal, thus we must not render any new frame (except, of course, when triggering it explicitly with the Of course, because we run single-threaded, the mutex is not necessary, but I think it is very much worth it because if someone does not know or forgets about this issue with GUI messages, then instead of seeing weird length scales (difficult to debug) they will actually encounter a deadlock, which is easy to spot directly in the code or with a debugger. Also, if one day the scene initialization or scale adjustment is decoupled from the frame rendering in separate threads, this should work straight away. |
I added the MINGW label that will trigger the Windows build. |
b12262b
to
db3fecd
Compare
db3fecd
to
c5cd7b7
Compare
db3fecd
to
47828d9
Compare
47828d9
to
c5cd7b7
Compare
710faa7
to
9017eda
Compare
What a nightmare ... Sorry for the mess, I'm not used to github PRs yet. |
9017eda
to
364b2cd
Compare
@anotheruserofgithub its failing again. I restarted the job. |
I guess it's not my fault ... Is it possible to rerun only the failing test or do you have to restart from the beginning? |
We have to rerun the whole thing. I restarted the job. We will see. |
Looks good now. Do you want me to merge or you have more changes? |
It's OK, you can merge, please :) |
Purpose
This PR implements methods for the automatic adjustment of radius & length scales of vector visualizers at initialization.
Some fixes are provided for non-critical issues.
Improvements in efficiency are also included.
Approach
Four new attributes are attached to each vector visualizer and can be independently enabled or disabled:
The first two attributes inform whether radius scale and length scale can be adjusted, respectively.
The third attribute allows to continuously maintain a constant pixel size through the auto-scale feature of OSG's AutoTransform, particularly when zooming in/out the scene, which is very convenient to be able to compare vector lengths (meaning, their relative strength) all along the simulation.
The fourth attribute serves as a reinforcement for the previous one, because it renders vectors on top of everything else drawn in the scene, therefore not only small vectors but also tips of arrow heads are always visible and comparable (although this may sometimes break the notion of perspective).
Two separate kinds of adjustments are applied:
Implemented heuristics are thoroughly documented above and inside method
VisualizationAbstract::chooseVectorScales
.Default values of their parameters are defined at the beginning of this same method.
Tests
Modelica.Mechanics.MultiBody.Examples.Elementary.ForceAndTorque
TestScalingVectorVisualizers.mo (click to expand)
Related Issues
ForceAndTorque
model has color issue: ForceAndTorque model does not set color of force arrow modelica/ModelicaStandardLibrary#3989