OpenXR/OpenVR (virtual reality support), new Python workbench WiP

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
kwahoo
Posts: 680
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by kwahoo »

catman wrote: Fri Jul 29, 2022 10:57 am That will be greate. You wrote your master is based on the link version, correct? When I modify models with that version, is there a risk they get incompatibilities to standard FreeCAD?
No, master is based on FreeCAD master, and the LinkDaily branch is based on the realthunder's LinkDaily.
The second one is much faster when the experimental renderer is enabled, but has a weird overhead - cannot push very high fps in simple scenes.
catman wrote: Fri Jul 29, 2022 10:57 am Yes I saw that bit. Can you say what is the difference to setting the transformation here https://github.com/kwahoo2/FreeCAD/blob ... er.cpp#L45, seems more convenient for a keyboard interface. In my tests it seemed to work.
This seems to be a good idea. I basically copied View3DInventorRiftViewer.cpp from original Juergen Rift implementation, and was using just keyboard for navigation.
Thank you for info about the crash. I'll retest it and update the code.
catman wrote: Fri Jul 29, 2022 10:57 am Have you been thinking to put this into a pull request for the master (OpenXR part)? Seems to to me like a well separatable section with little risk to impact other areas. Maye with a Preference option "experimental" it could be disabled by default. Basically thats what Blender is doing as well.
Yes this should replace the original Rift implementation, since that one does not work any more AFAIK.
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by catman »

kwahoo wrote: Fri Jul 29, 2022 7:22 pm No, master is based on FreeCAD master, and the LinkDaily branch is based on the realthunder's LinkDaily.
Excellent. I tried the Daily and got an XR image, but did not find a setting to enable a different renderer. The standard did not seem much different from the master performance. However I had trouble to get the Asm3 included in the daily so i could not load any non-trivial models. It ignored my .local/share/FreeCAD/Mod folder and the local src/Mod.
Anyway master is the best choice for me I think.

May I ask a general Coding question?
I know next to nothing about the FreeCAD guts. I would need an example code line to store a value (say a std::string) in memory such that it survives between 2 XR View calls. I am sure there is a typical FreeCAD way to do that like a lib call.
User avatar
kwahoo
Posts: 680
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by kwahoo »

catman wrote: Sat Jul 30, 2022 9:32 am Excellent. I tried the Daily and got an XR image, but did not find a setting to enable a different renderer.
It is under caching menu.
Image

catman wrote: Sat Jul 30, 2022 9:32 am I know next to nothing about the FreeCAD guts. I would need an example code line to store a value (say a std::string) in memory such that it survives between 2 XR View calls. I am sure there is a typical FreeCAD way to do that like a lib call.
Between two eye views?
Define the variable before (code location):

Code: Select all

xr::for_each_side_index([&](size_t eyeIndex) {

Or between two frames?
Then you can define (or declare, and define in a cpp file) the variable in a header file, and change its value in any function, in a cpp file.
As example:
Here is the oldTriggerVal array declared. It stores controllers triggers values from the previous frame.
Here it is defined (it gets the initial value)
And here it updates.

If you need something that is preserved after FreeCAD restart, take look at ParameterGrp, the old Rift implementation has actually good example of it https://github.com/kwahoo2/FreeCAD/blob ... er.cpp#L81

HTH
I am a complete noob in coding, so I may teach something very wrong by accident.
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by catman »

kwahoo wrote: Sat Jul 30, 2022 2:35 pm It is under caching menu.
interesting. Guess I should be more patient for the popups :oops:

kwahoo wrote: Sat Jul 30, 2022 2:35 pm
catman wrote: Sat Jul 30, 2022 9:32 am I would need an example code line to store a value (say a std::string) in memory such that it survives between 2 XR View calls.
Between two eye views?
Or between two frames?

If you need something that is preserved after FreeCAD restart, take look at ParameterGrp, the old Rift implementation has actually good example of it https://github.com/kwahoo2/FreeCAD/blob ... er.cpp#L81
Excellent. I think the last is the best option for what I have in mind. No way I would have found that on my own :D
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by catman »

@kwahoo after I moved to the master, I got a black image on the HMD the render window and all opened, but it just contained nothing. First I suspected an error in my code changes, but then I reverted to your master and also LinkDaily and got the same problem. Only 0.20_preXR got me an image.

I am a bit confused, because I can remember that initially I got an image with the LinkDaily build. Maybe there is something in my user parameters that triggered it but I did not find any clue.

Anyway, after some search I found this issue https://github.com/kwahoo2/FreeCAD/blob ... t.cpp#L190

Code: Select all

#if defined XR_USE_PLATFORM_XLIB
            glXMakeCurrent(xDisplay, glxDrawable, glxContext); //SteamVR bug workaround https://github.com/ValveSoftware/SteamVR-for-Linux/issues/421
#endif
I get my image back when I uncomment this line. I checked the link but its not really clear to me what that issue was (I know next to nothing about Steam). I saw that you created new class members to put the line there, so there must have been a very good reason.
For all what I see, it seems to me that this is incompatible to OpenHMD at least with the Oculus Rift.


Please allow me another question: all InventorWindows for Open** are created by static functions. The only place where they are called from is here https://github.com/kwahoo2/FreeCAD/blob ... .cpp#L2950. Wouldn't it be easier to use local static vars instead?
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by Kunda1 »

An aside, @kwahoo should we make a dedicated snap package for this experimental VR branch ?
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
kwahoo
Posts: 680
Joined: Fri Nov 29, 2013 3:09 pm
Contact:

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by kwahoo »

catman wrote: Fri Aug 12, 2022 6:12 pm Anyway, after some search I found this issue https://github.com/kwahoo2/FreeCAD/blob ... t.cpp#L190

Code: Select all

#if defined XR_USE_PLATFORM_XLIB
            glXMakeCurrent(xDisplay, glxDrawable, glxContext); //SteamVR bug workaround https://github.com/ValveSoftware/SteamVR-for-Linux/issues/421
#endif
I get my image back when I uncomment this line. I checked the link but its not really clear to me what that issue was (I know next to nothing about Steam). I saw that you created new class members to put the line there, so there must have been a very good reason.
For all what I see, it seems to me that this is incompatible to OpenHMD at least with the Oculus Rift.
We can remove this safely, I think. This was done for SteamVR 1.16 and it is not necessary for 1.14. Since all releases newer than 1.14 are broken in many ways, making workarounds for them seems to be pointless,
catman wrote: Fri Aug 12, 2022 6:12 pm Please allow me another question: all InventorWindows for Open** are created by static functions. The only place where they are called from is here https://github.com/kwahoo2/FreeCAD/blob ... .cpp#L2950. Wouldn't it be easier to use local static vars instead?
I have no opinion on this, sorry.
Kunda1 wrote: Fri Aug 12, 2022 6:36 pm An aside, @kwahoo should we make a dedicated snap package for this experimental VR branch ?
The question is: are there people than would use the snap package?

I had very bad experiences with various "snapped" software: picking wrong 3D implementation (llvmpipe instead of radeonsi), broken themes, slowness...
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by Kunda1 »

kwahoo wrote: Sat Aug 13, 2022 7:35 pm The question is: are there people than would use the snap package?

I had very bad experiences with various "snapped" software: picking wrong 3D implementation (llvmpipe instead of radeonsi), broken themes, slowness...
Oh i see, Was thinking there would potentially be more testers. Barrier for entry is compiling the fork, I'd think. Also ppd has been doing an amazing job with the FreeCAD snap packages. But your point is taken.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by catman »

Kunda1 wrote: Sat Aug 13, 2022 7:51 pm Oh i see, Was thinking there would potentially be more testers. Barrier for entry is compiling the fork, I'd think. Also ppd has been doing an amazing job with the FreeCAD snap packages. But your point is taken.
Is that a different effort from AppImage packages? Thats what most people are used to from Asm3 testing.

Personally I found it more difficult to get the VR chain up and running. At least on Ubuntu the repositories seem a bit ignorant to VR. I even had to use an AppImage for Blender on 22.04 since the repository version was compiled with VR disabled. Monado did not include OpenHMD drivers etc.
catman
Posts: 412
Joined: Fri Jan 11, 2019 10:42 pm

Re: OpenXR/OpenVR (virtual reality support), arch-friendly update

Post by catman »

Kunda1 wrote: Sat Aug 13, 2022 7:51 pm Was thinking there would potentially be more testers.
The code I saw for OpenXR only involves 3 C++ files and headers, basically its an alternative viewer. I do not know the constraints for C++ code in workbenches but do you know if technically this can be done in an external workbench as well? This would lower the testing barrier tremendously.
Post Reply