mirror of
https://github.com/hanetzer/sdraw_mods_cvr.git
synced 2025-09-05 03:19:23 +00:00
Fixed lips tracking
This commit is contained in:
parent
e84bbacb8d
commit
c2a219dfa3
6 changed files with 103 additions and 81 deletions
|
@ -1,7 +1,7 @@
|
|||
using ABI.CCK.Components;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Player.EyeMovement;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Systems.FaceTracking;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ml_dht
|
||||
|
@ -10,7 +10,7 @@ namespace ml_dht
|
|||
{
|
||||
static DesktopHeadTracking ms_instance = null;
|
||||
|
||||
TrackingModule m_trackingModule = null;
|
||||
DataParser m_dataParser = null;
|
||||
HeadTracked m_localTracked = null;
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
|
@ -20,8 +20,6 @@ namespace ml_dht
|
|||
|
||||
Settings.Init();
|
||||
|
||||
m_trackingModule = new TrackingModule();
|
||||
|
||||
// Patches
|
||||
HarmonyInstance.Patch(
|
||||
typeof(PlayerSetup).GetMethod(nameof(PlayerSetup.ClearAvatar)),
|
||||
|
@ -45,8 +43,8 @@ namespace ml_dht
|
|||
while(PlayerSetup.Instance == null)
|
||||
yield return null;
|
||||
|
||||
m_dataParser = new DataParser();
|
||||
m_localTracked = PlayerSetup.Instance.gameObject.AddComponent<HeadTracked>();
|
||||
FaceTrackingManager.Instance.RegisterModule(m_trackingModule);
|
||||
|
||||
// If you think it's a joke to put patch here, go on, try to put it in OnInitializeMelon, you melon :>
|
||||
HarmonyInstance.Patch(
|
||||
|
@ -54,6 +52,10 @@ namespace ml_dht
|
|||
null,
|
||||
new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnEyeControllerUpdate_Postfix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
HarmonyInstance.Patch(
|
||||
typeof(CVRFaceTracking).GetMethod("UpdateLocalData", BindingFlags.Instance | BindingFlags.NonPublic),
|
||||
new HarmonyLib.HarmonyMethod(typeof(DesktopHeadTracking).GetMethod(nameof(OnFaceTrackingLocalUpdate_Prefix), BindingFlags.Static | BindingFlags.NonPublic))
|
||||
);
|
||||
}
|
||||
|
||||
public override void OnDeinitializeMelon()
|
||||
|
@ -61,17 +63,17 @@ namespace ml_dht
|
|||
if(ms_instance == this)
|
||||
ms_instance = null;
|
||||
|
||||
m_trackingModule = null;
|
||||
m_dataParser = null;
|
||||
m_localTracked = null;
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
if(Settings.Enabled && (m_trackingModule != null))
|
||||
if(Settings.Enabled && (m_dataParser != null))
|
||||
{
|
||||
m_trackingModule.Update();
|
||||
m_dataParser.Update();
|
||||
if(m_localTracked != null)
|
||||
m_localTracked.UpdateTrackingData(ref m_trackingModule.GetLatestTrackingData());
|
||||
m_localTracked.UpdateTrackingData(ref m_dataParser.GetLatestTrackingData());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,5 +118,18 @@ namespace ml_dht
|
|||
MelonLoader.MelonLogger.Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static bool OnFaceTrackingLocalUpdate_Prefix(ref CVRFaceTracking __instance)
|
||||
{
|
||||
bool? l_result = ms_instance?.OnFaceTrackingLocalUpdate(__instance);
|
||||
return l_result.GetValueOrDefault(true);
|
||||
}
|
||||
bool OnFaceTrackingLocalUpdate(CVRFaceTracking p_component)
|
||||
{
|
||||
bool l_result = true;
|
||||
if(p_component.UseFacialTracking && (m_localTracked != null))
|
||||
l_result = !m_localTracked.UpdateFaceTracking(p_component);
|
||||
return l_result;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue