Hey, I noticed the plugin creates a ton of pressure on the heap, even with all features disabled.
After a quick glance at the code, it looks like you create 10 new List instances in "UpdateOrificeEntryTracking", "RemoveBoneAlignmentsForAtom" and "CacheBoneAlignmentRigidbodies", which are called on every frame. You also call GetComponentsInChildren multiple times per frame without passing reusable lists to it.
Whenever the garbage collection kicks in, the game freezes momentarily.
Another problematic spot is the string concatenation in "CacheBoneAlignmentRigidbodies". The hierarchyPath variable isn't used for anything else and string allocation is rather expensive.
Code:
Transform current = rb.transform;
string hierarchyPath = current.name;
while (current.parent != null && current.parent != atom.transform)
{
current = current.parent;
hierarchyPath = current.name + "/" + hierarchyPath;
}
if (hierarchyPath.Contains("Gen1") || hierarchyPath.Contains("Gen2") || hierarchyPath.Contains("Gen3"))
{
shouldCache = true;
}
Couldn't you do the same like so?
Code:
Transform current = rb.transform;
while (current != null && current != atom.transform)
{
if (Regex.IsMatch(current.name, "Gen[123]"))
{
shouldCache = true;
break;
}
current = current.parent;
}
OrificeDynamics and BetterBends are otherwise very awesome plugins. Keep up the good work.