diff --git a/Nerfed.Runtime/Systems/LocalToWorldSystem.cs b/Nerfed.Runtime/Systems/LocalToWorldSystem.cs index 56947a4..1949807 100644 --- a/Nerfed.Runtime/Systems/LocalToWorldSystem.cs +++ b/Nerfed.Runtime/Systems/LocalToWorldSystem.cs @@ -17,7 +17,7 @@ public class LocalToWorldSystem : MoonTools.ECS.System { private readonly bool useParallelFor = true; // When having a low amount of transforms or when in debug mode this might be slower. private readonly Filter rootEntitiesFilter; - private readonly Filter transformEntitiesFilter; + private readonly Filter entitiesWithoutLocalToWorldFilter; private readonly Action updateWorldTransform; public LocalToWorldSystem(World world) : base(world) @@ -25,7 +25,7 @@ public LocalToWorldSystem(World world) : base(world) rootEntitiesFilter = FilterBuilder.Include().Exclude().Build(); if (useParallelFor) { - transformEntitiesFilter = FilterBuilder.Include().Build(); + entitiesWithoutLocalToWorldFilter = FilterBuilder.Include().Exclude().Build(); updateWorldTransform = UpdateWorldTransformByIndex; } } @@ -42,12 +42,7 @@ public override void Update(TimeSpan delta) Profiler.BeginSample("ParallelFor.LocalToWorldCheck"); // This check is needed because some entities might not have a LocalToWorld component yet. // Adding this during the loop will break. - foreach (Entity entity in transformEntitiesFilter.Entities) { - if (Has(entity)) - { - continue; - } - + foreach (Entity entity in entitiesWithoutLocalToWorldFilter.Entities) { Set(entity, new LocalToWorld(Matrix4x4.Identity)); } Profiler.EndSample();