Commit 718f59c9 authored by Marek Szczerba's avatar Marek Szczerba
Browse files

Euler to quaternion conversion moved out of orientation tracking processing

parent c7cc7d9a
Loading
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -906,7 +906,11 @@ ivas_error IVAS_DEC_FeedHeadTrackData(
    HEAD_TRACK_DATA_HANDLE hHeadTrackData;
    int16_t i;

#ifdef FIX_I109_ORIENTATION_TRACKING
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || orientation == NULL )
#else
    if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL )
#endif
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }
@@ -922,6 +926,12 @@ ivas_error IVAS_DEC_FeedHeadTrackData(
    for ( i = 0; i < MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
    {
#ifdef FIX_I109_ORIENTATION_TRACKING
        /* check for Euler angle signaling */
        if ( orientation[i].w == -3.0f )
        {
            Euler2Quat( deg2rad( orientation[i].x ), deg2rad( orientation[i].y ), deg2rad( orientation[i].z ), &orientation[i] );
        }

        ivas_orient_trk_Process( hHeadTrackData->OrientationTracker, orientation[i], FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hHeadTrackData->Quaternions[i] );
#else
        hHeadTrackData->Quaternions[i].w = orientation[i].w;
+7 −18
Original line number Diff line number Diff line
@@ -665,56 +665,45 @@ ivas_error ivas_orient_trk_Process(
    float alpha = pOTR->alpha;
    float ang;
    ivas_error result;
    IVAS_QUATERNION absQuat;

    if ( pOTR == NULL || pTrkRot == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    /* check for Euler angle signaling */
    if ( absRot.w == -3.0f )
    {
        Euler2Quat( deg2rad( absRot.x ), deg2rad( absRot.y ), deg2rad( absRot.z ), &absQuat );
    }
    else
    {
        absQuat = absRot;
    }

    result = IVAS_ERR_OK;

    switch ( pOTR->trackingType )
    {
        case OTR_TRACKING_NONE:
            pOTR->trkRot = absQuat;
            pOTR->trkRot = absRot;
            break;

        case OTR_TRACKING_REF_ORIENT:
            /* Reset average orientation   */
            pOTR->absAvgRot = absQuat;
            pOTR->absAvgRot = absRot;

            /* Reset adaptation filter - start adaptation at center rate */
            pOTR->alpha = sinf( 2.0f * EVS_PI * pOTR->centerAdaptationRate / updateRate );

            /* Compute relative orientation = (absolute orientation) - (reference orientation) */
            QuaternionInverse( pOTR->refRot, &pOTR->trkRot );
            QuaternionProduct( pOTR->trkRot, absQuat, &pOTR->trkRot );
            QuaternionProduct( pOTR->trkRot, absRot, &pOTR->trkRot );
            break;

        case OTR_TRACKING_AVG_ORIENT:
            /* Compute average (low-pass filtered) absolute orientation */
            QuaternionSlerp( pOTR->absAvgRot, absQuat, alpha, &pOTR->absAvgRot );
            QuaternionSlerp( pOTR->absAvgRot, absRot, alpha, &pOTR->absAvgRot );

            /* Compute relative orientation = (absolute orientation) - (average absolute orientation) */
            QuaternionInverse( pOTR->absAvgRot, &pOTR->trkRot );
            QuaternionProduct( pOTR->trkRot, absQuat, &pOTR->trkRot );
            QuaternionProduct( pOTR->trkRot, absRot, &pOTR->trkRot );

            /* Adapt LPF constant based on orientation excursion relative to current mean:
            - low  cutoff (slow adaptation) for small excursions (around center)
            - high cutoff (fast adaptation) for large excursions (off-center)
            */
            ang = QuaternionAngle( absQuat, pOTR->trkRot );
            ang = QuaternionAngle( absRot, pOTR->trkRot );
            normalizedOrientation = ang * ang;

            relativeOrientationRate = sqrtf( normalizedOrientation ) / pOTR->adaptationAngle;
@@ -743,7 +732,7 @@ ivas_error ivas_orient_trk_Process(
        case OTR_TRACKING_REF_VEC_LEV:
        {
            /* This processing step of the OTR_TRACKING_REF_VEC/OTR_TRACKING_REF_VEC_LEVEL is identical */
            QuaternionProduct( pOTR->refRot, absQuat, &pOTR->trkRot );
            QuaternionProduct( pOTR->refRot, absRot, &pOTR->trkRot );
            break;
        }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
+16 −3
Original line number Diff line number Diff line
@@ -3967,6 +3967,9 @@ ivas_error IVAS_REND_SetHeadRotation(
)
{
    int16_t i;
#ifdef FIX_I109_ORIENTATION_TRACKING
    IVAS_QUATERNION rotQuat;
#endif

    /*-----------------------------------------------------------------*
     * Validate function arguments
@@ -3993,7 +3996,17 @@ ivas_error IVAS_REND_SetHeadRotation(
        for ( i = 0; i < RENDERER_HEAD_POSITIONS_PER_FRAME; ++i )
        {
#ifdef FIX_I109_ORIENTATION_TRACKING
            ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, headRot[i], FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[i] );
            /* check for Euler angle signaling */
            if ( headRot[i].w == -3.0f )
            {
                Euler2Quat( deg2rad( headRot[i].x ), deg2rad( headRot[i].y ), deg2rad( headRot[i].z ), &rotQuat );
            }
            else
            {
                rotQuat = headRot[i];
            }

            ivas_orient_trk_Process( hIvasRend->headRotData.hOrientationTracker, rotQuat, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, &hIvasRend->headRotData.headPositions[i] );
#else
            hIvasRend->headRotData.headPositions[i] = headRot[i];
#endif