public abstract IEnumerator ApplyPerformanceFilter( GameObject avatarObject, AvatarPerformanceStats perfStats, PerformanceRating ratingLimit, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent, AvatarPerformance.FilterBlockCallback onBlock );
public IEnumerator ApplyPerformanceFilters( GameObject avatarObject, AvatarPerformanceStats perfStats, PerformanceRating ratingLimit, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent, AvatarPerformance.FilterBlockCallback onBlock ) { foreach (AbstractPerformanceFilter performanceFilter in performanceFilters) { if (performanceFilter == null) { continue; } bool avatarBlocked = false; yield return(performanceFilter.ApplyPerformanceFilter(avatarObject, perfStats, ratingLimit, shouldIgnoreComponent, () => { avatarBlocked = true; })); if (!avatarBlocked) { continue; } onBlock(); break; } }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Particle Systems List <ParticleSystem> particleSystemBuffer = new List <ParticleSystem>(); yield return(ScanAvatarForComponentsOfType(avatarObject, particleSystemBuffer)); if (shouldIgnoreComponent != null) { particleSystemBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } AnalyzeParticleSystemRenderers(particleSystemBuffer, perfStats); yield return(null); }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Colliders List <Collider> colliderBuffer = new List <Collider>(); yield return(ScanAvatarForComponentsOfType(avatarObject, colliderBuffer)); colliderBuffer.RemoveAll( o => { if (shouldIgnoreComponent != null && shouldIgnoreComponent(o)) { return(true); } if (o.GetComponent <VRC.SDKBase.VRC_Station>() != null) { return(true); } return(false); } ); perfStats.physicsColliderCount = colliderBuffer.Count; // Rigidbodies List <Rigidbody> rigidbodyBuffer = new List <Rigidbody>(); yield return(ScanAvatarForComponentsOfType(avatarObject, rigidbodyBuffer)); rigidbodyBuffer.RemoveAll( o => { if (shouldIgnoreComponent != null && shouldIgnoreComponent(o)) { return(true); } if (o.GetComponent <VRC.SDKBase.VRC_Station>() != null) { return(true); } return(false); } ); perfStats.physicsRigidbodyCount = rigidbodyBuffer.Count; }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { if (_dynamicBoneType == null) { yield break; } // Dynamic Bone as Component List <Component> dynamicBoneComponentBuffer = new List <Component>(); List <object> dynamicBoneColliderObjectBuffer = new List <object>(); yield return(ScanAvatarForComponentsOfType(_dynamicBoneType, avatarObject, dynamicBoneComponentBuffer)); if (shouldIgnoreComponent != null) { dynamicBoneComponentBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } int totalSimulatedBoneCount = 0; int totalCollisionChecks = 0; Profiler.BeginSample("Analyze Dynamic Bones"); foreach (Component dynamicBone in dynamicBoneComponentBuffer) { Profiler.BeginSample("Single Dynamic Bone Component"); int simulatedBones = 0; // Add extra bones to the end of each chain if end bones are being used. float endLength = (float)_dynamicBoneEndLengthFieldInfo.GetValue(dynamicBone); Vector3 endOffset = (Vector3)_dynamicBoneEndOffsetFieldInfo.GetValue(dynamicBone); bool hasEndBones = endLength > 0 || endOffset != Vector3.zero; Transform root = (Transform)_dynamicBoneRootFieldInfo.GetValue(dynamicBone); if (root != null) { List <Transform> exclusions = (List <Transform>)_dynamicBoneExclusionsFieldInfo.GetValue(dynamicBone); // Calculate number of simulated bones for the hierarchy simulatedBones = CountTransformsRecursively(root, exclusions, hasEndBones); totalSimulatedBoneCount += simulatedBones; } int colliderListEntryCount = 0; IList colliderList = (IList)_dynamicBoneCollidersFieldInfo.GetValue(dynamicBone); if (colliderList != null) { foreach (object collider in colliderList) { colliderListEntryCount += 1; if (collider != null && !dynamicBoneColliderObjectBuffer.Contains(collider)) { dynamicBoneColliderObjectBuffer.Add(collider); } } } // The root bone is skipped in collision checks. totalCollisionChecks += (simulatedBones - 1) * colliderListEntryCount; Profiler.EndSample(); } Profiler.EndSample(); yield return(null); perfStats.dynamicBoneComponentCount = dynamicBoneComponentBuffer.Count; perfStats.dynamicBoneSimulatedBoneCount = totalSimulatedBoneCount; perfStats.dynamicBoneColliderCount = dynamicBoneColliderObjectBuffer.Count; perfStats.dynamicBoneCollisionCheckCount = totalCollisionChecks; }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { List <Renderer> renderers = new List <Renderer>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, renderers); if (shouldIgnoreComponent != null) { renderers.RemoveAll(c => shouldIgnoreComponent(c)); } AnalyzeGeometry(avatarObject, renderers, perfStats); AnalyzeMeshRenderers(renderers, perfStats); AnalyzeSkinnedMeshRenderers(renderers, perfStats); yield return(null); }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { List <Collider> colliderBuffer = new List <Collider>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, colliderBuffer); colliderBuffer.RemoveAll( o => { if (shouldIgnoreComponent != null && shouldIgnoreComponent(o)) { return(true); } if (o.GetComponent <VRC_Station>() != null) { return(true); } return(false); } ); perfStats.physicsColliderCount = colliderBuffer.Count; yield return(null); List <Rigidbody> rigidbodyBuffer = new List <Rigidbody>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, rigidbodyBuffer); rigidbodyBuffer.RemoveAll( o => { if (shouldIgnoreComponent != null && shouldIgnoreComponent(o)) { return(true); } if (o.GetComponent <VRC_Station>() != null) { return(true); } return(false); } ); perfStats.physicsRigidbodyCount = rigidbodyBuffer.Count; yield return(null); }
public IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { foreach (AbstractPerformanceScanner performanceScanner in performanceScanners) { if (performanceScanner == null) { continue; } yield return(performanceScanner.RunPerformanceScan(avatarObject, perfStats, shouldIgnoreComponent)); } }
public abstract IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent);
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Lights List <Light> lightBuffer = new List <Light>(); yield return(ScanAvatarForComponentsOfType(avatarObject, lightBuffer)); if (shouldIgnoreComponent != null) { lightBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } perfStats.lightCount = lightBuffer.Count; }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { lock (initLock) { if (!_searchedOptionalTypes) { FindDynamicBoneTypes(); _searchedOptionalTypes = true; } } int totalSimulatedBoneCount = 0; int totalCollisionChecks = 0; if (_dynamicBoneType == null) { yield break; } List <Component> dynamicBones = avatarObject.GetComponentsInChildren(_dynamicBoneType, includeInactiveObjectsInStats).ToList(); if (shouldIgnoreComponent != null) { dynamicBones.RemoveAll(c => shouldIgnoreComponent(c)); } List <object> colliders = new List <object>(); foreach (Component dynamicBone in dynamicBones) { int simulatedBones = 0; // Add extra bones to the end of each chain if end bones are being used. float endLength = (float)_dynamicBoneEndLengthFieldInfo.GetValue(dynamicBone); Vector3 endOffset = (Vector3)_dynamicBoneEndOffsetFieldInfo.GetValue(dynamicBone); bool hasEndBones = endLength > 0 || endOffset != Vector3.zero; Transform root = (Transform)_dynamicBoneRootFieldInfo.GetValue(dynamicBone); if (root != null) { List <Transform> exclusions = (List <Transform>)_dynamicBoneExclusionsFieldInfo.GetValue(dynamicBone); // Calculate number of simulated bones for the hierarchy simulatedBones = CountTransformsRecursively(root, exclusions, hasEndBones); totalSimulatedBoneCount += simulatedBones; } int colliderListEntryCount = 0; IList colliderList = (IList)_dynamicBoneCollidersFieldInfo.GetValue(dynamicBone); if (colliderList != null) { foreach (object collider in colliderList) { colliderListEntryCount += 1; if (collider != null && !colliders.Contains(collider)) { colliders.Add(collider); } } } // The root bone is skipped in collision checks. totalCollisionChecks += (simulatedBones - 1) * colliderListEntryCount; } perfStats.dynamicBoneComponentCount = dynamicBones.Count; perfStats.dynamicBoneSimulatedBoneCount = totalSimulatedBoneCount; perfStats.dynamicBoneColliderCount = colliders.Count; perfStats.dynamicBoneCollisionCheckCount = totalCollisionChecks; }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { int animatorCount = 0; // Animators List <Animator> animatorBuffer = new List <Animator>(); yield return(ScanAvatarForComponentsOfType(avatarObject, animatorBuffer)); if (shouldIgnoreComponent != null) { animatorBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } animatorCount += animatorBuffer.Count; // Animations List <Animation> animationBuffer = new List <Animation>(); yield return(ScanAvatarForComponentsOfType(avatarObject, animationBuffer)); if (shouldIgnoreComponent != null) { animationBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } animatorCount += animationBuffer.Count; perfStats.animatorCount += animatorCount; }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { int totalClothVertices = 0; List <Cloth> clothBuffer = new List <Cloth>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, clothBuffer); if (shouldIgnoreComponent != null) { clothBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } perfStats.clothCount = clothBuffer.Count; foreach (Cloth cloth in clothBuffer) { if (cloth == null) { continue; } Vector3[] clothVertices = cloth.vertices; if (clothVertices == null) { continue; } totalClothVertices += clothVertices.Length; } perfStats.clothMaxVertices = totalClothVertices; yield break; }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { List <Light> lightBuffer = new List <Light>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, lightBuffer); if (shouldIgnoreComponent != null) { lightBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } perfStats.lightCount = lightBuffer.Count; yield break; }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Renderers List <Renderer> rendererBuffer = new List <Renderer>(16); yield return(ScanAvatarForComponentsOfType(avatarObject, rendererBuffer)); if (shouldIgnoreComponent != null) { rendererBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } yield return(AnalyzeGeometry(avatarObject, rendererBuffer, perfStats)); AnalyzeMeshRenderers(rendererBuffer, perfStats); AnalyzeSkinnedMeshRenderers(rendererBuffer, perfStats); yield return(null); }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Line Renderers List <LineRenderer> lineRendererBuffer = new List <LineRenderer>(); yield return(ScanAvatarForComponentsOfType(avatarObject, lineRendererBuffer)); if (shouldIgnoreComponent != null) { lineRendererBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } int numLineRenderers = lineRendererBuffer.Count; perfStats.lineRendererCount = numLineRenderers; perfStats.materialCount = perfStats.materialCount.GetValueOrDefault() + numLineRenderers; }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Trail Renderers List <TrailRenderer> trailRendererBuffer = new List <TrailRenderer>(); yield return(ScanAvatarForComponentsOfType(avatarObject, trailRendererBuffer)); if (shouldIgnoreComponent != null) { trailRendererBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } int numTrailRenderers = trailRendererBuffer.Count; perfStats.trailRendererCount += numTrailRenderers; perfStats.materialCount += numTrailRenderers; }
public void RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { _limitComponentScansPerFrame = false; try { _coroutines.Push(RunPerformanceScanEnumerator(avatarObject, perfStats, shouldIgnoreComponent)); while (_coroutines.Count > 0) { IEnumerator currentCoroutine = _coroutines.Peek(); if (currentCoroutine.MoveNext()) { IEnumerator nestedCoroutine = currentCoroutine.Current as IEnumerator; if (nestedCoroutine != null) { _coroutines.Push(nestedCoroutine); } } else { _coroutines.Pop(); } } _coroutines.Clear(); } finally { _limitComponentScansPerFrame = true; } }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { List <LineRenderer> lineRenderers = new List <LineRenderer>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, lineRenderers); if (shouldIgnoreComponent != null) { lineRenderers.RemoveAll(c => shouldIgnoreComponent(c)); } int numLineRenderers = lineRenderers.Count; perfStats.lineRendererCount += numLineRenderers; perfStats.materialCount += numLineRenderers; yield break; }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Cloth List <Cloth> clothBuffer = new List <Cloth>(); yield return(ScanAvatarForComponentsOfType(avatarObject, clothBuffer)); if (shouldIgnoreComponent != null) { clothBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } int totalClothVertices = 0; foreach (Cloth cloth in clothBuffer) { if (cloth == null) { continue; } Vector3[] clothVertices = cloth.vertices; if (clothVertices == null) { continue; } totalClothVertices += clothVertices.Length; } perfStats.clothCount = clothBuffer.Count; perfStats.clothMaxVertices = totalClothVertices; }
public override IEnumerator RunPerformanceScanEnumerator(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { // Audio Sources List <AudioSource> audioSourceBuffer = new List <AudioSource>(); yield return(ScanAvatarForComponentsOfType(avatarObject, audioSourceBuffer)); if (shouldIgnoreComponent != null) { audioSourceBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } perfStats.audioSourceCount += audioSourceBuffer.Count; }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { List <ParticleSystem> particleSystems = new List <ParticleSystem>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, particleSystems); if (shouldIgnoreComponent != null) { particleSystems.RemoveAll(c => shouldIgnoreComponent(c)); } yield return(AnalyzeParticleSystemRenderers(particleSystems, perfStats)); }
public override IEnumerator RunPerformanceScan(GameObject avatarObject, AvatarPerformanceStats perfStats, AvatarPerformance.IgnoreDelegate shouldIgnoreComponent) { int animatorCount = 0; List <Animator> animatorBuffer = new List <Animator>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, animatorBuffer); if (shouldIgnoreComponent != null) { animatorBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } animatorCount += animatorBuffer.Count; yield return(null); List <Animation> animationBuffer = new List <Animation>(16); avatarObject.GetComponentsInChildren(includeInactiveObjectsInStats, animationBuffer); if (shouldIgnoreComponent != null) { animationBuffer.RemoveAll(c => shouldIgnoreComponent(c)); } animatorCount += animationBuffer.Count; perfStats.animatorCount = animatorCount; yield return(null); }