VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Quaternion AVR.Avatar.AVR_PoseProvider.CorrectBodyYawAngle ( Quaternion  rot)
inlineprivate

Definition at line 425 of file AVR_PoseProvider.cs.

425  {
426  float head_yaw = eyeTransform.localRotation.eulerAngles.y;
427  float body_yaw = last_yaw;
428 
429  // Get the difference in yaw between body and eyes/head
430  float yaw_diff = Mathf.DeltaAngle(head_yaw, body_yaw);
431 
432  // Account for max_head_yaw
433  yaw_diff = Mathf.Sign(yaw_diff) * Mathf.Max(0, Mathf.Abs(yaw_diff) - max_head_yaw);
434 
435  // Calcualte the speed at which we'll adapt.
436  float yaw_adapt_speed = Mathf.Abs(yaw_diff) * Time.deltaTime * 2.0f;
437 
438  // Adapt the rotation to the resulting yaw
439  return Quaternion.Euler(
440  bodyTransform.localRotation.eulerAngles.x,
441  Mathf.MoveTowardsAngle(body_yaw, head_yaw, yaw_adapt_speed),
442  bodyTransform.localRotation.eulerAngles.z
443  );
444  }
float max_head_yaw
Maximum yaw angle of the head in relation of the body