Skip to content
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

xr.controller_grip_location_get pre_draw callback not working #1894

Open
opheroth opened this issue May 12, 2024 · 5 comments
Open

xr.controller_grip_location_get pre_draw callback not working #1894

opheroth opened this issue May 12, 2024 · 5 comments

Comments

@opheroth
Copy link

opheroth commented May 12, 2024

Copying location from xr.controller_grip_location_get is not working as expected inside a pre_draw callback. There's always a noticeable 1 frame delay on moving objects. I've tried getting the location using bge and bpy, but the problem is still there.

The blend file contains a basic scene with a moving cube, and a sphere.
The navigation location works as expected and gets the position copied from the cube correctly, but the sphere should have the position copied from the left controller grip but the position gets delayed

Is there a way to correct this modifying only the python code inside the blend, or is this a bug?

CopyLocXR.zip

@youle31
Copy link
Collaborator

youle31 commented May 12, 2024

Hi, you can try to move pre_draw callback execution from KX_KetsjiEngine::RenderCameras to KX_Scene::RenderAfterCameraSetup and test. If it works for you, i'm ok to move it here.

@opheroth
Copy link
Author

Hi, I've tried moving it to different zones inside KX_Scene::RenderAfterCameraSetup, but the problem is still there. Setting a location works, but reading it, doesn't.

@opheroth
Copy link
Author

opheroth commented May 15, 2024

Doing some tests, seems like moving the object works, but reading the position of the controllers, could be happening before the scripts, and even if the navigation location changes, the controller position is not updated to the new navigation location until the next frame. I've printed the controller location, and the sphere location, and they're at the same position at the moment of running the script, for now it can be semi-fixed calculating the previous location of the navigation location - actual navigation location, then that vector can be added to the controller location, but the rotation still gets delayed, is less noticeable, but still there.
Edit: Forgot to mention that the calculation is done in python, not in the source code.

I'm still trying to find when are updated the values for controllers are. I would appreciate if you have a hint on where or how to fix it correctly.

@youle31
Copy link
Collaborator

youle31 commented May 16, 2024

You can look at KX_Scene, and search for "wm_xr" occurences. I haven't an XR device, and idk how to deal with that. You can try to move what is in KX_Scene... I won't be abled to review, but you can ask BluePrintRandom on discord to test what you did if you have a change proposal.

@opheroth
Copy link
Author

Thanks, I've made that and moved the callback section after the xr part in KH_Scene, but as mentioned, it seems it read the transformations, then the callback move the navigation_location, and if I read the controller location, it didn't updates, and reads the location before the navigation location change. If I find something I'll go to the discord channel and ask BluePrintRandom as you suggested. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants