Skip to content

Commit

Permalink
Merge pull request #108 from BasisVR/doolys-branch
Browse files Browse the repository at this point in the history
Doolys branch
  • Loading branch information
dooly123 authored Jan 13, 2025
2 parents ba0e643 + cabb5c1 commit c47337d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ public static void FullBodyCalibration()
BasisDebug.LogError("Missing Tracker for index " + Index + " with ID " + mapping);
}
}
//do the roles after to stop the animator switch issue
BasisLocalPlayer.Instance.LocalBoneDriver.CalculateHeading();

BasisLocalPlayer.Instance.AvatarDriver.ResetAvatarAnimator();
BasisLocalPlayer.Instance.AvatarDriver.CalibrateRoles();//not needed but still doing just incase
Expand Down Expand Up @@ -261,4 +259,4 @@ public static float MaxDistanceBeforeMax(BasisBoneTrackedRole role)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public class BasisBoneControl
public float LerpAmountNormal;
public float LerpAmountFastMovement;
public float AngleBeforeSpeedup;
public bool HasRotationalTarget;
public bool HasRotationalTarget = false;

public bool HasLineDraw;
public int LineDrawIndex;
public bool HasTarget;
public bool HasTarget = false;
public float3 Offset;
public float LerpAmount;

Expand Down Expand Up @@ -61,15 +61,15 @@ public void ComputeMovement(float DeltaTime)
{
if (IsHintRoleIgnoreRotation == false)
{ // Update the position of the secondary transform to maintain the initial offset
OutGoingData.position = math.lerp(OutGoingData.position, IncomingData.position + math.mul(IncomingData.rotation, InverseOffsetFromBone.position), trackersmooth);
OutGoingData.position = Vector3.Lerp(OutGoingData.position, IncomingData.position + math.mul(IncomingData.rotation, InverseOffsetFromBone.position), trackersmooth);
// Update the rotation of the secondary transform to maintain the initial offset
OutGoingData.rotation = math.slerp(OutGoingData.rotation, math.mul(IncomingData.rotation, InverseOffsetFromBone.rotation), trackersmooth);
OutGoingData.rotation = Quaternion.Slerp(OutGoingData.rotation, math.mul(IncomingData.rotation, InverseOffsetFromBone.rotation), trackersmooth);
}
else
{
OutGoingData.rotation = Quaternion.identity;
// Update the position of the secondary transform to maintain the initial offset
OutGoingData.position = math.lerp(OutGoingData.position, IncomingData.position + math.mul(IncomingData.rotation, InverseOffsetFromBone.position), trackersmooth);
OutGoingData.position = Vector3.Lerp(OutGoingData.position, IncomingData.position + math.mul(IncomingData.rotation, InverseOffsetFromBone.position), trackersmooth);
}
}
else
Expand Down
16 changes: 0 additions & 16 deletions Basis/Packages/com.basis.framework/Drivers/BaseBoneDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ public abstract class BaseBoneDriver : MonoBehaviour
public event SimulationHandler OnSimulate;
public event SimulationHandler OnPostSimulate;
public OrderedDelegate ReadyToRead = new OrderedDelegate();

public Quaternion QatCalibrationHeading;
public Vector3 CalibrationHeading;
public float CalibrationHeadingY;
/// <summary>
/// call this after updating the bone data
/// </summary>
Expand Down Expand Up @@ -79,18 +75,6 @@ public void SimulateAndApplyWithoutLerp()
SimulateWithoutLerp();
ApplyMovement();
}
public void CalculateHeading()
{
if (FindBone(out BasisBoneControl Head, BasisBoneTrackedRole.Head))
{
CalibrationHeadingY = Head.BoneTransform.localRotation.eulerAngles.y;
CalibrationHeading = new Vector3(0, CalibrationHeadingY, 0);
QatCalibrationHeading = Quaternion.Euler(CalibrationHeading);
Debug.DrawLine(Head.BoneTransform.position, Head.BoneTransform.position + (QatCalibrationHeading * new Vector3(0, 0, 1)), Color.black, 5f);
// Head.BoneModelTransform.position = Head.BoneTransform.position;
// Head.BoneModelTransform.rotation = Head.BoneTransform.rotation;
}
}
public void RemoveAllListeners()
{
for (int Index = 0; Index < ControlsLength; Index++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ public void InitialLocalCalibration(BasisLocalPlayer Player)
Builder.enabled = false;
Calibration(Player.BasisAvatar);
BasisLocalPlayer.Instance.LocalBoneDriver.RemoveAllListeners();
BasisLocalPlayer.Instance.LocalBoneDriver.CalculateHeading();
BasisLocalEyeFollowDriver = BasisHelpers.GetOrAddComponent<BasisLocalEyeFollowBase>(Player.BasisAvatar.gameObject);
BasisLocalEyeFollowDriver.Initalize(this,Player);
HeadScaledDown = Vector3.zero;
Expand Down Expand Up @@ -603,4 +602,4 @@ public GameObject CreateRig(string Role, bool Enabled, out Rig Rig, out RigLayer
return RigGameobject;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ public class BasisLocalCameraDriver : MonoBehaviour
public BasisLockToInput BasisLockToInput;
public bool HasEvents = false;
public Canvas MicrophoneCanvas;
public Transform CanvasTransform;
public RawImage MicrophoneMutedIcon;
public RawImage MicrophoneUnMutedIcon;
public Transform MicrophoneUnMutedIconTransform;

public Vector3 DesktopMicrophoneOffset = new Vector3(-0.001f, -0.0015f, 2f); // Adjust as needed for canvas position and depth
public Vector3 DesktopMicrophoneViewportPosition = new(0.2f, 0.15f, 1f); // Adjust as needed for canvas position and depth
public Vector3 VRMicrophoneOffset = new Vector3(-0.0004f, -0.0015f, 2f);

public AudioClip MuteSound;
Expand Down Expand Up @@ -255,7 +256,7 @@ public static void GetPositionAndRotation(out Vector3 Position,out Quaternion Ro
}
public void OnHeightChanged()
{
this.gameObject.transform.localScale = Vector3.one * LocalPlayer.EyeRatioAvatarToAvatarDefaultScale;
this.transform.localScale = Vector3.one * LocalPlayer.EyeRatioAvatarToAvatarDefaultScale;
}
public void OnDisable()
{
Expand Down Expand Up @@ -283,11 +284,13 @@ public void BeginCameraRendering(ScriptableRenderContext context, Camera Camera)
if (CameraData.allowXRRendering)
{
Vector2 EyeTextureSize = new Vector2(XRSettings.eyeTextureWidth, XRSettings.eyeTextureHeight);
MicrophoneCanvas.transform.localPosition = CalculatePosition(EyeTextureSize, VRMicrophoneOffset);
CanvasTransform.localPosition = CalculatePosition(EyeTextureSize, VRMicrophoneOffset);
}
else
{
MicrophoneCanvas.transform.localPosition = Camera.ViewportToScreenPoint(DesktopMicrophoneOffset);
Vector3 worldPoint = Camera.ViewportToWorldPoint(DesktopMicrophoneViewportPosition);
Vector3 localPos = this.transform.InverseTransformPoint(worldPoint);//asume this transform is also camera position
CanvasTransform.localPosition = localPos;
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,6 @@ private void ApplyPositionControl(BasisBoneControl boneControl)
float3 customDirection = math.mul(boneControl.Target.OutGoingData.rotation, boneControl.Offset);
boneControl.OutGoingData.position = boneControl.Target.OutGoingData.position + customDirection;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public partial class BasisNetworkReceiver : BasisNetworkPlayer
public double TimeInThePast;
public bool HasAvatarInitalized;

public BasicOneEuroFilterParallelJob oneEuroFilterJob;
public BasisOneEuroFilterParallelJob oneEuroFilterJob;
public float MinCutoff = 0.001f;
public float Beta = 5f;
public float DerivativeCutoff = 1.0f;
Expand Down Expand Up @@ -319,7 +319,7 @@ public void ForceUpdateFilters()
derivativeFilters[i] = new float2(0,0);
}

oneEuroFilterJob = new BasicOneEuroFilterParallelJob
oneEuroFilterJob = new BasisOneEuroFilterParallelJob
{
InputValues = musclesPreEuro,
OutputValues = EuroValuesOutput,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// A job struct for processing OneEuroFilter in parallel
[BurstCompile]
public struct BasicOneEuroFilterParallelJob : IJobParallelFor
public struct BasisOneEuroFilterParallelJob : IJobParallelFor
{
[ReadOnly]
public NativeArray<float> InputValues;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,11 @@ MonoBehaviour:
BasisLockToInput: {fileID: 5985133177976618905}
HasEvents: 0
MicrophoneCanvas: {fileID: 3373432966423603715}
CanvasTransform: {fileID: 309437807573434354}
MicrophoneMutedIcon: {fileID: 7951072778522726859}
MicrophoneUnMutedIcon: {fileID: 1908197658278707850}
MicrophoneUnMutedIconTransform: {fileID: 1619504432556682231}
DesktopMicrophoneOffset: {x: -0.0005, y: -0.0005, z: 1}
DesktopMicrophoneViewportPosition: {x: 0.2, y: 0.15, z: 1}
VRMicrophoneOffset: {x: -0.0001, y: -0.00025, z: 1}
MuteSound: {fileID: 8300000, guid: 5b9ed5013ea1941499840ac97ad2b8e9, type: 3}
UnMuteSound: {fileID: 8300000, guid: fbd61add38ba2d04baedb52b69c6e1b3, type: 3}
Expand Down

0 comments on commit c47337d

Please sign in to comment.