-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from anatawa12/split-util-for-vrcsdk
refactor: split utils for components of VRCSDK
- Loading branch information
Showing
3 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using VRC.Dynamics; | ||
|
||
namespace Anatawa12.AvatarOptimizer | ||
{ | ||
partial class Utils | ||
{ | ||
public static Transform GetTarget(this VRCPhysBoneBase physBoneBase) => | ||
physBoneBase.rootTransform ? physBoneBase.rootTransform : physBoneBase.transform; | ||
|
||
public static IEnumerable<Transform> GetAffectedTransforms(this VRCPhysBoneBase physBoneBase) | ||
{ | ||
var ignores = new HashSet<Transform>(physBoneBase.ignoreTransforms); | ||
var queue = new Queue<Transform>(); | ||
queue.Enqueue(physBoneBase.GetTarget()); | ||
|
||
while (queue.Count != 0) | ||
{ | ||
var transform = queue.Dequeue(); | ||
yield return transform; | ||
|
||
foreach (var child in transform.DirectChildrenEnumerable()) | ||
if (!ignores.Contains(child)) | ||
queue.Enqueue(child); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters