mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
[RelativeSync] Attempt to fix interpolation
This commit is contained in:
parent
ca7df56e76
commit
c46bc61619
2 changed files with 18 additions and 10 deletions
|
@ -8,6 +8,9 @@ public class RelativeSyncController : MonoBehaviour
|
|||
{
|
||||
private static float MaxMagnitude = 750000000000f;
|
||||
|
||||
private float _updateInterval = 0.05f;
|
||||
private float _lastUpdate;
|
||||
|
||||
private string _userId;
|
||||
private PuppetMaster puppetMaster { get; set; }
|
||||
private NetIKController netIkController { get; set; }
|
||||
|
@ -63,9 +66,7 @@ public class RelativeSyncController : MonoBehaviour
|
|||
relativeHipRot = Quaternion.Inverse(worldRootRot) * hipRot;
|
||||
}
|
||||
|
||||
// todo: this is fucked and idk why, is technically slightly differing sync rates,
|
||||
// but even reimplementing dynamic tps here didnt fix the jitter
|
||||
float lerp = netIkController.GetLerpSpeed();
|
||||
float lerp = Mathf.Min((Time.time - _lastUpdate) / _updateInterval, 1f);
|
||||
|
||||
Vector3 targetLocalPosition = _relativeSyncData.LocalRootPosition;
|
||||
Quaternion targetLocalRotation = Quaternion.Euler(_relativeSyncData.LocalRootRotation);
|
||||
|
@ -109,9 +110,6 @@ public class RelativeSyncController : MonoBehaviour
|
|||
hipTrans.position = transform.position + transform.rotation * relativeHipPos;
|
||||
hipTrans.rotation = transform.rotation * relativeHipRot;
|
||||
}
|
||||
|
||||
_lastSyncData.LocalRootPosition = targetLocalPosition;
|
||||
_lastSyncData.LocalRootRotation = targetLocalRotation.eulerAngles;
|
||||
}
|
||||
|
||||
#endregion Unity Events
|
||||
|
@ -142,6 +140,16 @@ public class RelativeSyncController : MonoBehaviour
|
|||
|
||||
public void SetRelativePositions(Vector3 position, Vector3 rotation)
|
||||
{
|
||||
// calculate update interval
|
||||
float prevUpdate = _lastUpdate;
|
||||
_lastUpdate = Time.time;
|
||||
_updateInterval = _lastUpdate - prevUpdate;
|
||||
|
||||
// cycle last sync data
|
||||
_lastSyncData.LocalRootPosition = _relativeSyncData.LocalRootPosition;
|
||||
_lastSyncData.LocalRootRotation = _relativeSyncData.LocalRootRotation;
|
||||
|
||||
// set new sync data
|
||||
_relativeSyncData.LocalRootPosition = position;
|
||||
_relativeSyncData.LocalRootRotation = rotation;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r26/RelativeSync.dll",
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r27/RelativeSync.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/RelativeSync/",
|
||||
"changelog": "- Initial Release",
|
||||
"embedcolor": "#507e64"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue