private static void DynamicBoneOptimize(AIChara.ChaControl character)
        {
            if (character == null)
            {
                return;
            }

            VisibilityMask visibilityMask     = VisibilityMask.None;
            bool           bodyVisibleInRange = false;

            if (character.IsVisibleInCamera)
            {
                if (CheckDistance(character.cmpBoneBody.transform.position, _genitalRangeSquared))
                {
                    visibilityMask |= VisibilityMask.VaginaMask;
                }

                if ((visibilityMask != 0) || CheckDistance(character.cmpBoneBody.transform.position, _hairRangeSquared))
                {
                    visibilityMask |= VisibilityMask.HairMask;
                }

                if ((visibilityMask != 0) || CheckDistance(character.cmpBoneBody.transform.position, _clothingRangeSquared))
                {
                    visibilityMask |= VisibilityMask.ClothingMask;
                }

                if (CheckDistance(character.cmpBoneBody.transform.position, _bodyRangeSquared))
                {
                    bodyVisibleInRange = true;
                }
            }

            SetStateDynamicBones(character, character.IsVisibleInCamera, visibilityMask, bodyVisibleInRange, true);
        }
        private static void SetStateDynamicBones(AIChara.ChaControl character, bool isVisible, VisibilityMask visibilityMask, bool isVisibleInBodyRange = false, bool setIllusionColliders = false)
        {
            if (AIMainGameOptimizations._IKSolverChecks.Value)
            {
                if (character.fullBodyIK.enabled != isVisible)
                {
                    character.fullBodyIK.enabled = isVisible;
                }
            }

            if (AIMainGameOptimizations._LookControllerChecks.Value)
            {
                if (character.neckLookCtrl.enabled != isVisible)
                {
                    character.neckLookCtrl.enabled = isVisible;
                }

                if (character.eyeLookCtrl.enabled != isVisible)
                {
                    character.eyeLookCtrl.enabled = isVisible;
                }
            }

            foreach (var dynamicBone in character.GetComponentsInChildren <DynamicBone>(true))
            {
                if (!dynamicBone)
                {
                    continue;
                }

                bool bIsVisibleInRange = isVisible;
                if (dynamicBone.m_Root != null)
                {
                    if (dynamicBone.m_Root.name.Contains("V****a"))
                    {
                        bIsVisibleInRange = (visibilityMask & VisibilityMask.VaginaMask) == VisibilityMask.VaginaMask;
                    }
                    else if (dynamicBone.m_Root.name.Contains("hair"))
                    {
                        bIsVisibleInRange = (visibilityMask & VisibilityMask.HairMask) == VisibilityMask.HairMask;
                    }
                    else
                    {
                        bIsVisibleInRange = (visibilityMask & VisibilityMask.ClothingMask) == VisibilityMask.ClothingMask;
                    }
                }

                if (dynamicBone.enabled != bIsVisibleInRange)
                {
                    dynamicBone.enabled = bIsVisibleInRange;
                }
            }

            foreach (var dynamicBoneCollider in character.GetComponentsInChildren <DynamicBoneCollider>(true))
            {
                if (!dynamicBoneCollider)
                {
                    continue;
                }

                if (dynamicBoneCollider.enabled != isVisibleInBodyRange)
                {
                    dynamicBoneCollider.enabled = isVisibleInBodyRange;
                }
            }

            if (!setIllusionColliders)
            {
                return;
            }

            foreach (var dynamicBoneV2 in character.GetComponentsInChildren <DynamicBone_Ver02>(true))
            {
                if (!dynamicBoneV2)
                {
                    continue;
                }

                if (dynamicBoneV2.enabled != isVisibleInBodyRange)
                {
                    dynamicBoneV2.enabled = isVisibleInBodyRange;
                }
            }
        }