[vlc-devel] [PATCH 08/18] win32/sensors: use vlc_viewpoint_from_euler

Alexandre Janniaux ajanni at videolabs.io
Wed Mar 31 09:25:40 UTC 2021


From: Alexandre Janniaux <alexandre.janniaux at gmail.com>

---
 modules/video_output/win32/sensors.cpp | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/modules/video_output/win32/sensors.cpp b/modules/video_output/win32/sensors.cpp
index 34794ef6d2..4fdeac6d72 100644
--- a/modules/video_output/win32/sensors.cpp
+++ b/modules/video_output/win32/sensors.cpp
@@ -119,12 +119,13 @@ public:
             PropVariantClear(&pvRot);
         }
 
-        vlc_viewpoint_t vp = {
+        /* Zero initialize vp for field of view. */
+        vlc_viewpoint_t vp {};
+        vlc_viewpoint_from_euler(&vp,
             old_pos.yaw   - current_pos.yaw,
             old_pos.pitch - current_pos.pitch,
-            old_pos.roll  - current_pos.roll,
-            0.0f
-        };
+            old_pos.roll  - current_pos.roll);
+
         vout_display_SendEventViewpointMoved(vd, &vp);
         return S_OK;
     }
@@ -181,27 +182,33 @@ void *HookWindowsSensors(vout_display_t *vd, HWND hwnd)
                         {
                             vlc_viewpoint_t start_viewpoint;
                             vlc_viewpoint_init(&start_viewpoint);
+                            float yaw=0.f, pitch=0.f, roll=0.f;
+
                             PROPVARIANT pvRot;
                             PropVariantInit(&pvRot);
                             hr = pSensor->GetProperty(SENSOR_DATA_TYPE_TILT_X_DEGREES, &pvRot);
                             if (SUCCEEDED(hr) && pvRot.vt == VT_R4)
                             {
-                                start_viewpoint.pitch = pvRot.fltVal;
+                                pitch = pvRot.fltVal;
                                 PropVariantClear(&pvRot);
                             }
                             hr = pSensor->GetProperty(SENSOR_DATA_TYPE_TILT_Y_DEGREES, &pvRot);
                             if (SUCCEEDED(hr) && pvRot.vt == VT_R4)
                             {
-                                start_viewpoint.roll = pvRot.fltVal;
+                                roll = pvRot.fltVal;
                                 PropVariantClear(&pvRot);
                             }
                             hr = pSensor->GetProperty(SENSOR_DATA_TYPE_TILT_Z_DEGREES, &pvRot);
                             if (SUCCEEDED(hr) && pvRot.vt == VT_R4)
                             {
-                                start_viewpoint.yaw = pvRot.fltVal;
+                                yaw = pvRot.fltVal;
                                 PropVariantClear(&pvRot);
                             }
 
+                            vlc_viewpoint_from_euler(
+                                    &start_viewpoint,
+                                    yaw, pitch,roll);
+
                             SensorReceiver *received = new(std::nothrow) SensorReceiver(vd, start_viewpoint);
                             if (received)
                             {
-- 
2.31.0



More information about the vlc-devel mailing list