[vlc-devel] [PATCH 09/18] input: use vlc_viewpoint_to/from_euler

Steve Lhomme robux4 at ycbcr.xyz
Fri Apr 2 06:20:33 UTC 2021


On 2021-03-31 11:25, Alexandre Janniaux wrote:
> From: Alexandre Janniaux <alexandre.janniaux at gmail.com>
> 
> ---
>   src/input/input.c | 21 +++++++++++----------
>   1 file changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/src/input/input.c b/src/input/input.c
> index ea64473a0b..69552bc3e5 100644
> --- a/src/input/input.c
> +++ b/src/input/input.c
> @@ -1709,30 +1709,34 @@ static void ControlNav( input_thread_t *p_input, int i_type )
>           return; /* The demux handled the navigation control */
>   
>       /* Handle Up/Down/Left/Right if the demux can't navigate */
> -    vlc_viewpoint_t vp = {0};
> +    bool viewpoint_updated = 1;

s/1/true/

> +    float yaw = 0.f, pitch = 0.f, roll = 0.f;
> +    vlc_viewpoint_to_euler(&priv->viewpoint, &yaw, &pitch, &roll);
> +
>       int vol_direction = 0;
>       int seek_direction = 0;
>       switch( i_type )
>       {
>           case INPUT_CONTROL_NAV_UP:
>               vol_direction = 1;
> -            vp.pitch = -1.f;
> +            pitch -= 1.f;
>               break;
>           case INPUT_CONTROL_NAV_DOWN:
>               vol_direction = -1;
> -            vp.pitch = 1.f;
> +            pitch += 1.f;
>               break;
>           case INPUT_CONTROL_NAV_LEFT:
>               seek_direction = -1;
> -            vp.yaw = -1.f;
> +            yaw -= 1.f;
>               break;
>           case INPUT_CONTROL_NAV_RIGHT:
>               seek_direction = 1;
> -            vp.yaw = 1.f;
> +            yaw += 1.f;
>               break;
>           case INPUT_CONTROL_NAV_ACTIVATE:
>           case INPUT_CONTROL_NAV_POPUP:
>           case INPUT_CONTROL_NAV_MENU:
> +            viewpoint_updated = false;
>               return;
>           default:
>               vlc_assert_unreachable();
> @@ -1752,13 +1756,10 @@ static void ControlNav( input_thread_t *p_input, int i_type )
>       }
>       free( pp_vout );
>   
> -    if( b_viewpoint_ch )
> +    if( b_viewpoint_ch && viewpoint_updated )
>       {
>           priv->viewpoint_changed = true;
> -        priv->viewpoint.yaw   += vp.yaw;
> -        priv->viewpoint.pitch += vp.pitch;
> -        priv->viewpoint.roll  += vp.roll;
> -        priv->viewpoint.fov   += vp.fov;
> +        vlc_viewpoint_from_euler( &priv->viewpoint, yaw, pitch, roll );
>           ViewpointApply( p_input );
>           return;
>       }
> -- 
> 2.31.0
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
> 


More information about the vlc-devel mailing list