Refactor MTP Setup Stack
An unexpected diversion occurred this week when the state of the settings stack needed to be rewritten.
There's been a long-standing issue with serialization in the MindTwin project. Since the project uses mostly custom classes for various parts of the rig, each component's serialization was creating needless slowdowns during playback - particularly in Plug and PlugFrame classes and their dependencies.
I initially didn't want to rewrite the core structure and attempted to patch fix parts. In doing so, I broke lots of things and decided to refactor it correctly.
The result is a gain of 5-10 fps, quicker load times, less crashing, cleaner code and a more flexible serialization structure moving forward.
public void Setup () { setup_complete = false; FaceRigComponents components = FaceRigSetup.GetComponents(); head_transform = components.HeadTop; setup_top = FaceRigSetup.GetSetupTop(); mask_geometry = FaceRigSetup.GetMaskGeo(); mesh = FaceRigSetup.GetMesh(mask_geometry); FaceRigSetup.MakeSpecMesh(mesh); points = FaceRigSetup.GetPoints(this, mesh); bones = this.gameObject.AddComponent<FaceBones>(); bones.Setup(components.AifFaceRigTop); EyeRigComponents eye_components = EyeSetup.SetupEyePoints(components); mocap = new MocapController(); mocap.Setup(); eyes = this.gameObject.AddComponent<Eyes>(); eyes.Setup(components, eye_components); lips = this.gameObject.AddComponent<Lips>(); lips.Setup(components); mouth = this.gameObject.AddComponent<Mouth>(); mouth.Setup(components); falloff_points = new FaceFalloffPoints(); falloff_points.Setup(); SetupDisplayMask(); eyes.Draw(); setup_complete = true; falloff_points.SetActive(false); mouth.Debug.SetActive(false); lips.Debug.SetActive(false); new UnityEditor.SerializedObject(this).ApplyModifiedProperties(); }