destroy all rigid bodies on clients except for the root bone - they work for themselves, and bones look deformed and stretched

This commit is contained in:
in0finite 2021-02-06 19:20:21 +01:00
parent d525a99575
commit 6f21cc8bf0
2 changed files with 13 additions and 0 deletions

View file

@ -124,6 +124,13 @@ namespace SanAndreasUnity.Behaviours.Peds
m_framesDict = model.Frames.ToDictionary(f => f.BoneId, f => new BoneInfo(f.transform));
// destroy all rigid bodies except for the root bone - they work for themselves, and bones look deformed and stretched
m_framesDict
.Where(pair => pair.Key != 0)
.Select(pair => pair.Value.Rigidbody)
.WhereAlive()
.ForEach(Object.Destroy);
Object.Destroy(model.AnimComponent);
Object.Destroy(model);

View file

@ -563,6 +563,12 @@ namespace SanAndreasUnity.Utilities
}
}
public static IEnumerable<T> WhereAlive<T> (this IEnumerable<T> enumerable)
where T : UnityEngine.Object
{
return enumerable.Where(obj => obj != null);
}
public static int RemoveDeadObjects<T> (this List<T> list) where T : UnityEngine.Object
{
return list.RemoveAll(item => null == item);