Skip to content

Commit

Permalink
SRanipal optimisations
Browse files Browse the repository at this point in the history
  • Loading branch information
VolcanicArts committed Mar 8, 2023
1 parent 5777481 commit b45ca69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
18 changes: 4 additions & 14 deletions VRCOSC.Game/Modules/SRanipalAPIInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,16 @@ public void Initialise(bool eye, bool lip)

public void Release()
{
if (eyeAvailable) SRanipalAPI.Release(2);
if (lipAvailable) SRanipalAPI.Release(3);
SRanipalAPI.Release(2);
SRanipalAPI.Release(3);

EyeStatus.SetDefault();
LipStatus.SetDefault();
}

public void Update()
{
if (eyeAvailable) updateEye();
if (lipAvailable) updateLip();
}

private void updateEye()
{
SRanipalAPI.GetEyeData(ref EyeData);
}

private void updateLip()
{
SRanipalAPI.GetLipData(ref LipData);
if (eyeAvailable) SRanipalAPI.GetEyeData(ref EyeData);
if (lipAvailable) SRanipalAPI.GetLipData(ref LipData);
}
}
4 changes: 2 additions & 2 deletions VRCOSC.Modules/FaceTracking/Interface/SRanipalInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public void Initialise(bool eye, bool lip)
public void Update()
{
APIInterface.Update();
EyeData.Update(APIInterface.EyeData);
LipData.Update(APIInterface.LipData);
if (EyeAvailable) EyeData.Update(APIInterface.EyeData);
if (LipAvailable) LipData.Update(APIInterface.LipData);
}

public void Release()
Expand Down
6 changes: 4 additions & 2 deletions VRCOSC.Modules/FaceTracking/SRanipalModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public SRanipalModule()

private void handleStatus(string name, Error status)
{
if (State.Value != ModuleState.Started) return;

switch (status)
{
case Error.WORK:
Expand Down Expand Up @@ -118,8 +120,8 @@ protected override void OnAvatarChange()
if (AvatarConfig is null) return;

Log($"Avatar change detected. Parsing avatar {AvatarConfig.Name} with {AvatarConfig.Parameters.Count} parameters");
lipParams.ForEach(key => auditParameter(key));
eyeParams.ForEach(key => auditParameter(key));
if (GetSetting<bool>(SRanipalSetting.EyeEnable)) eyeParams.ForEach(key => auditParameter(key));
if (GetSetting<bool>(SRanipalSetting.LipEnable)) lipParams.ForEach(key => auditParameter(key));

var finalCount = parameterData.Select(pair => pair.Value.TotalCount).Sum();
Log($"Detected {finalCount} usable parameters");
Expand Down

0 comments on commit b45ca69

Please sign in to comment.