GodotVR / godot_oculus_mobile

Godot Oculus mobile drivers (Oculus Go / Oculus Quest)
MIT License
169 stars 34 forks source link

GDScript API for velocity/acceleration access #63

Closed NeoSpark314 closed 4 years ago

NeoSpark314 commented 4 years ago

Hi,

me again with another API extension proposal :-) There was a short discussion yesterday on discord if there is an elegant method to get the controller velocities. So far I used the averaging method from the godot vr starter tutorial. But this is rather unprecise. The VrApi already has this information available and it is queried each frame.

This proposal extends the OvrUtilities.gdns API to allow accessing the acceleration and velocity information for the controllers and the head that was predicted for the next display frame. In gdscript access will look then like this:

ovrUtilities.get_controller_angular_acceleration(controller_id)
ovrUtilities.get_head_linear_velocity()

To achieve this I extended the struct ControllerState from ovr_mobile_controller.h to also contain and remember the pose information.

I tried to match a bit the API to what I understood from the last comments. That is why I made 4 separate functions for linear/angular velocity/acceleration instead of returning everything together in an array for example. Let me know what you think and if it would be a good addition to the godot_oculus_mobile API.

NeoSpark314 commented 4 years ago

I added the const pointer + the check if the controller is connected and squashed the commits.